34#ifndef CMSIS_PLUS_DRIVER_SERIAL_H_
35#define CMSIS_PLUS_DRIVER_SERIAL_H_
50#pragma GCC diagnostic push
53#pragma clang diagnostic ignored "-Wc++98-compat"
262#pragma GCC diagnostic push
263#pragma GCC diagnostic ignored "-Wpadded"
322#pragma GCC diagnostic pop
352#pragma GCC diagnostic push
353#pragma GCC diagnostic ignored "-Wpadded"
393#pragma GCC diagnostic pop
451#pragma GCC diagnostic push
452#pragma GCC diagnostic ignored "-Wpadded"
528#pragma GCC diagnostic pop
534#pragma GCC diagnostic push
535#pragma GCC diagnostic ignored "-Wpadded"
570 const
void* cb_object =
nullptr) noexcept;
578 const serial::Capabilities&
588 send (const
void* data,
std::
size_t num) noexcept;
597 receive (
void* data,
std::
size_t num) noexcept;
607 transfer (const
void* data_out,
void* data_in,
std::
size_t num) noexcept;
630 configure (serial::config_t cfg, serial::config_arg_t arg) noexcept;
638 control (serial::control_t ctrl) noexcept;
659 serial::Modem_status&
672 clean (
void) noexcept;
678 virtual const serial::Capabilities&
704 virtual serial::Status&
710 virtual serial::Modem_status&
726#pragma GCC diagnostic pop
736 Status::is_tx_busy (
void)
742 Status::is_rx_busy (
void)
748 Status::is_tx_underflow (
void)
754 Status::is_rx_overflow (
void)
760 Status::is_rx_break (
void)
766 Status::is_rx_framing_error (
void)
772 Status::is_rx_parity_error (
void)
780 Modem_status::is_cts_active (
void)
786 Modem_status::is_dsr_active (
void)
792 Modem_status::is_dcd_active (
void)
798 Modem_status::is_ri_active (
void)
868#pragma GCC diagnostic pop
void signal_event(event_t event) noexcept
Signal serial events.
serial::Status & get_status(void) noexcept
Get serial port status.
return_t control(serial::control_t ctrl) noexcept
Control the serial interface.
serial::Modem_status modem_status_
virtual serial::Status & do_get_status(void) noexcept=0
Serial & operator=(const Serial &)=delete
virtual return_t do_control(serial::control_t ctrl) noexcept=0
void clean(void) noexcept
return_t control_modem_line(serial::Modem_control ctrl) noexcept
Configure serial modem lines.
virtual serial::Modem_status & do_get_modem_status(void) noexcept=0
Serial(const Serial &)=delete
const void * cb_object_
Pointer to object instance associated with this driver.
return_t receive(void *data, std::size_t num) noexcept
Start the serial receiver.
virtual std::size_t do_get_rx_count(void) noexcept=0
virtual return_t do_receive(void *data, std::size_t num) noexcept=0
virtual return_t do_configure(serial::config_t cfg, serial::config_arg_t arg) noexcept=0
virtual std::size_t do_get_tx_count(void) noexcept=0
std::size_t get_rx_count(void) noexcept
Get received bytes count.
return_t configure(serial::config_t cfg, serial::config_arg_t arg) noexcept
Configure the serial interface.
signal_event_t cb_func_
Pointer to static function that implements the callback.
virtual ~Serial() noexcept override
virtual return_t do_control_modem_line(serial::Modem_control ctrl) noexcept=0
virtual return_t do_send(const void *data, std::size_t num) noexcept=0
serial::Modem_status & get_modem_status(void) noexcept
Get serial modem lines state.
std::size_t get_tx_count(void) noexcept
Get transmitted bytes count.
const serial::Capabilities & get_capabilities(void) noexcept
Get driver capabilities.
virtual const serial::Capabilities & do_get_capabilities(void) noexcept=0
return_t send(const void *data, std::size_t num) noexcept
Start the serial transmitter.
return_t transfer(const void *data_out, void *data_in, std::size_t num) noexcept
Start sending/receiving data to/from the serial transmitter/receiver.
void register_callback(signal_event_t cb_func, const void *cb_object=nullptr) noexcept
Register event callback.
virtual return_t do_transfer(const void *data_out, void *data_in, std::size_t num) noexcept=0
Serial device driver capabilities.
bool event_dcd
Signal RI change event.
bool synchronous_slave
supports Single-wire mode
bool dtr
DSR Line: false=not available, true=available.
bool dsr
DCD Line: false=not available, true=available.
bool rts
CTS Line: false=not available, true=available.
bool event_cts
Signal DSR change event.
bool event_dsr
Signal DCD change event.
bool event_rx_timeout
RTS Line: false=not available, true=available.
bool flow_control_cts
Transmit completed event.
bool single_wire
supports IrDA mode
bool smart_card_clock
RTS Flow Control available.
bool synchronous_master
supports Synchronous Slave mode
bool irda
supports Smart Card mode
bool ri
Signal CTS change event.
bool cts
DTR Line: false=not available, true=available.
bool asynchronous
< supports Asynchronous mode
bool smart_card
Smart Card Clock generator available.
bool event_tx_complete
Signal receive character timeout event.
bool dcd
RI Line: false=not available, true=available.
bool flow_control_rts
CTS Flow Control available.
bool dsr
DCD state: true=Active, false=Inactive.
bool dcd
RI state: true=Active, false=Inactive.
bool cts
< CTS state: true=Active, false=Inactive
bool is_rx_overflow(void)
bool rx_overflow
Break detected on receive (cleared on start of next receive operation)
bool tx_busy
< Transmitter busy flag
bool tx_underflow
Receive data overflow detected (cleared on start of next receive operation)
bool is_rx_parity_error(void)
bool rx_busy
Transmit data underflow detected (cleared on start of next send operation)
bool rx_framing_error
Parity error detected on receive (cleared on start of next receive operation)
bool is_rx_framing_error(void)
bool is_tx_underflow(void)
bool rx_break
Framing error detected on receive (cleared on start of next receive operation)
constexpr config_t PARITY_Msk
No Parity = (default);.
constexpr bit_number_t DATA_BITS_Pos
constexpr config_t CPHA0
CPHA = 1.
constexpr config_t FLOW_CONTROL_RTS
CTS Flow Control.
constexpr config_t STOP_BITS_2
1.5 Stop bits
constexpr config_t PARITY_NONE
Even Parity.
constexpr config_t DATA_BITS_8
9 Data bits
constexpr config_t DEFAULT_TX_VALUE
< Set default Transmit value = (Synchronous Receive only); arg = value
constexpr config_t SMART_CARD_NACK
constexpr config_t DATA_BITS_6
7 Data bits
constexpr config_t DATA_BITS_9
constexpr return_t ERROR_MODE
< Specified Mode not supported
constexpr config_t MODE_IRDA
UART Smart Card; arg = Baudrate.
constexpr bit_number_t PARITY_Pos
constexpr config_t CPHA_Msk
CPHA = 0 = (default);.
constexpr config_t IRDA_PULSE
Set Smart Card Guard Time; arg = number of bit periods.
constexpr config_t STOP_BITS_1
2 Stop bits
constexpr config_t DATA_BITS_Msk
5 Data bits
constexpr config_t MODE_SYNCHRONOUS_MASTER
Synchronous Slave = (external clock signal);.
constexpr config_t DATA_BITS_7
8 Data bits = (default);
constexpr config_t CPOL_Msk
CPOL = 0 = (default);.
constexpr config_t FLOW_CONTROL_RTS_CTS
constexpr config_t FLOW_CONTROL_CTS
RTS/CTS Flow Control.
constexpr config_t PARITY_EVEN
Odd Parity.
constexpr config_t DATA_BITS_5
6 Data bit
constexpr config_t FLOW_CONTROL_Msk
No Flow Control = (default);.
constexpr config_t MODE_ASYNCHRONOUS
< UART = (Asynchronous);; arg = Baudrate
constexpr config_t SMART_CARD_CLOCK
Smart Card NACK generation; arg: 0=disabled, 1=enabled.
constexpr config_t MODE_SYNCHRONOUS_SLAVE
UART Single-wire = (half-duplex);; arg = Baudrate.
constexpr bit_number_t CPHA_Pos
constexpr return_t ERROR_DATA_BITS
Specified Parity not supported.
constexpr config_t MODE_SMART_CARD
constexpr bit_number_t CONFIG_Pos
constexpr config_t CONFIG_Msk(0xFFUL<< CONFIG_Pos)
constexpr config_t FLOW_CONTROL_NONE
RTS Flow Control.
constexpr return_t ERROR_CPHA
@ abort_receive
Abort Serial::transfer()
@ abort_send
Abort Serial::receive()
@ enable_break
Abort Serial::send()
@ disable_tx
Disable Receiver.
@ abort_transfer
Disable Transmitter.
@ enable_tx
Enable Transmitter.
@ enable_rx
Enable Continuous Break transmission.
@ disable_rx
Disable Continuous Break transmission;.
constexpr bit_number_t STOP_BITS_Pos
@ cts
DSR state changed (optional)
@ rx_framing_error
Parity error detected on receive.
@ transfer_complete
Transmit completed (optional)
@ dsr
DCD state changed (optional)
@ rx_parity_error
CTS state changed (optional)
@ rx_break
Framing error detected on receive.
@ tx_underflow
Receive data overflow.
@ dcd
RI state changed (optional)
@ rx_timeout
Break detected on receive.
@ receive_complete
Transfer completed.
@ rx_overflow
Receive character timeout (optional)
@ tx_complete
Transmit data not available (Synchronous Slave)
@ send_complete
Send completed; however USART may still transmit data.
constexpr config_t SMART_CARD_GUARD_TIME
Set Smart Card Clock in Hz; arg: 0=Clock not generated.
constexpr return_t ERROR_BAUDRATE
Specified number of Data bits not supported.
constexpr config_t MODE_SINGLE_WIRE
UART IrDA; arg = Baudrate.
constexpr return_t ERROR_FLOW_CONTROL
Specified Clock Polarity not supported.
constexpr config_t PARITY_ODD
constexpr config_t STOP_BITS_Msk
1 Stop bit = (default);
constexpr return_t ERROR_STOP_BITS
Specified Flow Control not supported.
constexpr bit_number_t FLOW_CONFIG_Pos
constexpr config_t STOP_BITS_0_5
constexpr config_t STOP_BITS_1_5
0.5 Stop bits
Modem_control
Configuration to change the serial modem lines.
@ clear_rts
Deactivate RTS.
constexpr return_t ERROR_CPOL
Specified Clock Phase not supported.
constexpr return_t ERROR_PARITY
Specified number of Stop bits not supported.
constexpr config_t CPOL0
CPOL = 1.
constexpr bit_number_t CPOL_Pos
constexpr return_t ERROR_SPECIFIC
void(* signal_event_t)(const void *object, event_t event)