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" 53 void baud(
int baudrate);
83 void format(
int bits = 8, Parity parity = SerialBase::None,
int stop_bits = 1);
119 "The attach function does not support cv-qualifiers. Replaced by " 120 "attach(callback(obj, method), type).")
121 void attach(T *obj,
void (T::*method)(), IrqType type = RxIrq)
137 "The attach function does not support cv-qualifiers. Replaced by " 138 "attach(callback(obj, method), type).")
139 void
attach(T *obj,
void (*method)(T *), IrqType type = RxIrq)
182 #if !defined(DOXYGEN_ONLY) 187 virtual void lock(
void);
191 virtual void unlock(
void);
205 static void _irq_handler(uint32_t
id,
SerialIrq irq_type);
207 #if DEVICE_SERIAL_ASYNCH 241 int write(
const uint16_t *buffer,
int length,
const event_callback_t &callback,
int event = SERIAL_EVENT_TX_COMPLETE);
265 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);
283 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);
305 #if !defined(DOXYGEN_ONLY) 307 void start_read(
void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &callback,
int event,
unsigned char char_match);
308 void start_write(
const void *buffer,
int buffer_size,
char buffer_width,
const event_callback_t &callback,
int event);
309 void interrupt_handler_asynch(
void);
313 #if !defined(DOXYGEN_ONLY) 320 int _base_putc(
int c);
330 #if DEVICE_SERIAL_ASYNCH 345 const PinName _tx_pin;
346 const PinName _rx_pin;
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.
SerialIrq
Serial interrupt sources.
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 enable_input(bool enable=true)
Enable serial input.
void enable_output(bool enable=true)
Enable serial output.
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.