forked SoftSerial
Fork of SoftSerial by
Diff: SoftSerial.cpp
- Revision:
- 0:8edaa7abe724
- Child:
- 1:f8b4b764ace7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SoftSerial.cpp Sat Apr 26 14:46:03 2014 +0000
@@ -0,0 +1,29 @@
+#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;
+ 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;
+}
