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 "platform/PlatformMutex.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 69 int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
80 int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
110 ssize_t
write(
const void *buffer,
size_t length)
override;
126 ssize_t
read(
void *buffer,
size_t length)
override;
132 int close()
override;
155 off_t
seek(off_t offset,
int whence)
override;
170 _blocking = blocking;
250 using SerialBase::Parity;
251 using SerialBase::None;
252 using SerialBase::Odd;
253 using SerialBase::Even;
254 using SerialBase::Forced1;
255 using SerialBase::Forced0;
265 int bits = 8, Parity parity = BufferedSerial::None,
int stop_bits = 1
271 using SerialBase::Flow;
272 using SerialBase::Disabled;
273 using SerialBase::RTS;
274 using SerialBase::CTS;
275 using SerialBase::RTSCTS;
295 void api_unlock(
void);
302 ssize_t write_unbuffered(
const char *buf_ptr,
size_t length);
307 void enable_rx_irq();
312 void disable_rx_irq();
317 void enable_tx_irq();
322 void disable_tx_irq();
335 bool _blocking =
true;
336 bool _tx_irq_enabled =
false;
337 bool _rx_irq_enabled =
false;
338 bool _tx_enabled =
true;
339 bool _rx_enabled =
true;
370 #endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY) 371 #endif //MBED_BUFFEREDSERIAL_H void set_format(int bits=8, Parity parity=BufferedSerial::None, int stop_bits=1)
Set the transmission format used by the serial port.
ssize_t write(const void *buffer, size_t length) override
Write the contents of a buffer to a file.
void baud(int baudrate)
Set the baud rate of the serial port.
bool readable() const
Definition depends on the subclass implementing FileHandle.
Templated Circular buffer class.
int sync() override
Flush any buffers associated with the file.
int isatty() override
Check if the file in an interactive terminal device.
short poll(short events) const final
Equivalent to POSIX poll().
Prevents generation of copy constructor and copy assignment operator in derived classes.
off_t seek(off_t offset, int whence) override
Move the file position to a given offset from from a given location.
void sigio(Callback< void()> func) override
Register a callback on state change of the file.
void set_baud(int baud)
Set the baud rate.
A base class for serial port implementations Can't be instantiated directly (use UnbufferedSerial or ...
int set_blocking(bool blocking) override
Set blocking or non-blocking mode The default is blocking.
void set_data_carrier_detect(PinName dcd_pin, bool active_high=false)
Setup interrupt handler for DCD line.
int close() override
Close a file.
int enable_input(bool enabled) override
Enable or disable input.
A digital interrupt input, used to call a function on a rising or falling edge.
Class providing buffered UART communication functionality using separate circular buffer for send and...
bool is_blocking() const override
Check current blocking or non-blocking mode for file operations.
int enable_output(bool enabled) override
Enable or disable output.
bool writable() const
Definition depends on the subclass implementing FileHandle.
ssize_t read(void *buffer, size_t length) override
Read the contents of a file into a buffer.
Callback class based on template specialization.
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, with a particular baud rate.
void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC)
Set the flow control type on the serial port.