an SPI interface the cmu pixy camera
Dependents: robotic_fish_ver_4_9_pixy UMO
pixy.h@1:439c7574a5ee, 2014-06-02 (annotated)
- Committer:
- sandwich
- Date:
- Mon Jun 02 21:30:22 2014 +0000
- Revision:
- 1:439c7574a5ee
- Parent:
- 0:1b99a0bee9e0
- Child:
- 2:fc86438b206f
removed unused struct
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:1b99a0bee9e0 | 1 | #pragma once |
sandwich | 0:1b99a0bee9e0 | 2 | #include "mbed.h" |
sandwich | 0:1b99a0bee9e0 | 3 | |
sandwich | 0:1b99a0bee9e0 | 4 | //a class to aid in SPI communication with the pixy camera |
sandwich | 0:1b99a0bee9e0 | 5 | |
sandwich | 0:1b99a0bee9e0 | 6 | //this details the object block format of returned data as described in |
sandwich | 0:1b99a0bee9e0 | 7 | //http://www.cmucam.org/projects/cmucam5/wiki/Pixy_Serial_Protocol |
sandwich | 0:1b99a0bee9e0 | 8 | |
sandwich | 0:1b99a0bee9e0 | 9 | //blatantly stole this from their code |
sandwich | 0:1b99a0bee9e0 | 10 | struct Block |
sandwich | 0:1b99a0bee9e0 | 11 | { |
sandwich | 0:1b99a0bee9e0 | 12 | uint16_t signature; |
sandwich | 0:1b99a0bee9e0 | 13 | uint16_t x; |
sandwich | 0:1b99a0bee9e0 | 14 | uint16_t y; |
sandwich | 0:1b99a0bee9e0 | 15 | uint16_t width; |
sandwich | 0:1b99a0bee9e0 | 16 | uint16_t height; |
sandwich | 0:1b99a0bee9e0 | 17 | }; |
sandwich | 0:1b99a0bee9e0 | 18 | |
sandwich | 0:1b99a0bee9e0 | 19 | class pixySPI |
sandwich | 0:1b99a0bee9e0 | 20 | { |
sandwich | 0:1b99a0bee9e0 | 21 | private: |
sandwich | 0:1b99a0bee9e0 | 22 | SPI* spi; |
sandwich | 0:1b99a0bee9e0 | 23 | Serial* debug; |
sandwich | 0:1b99a0bee9e0 | 24 | //SPI spi(p5, p6, p7); // mosi, miso, sclk |
sandwich | 0:1b99a0bee9e0 | 25 | short sync; //the block signature. 16 bits |
sandwich | 0:1b99a0bee9e0 | 26 | short readTwoBytesLSB(); |
sandwich | 0:1b99a0bee9e0 | 27 | void readNBytes(char* buf, int num); |
sandwich | 0:1b99a0bee9e0 | 28 | public: |
sandwich | 0:1b99a0bee9e0 | 29 | pixySPI(PinName mosi,PinName miso,PinName sclk, Serial* ser); |
sandwich | 0:1b99a0bee9e0 | 30 | ~pixySPI(); |
sandwich | 0:1b99a0bee9e0 | 31 | Block getBlock(Serial* debug); |
sandwich | 0:1b99a0bee9e0 | 32 | char getRawData(); |
sandwich | 0:1b99a0bee9e0 | 33 | }; |