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);
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 212 int write(
const uint16_t *buffer,
int length,
const event_callback_t &callback,
int event = SERIAL_EVENT_TX_COMPLETE);
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 307 DMAUsage _tx_usage = DMA_USAGE_NEVER;
308 DMAUsage _rx_usage = DMA_USAGE_NEVER;
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;
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 UnbufferedSerial or ...
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.