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.
Dependencies: buffered-serial1 mbed-rtos mbed
Fork of Serial_interrupts by
Diff: buffered_serial.h
- Revision:
- 8:df59d668cab1
- Parent:
- 7:180678808740
- Child:
- 9:dbcc3caeba88
--- a/buffered_serial.h Mon Dec 10 23:27:28 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#ifndef BUFFERED_SERIAL_H
-#define BUFFERED_SERIAL_H
-
-#define BUFFER_SIZE 255
-#define LINE_SIZE 80
-#define NEXT(x) ((x+1)&BUFFER_SIZE)
-#define IS_TX_FULL (((tx_in + 1) & BUFFER_SIZE) == tx_out)
-#define IS_RX_FULL (((rx_in + 1) & BUFFER_SIZE) == rx_out)
-#define IS_RX_EMPTY (rx_in == rx_out)
-
-#include "mbed.h"
-#include "rtos.h"
-
-class BufferedSerial : public Serial
-{
-public:
- BufferedSerial(PinName tx, PinName rx);
-
- void send_line(char*);
- void read_line(char*);
-
-private:
- void Tx_interrupt();
- void Rx_interrupt();
-
-// for disabling the irq
- IRQn device_irqn;
-// Circular buffers for serial TX and RX data - used by interrupt routines
-// might need to increase buffer size for high baud rates
- char tx_buffer[BUFFER_SIZE];
- char rx_buffer[BUFFER_SIZE];
-// Circular buffer pointers
-// volatile makes read-modify-write atomic
- volatile int tx_in;
- volatile int tx_out;
- volatile int rx_in;
- volatile int rx_out;
-// Line buffers for sprintf and sscanf
- char tx_line[LINE_SIZE];
- char rx_line[LINE_SIZE];
-
- DigitalOut led1;
- DigitalOut led2;
-
- Semaphore rx_sem;
- Semaphore tx_sem;
-};
-
-#endif
\ No newline at end of file
