58 stm32cubemx_helper::set_context<Handle, UartRxIt>(
this);
59 HAL_UART_RegisterCallback(
60 Handle, HAL_UART_RX_COMPLETE_CB_ID, [](UART_HandleTypeDef *huart) {
61 auto uart = stm32cubemx_helper::get_context<Handle, UartRxIt>();
62 uart->queue_.push(uart->buf_);
63 HAL_UART_Receive_IT(huart, &uart->buf_, 1);
65 HAL_UART_RegisterCallback(
66 Handle, HAL_UART_ERROR_CB_ID,
67 [](UART_HandleTypeDef *huart) { HAL_UART_AbortReceive_IT(huart); });
68 HAL_UART_RegisterCallback(
69 Handle, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID,
70 [](UART_HandleTypeDef *huart) {
71 auto rx = stm32cubemx_helper::get_context<Handle, UartRxIt>();
72 HAL_UART_Receive_IT(huart, &rx->buf_, 1);
74 HAL_UART_Receive_IT(Handle, &buf_, 1);
78 HAL_UART_AbortReceive(Handle);
79 HAL_UART_UnRegisterCallback(Handle, HAL_UART_RX_COMPLETE_CB_ID);
80 HAL_UART_UnRegisterCallback(Handle, HAL_UART_ERROR_CB_ID);
81 HAL_UART_UnRegisterCallback(Handle, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID);
82 stm32cubemx_helper::set_context<Handle, UartRxIt>(
nullptr);