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.
Dependents: Adafruit_FONA_Library_FONAtest
Fork of SoftSerial by
SoftSerial.cpp
- Committer:
- Sissors
- Date:
- 2014-04-27
- Revision:
- 6:517082212c00
- Parent:
- 5:acfd0329f648
- Child:
- 9:4e4617c4a441
File content as of revision 6:517082212c00:
#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;
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(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;
}
