18#ifndef MBED_BUFFEREDSERIAL_H
19#define MBED_BUFFEREDSERIAL_H
21#include "platform/platform.h"
23#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
25#include "platform/FileHandle.h"
26#include "drivers/SerialBase.h"
27#include "drivers/InterruptIn.h"
28#include "rtos/Mutex.h"
29#include "platform/CircularBuffer.h"
30#include "platform/NonCopyable.h"
32#ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE
33#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256
36#ifndef MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE
37#define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256
70 int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
82 int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
92 short poll(
short events)
const final;
112 ssize_t
write(
const void *buffer,
size_t length)
override;
128 ssize_t
read(
void *buffer,
size_t length)
override;
157 off_t
seek(off_t offset,
int whence)
override;
172 _blocking = blocking;
252 using SerialBase::Parity;
253 using SerialBase::None;
254 using SerialBase::Odd;
255 using SerialBase::Even;
256 using SerialBase::Forced1;
257 using SerialBase::Forced0;
267 int bits = 8, Parity parity = BufferedSerial::None,
int stop_bits = 1
273 using SerialBase::Flow;
274 using SerialBase::Disabled;
275 using SerialBase::RTS;
276 using SerialBase::CTS;
277 using SerialBase::RTSCTS;
297 void api_unlock(
void);
304 ssize_t write_unbuffered(
const char *buf_ptr,
size_t length);
309 void update_rx_irq();
314 void disable_rx_irq();
319 void update_tx_irq();
324 void disable_tx_irq();
337 bool _blocking =
true;
338 bool _tx_irq_enabled =
false;
339 bool _rx_irq_enabled =
false;
Class providing buffered UART communication functionality using separate circular buffer for send and...
short poll(short events) const final
Equivalent to POSIX poll().
int enable_input(bool enabled) override
Enable or disable input.
off_t seek(off_t offset, int whence) override
Move the file position to a given offset from from a given location.
BufferedSerial(const serial_pinmap_t &static_pinmap, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
Create a BufferedSerial port, connected to the specified transmit and receive pins,...
ssize_t write(const void *buffer, size_t length) override
Write the contents of a buffer to a file.
int sync() override
Flush any buffers associated with the file.
bool is_blocking() const override
Check current blocking or non-blocking mode for file operations.
void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC)
Set the flow control type on the serial port.
void sigio(Callback< void()> func) override
Register a callback on state change of the file.
BufferedSerial(PinName tx, PinName rx, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
Create a BufferedSerial port, connected to the specified transmit and receive pins,...
void set_format(int bits=8, Parity parity=BufferedSerial::None, int stop_bits=1)
Set the transmission format used by the serial port.
void set_data_carrier_detect(PinName dcd_pin, bool active_high=false)
Setup interrupt handler for DCD line.
int enable_output(bool enabled) override
Enable or disable output.
int close() override
Close a file.
void set_baud(int baud)
Set the baud rate.
ssize_t read(void *buffer, size_t length) override
Read the contents of a file into a buffer.
int set_blocking(bool blocking) override
Set blocking or non-blocking mode The default is blocking.
int isatty() override
Check if the file in an interactive terminal device.
Callback class based on template specialization.
Templated Circular buffer class.
bool writable() const
Definition depends on the subclass implementing FileHandle.
bool readable() const
Definition depends on the subclass implementing FileHandle.
A digital interrupt input, used to call a function on a rising or falling edge.
Prevents generation of copy constructor and copy assignment operator in derived classes.
A base class for serial port implementations Can't be instantiated directly (use UnbufferedSerial or ...
void baud(int baudrate)
Set the baud rate of the serial port.
The Mutex class is used to synchronize the execution of threads.