Not work original Lib on F446RE & L432KC . Change usage prime() & setNext() for both TX and RX function due to unexpected behavior (maybe os TimerEvent function problem)
Dependents: BufferedSoftSerial
SoftSerial.cpp
- Committer:
- kenjiArai
- Date:
- 2020-05-10
- Revision:
- 12:cd58d03b8559
- Parent:
- 11:a0029614de72
- Child:
- 13:6399b30798a5
File content as of revision 12:cd58d03b8559:
// Modified by K.Arai / JH1PJL May 10th, 2020 #include "SoftSerial.h" SoftSerial::SoftSerial(PinName TX, PinName RX, const char* name) { tx_en = rx_en = false; read_buffer = 0; if (TX != NC) { tx = new DigitalOut(TX); tx_en = true; tx->write(1); tx_bit = -1; txticker.attach(this, &SoftSerial::tx_handler); } if (RX != NC) { rx = new InterruptIn(RX); rx_en = true; out_valid = false; rxticker.attach(this, &SoftSerial::rx_handler); rx->fall(callback(this, &SoftSerial::rx_gpio_irq_handler)); } baud(9600); format(); } SoftSerial::~SoftSerial() { if (tx_en) { delete(tx); } if (rx_en) { delete(rx); } } void SoftSerial::baud(int baudrate) { bit_period = 1000000 / baudrate; } void SoftSerial::format(int bits, Parity parity, int stop_bits) { _bits = bits; _parity = parity; _stop_bits = stop_bits; _total_bits = 2 + _bits + _stop_bits + (bool)_parity; }