I am trying to use the uartReceiveTimeout() function from the UART driver API but I don't know how to use timeout_cb() callback.
My code is:
Code: Select all
static void timeout_cb_(UARTDriver *uartp) {
(void)uartp;
uart_error_ = CB_UART_TIMEOUT_DETECTED;
}
static size_t np = READING_BLOCK_SIZE_L4R5ZI;
static void init_uart_driver_(void) {
static const UARTConfig c = {NULL,
NULL,
rxend_cb_,
NULL,
rxerr_cb_,
timeout_cb_,
0,
UART_DRIVE_SPEED_BAUD_RATE,
0,
USART_CR2_LINEN,
0
};
uartObjectInit(&UART_DRIVE_L4R5ZI);
uartStart(&UART_DRIVE_L4R5ZI, &c);
palSetPadMode(
UART_DRIVE_TX_PORT_L4R5ZI,
UART_DRIVE_TX_PAD_L4R5ZI,
PAL_MODE_ALTERNATE(UART_DRIVE_ALTER_FUNC_L4R5ZI) | PAL_STM32_OSPEED_HIGH | PAL_STM32_OTYPE_PUSHPULL);
palSetPadMode(
UART_DRIVE_RX_PORT_L4R5ZI,
UART_DRIVE_RX_PAD_L4R5ZI,
PAL_MODE_ALTERNATE(UART_DRIVE_ALTER_FUNC_L4R5ZI) | PAL_STM32_OSPEED_HIGH | PAL_STM32_OTYPE_PUSHPULL);
np = READING_BLOCK_SIZE_L4R5ZI;
uartReceiveTimeout(&UART_DRIVE_L4R5ZI, &np, rx_block_buffer, TIME_MS2I(1));
}
I have verified that np is zero but the callback doesn't run. Shouldn't callback be invoked? When is callback invoked?
When the timeout is completed and I have not received anything, after calling the uartStopReceiveI() function, does the DMA stop?
The driver internally does not have a buffer associated to the DMA, it uses directly what the STM32 provides. Is this so?
Thank you.