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
00001 #include "SoftSerial.h" 00002 00003 SoftSerial::SoftSerial(PinName TX, PinName RX, const char* name) { 00004 tx_en = rx_en = false; 00005 read_buffer = 0; 00006 if (TX != NC) { 00007 tx = new DigitalOut(TX); 00008 tx_en = true; 00009 tx->write(1); 00010 tx_bit = -1; 00011 txticker.attach(this, &SoftSerial::tx_handler); 00012 } 00013 if (RX != NC) { 00014 rx = new InterruptIn(RX); 00015 rx_en = true; 00016 out_valid = false; 00017 rxticker.attach(this, &SoftSerial::rx_handler); 00018 rx->fall(this, &SoftSerial::rx_gpio_irq_handler); 00019 } 00020 00021 baud(9600); 00022 format(); 00023 } 00024 00025 SoftSerial::~SoftSerial() { 00026 if (tx_en) 00027 delete(tx); 00028 if (rx_en) 00029 delete(rx); 00030 } 00031 00032 void SoftSerial::baud(int baudrate) { 00033 bit_period = 1000000 / baudrate; 00034 } 00035 00036 void SoftSerial::format(int bits, Parity parity, int stop_bits) { 00037 _bits = bits; 00038 _parity = parity; 00039 _stop_bits = stop_bits; 00040 _total_bits = 1 + _bits + _stop_bits + (bool)_parity; 00041 }
Generated on Tue Jul 12 2022 19:58:55 by
1.7.2
