Software Serial lib
Dependents: BufferedSoftSerial
Fork of SoftSerial by
SoftSerial.cpp
- Committer:
- Sissors
- Date:
- 2014-04-26
- Revision:
- 5:acfd0329f648
- Parent:
- 2:9e01a38606b4
- Child:
- 6:517082212c00
File content as of revision 5:acfd0329f648:
#include "SoftSerial.h" SoftSerial::SoftSerial(PinName TX, PinName RX, const char* name) { tx_en = rx_en = false; if (TX != NC) { tx = new DigitalOut(TX); tx_en = true; tx->write(1); tx_bit = -1; } if (RX != NC) { rx = new InterruptIn(RX); rx_en = true; out_valid = false; rx->fall(this, &SoftSerial::rx_gpio_irq_handler); } baud(9600); format(); } 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 = 1 + _bits + _stop_bits + (bool)_parity; }