ワークショップ用のサンプルプログラムです。

Dependencies:   DHT mbed

Committer:
jksoft
Date:
Fri Apr 29 21:07:24 2016 +0000
Revision:
0:a967c8649563
??

Who changed what in which revision?

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