SAKURA Internet IoT Beta Communication Module Library for mbed

Dependents:   SakuraIO_Standard SakuraIO_FirmwareUpdate

Committer:
sakurafan
Date:
Sun Nov 13 06:52:34 2016 +0000
Revision:
0:f3b80b2bdb14
1st ported build;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sakurafan 0:f3b80b2bdb14 1 #include <stdint.h>
sakurafan 0:f3b80b2bdb14 2 #include "SakuraIO.h"
sakurafan 0:f3b80b2bdb14 3 #include "SakuraIOAlphaCompat.h"
sakurafan 0:f3b80b2bdb14 4
sakurafan 0:f3b80b2bdb14 5 SakuraIOAlphaCompatSPI::SakuraIOAlphaCompatSPI(SPI &spi, PinName cs){
sakurafan 0:f3b80b2bdb14 6 sakuraio = new SakuraIO_SPI(spi, cs);
sakurafan 0:f3b80b2bdb14 7 }
sakurafan 0:f3b80b2bdb14 8
sakurafan 0:f3b80b2bdb14 9 SakuraIOAlphaCompatSPI::SakuraIOAlphaCompatSPI(PinName mosi, PinName miso, PinName sck, PinName cs){
sakurafan 0:f3b80b2bdb14 10 sakuraio = new SakuraIO_SPI(mosi, miso, sck, cs);
sakurafan 0:f3b80b2bdb14 11 }
sakurafan 0:f3b80b2bdb14 12
sakurafan 0:f3b80b2bdb14 13 SakuraIOAlphaCompatI2C::SakuraIOAlphaCompatI2C(I2C &i2c){
sakurafan 0:f3b80b2bdb14 14 sakuraio = new SakuraIO_I2C(i2c);
sakurafan 0:f3b80b2bdb14 15 }
sakurafan 0:f3b80b2bdb14 16
sakurafan 0:f3b80b2bdb14 17 SakuraIOAlphaCompatI2C::SakuraIOAlphaCompatI2C(PinName sda, PinName scl){
sakurafan 0:f3b80b2bdb14 18 sakuraio = new SakuraIO_I2C(sda, scl);
sakurafan 0:f3b80b2bdb14 19 }
sakurafan 0:f3b80b2bdb14 20
sakurafan 0:f3b80b2bdb14 21 uint8_t SakuraIOAlphaCompat::getNetworkStatus() {
sakurafan 0:f3b80b2bdb14 22 if((sakuraio->getConnectionStatus() & 0x80) == 0x80){
sakurafan 0:f3b80b2bdb14 23 return 1;
sakurafan 0:f3b80b2bdb14 24 }
sakurafan 0:f3b80b2bdb14 25 return 0;
sakurafan 0:f3b80b2bdb14 26 }
sakurafan 0:f3b80b2bdb14 27
sakurafan 0:f3b80b2bdb14 28 void SakuraIOAlphaCompat::transmit(uint8_t mode){
sakurafan 0:f3b80b2bdb14 29 if(mode != TRANSMIT_ONCE){
sakurafan 0:f3b80b2bdb14 30 return;
sakurafan 0:f3b80b2bdb14 31 }
sakurafan 0:f3b80b2bdb14 32 sakuraio->send();
sakurafan 0:f3b80b2bdb14 33 }
sakurafan 0:f3b80b2bdb14 34
sakurafan 0:f3b80b2bdb14 35 uint8_t SakuraIOAlphaCompat::getTxChannelStatus(uint8_t ch){
sakurafan 0:f3b80b2bdb14 36 uint8_t available = 0;
sakurafan 0:f3b80b2bdb14 37 uint8_t queued = 0;
sakurafan 0:f3b80b2bdb14 38 sakuraio->getTxQueueLength(&available, &queued);
sakurafan 0:f3b80b2bdb14 39 if(queued > 0){
sakurafan 0:f3b80b2bdb14 40 return 1;
sakurafan 0:f3b80b2bdb14 41 }
sakurafan 0:f3b80b2bdb14 42 return 0;
sakurafan 0:f3b80b2bdb14 43 }
sakurafan 0:f3b80b2bdb14 44
sakurafan 0:f3b80b2bdb14 45 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, int32_t data){
sakurafan 0:f3b80b2bdb14 46 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 47 }
sakurafan 0:f3b80b2bdb14 48 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, uint32_t data){
sakurafan 0:f3b80b2bdb14 49 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 50 }
sakurafan 0:f3b80b2bdb14 51 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, int64_t data){
sakurafan 0:f3b80b2bdb14 52 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 53 }
sakurafan 0:f3b80b2bdb14 54 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, uint64_t data){
sakurafan 0:f3b80b2bdb14 55 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 56 }
sakurafan 0:f3b80b2bdb14 57 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, float data){
sakurafan 0:f3b80b2bdb14 58 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 59 }
sakurafan 0:f3b80b2bdb14 60 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, double data){
sakurafan 0:f3b80b2bdb14 61 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 62 }
sakurafan 0:f3b80b2bdb14 63 void SakuraIOAlphaCompat::writeChannel(uint8_t ch, uint8_t *data){
sakurafan 0:f3b80b2bdb14 64 sakuraio->enqueueTx(ch, data);
sakurafan 0:f3b80b2bdb14 65 }