Simple IoT Board用のライブラリです。 ESP8266ライブラリの軽量化 送信のみのソフトシリアルライブラリを含んでいます。

Dependents:   SITB_HttpGetSample SITB_IFTTTSample SITB_INA226PRC AmbientExampleSITB ... more

Committer:
jksoft
Date:
Sun Nov 15 13:36:44 2015 +0000
Revision:
0:890c12951e96
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:890c12951e96 1 #include "SoftSerialSendOnry.h"
jksoft 0:890c12951e96 2
jksoft 0:890c12951e96 3 SoftSerialSendOnry::SoftSerialSendOnry(PinName TX, const char* name) {
jksoft 0:890c12951e96 4 tx_en = false;
jksoft 0:890c12951e96 5 if (TX != NC) {
jksoft 0:890c12951e96 6 tx = new DigitalOut(TX);
jksoft 0:890c12951e96 7 tx_en = true;
jksoft 0:890c12951e96 8 tx->write(1);
jksoft 0:890c12951e96 9 tx_bit = -1;
jksoft 0:890c12951e96 10 txticker.attach(this, &SoftSerialSendOnry::tx_handler);
jksoft 0:890c12951e96 11 }
jksoft 0:890c12951e96 12
jksoft 0:890c12951e96 13 baud(9600);
jksoft 0:890c12951e96 14 format();
jksoft 0:890c12951e96 15 }
jksoft 0:890c12951e96 16
jksoft 0:890c12951e96 17 SoftSerialSendOnry::~SoftSerialSendOnry() {
jksoft 0:890c12951e96 18 if (tx_en)
jksoft 0:890c12951e96 19 delete(tx);
jksoft 0:890c12951e96 20 }
jksoft 0:890c12951e96 21
jksoft 0:890c12951e96 22 void SoftSerialSendOnry::baud(int baudrate) {
jksoft 0:890c12951e96 23 bit_period = 1000000 / baudrate;
jksoft 0:890c12951e96 24 }
jksoft 0:890c12951e96 25
jksoft 0:890c12951e96 26 void SoftSerialSendOnry::format(int bits, Parity parity, int stop_bits) {
jksoft 0:890c12951e96 27 _bits = bits;
jksoft 0:890c12951e96 28 _parity = parity;
jksoft 0:890c12951e96 29 _stop_bits = stop_bits;
jksoft 0:890c12951e96 30 _total_bits = 1 + _bits + _stop_bits + (bool)_parity;
jksoft 0:890c12951e96 31 }
jksoft 0:890c12951e96 32
jksoft 0:890c12951e96 33 int SoftSerialSendOnry::_getc()
jksoft 0:890c12951e96 34 {
jksoft 0:890c12951e96 35 return(0);
jksoft 0:890c12951e96 36 }