#include <SerialBase.h>
|
enum | Parity {
None = 0,
Odd,
Even,
Forced1,
Forced0
} |
|
enum | IrqType { RxIrq = 0,
TxIrq
} |
|
enum | Flow { Disabled = 0,
RTS,
CTS,
RTSCTS
} |
|
typedef mbed::util::FunctionPointer2< void, Buffer, int > | event_callback_t |
|
|
void | baud (int baudrate) |
|
void | format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1) |
|
int | readable () |
|
int | writeable () |
|
void | attach (void(*fptr)(void), IrqType type=RxIrq) |
|
template<typename T > |
void | attach (T *tptr, void(T::*mptr)(void), IrqType type=RxIrq) |
|
void | send_break () |
|
void | set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC) |
|
int | write (void *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE) |
|
int | write (const Buffer &buf, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE) |
|
void | abort_write () |
|
int | read (void *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH) |
|
int | read (const Buffer &buffer, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH) |
|
void | abort_read () |
|
int | set_dma_usage_tx (DMAUsage usage) |
|
int | set_dma_usage_rx (DMAUsage usage) |
|
|
static void | _irq_handler (uint32_t id, SerialIrq irq_type) |
|
|
void | start_read (const Buffer &buffer, char buffer_width, const event_callback_t &callback, int event, unsigned char char_match) |
|
void | start_write (const Buffer &buffer, char buffer_width, const event_callback_t &callback, int event) |
|
void | interrupt_handler_asynch (void) |
|
| SerialBase (PinName tx, PinName rx) |
|
int | _base_getc () |
|
int | _base_putc (int c) |
|
A base class for serial port implementations Can't be instantiated directly (use Serial or RawSerial)
Serial transfer callback
- Parameters
-
Buffer | the transfer buffer |
int | the event that triggered the calback |
void mbed::SerialBase::abort_read |
( |
void |
| ) |
|
Abort the on-going read transfer
void mbed::SerialBase::abort_write |
( |
void |
| ) |
|
Abort the on-going write transfer
void mbed::SerialBase::attach |
( |
void(*)(void) |
fptr, |
|
|
IrqType |
type = RxIrq |
|
) |
| |
Attach a function to call whenever a serial interrupt is generated
- Parameters
-
fptr | A pointer to a void function, or 0 to set as none |
type | Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty) |
template<typename T >
void mbed::SerialBase::attach |
( |
T * |
tptr, |
|
|
void(T::*)(void) |
mptr, |
|
|
IrqType |
type = RxIrq |
|
) |
| |
|
inline |
Attach a member function to call whenever a serial interrupt is generated
- Parameters
-
tptr | pointer to the object to call the member function on |
mptr | pointer to the member function to be called |
type | Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty) |
void mbed::SerialBase::baud |
( |
int |
baudrate | ) |
|
Set the baud rate of the serial port
- Parameters
-
baudrate | The baudrate of the serial port (default = 9600). |
void mbed::SerialBase::format |
( |
int |
bits = 8 , |
|
|
Parity |
parity = SerialBase::None , |
|
|
int |
stop_bits = 1 |
|
) |
| |
Set the transmission format used by the serial port
- Parameters
-
bits | The number of bits in a word (5-8; default = 8) |
parity | The parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) |
stop | The number of stop bits (1 or 2; default = 1) |
int mbed::SerialBase::read |
( |
void * |
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. The completition invokes registred RX event callback.
- Parameters
-
buffer | The buffer where received data will be stored |
length | The buffer length |
callback | The event callback function |
event | The logical OR of RX events |
char_match | The matching character |
int mbed::SerialBase::read |
( |
const Buffer & |
buffer, |
|
|
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. The completition invokes registred RX event callback.
- Parameters
-
buffer | The buffer where received data will be stored |
callback | The event callback function |
event | The logical OR of RX events |
char_match | The matching character |
int mbed::SerialBase::readable |
( |
| ) |
|
Determine if there is a character available to read
typedef FunctionPointer3<void, Buffer, int, void*> event_callback_t; typedef OneWayTransaction<event_callback_t> transaction_data_t; typedef Transaction<SerialBase, transaction_data_t> transaction_t;
- Returns
- 1 if there is a character available to read, 0 otherwise
void mbed::SerialBase::send_break |
( |
| ) |
|
Generate a break condition on the serial line
int mbed::SerialBase::set_dma_usage_rx |
( |
DMAUsage |
usage | ) |
|
Configure DMA usage suggestion for non-blocking RX transfers
- Parameters
-
usage | The usage DMA hint for peripheral |
- Returns
- Zero if the usage was set, -1 if a transaction is on-going
int mbed::SerialBase::set_dma_usage_tx |
( |
DMAUsage |
usage | ) |
|
Configure DMA usage suggestion for non-blocking TX transfers
- Parameters
-
usage | The usage DMA hint for peripheral |
- Returns
- Zero if the usage was set, -1 if a transaction is on-going
void mbed::SerialBase::set_flow_control |
( |
Flow |
type, |
|
|
PinName |
flow1 = NC , |
|
|
PinName |
flow2 = NC |
|
) |
| |
Set the flow control type on the serial port
- Parameters
-
type | the flow control type (Disabled, RTS, CTS, RTSCTS) |
flow1 | the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS) |
flow2 | the second flow control pin (CTS for RTSCTS) |
int mbed::SerialBase::write |
( |
void * |
buffer, |
|
|
int |
length, |
|
|
const event_callback_t & |
callback, |
|
|
int |
event = SERIAL_EVENT_TX_COMPLETE |
|
) |
| |
Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback
- Parameters
-
buffer | The buffer where received data will be stored |
length | The buffer length |
callback | The event callback function |
event | The logical OR of TX events |
int mbed::SerialBase::write |
( |
const Buffer & |
buf, |
|
|
const event_callback_t & |
callback, |
|
|
int |
event = SERIAL_EVENT_TX_COMPLETE |
|
) |
| |
Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback
- Parameters
-
buffer | The buffer where received data will be stored |
callback | The event callback function |
event | The logical OR of TX events |
int mbed::SerialBase::writeable |
( |
| ) |
|
Determine if there is space available to write a character
- Returns
- 1 if there is space to write a character, 0 otherwise
The documentation for this class was generated from the following files: