ワークショップ用のサンプル

Dependencies:   Milkcocoa mbed

Fork of MilkcocoaSampleESP8266 by Junichi Katsu

Committer:
jksoft
Date:
Fri Dec 18 04:47:41 2015 +0000
Revision:
0:82d5445a9461
??

Who changed what in which revision?

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