Software serial, for when you are out of serial pins
Dependents: BufferedSoftSerial neurGAI_Seeed_BLUETOOTH LPC-SD-35 ESP-WROOM-02_test ... more
SoftSerial.cpp
- Committer:
- Sissors
- Date:
- 2014-04-26
- Revision:
- 1:f8b4b764ace7
- Parent:
- 0:8edaa7abe724
- Child:
- 2:9e01a38606b4
File content as of revision 1:f8b4b764ace7:
#include "SoftSerial.h" SoftSerial::SoftSerial(PinName TX, PinName RX) { 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; }