SAKURA Internet IoT Communication Module Library for mbed

Dependents:   patlite_sakuraio sakuraio_lte_firmwareupdater shownet2017-iinebutton patlite_sakuraio_stack ... more

SAKURA Internet IoT Communication Module Library for mbed

Sakura Communication Module (with sakura.io) library for mbed.

Support

This library supports following products.

Reference

Please see the datasheet.

License

The MIT License (MIT)

Copyright (c) SAKURA Internet Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Committer:
spiralray
Date:
Sat Nov 19 03:20:17 2016 +0000
Revision:
0:8d34375d954c
Child:
3:c54a1eba22c4
First commit(This only works with SPI)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
spiralray 0:8d34375d954c 1 #include "mbed.h"
spiralray 0:8d34375d954c 2 #include "SakuraIO.h"
spiralray 0:8d34375d954c 3 #include "SakuraIO/debug.h"
spiralray 0:8d34375d954c 4
spiralray 0:8d34375d954c 5
spiralray 0:8d34375d954c 6 void SakuraIO_SPI::begin(){
spiralray 0:8d34375d954c 7 dbgln("CS=0");
spiralray 0:8d34375d954c 8 cs = 0;
spiralray 0:8d34375d954c 9 }
spiralray 0:8d34375d954c 10
spiralray 0:8d34375d954c 11 void SakuraIO_SPI::end(){
spiralray 0:8d34375d954c 12 dbgln("CS=1");
spiralray 0:8d34375d954c 13 cs = 1;
spiralray 0:8d34375d954c 14 wait_us(20);
spiralray 0:8d34375d954c 15 }
spiralray 0:8d34375d954c 16
spiralray 0:8d34375d954c 17 void SakuraIO_SPI::sendByte(uint8_t data){
spiralray 0:8d34375d954c 18 wait_us(20);
spiralray 0:8d34375d954c 19 dbg("Send=");
spiralray 0:8d34375d954c 20 dbgln(data);
spiralray 0:8d34375d954c 21 wait_us(10);
spiralray 0:8d34375d954c 22 spi.write(data);
spiralray 0:8d34375d954c 23 }
spiralray 0:8d34375d954c 24
spiralray 0:8d34375d954c 25
spiralray 0:8d34375d954c 26 uint8_t SakuraIO_SPI::receiveByte(bool stop){
spiralray 0:8d34375d954c 27 return receiveByte();
spiralray 0:8d34375d954c 28 }
spiralray 0:8d34375d954c 29
spiralray 0:8d34375d954c 30 uint8_t SakuraIO_SPI::receiveByte(){
spiralray 0:8d34375d954c 31 uint8_t ret;
spiralray 0:8d34375d954c 32 wait_us(10);
spiralray 0:8d34375d954c 33 ret = spi.write(0x00);
spiralray 0:8d34375d954c 34 dbg("Recv=");
spiralray 0:8d34375d954c 35 dbgln(ret);
spiralray 0:8d34375d954c 36 return ret;
spiralray 0:8d34375d954c 37 }
spiralray 0:8d34375d954c 38
spiralray 0:8d34375d954c 39 SakuraIO_SPI::SakuraIO_SPI(SPI &_spi, DigitalOut &_cs): spi(_spi), cs(_cs){
spiralray 0:8d34375d954c 40 cs = 1;
spiralray 0:8d34375d954c 41 }