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

Dependents:   SITB_HttpGetSample SITB_IFTTTSample SITB_INA226PRC AmbientExampleSITB ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SoftSerialSendOnry.cpp Source File

SoftSerialSendOnry.cpp

00001 #include "SoftSerialSendOnry.h"
00002 
00003 SoftSerialSendOnry::SoftSerialSendOnry(PinName TX, const char* name) {
00004     tx_en = false;
00005     if (TX != NC) {
00006         tx = new DigitalOut(TX);
00007         tx_en = true;
00008         tx->write(1);
00009         tx_bit = -1;
00010         txticker.attach(this, &SoftSerialSendOnry::tx_handler);
00011     }
00012     
00013     baud(9600);
00014     format();
00015 }
00016 
00017 SoftSerialSendOnry::~SoftSerialSendOnry() {
00018     if (tx_en)
00019         delete(tx);
00020 }
00021 
00022 void SoftSerialSendOnry::baud(int baudrate) {
00023     bit_period = 1000000 / baudrate;
00024 }
00025 
00026 void SoftSerialSendOnry::format(int bits, Parity parity, int stop_bits) {
00027     _bits = bits;
00028     _parity = parity;
00029     _stop_bits = stop_bits;
00030     _total_bits = 1 + _bits + _stop_bits + (bool)_parity;
00031 }
00032 
00033 int SoftSerialSendOnry::_getc()
00034 {
00035     return(0);    
00036 }