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 BufferedSerial by
Diff: BufferedSerial.h
- Revision:
- 12:c7947d444267
- Parent:
- 11:779304f9c5d2
- Child:
- 13:b4080afc8cd5
diff -r 779304f9c5d2 -r c7947d444267 BufferedSerial.h
--- a/BufferedSerial.h Sun Jul 26 21:53:11 2015 +0000
+++ b/BufferedSerial.h Sat Feb 13 14:14:50 2016 +0000
@@ -1,5 +1,6 @@
-
/**
+ * Adapted by Benjamin Hepp (benjamin.hepp@inf.ethz.ch) to include blocking when write-buffer is full.
+ *
* @file BufferedSerial.h
* @brief Software Buffer - Extends mbed Serial functionallity adding irq driven TX and RX
* @author sam grove
@@ -74,23 +75,30 @@
Buffer <char> _rxbuf;
Buffer <char> _txbuf;
uint32_t _buf_size;
- uint32_t _tx_multiple;
+ uint32_t _buffered_bytes;
void rxIrq(void);
void txIrq(void);
void prime(void);
-
+
public:
/** Create a BufferedSerial port, connected to the specified transmit and receive pins
* @param tx Transmit pin
* @param rx Receive pin
- * @param buf_size printf() buffer size
- * @param tx_multiple amount of max printf() present in the internal ring buffer at one time
- * @param name optional name
+ * @param buf_size Write and read buffer size
* @note Either tx or rx may be specified as NC if unused
*/
- BufferedSerial(PinName tx, PinName rx, uint32_t buf_size = 256, uint32_t tx_multiple = 4,const char* name=NULL);
-
+ BufferedSerial(PinName tx, PinName rx, uint32_t buf_size = 4096);
+
+ /** Create a BufferedSerial port, connected to the specified transmit and receive pins
+ * @param tx Transmit pin
+ * @param rx Receive pin
+ * @param baud_rate Baud rate
+ * @param buf_size Write and read Buffer size
+ * @note Either tx or rx may be specified as NC if unused
+ */
+ BufferedSerial(PinName tx, PinName rx, int baud_rate, uint32_t buf_size = 4096);
+
/** Destroy a BufferedSerial port
*/
virtual ~BufferedSerial(void);
@@ -101,7 +109,7 @@
virtual int readable(void);
/** Check to see if the tx buffer has room
- * @return 1 always has room and can overwrite previous content if too small / slow
+ * @return 1 if there is space left in the ring-buffer, 0 otherwise
*/
virtual int writeable(void);
