17#ifndef MBED_SERIALBASE_H
18#define MBED_SERIALBASE_H
20#include "platform/platform.h"
22#if DEVICE_SERIAL || defined(DOXYGEN_ONLY)
24#include "platform/Callback.h"
25#include "hal/serial_api.h"
26#include "platform/mbed_toolchain.h"
27#include "platform/NonCopyable.h"
29#if DEVICE_SERIAL_ASYNCH
30#include "platform/CThunk.h"
83 void format(
int bits = 8, Parity parity = SerialBase::None,
int stop_bits = 1);
146#if !defined(DOXYGEN_ONLY)
151 virtual void lock(
void);
155 virtual void unlock(
void);
176 static void _irq_handler(uint32_t
id,
SerialIrq irq_type);
178#if DEVICE_SERIAL_ASYNCH
236 int read(uint8_t *buffer,
int length,
const event_callback_t &
callback,
int event = SERIAL_EVENT_RX_COMPLETE,
unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
254 int read(uint16_t *buffer,
int length,
const event_callback_t &
callback,
int event = SERIAL_EVENT_RX_COMPLETE,
unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
276#if !defined(DOXYGEN_ONLY)
278 void start_read(
void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &
callback,
int event,
unsigned char char_match);
279 void start_write(
const void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &
callback,
int event);
280 void interrupt_handler_asynch(
void);
284#if !defined(DOXYGEN_ONLY)
292 int _base_putc(
int c);
305#if DEVICE_SERIAL_ASYNCH
311 bool _tx_asynch_set =
false;
312 bool _rx_asynch_set =
false;
318 bool _rx_enabled =
true;
319 bool _tx_enabled =
true;
320 const PinName _tx_pin;
321 const PinName _rx_pin;
323 void (
SerialBase::*_set_flow_control_dp_func)(Flow, PinName, PinName) = NULL;
326 Flow _flow_type = Disabled;
Class for created a pointer with data bound to it.
Callback class based on template specialization.
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 ...
int read(uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
Begin asynchronous reading using 16bit buffer.
void set_break()
Generate a break condition on the serial line NOTE: Clear break needs to run at least one frame after...
int read(uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
Begin asynchronous reading using 8bit buffer.
void abort_read()
Abort the on-going read transfer.
int readable()
Determine if there is a character available to read.
void attach(Callback< void()> func, IrqType type=RxIrq)
Attach a function to call whenever a serial interrupt is generated.
void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC)
Set the flow control type on the serial port.
int write(const uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
Begin asynchronous write using 8bit buffer.
void send_break()
Generate a break condition on the serial line.
void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
Set the transmission format used by the serial port.
void abort_write()
Abort the on-going write transfer.
int set_dma_usage_rx(DMAUsage usage)
Configure DMA usage suggestion for non-blocking RX transfers.
int write(const uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
Begin asynchronous write using 16bit buffer.
void enable_output(bool enable=true)
Enable serial output.
void baud(int baudrate)
Set the baud rate of the serial port.
int writeable()
Determine if there is space available to write a character.
int set_dma_usage_tx(DMAUsage usage)
Configure DMA usage suggestion for non-blocking TX transfers.
void clear_break()
Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is ...
void enable_input(bool enable=true)
Enable serial input.
void set_flow_control(Flow type, const serial_fc_pinmap_t &static_pinmap)
Set the flow control type on the serial port.
SerialIrq
Serial interrupt sources.
DMAUsage
Enumeration of possible DMA usage hints.
@ DMA_USAGE_NEVER
Never use DMA.
Asynch serial HAL structure.