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.
Fork of SakuraIO by
SakuraIO.h
00001 #ifndef _SAKURAIO_H_ 00002 #define _SAKURAIO_H_ 00003 00004 #include "mbed.h" 00005 #include <SakuraIO/commands.h> 00006 00007 class SakuraIO 00008 { 00009 protected: 00010 virtual void begin(){} 00011 virtual void end(){} 00012 00013 virtual void sendByte(uint8_t data){} 00014 //virtual void finishSending(){} 00015 00016 virtual uint8_t startReceive(uint8_t length){return length;}; 00017 virtual uint8_t receiveByte(){return 0x00;} 00018 virtual uint8_t receiveByte(bool stop){return 0x00;} 00019 //virtual void finishReceiving(){} 00020 00021 uint8_t executeCommand(uint8_t cmd,uint8_t requestLength, uint8_t *request, uint8_t *responseLength, uint8_t *response); 00022 00023 uint8_t enqueueTxRaw(uint8_t ch, uint8_t type, uint8_t length, uint8_t *data, uint64_t offset); 00024 00025 public: 00026 uint8_t getConnectionStatus(); 00027 uint8_t getSignalQuarity(); 00028 uint64_t getUnixtime(); 00029 uint8_t echoback(uint8_t length, uint8_t *data, uint8_t *response); 00030 uint16_t getADC(uint8_t channel); 00031 uint8_t enqueueTx(uint8_t ch, int32_t value, uint64_t offset); 00032 uint8_t enqueueTx(uint8_t ch, uint32_t value, uint64_t offset); 00033 uint8_t enqueueTx(uint8_t ch, int64_t value, uint64_t offset); 00034 uint8_t enqueueTx(uint8_t ch, uint64_t value, uint64_t offset); 00035 uint8_t enqueueTx(uint8_t ch, float value, uint64_t offset); 00036 uint8_t enqueueTx(uint8_t ch, double value, uint64_t offset); 00037 uint8_t enqueueTx(uint8_t ch, uint8_t value[8], uint64_t offset); 00038 uint8_t enqueueTx(uint8_t ch, int32_t value); 00039 uint8_t enqueueTx(uint8_t ch, uint32_t value); 00040 uint8_t enqueueTx(uint8_t ch, int64_t value); 00041 uint8_t enqueueTx(uint8_t ch, uint64_t value); 00042 uint8_t enqueueTx(uint8_t ch, float value); 00043 uint8_t enqueueTx(uint8_t ch, double value); 00044 uint8_t enqueueTx(uint8_t ch, uint8_t value[8]); 00045 uint8_t getTxQueueLength(uint8_t *available, uint8_t *queued); 00046 uint8_t clearTx(); 00047 uint8_t getTxStatus(uint8_t *queue, uint8_t *immediate); 00048 uint8_t send(); 00049 uint8_t dequeueRx(uint8_t *ch, uint8_t *type, uint8_t *value, int64_t *offset); 00050 uint8_t peekRx(uint8_t *ch, uint8_t *type, uint8_t *value, int64_t *offset); 00051 uint8_t getRxQueueLength(uint8_t *available, uint8_t *queued); 00052 uint8_t clearRx(); 00053 uint16_t getProductID(); 00054 uint8_t getUniqueID(char *data); 00055 uint8_t getFirmwareVersion(char *data); 00056 uint8_t unlock(); 00057 uint8_t updateFirmware(); 00058 uint8_t getFirmwareUpdateStatus(); 00059 uint8_t reset(); 00060 }; 00061 00062 class SakuraIO_SPI : public SakuraIO 00063 { 00064 protected: 00065 SPI spi; 00066 DigitalOut cs; 00067 virtual void begin(); 00068 virtual void end(); 00069 virtual void sendByte(uint8_t data); 00070 virtual uint8_t receiveByte(bool stop); 00071 virtual uint8_t receiveByte(); 00072 public: 00073 SakuraIO_SPI(SPI &_spi, PinName _cs); 00074 SakuraIO_SPI(PinName _mosi, PinName _miso, PinName _sck, PinName _cs); 00075 }; 00076 00077 class SakuraIO_I2C : public SakuraIO 00078 { 00079 protected: 00080 I2C i2c; 00081 int _length; 00082 00083 virtual void begin(); 00084 virtual void end(); 00085 virtual void sendByte(uint8_t data); 00086 virtual uint8_t startReceive(uint8_t length); 00087 virtual uint8_t receiveByte(bool stop); 00088 virtual uint8_t receiveByte(); 00089 uint8_t mode; 00090 public: 00091 SakuraIO_I2C (I2C &_i2c); 00092 SakuraIO_I2C (PinName sda, PinName scl); 00093 }; 00094 00095 #endif // _SAKURAIO_H_
Generated on Sun Jul 17 2022 01:16:21 by
1.7.2
