![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
ワークショップ用に公開しているものです。
Fork of Arch_Analog_Thermistor_Blinker by
SoftSerialSendOnly/SoftSerialSendOnry.cpp@9:5a7dca00d87b, 2016-02-27 (annotated)
- Committer:
- jksoft
- Date:
- Sat Feb 27 05:38:49 2016 +0000
- Revision:
- 9:5a7dca00d87b
????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 9:5a7dca00d87b | 1 | #include "SoftSerialSendOnry.h" |
jksoft | 9:5a7dca00d87b | 2 | |
jksoft | 9:5a7dca00d87b | 3 | SoftSerialSendOnry::SoftSerialSendOnry(PinName TX, const char* name) { |
jksoft | 9:5a7dca00d87b | 4 | tx_en = false; |
jksoft | 9:5a7dca00d87b | 5 | if (TX != NC) { |
jksoft | 9:5a7dca00d87b | 6 | tx = new DigitalOut(TX); |
jksoft | 9:5a7dca00d87b | 7 | tx_en = true; |
jksoft | 9:5a7dca00d87b | 8 | tx->write(1); |
jksoft | 9:5a7dca00d87b | 9 | tx_bit = -1; |
jksoft | 9:5a7dca00d87b | 10 | txticker.attach(this, &SoftSerialSendOnry::tx_handler); |
jksoft | 9:5a7dca00d87b | 11 | } |
jksoft | 9:5a7dca00d87b | 12 | |
jksoft | 9:5a7dca00d87b | 13 | baud(9600); |
jksoft | 9:5a7dca00d87b | 14 | format(); |
jksoft | 9:5a7dca00d87b | 15 | } |
jksoft | 9:5a7dca00d87b | 16 | |
jksoft | 9:5a7dca00d87b | 17 | SoftSerialSendOnry::~SoftSerialSendOnry() { |
jksoft | 9:5a7dca00d87b | 18 | if (tx_en) |
jksoft | 9:5a7dca00d87b | 19 | delete(tx); |
jksoft | 9:5a7dca00d87b | 20 | } |
jksoft | 9:5a7dca00d87b | 21 | |
jksoft | 9:5a7dca00d87b | 22 | void SoftSerialSendOnry::baud(int baudrate) { |
jksoft | 9:5a7dca00d87b | 23 | bit_period = 1000000 / baudrate; |
jksoft | 9:5a7dca00d87b | 24 | } |
jksoft | 9:5a7dca00d87b | 25 | |
jksoft | 9:5a7dca00d87b | 26 | void SoftSerialSendOnry::format(int bits, Parity parity, int stop_bits) { |
jksoft | 9:5a7dca00d87b | 27 | _bits = bits; |
jksoft | 9:5a7dca00d87b | 28 | _parity = parity; |
jksoft | 9:5a7dca00d87b | 29 | _stop_bits = stop_bits; |
jksoft | 9:5a7dca00d87b | 30 | _total_bits = 1 + _bits + _stop_bits + (bool)_parity; |
jksoft | 9:5a7dca00d87b | 31 | } |
jksoft | 9:5a7dca00d87b | 32 | |
jksoft | 9:5a7dca00d87b | 33 | int SoftSerialSendOnry::_getc() |
jksoft | 9:5a7dca00d87b | 34 | { |
jksoft | 9:5a7dca00d87b | 35 | return(0); |
jksoft | 9:5a7dca00d87b | 36 | } |