Hi,
I have a little problem to use the UART driver. I've looked at the
Receiver sub State Machine diagram but I don't know how to invoke the
uartStartReceive() function. It gives the impression that it has to be invoked more than once but I don't know where.

In my project, I start the driver and invoke the
uartStartReceive() function from this function:
Code: Select all
static void init_uart_driver_(void) {
if (uart_initializated) {
return;
}
static const UARTConfig c = {NULL, // End of transmission buffer callback
NULL, // Physical end of transmission callback
rxend_cb_, // Receive buffer filled callback
rxchar_cb_, // Character received while out if the UART_RECEIVE state
rxerr_cb_, // Receive error callback
timeout_cb_, // Receiver timeout callback. Handles both idle and timeout
// interrupts depending on configured flags in CR registers and
// supported hardware features.
0, // Receiver timeout value in terms of number of bit duration.
// Set it to 0 when you want to handle idle interrupt instead of
// hardware timeout
UART_DRIVE_SPEED_BAUD_RATE, // Bit rate
0, // Initialization value for the CR1 register.
USART_CR2_LINEN, // Initialization value for the CR2 register.
0 // Initialization value for the CR3 register.
};
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);
reset_char_buffer(rx_block_buffer, RX_BUFFER_SIZE_L4R5ZI);
uartStartReceive(&UART_DRIVE_L4R5ZI, READING_BLOCK_SIZE_L4R5ZI,
rx_block_buffer);
uart_initializated = true;
}
My buffer(
rx_block_buffer) has a size of 80 characters. In the
rxend_cb_ callback, I do the following:
Code: Select all
static void rxend_cb_(UARTDriver *uartp) {
(void)uartp;
chMtxLock(&mtx_bp_);
push_buffer_policy(&uart_block_bp, rx_block_buffer);
chMtxUnlock(&mtx_bp_);
chEvtSignalI(uart_th_producer, UART_PRODUCER_EVENT_L4R5ZI);
}
The content of the
rx_block_buffer buffer is stored in a
FIFO object and signaled to a thread to tell it to consume what is in the FIFO object.
If I run my program, it only reads once and if I invoke the
uartStartReceive() function inside the
rxend_cb_ callback, an exception is generated after a reading.
Code: Select all
_unhandled_exception:
0800029e: b.n 0x800029e <_unhandled_exception>
In vector.S:
Code: Select all
_unhandled_exception:
.stay:
b .stay
Stack;
Code: Select all
Thread [1] (Suspended: Signal 'SIGINT' received. Description: Interrupt.)
2 _unhandled_exception() vectors.S:1027 0x0800029e
1 VectorFC() vectors.S:1021 0x0800029e
Where do you have to invoke the
uartStartReceive() function?
Thank you.