60 stm32cubemx_helper::set_context<Handle, UartRxDma>(
this);
61 HAL_UART_RegisterCallback(
62 Handle, HAL_UART_ERROR_CB_ID,
63 [](UART_HandleTypeDef *huart) { HAL_UART_AbortReceive_IT(huart); });
64 HAL_UART_RegisterCallback(
65 Handle, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID,
66 [](UART_HandleTypeDef *huart) {
67 auto rx = stm32cubemx_helper::get_context<Handle, UartRxDma>();
68 HAL_UART_Receive_DMA(huart, rx->buf_.data(), rx->buf_.size());
69 rx->read_idx_.store(0, std::memory_order_relaxed);
71 HAL_UART_Receive_DMA(Handle, buf_.data(), buf_.size());
75 HAL_UART_AbortReceive(Handle);
76 HAL_UART_UnRegisterCallback(Handle, HAL_UART_ERROR_CB_ID);
77 HAL_UART_UnRegisterCallback(Handle, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID);
78 stm32cubemx_helper::set_context<Handle, UartRxDma>(
nullptr);