Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: pixy2 pixy2_10_0042 0000Non_stop_code_v1 0000Non_stop_code_v3 ... more
Fork of pixy by
PixyLinkSPI.h
00001 #ifndef TUIASI_PIXYLINKSPI_H 00002 #define TUIASI_PIXYLINKSPI_H 00003 00004 #include "SPI.h" 00005 #include "PixyLink.h" 00006 00007 class PixyLinkSPI : public PixyLink, private SPI 00008 { 00009 public: 00010 PixyLinkSPI(PinName mosi, PinName miso, PinName sclk) : 00011 SPI(mosi, miso, sclk), outLen(0), outIndex(0) { 00012 }; 00013 00014 virtual uint16_t getWord() { 00015 uint16_t w = ((uint16_t)getByte()) << 8; 00016 return w | getByte(); 00017 }; 00018 00019 virtual uint8_t getByte() { 00020 uint8_t c = 0x00; 00021 if (outIndex < outLen) { 00022 c = outBuf[outIndex++]; 00023 } 00024 return write(c); 00025 }; 00026 00027 virtual int8_t send(uint8_t *data, uint8_t len) { 00028 if (len > PIXY_OUTBUF_SIZE || outLen != 0) 00029 return -1; 00030 memcpy(outBuf, data, len); 00031 outLen = len; 00032 outIndex = 0; 00033 return len; 00034 }; 00035 00036 private: 00037 static const uint8_t PIXY_OUTBUF_SIZE = 6; 00038 static const uint8_t PIXY_SYNC_BYTE = 0x5a; 00039 static const uint8_t PIXY_SYNC_BYTE_DATA = 0x5b; 00040 00041 uint8_t outBuf[PIXY_OUTBUF_SIZE]; 00042 uint8_t outLen; 00043 uint8_t outIndex; 00044 00045 }; 00046 #endif //TUIASI_PIXYLINKSPI_H
Generated on Tue Jul 12 2022 15:51:01 by
1.7.2
