ChibiOS/HAL 9.0.0
|
Generic SIO Driver. More...
Generic SIO Driver.
This driver abstracts a generic serial communication channel, usually an UART, this driver is similar to Serial and UART drivers but follows a different concept:
HAL_USE_SIO
option must be enabled in halconf.h
.The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).
SIO masks offsets | |
#define | SIO_EV_RXNOTEMPY_POS 2 /* CHN_INPUT_AVAILABLE */ |
#define | SIO_EV_TXNOTFULL_POS 3 /* CHN_OUTPUT_EMPTY */ |
#define | SIO_EV_TXDONE_POS 4 /* CHN_TRANSMISSION_END */ |
#define | SIO_EV_ALL_ERRORS_POS SIO_EV_PARITY_ERR_POS |
#define | SIO_EV_PARITY_ERR_POS 5 /* CHN_PARITY_ERROR */ |
#define | SIO_EV_FRAMING_ERR_POS 6 /* CHN_FRAMING_ERROR */ |
#define | SIO_EV_NOISE_ERR_POS 7 /* CHN_NOISE_ERROR */ |
#define | SIO_EV_OVERRUN_ERR_POS 8 /* CHN_OVERRUN_ERROR */ |
#define | SIO_EV_RXIDLE_POS 9 /* CHN_IDLE_DETECTED */ |
#define | SIO_EV_RXBREAK_POS 10 /* CHN_BREAK_DETECTED */ |
Event flags (compatible with channel and serial events) | |
#define | SIO_EV_NONE 0U |
#define | SIO_EV_RXNOTEMPY (1U << SIO_EV_RXNOTEMPY_POS) |
#define | SIO_EV_TXNOTFULL (1U << SIO_EV_TXNOTFULL_POS) |
#define | SIO_EV_ALL_DATA (SIO_EV_RXNOTEMPY | SIO_EV_TXNOTFULL) |
#define | SIO_EV_TXDONE (1U << SIO_EV_TXDONE_POS) |
#define | SIO_EV_PARITY_ERR (1U << SIO_EV_PARITY_ERR_POS) |
#define | SIO_EV_FRAMING_ERR (1U << SIO_EV_FRAMING_ERR_POS) |
#define | SIO_EV_NOISE_ERR (1U << SIO_EV_NOISE_ERR_POS) |
#define | SIO_EV_OVERRUN_ERR (1U << SIO_EV_OVERRUN_ERR_POS) |
#define | SIO_EV_RXIDLE (1U << SIO_EV_RXIDLE_POS) |
#define | SIO_EV_RXBREAK (1U << SIO_EV_RXBREAK_POS) |
#define | SIO_EV_ALL_ERRORS |
#define | SIO_EV_ALL_EVENTS |
Additional messages | |
#define | SIO_MSG_ERRORS (msg_t)1 |
SIO configuration options | |
#define | SIO_DEFAULT_BITRATE 38400 |
Default bit rate. | |
#define | SIO_USE_SYNCHRONIZATION TRUE |
Support for thread synchronization API. | |
#define | SIO_USE_STREAMS_INTERFACE SIO_USE_SYNCHRONIZATION |
Support for streams interfacwe. |
Low level driver helper macros | |
#define | __sio_callback(siop) |
SIO callback. | |
#define | __sio_wakeup_errors(siop) |
Wakes up because RX errors. | |
#define | __sio_wakeup_rx(siop) |
Wakes up the RX-waiting thread. | |
#define | __sio_wakeup_rxidle(siop) |
Wakes up the RX-idle-waiting thread. | |
#define | __sio_wakeup_tx(siop) |
Wakes up the TX-waiting thread. | |
#define | __sio_wakeup_txend(siop) |
Wakes up the TXend-waiting thread. |
PLATFORM configuration options | |
#define | PLATFORM_SIO_USE_SIO1 FALSE |
SIO driver enable switch. |
Data Structures | |
struct | hal_sio_config |
Driver configuration structure. More... | |
struct | sio_driver_vmt |
SIODriver virtual methods table. More... | |
struct | hal_sio_driver |
Structure representing a SIO driver. More... |
Macros | |
#define | _sio_driver_methods _base_channel_methods |
SIODriver specific methods. | |
#define | sioSetCallbackX(siop, f) |
Associates a callback to the SIO instance. | |
#define | sioIsRXEmptyX(siop) |
Determines the state of the RX FIFO. | |
#define | sioIsRXIdleX(siop) |
Determines the activity state of the receiver. | |
#define | sioHasRXErrorsX(siop) |
Determines if RX has pending errors to be read and cleared. | |
#define | sioIsTXFullX(siop) |
Determines the state of the TX FIFO. | |
#define | sioIsTXOngoingX(siop) |
Determines the transmission state. | |
#define | sioWriteEnableFlagsX(siop, mask) |
Writes the enabled events mask. | |
#define | sioSetEnableFlagsX(siop, mask) |
Sets flags into the enabled events flags mask. | |
#define | sioClearEnableFlagsX(siop, mask) |
Clears flags from the enabled events flags mask. | |
#define | sioGetEnableFlagsX(siop) |
Return the enabled condition flags mask. | |
#define | sioGetAndClearErrorsX(siop) |
Get and clears SIO error event flags. | |
#define | sioGetAndClearEventsX(siop) |
Get and clears SIO event flags. | |
#define | sioGetEventsX(siop) |
Returns the pending SIO event flags. | |
#define | sioGetX(siop) |
Returns one frame from the RX FIFO. | |
#define | sioPutX(siop, data) |
Pushes one frame into the TX FIFO. | |
#define | sioAsyncReadX(siop, size, buffer) |
Reads data from the RX FIFO. | |
#define | sioAsyncWriteX(siop, size, buffer) |
Writes data into the TX FIFO. | |
#define | sioControlX(siop, operation, arg) |
Control operation on a serial port. | |
#define | __sio_reloc_field(v, m, s, d) |
Relocates a bit field. | |
#define | sio_lld_driver_fields uint32_t dummy; |
Low level fields of the SIO driver structure. | |
#define | sio_lld_config_fields uint32_t dummy; |
Low level fields of the SIO configuration structure. | |
#define | sio_lld_is_rx_empty(siop) |
Determines the state of the RX FIFO. | |
#define | sio_lld_is_rx_idle(siop) |
Determines the activity state of the receiver. | |
#define | sio_lld_has_rx_errors(siop) |
Determines if RX has pending error events to be read and cleared. | |
#define | sio_lld_is_tx_full(siop) |
Determines the state of the TX FIFO. | |
#define | sio_lld_is_tx_ongoing(siop) |
Determines the transmission state. |
Typedefs | |
typedef eventflags_t | sioevents_t |
Type of event flags. | |
typedef struct hal_sio_driver | SIODriver |
Type of structure representing a SIO driver. | |
typedef struct hal_sio_config | SIOConfig |
Type of structure representing a SIO configuration. | |
typedef void(* | siocb_t) (SIODriver *siop) |
Generic SIO notification callback type. |
Enumerations | |
enum | siostate_t { SIO_UNINIT = 0 , SIO_STOP = 1 , SIO_READY = 2 } |
Driver state machine possible states. More... |
Functions | |
static size_t | sync_write (void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout) |
static size_t | sync_read (void *ip, uint8_t *bp, size_t n, sysinterval_t timeout) |
static size_t | __write (void *ip, const uint8_t *bp, size_t n) |
static size_t | __read (void *ip, uint8_t *bp, size_t n) |
static msg_t | __put (void *ip, uint8_t b) |
static msg_t | __get (void *ip) |
static msg_t | __putt (void *ip, uint8_t b, sysinterval_t timeout) |
static msg_t | __gett (void *ip, sysinterval_t timeout) |
static size_t | __writet (void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout) |
static size_t | __readt (void *ip, uint8_t *bp, size_t n, sysinterval_t timeout) |
static msg_t | __ctl (void *ip, unsigned int operation, void *arg) |
void | sioInit (void) |
SIO Driver initialization. | |
void | sioObjectInit (SIODriver *siop) |
Initializes the standard part of a SIODriver structure. | |
msg_t | sioStart (SIODriver *siop, const SIOConfig *config) |
Configures and activates the SIO peripheral. | |
void | sioStop (SIODriver *siop) |
Deactivates the SIO peripheral. | |
void | sioWriteEnableFlags (SIODriver *siop, sioevents_t mask) |
Writes the enabled events flags mask. | |
void | sioSetEnableFlags (SIODriver *siop, sioevents_t mask) |
Sets flags into the enabled events flags mask. | |
void | sioClearEnableFlags (SIODriver *siop, sioevents_t mask) |
Clears flags from the enabled events flags mask. | |
sioevents_t | sioGetAndClearErrors (SIODriver *siop) |
Get and clears SIO error event flags. | |
sioevents_t | sioGetAndClearEvents (SIODriver *siop) |
Get and clears SIO event flags. | |
sioevents_t | sioGetEvents (SIODriver *siop) |
Returns the pending SIO event flags. | |
size_t | sioAsyncRead (SIODriver *siop, uint8_t *buffer, size_t n) |
Reads data from the RX FIFO. | |
size_t | sioAsyncWrite (SIODriver *siop, const uint8_t *buffer, size_t n) |
Writes data into the TX FIFO. | |
msg_t | sioSynchronizeRX (SIODriver *siop, sysinterval_t timeout) |
Synchronizes with RX FIFO data availability. | |
msg_t | sioSynchronizeRXIdle (SIODriver *siop, sysinterval_t timeout) |
Synchronizes with RX going idle. | |
msg_t | sioSynchronizeTX (SIODriver *siop, sysinterval_t timeout) |
Synchronizes with TX FIFO space availability. | |
msg_t | sioSynchronizeTXEnd (SIODriver *siop, sysinterval_t timeout) |
Synchronizes with TX completion. | |
void | sio_lld_init (void) |
Low level SIO driver initialization. | |
msg_t | sio_lld_start (SIODriver *siop) |
Configures and activates the SIO peripheral. | |
void | sio_lld_stop (SIODriver *siop) |
Deactivates the SIO peripheral. | |
void | sio_lld_update_enable_flags (SIODriver *siop) |
Enable flags change notification. | |
sioevents_t | sio_lld_get_and_clear_errors (SIODriver *siop) |
Get and clears SIO error event flags. | |
sioevents_t | sio_lld_get_and_clear_events (SIODriver *siop) |
Get and clears SIO event flags. | |
sioevents_t | sio_lld_get_events (SIODriver *siop) |
Returns the pending SIO event flags. | |
size_t | sio_lld_read (SIODriver *siop, uint8_t *buffer, size_t n) |
Reads data from the RX FIFO. | |
size_t | sio_lld_write (SIODriver *siop, const uint8_t *buffer, size_t n) |
Writes data into the TX FIFO. | |
msg_t | sio_lld_get (SIODriver *siop) |
Returns one frame from the RX FIFO. | |
void | sio_lld_put (SIODriver *siop, uint_fast16_t data) |
Pushes one frame into the TX FIFO. | |
msg_t | sio_lld_control (SIODriver *siop, unsigned int operation, void *arg) |
Control operation on a serial port. | |
void | sio_lld_serve_interrupt (SIODriver *siop) |
Serves an UART interrupt. |
Variables | |
static const struct sio_driver_vmt | vmt |
SIODriver | SIOD1 |
SIO1 driver identifier. |
#define SIO_EV_RXNOTEMPY_POS 2 /* CHN_INPUT_AVAILABLE */ |
#define SIO_EV_TXNOTFULL_POS 3 /* CHN_OUTPUT_EMPTY */ |
#define SIO_EV_TXDONE_POS 4 /* CHN_TRANSMISSION_END */ |
#define SIO_EV_ALL_ERRORS_POS SIO_EV_PARITY_ERR_POS |
#define SIO_EV_PARITY_ERR_POS 5 /* CHN_PARITY_ERROR */ |
#define SIO_EV_FRAMING_ERR_POS 6 /* CHN_FRAMING_ERROR */ |
#define SIO_EV_NOISE_ERR_POS 7 /* CHN_NOISE_ERROR */ |
#define SIO_EV_OVERRUN_ERR_POS 8 /* CHN_OVERRUN_ERROR */ |
#define SIO_EV_RXIDLE_POS 9 /* CHN_IDLE_DETECTED */ |
#define SIO_EV_RXBREAK_POS 10 /* CHN_BREAK_DETECTED */ |
#define SIO_EV_NONE 0U |
Definition at line 56 of file hal_sio.h.
Referenced by sioStart().
#define SIO_EV_RXNOTEMPY (1U << SIO_EV_RXNOTEMPY_POS) |
Definition at line 57 of file hal_sio.h.
Referenced by __bsio_default_cb().
#define SIO_EV_TXNOTFULL (1U << SIO_EV_TXNOTFULL_POS) |
Definition at line 58 of file hal_sio.h.
Referenced by __bsio_default_cb().
#define SIO_EV_ALL_DATA (SIO_EV_RXNOTEMPY | SIO_EV_TXNOTFULL) |
Definition at line 59 of file hal_sio.h.
Referenced by __bsio_default_cb().
#define SIO_EV_TXDONE (1U << SIO_EV_TXDONE_POS) |
#define SIO_EV_PARITY_ERR (1U << SIO_EV_PARITY_ERR_POS) |
#define SIO_EV_FRAMING_ERR (1U << SIO_EV_FRAMING_ERR_POS) |
#define SIO_EV_NOISE_ERR (1U << SIO_EV_NOISE_ERR_POS) |
#define SIO_EV_OVERRUN_ERR (1U << SIO_EV_OVERRUN_ERR_POS) |
#define SIO_EV_RXIDLE (1U << SIO_EV_RXIDLE_POS) |
#define SIO_EV_RXBREAK (1U << SIO_EV_RXBREAK_POS) |
#define SIO_EV_ALL_ERRORS |
#define SIO_EV_ALL_EVENTS |
Definition at line 72 of file hal_sio.h.
Referenced by bsioStart(), and sioStart().
#define SIO_MSG_ERRORS (msg_t)1 |
Definition at line 83 of file hal_sio.h.
Referenced by sioSynchronizeRX(), and sioSynchronizeRXIdle().
#define SIO_DEFAULT_BITRATE 38400 |
#define SIO_USE_SYNCHRONIZATION TRUE |
#define SIO_USE_STREAMS_INTERFACE SIO_USE_SYNCHRONIZATION |
#define _sio_driver_methods _base_channel_methods |
#define sioSetCallbackX | ( | siop, | |
f ) |
Associates a callback to the SIO instance.
[in] | siop | pointer to the SIODriver object |
[in] | f | callback to be associated |
Definition at line 260 of file hal_sio.h.
Referenced by bsioStart().
#define sioIsRXEmptyX | ( | siop | ) |
Determines the state of the RX FIFO.
[in] | siop | pointer to the SIODriver object |
false | if RX FIFO is not empty. |
true | if RX FIFO is empty. |
Definition at line 272 of file hal_sio.h.
Referenced by __bsio_pop_data(), and sioSynchronizeRX().
#define sioIsRXIdleX | ( | siop | ) |
Determines the activity state of the receiver.
[in] | siop | pointer to the SIODriver object |
false | if RX is in active state. |
true | if RX is in idle state. |
Definition at line 284 of file hal_sio.h.
Referenced by sioSynchronizeRXIdle().
#define sioHasRXErrorsX | ( | siop | ) |
Determines if RX has pending errors to be read and cleared.
[in] | siop | pointer to the SIODriver object |
false | if RX has no pending events. |
true | if RX has pending events. |
Definition at line 297 of file hal_sio.h.
Referenced by sioSynchronizeRX(), and sioSynchronizeRXIdle().
#define sioIsTXFullX | ( | siop | ) |
Determines the state of the TX FIFO.
[in] | siop | pointer to the SIODriver object |
false | if TX FIFO is not full. |
true | if TX FIFO is full. |
Definition at line 309 of file hal_sio.h.
Referenced by __bsio_push_data(), and sioSynchronizeTX().
#define sioIsTXOngoingX | ( | siop | ) |
Determines the transmission state.
[in] | siop | pointer to the SIODriver object |
false | if transmission is over. |
true | if transmission is ongoing. |
Definition at line 321 of file hal_sio.h.
Referenced by sioSynchronizeTXEnd().
#define sioWriteEnableFlagsX | ( | siop, | |
mask ) |
Writes the enabled events mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be written |
Definition at line 331 of file hal_sio.h.
Referenced by bsioStart(), sioStart(), and sioWriteEnableFlags().
#define sioSetEnableFlagsX | ( | siop, | |
mask ) |
Sets flags into the enabled events flags mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be set |
Definition at line 344 of file hal_sio.h.
Referenced by sioSetEnableFlags().
#define sioClearEnableFlagsX | ( | siop, | |
mask ) |
Clears flags from the enabled events flags mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be cleared |
Definition at line 357 of file hal_sio.h.
Referenced by sioClearEnableFlags().
#define sioGetEnableFlagsX | ( | siop | ) |
#define sioGetAndClearErrorsX | ( | siop | ) |
Get and clears SIO error event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 379 of file hal_sio.h.
Referenced by sioGetAndClearErrors().
#define sioGetAndClearEventsX | ( | siop | ) |
Get and clears SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 389 of file hal_sio.h.
Referenced by __bsio_default_cb(), and sioGetAndClearEvents().
#define sioGetEventsX | ( | siop | ) |
Returns the pending SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 399 of file hal_sio.h.
Referenced by sioGetEvents().
#define sioGetX | ( | siop | ) |
Returns one frame from the RX FIFO.
[in] | siop | pointer to the SIODriver object |
Definition at line 410 of file hal_sio.h.
Referenced by __bsio_pop_data(), __get(), and __gett().
#define sioPutX | ( | siop, | |
data ) |
Pushes one frame into the TX FIFO.
[in] | siop | pointer to the SIODriver object |
[in] | data | frame to be written |
Definition at line 421 of file hal_sio.h.
Referenced by __bsio_push_data(), __put(), and __putt().
#define sioAsyncReadX | ( | siop, | |
size, | |||
buffer ) |
Reads data from the RX FIFO.
This function is non-blocking, data is read if present and the effective amount is returned.
rxne_cb
callback handler.[in] | siop | pointer to the SIODriver object |
[in] | size | maximum number of frames to read |
[in] | buffer | buffer for the received data |
Definition at line 437 of file hal_sio.h.
Referenced by sioAsyncRead().
#define sioAsyncWriteX | ( | siop, | |
size, | |||
buffer ) |
Writes data into the TX FIFO.
This function is non-blocking, data is written if there is space in the FIFO and the effective amount is returned.
txnf_cb
callback handler.[in] | siop | pointer to the SIODriver object |
[in] | size | maximum number of frames to read |
[out] | buffer | buffer containing the data to be transmitted |
Definition at line 453 of file hal_sio.h.
Referenced by sioAsyncWrite().
#define sioControlX | ( | siop, | |
operation, | |||
arg ) |
Control operation on a serial port.
[in] | siop | pointer to the SIODriver object |
[in] | operation | control operation code |
[in,out] | arg | operation argument |
MSG_OK | in case of success. |
MSG_TIMEOUT | in case of operation timeout. |
MSG_RESET | in case of operation reset. |
Definition at line 469 of file hal_sio.h.
Referenced by __bsio_ctl().
#define __sio_callback | ( | siop | ) |
#define __sio_wakeup_errors | ( | siop | ) |
Wakes up because RX errors.
[in] | siop | pointer to the SIODriver object |
#define __sio_wakeup_rx | ( | siop | ) |
#define __sio_wakeup_rxidle | ( | siop | ) |
#define __sio_wakeup_tx | ( | siop | ) |
#define __sio_wakeup_txend | ( | siop | ) |
#define __sio_reloc_field | ( | v, | |
m, | |||
s, | |||
d ) |
#define PLATFORM_SIO_USE_SIO1 FALSE |
SIO driver enable switch.
If set to TRUE
the support for SIO1 is included.
FALSE
. Definition at line 48 of file hal_sio_lld.h.
#define sio_lld_driver_fields uint32_t dummy; |
Low level fields of the SIO driver structure.
Definition at line 67 of file hal_sio_lld.h.
#define sio_lld_config_fields uint32_t dummy; |
Low level fields of the SIO configuration structure.
Definition at line 73 of file hal_sio_lld.h.
#define sio_lld_is_rx_empty | ( | siop | ) |
Determines the state of the RX FIFO.
[in] | siop | pointer to the SIODriver object |
false | if RX FIFO is not empty |
true | if RX FIFO is empty |
Definition at line 87 of file hal_sio_lld.h.
#define sio_lld_is_rx_idle | ( | siop | ) |
Determines the activity state of the receiver.
[in] | siop | pointer to the SIODriver object |
false | if RX is in active state. |
true | if RX is in idle state. |
Definition at line 100 of file hal_sio_lld.h.
#define sio_lld_has_rx_errors | ( | siop | ) |
Determines if RX has pending error events to be read and cleared.
[in] | siop | pointer to the SIODriver object |
false | if RX has no pending events |
true | if RX has pending events |
Definition at line 115 of file hal_sio_lld.h.
#define sio_lld_is_tx_full | ( | siop | ) |
Determines the state of the TX FIFO.
[in] | siop | pointer to the SIODriver object |
false | if TX FIFO is not full |
true | if TX FIFO is full |
Definition at line 128 of file hal_sio_lld.h.
#define sio_lld_is_tx_ongoing | ( | siop | ) |
Determines the transmission state.
[in] | siop | pointer to the SIODriver object |
false | if transmission is idle |
true | if transmission is ongoing |
Definition at line 141 of file hal_sio_lld.h.
typedef eventflags_t sioevents_t |
typedef struct hal_sio_driver SIODriver |
typedef struct hal_sio_config SIOConfig |
typedef void(* siocb_t) (SIODriver *siop) |
enum siostate_t |
|
static |
Definition at line 46 of file hal_sio.c.
References MSG_OK, sioAsyncWrite(), and sioSynchronizeTX().
Referenced by __write(), and __writet().
|
static |
Definition at line 68 of file hal_sio.c.
References MSG_OK, sioAsyncRead(), and sioSynchronizeRX().
Referenced by __read(), and __readt().
|
static |
Definition at line 95 of file hal_sio.c.
References sync_write(), and TIME_INFINITE.
|
static |
Definition at line 100 of file hal_sio.c.
References sync_read(), and TIME_INFINITE.
|
static |
Definition at line 105 of file hal_sio.c.
References MSG_OK, sioPutX, sioSynchronizeTX(), and TIME_INFINITE.
|
static |
Definition at line 118 of file hal_sio.c.
References MSG_OK, sioGetX, sioSynchronizeRX(), and TIME_INFINITE.
|
static |
Definition at line 130 of file hal_sio.c.
References MSG_OK, sioPutX, and sioSynchronizeTX().
|
static |
Definition at line 143 of file hal_sio.c.
References MSG_OK, sioGetX, and sioSynchronizeRX().
|
static |
Definition at line 155 of file hal_sio.c.
References sync_write().
|
static |
Definition at line 161 of file hal_sio.c.
References sync_read().
|
static |
Definition at line 167 of file hal_sio.c.
References CHN_CTL_INVALID, CHN_CTL_NOP, HAL_RET_SUCCESS, HAL_RET_UNKNOWN_CTL, osalDbgCheck, and sio_lld_control().
void sioInit | ( | void | ) |
SIO Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 204 of file hal_sio.c.
References sio_lld_init().
Referenced by halInit().
void sioObjectInit | ( | SIODriver * | siop | ) |
Initializes the standard part of a SIODriver
structure.
[out] | siop | pointer to the SIODriver object |
Definition at line 216 of file hal_sio.c.
References hal_sio_driver::arg, hal_sio_driver::cb, hal_sio_driver::config, hal_sio_driver::enabled, SIO_STOP, hal_sio_driver::state, hal_sio_driver::sync_rx, hal_sio_driver::sync_rxidle, hal_sio_driver::sync_tx, hal_sio_driver::sync_txend, hal_sio_driver::vmt, and vmt.
Referenced by sio_lld_init().
Configures and activates the SIO peripheral.
[in] | siop | pointer to the SIODriver object |
[in] | config | pointer to the SIOConfig object, can be NULL if the default configuration is desired |
Definition at line 249 of file hal_sio.c.
References hal_sio_driver::config, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_EV_ALL_EVENTS, SIO_EV_NONE, sio_lld_start(), SIO_READY, SIO_STOP, sioWriteEnableFlagsX, and hal_sio_driver::state.
Referenced by bsioStart().
void sioStop | ( | SIODriver * | siop | ) |
Deactivates the SIO peripheral.
[in] | siop | pointer to the SIODriver object |
Definition at line 292 of file hal_sio.c.
References hal_sio_driver::arg, hal_sio_driver::cb, hal_sio_driver::config, MSG_RESET, osalDbgAssert, osalDbgCheck, osalOsRescheduleS(), osalSysLock(), osalSysUnlock(), osalThreadResumeI(), sio_lld_stop(), SIO_READY, SIO_STOP, hal_sio_driver::state, hal_sio_driver::sync_rx, hal_sio_driver::sync_rxidle, hal_sio_driver::sync_tx, and hal_sio_driver::sync_txend.
Referenced by bsioStop().
void sioWriteEnableFlags | ( | SIODriver * | siop, |
sioevents_t | mask ) |
Writes the enabled events flags mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be written |
Definition at line 327 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioWriteEnableFlagsX, and hal_sio_driver::state.
void sioSetEnableFlags | ( | SIODriver * | siop, |
sioevents_t | mask ) |
Sets flags into the enabled events flags mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be set |
Definition at line 348 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioSetEnableFlagsX, and hal_sio_driver::state.
void sioClearEnableFlags | ( | SIODriver * | siop, |
sioevents_t | mask ) |
Clears flags from the enabled events flags mask.
[in] | siop | pointer to the SIODriver object |
[in] | mask | enabled events mask to be cleared |
Definition at line 369 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioClearEnableFlagsX, and hal_sio_driver::state.
sioevents_t sioGetAndClearErrors | ( | SIODriver * | siop | ) |
Get and clears SIO error event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 390 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioGetAndClearErrorsX, and hal_sio_driver::state.
sioevents_t sioGetAndClearEvents | ( | SIODriver * | siop | ) |
Get and clears SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 414 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioGetAndClearEventsX, and hal_sio_driver::state.
sioevents_t sioGetEvents | ( | SIODriver * | siop | ) |
Returns the pending SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 438 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioGetEventsX, and hal_sio_driver::state.
size_t sioAsyncRead | ( | SIODriver * | siop, |
uint8_t * | buffer, | ||
size_t | n ) |
Reads data from the RX FIFO.
This function is non-blocking, data is read if present and the effective amount is returned.
rxne_cb
callback handler.[in] | siop | pointer to the SIODriver object |
[in] | buffer | buffer for the received data |
[in] | n | maximum number of frames to read |
Definition at line 468 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioAsyncReadX, and hal_sio_driver::state.
Referenced by sync_read().
size_t sioAsyncWrite | ( | SIODriver * | siop, |
const uint8_t * | buffer, | ||
size_t | n ) |
Writes data into the TX FIFO.
This function is non-blocking, data is written if there is space in the FIFO and the effective amount is returned.
txnf_cb
callback handler.[in] | siop | pointer to the SIODriver object |
[out] | buffer | buffer containing the data to be transmitted |
[in] | n | maximum number of frames to read |
Definition at line 497 of file hal_sio.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SIO_READY, sioAsyncWriteX, and hal_sio_driver::state.
Referenced by sync_write().
msg_t sioSynchronizeRX | ( | SIODriver * | siop, |
sysinterval_t | timeout ) |
Synchronizes with RX FIFO data availability.
[in] | siop | pointer to an SIODriver structure |
[in] | timeout | synchronization timeout |
MSG_OK | if there is data in the RX FIFO. |
MSG_TIMEOUT | if synchronization timed out. |
MSG_RESET | it the operation has been stopped while waiting. |
SIO_MSG_ERRORS | if RX errors occurred before or during wait. |
Definition at line 529 of file hal_sio.c.
References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_MSG_ERRORS, SIO_READY, sioHasRXErrorsX, sioIsRXEmptyX, hal_sio_driver::state, and hal_sio_driver::sync_rx.
Referenced by __get(), __gett(), and sync_read().
msg_t sioSynchronizeRXIdle | ( | SIODriver * | siop, |
sysinterval_t | timeout ) |
Synchronizes with RX going idle.
[in] | siop | pointer to an SIODriver structure |
[in] | timeout | synchronization timeout |
MSG_OK | if RW went idle. |
MSG_TIMEOUT | if synchronization timed out. |
MSG_RESET | it the operation has been stopped while waiting. |
SIO_MSG_ERRORS | if RX errors occurred before or during wait. |
Definition at line 574 of file hal_sio.c.
References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_MSG_ERRORS, SIO_READY, sioHasRXErrorsX, sioIsRXIdleX, hal_sio_driver::state, and hal_sio_driver::sync_rxidle.
msg_t sioSynchronizeTX | ( | SIODriver * | siop, |
sysinterval_t | timeout ) |
Synchronizes with TX FIFO space availability.
[in] | siop | pointer to an SIODriver structure |
[in] | timeout | synchronization timeout |
MSG_OK | if there is space in the TX FIFO. |
MSG_TIMEOUT | if synchronization timed out. |
MSG_RESET | operation has been stopped while waiting. |
Definition at line 621 of file hal_sio.c.
References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_READY, sioIsTXFullX, hal_sio_driver::state, and hal_sio_driver::sync_tx.
Referenced by __put(), __putt(), and sync_write().
msg_t sioSynchronizeTXEnd | ( | SIODriver * | siop, |
sysinterval_t | timeout ) |
Synchronizes with TX completion.
[in] | siop | pointer to an SIODriver structure |
[in] | timeout | synchronization timeout |
MSG_OK | if TX operation finished. |
MSG_TIMEOUT | if synchronization timed out. |
Definition at line 659 of file hal_sio.c.
References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_READY, sioIsTXOngoingX, hal_sio_driver::state, and hal_sio_driver::sync_txend.
void sio_lld_init | ( | void | ) |
Low level SIO driver initialization.
Definition at line 65 of file hal_sio_lld.c.
References SIOD1, and sioObjectInit().
Referenced by sioInit().
Configures and activates the SIO peripheral.
[in] | siop | pointer to the SIODriver object |
Definition at line 81 of file hal_sio_lld.c.
References HAL_RET_IS_INVALID, HAL_RET_SUCCESS, osalDbgAssert, SIO_STOP, SIOD1, and hal_sio_driver::state.
Referenced by sioStart().
void sio_lld_stop | ( | SIODriver * | siop | ) |
Deactivates the SIO peripheral.
[in] | siop | pointer to the SIODriver object |
Definition at line 114 of file hal_sio_lld.c.
References SIO_READY, SIOD1, and hal_sio_driver::state.
Referenced by sioStop().
void sio_lld_update_enable_flags | ( | SIODriver * | siop | ) |
Enable flags change notification.
[in] | siop | pointer to the SIODriver object |
Definition at line 133 of file hal_sio_lld.c.
sioevents_t sio_lld_get_and_clear_errors | ( | SIODriver * | siop | ) |
Get and clears SIO error event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 146 of file hal_sio_lld.c.
sioevents_t sio_lld_get_and_clear_events | ( | SIODriver * | siop | ) |
Get and clears SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 162 of file hal_sio_lld.c.
sioevents_t sio_lld_get_events | ( | SIODriver * | siop | ) |
Returns the pending SIO event flags.
[in] | siop | pointer to the SIODriver object |
Definition at line 178 of file hal_sio_lld.c.
size_t sio_lld_read | ( | SIODriver * | siop, |
uint8_t * | buffer, | ||
size_t | n ) |
Reads data from the RX FIFO.
The function is not blocking, it writes frames until there is space available without waiting.
[in] | siop | pointer to an SIODriver structure |
[in] | buffer | pointer to the buffer for read frames |
[in] | n | maximum number of frames to be read |
0 | if the TX FIFO is full. |
Definition at line 197 of file hal_sio_lld.c.
size_t sio_lld_write | ( | SIODriver * | siop, |
const uint8_t * | buffer, | ||
size_t | n ) |
Writes data into the TX FIFO.
The function is not blocking, it writes frames until there is space available without waiting.
[in] | siop | pointer to an SIODriver structure |
[in] | buffer | pointer to the buffer for read frames |
[in] | n | maximum number of frames to be written |
0 | if the TX FIFO is full. |
Definition at line 216 of file hal_sio_lld.c.
Returns one frame from the RX FIFO.
[in] | siop | pointer to the SIODriver object |
Definition at line 233 of file hal_sio_lld.c.
void sio_lld_put | ( | SIODriver * | siop, |
uint_fast16_t | data ) |
Pushes one frame into the TX FIFO.
[in] | siop | pointer to the SIODriver object |
[in] | data | frame to be written |
Definition at line 250 of file hal_sio_lld.c.
Control operation on a serial port.
[in] | siop | pointer to the SIODriver object |
[in] | operation | control operation code |
[in,out] | arg | operation argument |
MSG_OK | in case of success. |
MSG_TIMEOUT | in case of operation timeout. |
MSG_RESET | in case of operation reset. |
Definition at line 270 of file hal_sio_lld.c.
References MSG_OK.
Referenced by __ctl().
void sio_lld_serve_interrupt | ( | SIODriver * | siop | ) |
Serves an UART interrupt.
[in] | siop | pointer to the SIODriver object |
Definition at line 286 of file hal_sio_lld.c.
|
static |
SIODriver SIOD1 |
SIO1 driver identifier.
Definition at line 41 of file hal_sio_lld.c.
Referenced by sio_lld_init(), sio_lld_start(), and sio_lld_stop().