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" 31 #include "hal/dma_api.h" 50 void baud(
int baudrate);
80 void format(
int bits = 8, Parity parity = SerialBase::None,
int stop_bits = 1);
116 "The attach function does not support cv-qualifiers. Replaced by " 117 "attach(callback(obj, method), type).")
118 void attach(T *obj,
void (T::*method)(), IrqType type = RxIrq)
134 "The attach function does not support cv-qualifiers. Replaced by " 135 "attach(callback(obj, method), type).")
136 void
attach(T *obj,
void (*method)(T *), IrqType type = RxIrq)
155 #if !defined(DOXYGEN_ONLY) 160 virtual void lock(
void);
164 virtual void unlock(
void);
178 static void _irq_handler(uint32_t
id, SerialIrq irq_type);
180 #if DEVICE_SERIAL_ASYNCH 214 int write(
const uint16_t *buffer,
int length,
const event_callback_t &callback,
int event = SERIAL_EVENT_TX_COMPLETE);
238 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);
256 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);
278 #if !defined(DOXYGEN_ONLY) 280 void start_read(
void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &callback,
int event,
unsigned char char_match);
281 void start_write(
const void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &callback,
int event);
282 void interrupt_handler_asynch(
void);
286 #if !defined(DOXYGEN_ONLY) 292 int _base_putc(
int c);
294 #if DEVICE_SERIAL_ASYNCH void send_break()
Generate a break condition on the serial line.
void baud(int baudrate)
Set the baud rate of 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.
Prevents generation of copy constructor and copy assignment operator in derived classes.
int writeable()
Determine if there is space available to write a character.
A base class for serial port implementations Can't be instantiated directly (use Serial or RawSerial)...
void clear_break()
Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is ...
void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC)
Set the flow control type on the serial port.
int readable()
Determine if there is a character available to read.
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 attach(Callback< void()> func, IrqType type=RxIrq)
Attach a function to call whenever a serial interrupt is generated.
Asynch serial HAL structure.
void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
Set the transmission format used by the serial port.
Class for created a pointer with data bound to it.
void set_break()
Generate a break condition on the serial line NOTE: Clear break needs to run at least one frame after...
void abort_read()
Abort the on-going read transfer.
int set_dma_usage_tx(DMAUsage usage)
Configure DMA usage suggestion for non-blocking TX transfers.
Callback class based on template specialization.
int set_dma_usage_rx(DMAUsage usage)
Configure DMA usage suggestion for non-blocking RX transfers.
void abort_write()
Abort the on-going write transfer.