Skip to content

Commit 00a7616

Browse files
when UART err occurs, disable listener mode, so that it can be detected, and restarted.
1 parent bd13385 commit 00a7616

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/per/uart.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ class UartHandler::Impl
6666
EndCallbackFunctionPtr end_callback,
6767
void* callback_context);
6868

69-
/** Starts the DMA Reception in "Listen" mode.
70-
* In this mode the DMA is configured for circular
69+
/** Starts the DMA Reception in "Listen" mode.
70+
* In this mode the DMA is configured for circular
7171
* behavior, and the IDLE interrupt is enabled.
72-
*
72+
*
7373
* At TC, HT, and IDLE interrupts data must be processed.
74-
*
74+
*
7575
* Size must be set so that at maximum bandwidth, the software
7676
* has time to process N bytes before the next circular IRQ is fired
77-
*
77+
*
7878
*/
7979
Result DmaListenStart(uint8_t* buff,
8080
size_t size,
@@ -132,7 +132,7 @@ class UartHandler::Impl
132132
static EndCallbackFunctionPtr next_end_callback_;
133133
static void* next_callback_context_;
134134

135-
/** Not static -- any UART can use this
135+
/** Not static -- any UART can use this
136136
* until we had dynamic DMA stream handling
137137
* this will consume the sole DMA stream for UART Rx
138138
*/
@@ -959,7 +959,7 @@ extern "C" void dsy_uart_global_init()
959959

960960
/** static handler for Listener Mode of Rx to handle
961961
* non-aligned transfers during DMA Reception.
962-
*
962+
*
963963
* this is the equivalent of what the old FifoHandler stuff
964964
* did, but removes all of the fifo'ing, and replaces it with a user
965965
* callback. The MIDI UART Transport is an example of how this might be used.
@@ -969,9 +969,9 @@ static void UART_CheckRxListener(UartHandler::Impl* handle)
969969
size_t pos;
970970
size_t old_pos = handle->circular_rx_last_pos_;
971971

972-
/** calculate pos. in buffer
972+
/** calculate pos. in buffer
973973
* TODO: make flexible for other DMA STreams
974-
*
974+
*
975975
*/
976976
uint8_t* buffer = handle->circular_rx_buff_;
977977
pos = handle->circular_rx_total_size_
@@ -1103,10 +1103,8 @@ extern "C" void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef* huart)
11031103

11041104
extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart)
11051105
{
1106-
/** TODO: This hooks into the "Normal" DMA completion,
1107-
* might want to change this to have a different fallthrough
1108-
* for "listener_mode_"
1109-
*/
1106+
auto* handle = MapInstanceToHandle(huart->Instance);
1107+
handle->listener_mode_ = false;
11101108
UartHandler::Impl::DmaTransferFinished(huart, UartHandler::Result::ERR);
11111109
}
11121110

0 commit comments

Comments
 (0)