Homologation Cachan
Fork of TPixy-Interface by
Diff: TPixyInterface.h
- Revision:
- 3:66df7d295245
- Parent:
- 0:ef0e3c67dc5b
diff -r fa582d9d91b5 -r 66df7d295245 TPixyInterface.h --- a/TPixyInterface.h Mon Mar 14 17:50:40 2016 +0000 +++ b/TPixyInterface.h Mon Mar 14 18:53:43 2016 +0000 @@ -29,14 +29,34 @@ #define PIXY_SYNC_BYTE_DATA 0x5b #define PIXY_BUF_SIZE 16 +/** An interface for communicating between the Pixy and a specific hardware interface + */ class TPixyInterface { public: + /** Creates a TPixyInterface + */ TPixyInterface() {} + /** Initializes a TPixyInterface + */ virtual void init() = 0; + /** Sends the given data to the Pixy with a given data length + * @param data the data to send + * @param len the length of the data to send + * @return the interface return signal + */ virtual int8_t send(uint8_t *data, uint8_t len) = 0; + /** Sets an argument for the interface to use + * @param arg the argument to use + */ virtual void setArg(uint16_t arg) = 0; + /** Reads a word from the interface + * @return the word read from the interface + */ virtual uint16_t getWord() = 0; + /** Reads a byte from the interface + * @return the byte read from the interface + */ virtual uint8_t getByte() = 0; }; @@ -55,15 +75,36 @@ bool write(BufType c); }; +/** An interface for communicating between the Pixy via an SPI interface + */ class PixyInterfaceSPI : TPixyInterface { public: SPI* spi; + /** Constructs a PixyInterfaceSPI object + * @param interface the SPI pointer + */ PixyInterfaceSPI(SPI* interface); + /** Initializes the PixyInterfaceSPI + */ virtual void init(); + /** Reads a word from the interface + * @return the word read from the interface + */ virtual uint16_t getWord(); + /** Reads a byte from the interface + * @return the byte read from the interface + */ virtual uint8_t getByte(); + /** Sends the given data to the Pixy with a given data length + * @param data the data to send + * @param len the length of the data to send + * @return the interface return signal + */ virtual int8_t send(uint8_t *data, uint8_t len); + /** Sets an argument for the interface to use [unused] + * @param arg the argument to use + */ virtual void setArg(uint16_t arg); private: