You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The UART class write method currently blocks waiting on a flag that will not be set until the transmission is complete. For low baud rates this can be a long time. There is currently a SafeRingBuffer instance allocated in the class, but no attempt has been made to make use of it. The code as written now submits a pointer to the HAL and then hangs until the transmission ends.
The flag tx_done is only set in the interrupt handler after transmission ends.
/* -------------------------------------------------------------------------- */
void UART::WrapperCallback(uart_callback_args_t *p_args) {
/* -------------------------------------------------------------------------- */
uint32_t channel = p_args->channel;
UART *uart_ptr = UART::g_uarts[channel];
if(uart_ptr == nullptr) {
return;
}
switch (p_args->event){
case UART_EVENT_ERR_PARITY:
case UART_EVENT_ERR_FRAMING:
case UART_EVENT_ERR_OVERFLOW:
case UART_EVENT_RX_COMPLETE: // This is called when all the "expected" data are received
{
break;
}
case UART_EVENT_TX_COMPLETE:
case UART_EVENT_TX_DATA_EMPTY:
{
//uint8_t to_enqueue = uart_ptr->txBuffer.available() < uart_ptr->uart_ctrl.fifo_depth ? uart_ptr->txBuffer.available() : uart_ptr->uart_ctrl.fifo_depth;
//while (to_enqueue) {
uart_ptr->tx_done = true;
break;
}
case UART_EVENT_RX_CHAR:
{
if (uart_ptr->rxBuffer.availableForStore()) {
uart_ptr->rxBuffer.store_char(p_args->data);
}
break;
}
case UART_EVENT_BREAK_DETECT:
{
break;
}
}
}
Additionally, by not making use of the buffer, a pointer to the users data is passed into the HAL. This means that any changes made to the data behind that pointer while it's still being sent will corrupt the output. Using the txBuffer will solve that problem as well.
The text was updated successfully, but these errors were encountered:
The UART class write method currently blocks waiting on a flag that will not be set until the transmission is complete. For low baud rates this can be a long time. There is currently a SafeRingBuffer instance allocated in the class, but no attempt has been made to make use of it. The code as written now submits a pointer to the HAL and then hangs until the transmission ends.
The flag
tx_done
is only set in the interrupt handler after transmission ends.Additionally, by not making use of the buffer, a pointer to the users data is passed into the HAL. This means that any changes made to the data behind that pointer while it's still being sent will corrupt the output. Using the txBuffer will solve that problem as well.
The text was updated successfully, but these errors were encountered: