28 #if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__) 38 #define UART_NO_ERROR 0 39 #define UART_PARITY_ERROR 4 40 #define UART_FRAMING_ERROR 8 41 #define UART_OVERRUN_ERROR 16 42 #define UART_NOISE_ERROR 32 43 #define UART_BREAK_DETECTED 64 58 #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) 59 #define UART_USE_WAIT FALSE 66 #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 67 #define UART_USE_MUTUAL_EXCLUSION FALSE 116 #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) 124 #define _uart_wakeup_tx1_isr(uartp) { \ 125 if ((uartp)->early == true) { \ 126 osalSysLockFromISR(); \ 127 osalThreadResumeI(&(uartp)->threadtx, MSG_OK); \ 128 osalSysUnlockFromISR(); \ 132 #define _uart_wakeup_tx1_isr(uartp) 135 #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) 143 #define _uart_wakeup_tx2_isr(uartp) { \ 144 if ((uartp)->early == false) { \ 145 osalSysLockFromISR(); \ 146 osalThreadResumeI(&(uartp)->threadtx, MSG_OK); \ 147 osalSysUnlockFromISR(); \ 151 #define _uart_wakeup_tx2_isr(uartp) 154 #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) 162 #define _uart_wakeup_rx_complete_isr(uartp) { \ 163 osalSysLockFromISR(); \ 164 osalThreadResumeI(&(uartp)->threadrx, MSG_OK); \ 165 osalSysUnlockFromISR(); \ 168 #define _uart_wakeup_rx_complete_isr(uartp) 171 #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) 179 #define _uart_wakeup_rx_error_isr(uartp) { \ 180 osalSysLockFromISR(); \ 181 osalThreadResumeI(&(uartp)->threadrx, MSG_RESET); \ 182 osalSysUnlockFromISR(); \ 185 #define _uart_wakeup_rx_error_isr(uartp) 188 #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) 196 #define _uart_wakeup_rx_timeout_isr(uartp) { \ 197 osalSysLockFromISR(); \ 198 osalThreadResumeI(&(uartp)->threadrx, MSG_TIMEOUT); \ 199 osalSysUnlockFromISR(); \ 202 #define _uart_wakeup_rx_timeout_isr(uartp) 219 #define _uart_tx1_isr_code(uartp) { \ 220 (uartp)->txstate = UART_TX_COMPLETE; \ 221 if ((uartp)->config->txend1_cb != NULL) { \ 222 (uartp)->config->txend1_cb(uartp); \ 224 if ((uartp)->txstate == UART_TX_COMPLETE) { \ 225 (uartp)->txstate = UART_TX_IDLE; \ 227 _uart_wakeup_tx1_isr(uartp); \ 244 #define _uart_tx2_isr_code(uartp) { \ 245 if ((uartp)->config->txend2_cb != NULL) { \ 246 (uartp)->config->txend2_cb(uartp); \ 248 _uart_wakeup_tx2_isr(uartp); \ 265 #define _uart_rx_complete_isr_code(uartp) { \ 266 (uartp)->rxstate = UART_RX_COMPLETE; \ 267 if ((uartp)->config->rxend_cb != NULL) { \ 268 (uartp)->config->rxend_cb(uartp); \ 270 if ((uartp)->rxstate == UART_RX_COMPLETE) { \ 271 (uartp)->rxstate = UART_RX_IDLE; \ 272 uart_enter_rx_idle_loop(uartp); \ 274 _uart_wakeup_rx_complete_isr(uartp); \ 292 #define _uart_rx_error_isr_code(uartp, errors) { \ 293 if ((uartp)->config->rxerr_cb != NULL) { \ 294 (uartp)->config->rxerr_cb(uartp, errors); \ 296 _uart_wakeup_rx_error_isr(uartp); \ 313 #define _uart_rx_idle_code(uartp) { \ 314 if ((uartp)->config->rxchar_cb != NULL) \ 315 (uartp)->config->rxchar_cb(uartp, (uartp)->rxbuf); \ 332 #define _uart_timeout_isr_code(uartp) { \ 333 if ((uartp)->config->timeout_cb != NULL) { \ 334 (uartp)->config->timeout_cb(uartp); \ 336 _uart_wakeup_rx_timeout_isr(uartp); \ 360 #if UART_USE_WAIT == TRUE 368 #if UART_USE_MUTUAL_EXCLUSION == TRUE PLATFORM UART subsystem low level driver header.
void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf)
Starts a transmission on the UART peripheral.
size_t uartStopReceive(UARTDriver *uartp)
Stops any ongoing receive operation.
uint64_t sysinterval_t
Type of time interval.
void uartInit(void)
UART Driver initialization.
size_t uartStopSendI(UARTDriver *uartp)
Stops any ongoing transmission.
void uartStop(UARTDriver *uartp)
Deactivates the UART peripheral.
msg_t uartSendTimeout(UARTDriver *uartp, size_t *np, const void *txbuf, sysinterval_t timeout)
Performs a transmission on the UART peripheral.
size_t uartStopReceiveI(UARTDriver *uartp)
Stops any ongoing receive operation.
uartstate_t
Driver state machine possible states.
size_t uartStopSend(UARTDriver *uartp)
Stops any ongoing transmission.
msg_t uartReceiveTimeout(UARTDriver *uartp, size_t *np, void *rxbuf, sysinterval_t timeout)
Performs a receive operation on the UART peripheral.
uarttxstate_t
Transmitter state machine states.
void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf)
Starts a transmission on the UART peripheral.
void uartStartReceiveI(UARTDriver *uartp, size_t n, void *rxbuf)
Starts a receive operation on the UART peripheral.
void uartReleaseBus(UARTDriver *uartp)
Releases exclusive access to the UART bus.
void uartAcquireBus(UARTDriver *uartp)
Gains exclusive access to the UART bus.
void uartStartReceive(UARTDriver *uartp, size_t n, void *rxbuf)
Starts a receive operation on the UART peripheral.
uartrxstate_t
Receiver state machine states.
void uartStart(UARTDriver *uartp, const UARTConfig *config)
Configures and activates the UART peripheral.
Driver configuration structure.
void uartObjectInit(UARTDriver *uartp)
Initializes the standard part of a UARTDriver structure.
Structure representing an UART driver.
msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, const void *txbuf, sysinterval_t timeout)
Performs a transmission on the UART peripheral.