Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SoftSerial by
SoftSerial.cpp
- Committer:
- Sissors
- Date:
- 2014-04-26
- Revision:
- 2:9e01a38606b4
- Parent:
- 1:f8b4b764ace7
- Child:
- 5:acfd0329f648
File content as of revision 2:9e01a38606b4:
#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;
_total_bits = 1 + _bits + _stop_bits + (bool)_parity;
}
