STM32F4 UART HAL Driver

后端 未结 6 1010
北荒
北荒 2021-01-30 04:49

I\'m trying to figure out how to use this new HAL driver. I want to receive data using the HAL_UART_Receive_IT() which sets up the device to run an interrupt functi

6条回答
  •  伪装坚强ぢ
    2021-01-30 05:05

    I had to face the same problem in my project. What I did is start reading 1 byte with HAL_USART_Receive_IT() right after the peripheral initialization.

    Then I wrote a callback on transfer complete which puts the byte in a buffer, sets a flag if command is complete and then calls HAL_USART_Receive_IT() again for another byte.

    It seems to work nice for me since I receive commands trough the USART whose first byte tells me how many bytes more the command is going to be long. Maybe it could work for you too!

提交回复
热议问题