2024-12-12 12:07 AM
Hello,
I am trying to put the Lorawan keys (DEVEUI,APPEUI, APPKEY) from a serial terminal using uart communication for end node application. I am using uart interrupts for this. There is cubemx generated usart_if.c file which contains HAL_UART_RxCpltCallback() already. This is the code snippet:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* USER CODE BEGIN HAL_UART_RxCpltCallback_1 */
/* USER CODE END HAL_UART_RxCpltCallback_1 */
if (huart->Instance == USART2)
{
if ((NULL != RxCpltCallback) && (HAL_UART_ERROR_NONE == huart->ErrorCode))
{
RxCpltCallback(&charRx, 1, 0);
}
HAL_UART_Receive_IT(huart, &charRx, 1);
}
/* USER CODE BEGIN HAL_UART_RxCpltCallback_2 */
/* USER CODE END HAL_UART_RxCpltCallback_2 */
}
How to modify this with my code so that I can receive a command from serial terminal and proceed accordingly.
Thank you.
2024-12-12 05:49 AM - edited 2024-12-12 06:09 AM
hal_uart.c has _weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart), but it has attribute as _weak
as weak, so you have to implement your version such as setting a flag or copy the data etc..
avoid time consuming activities since it is an interrupt.
_weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback can be implemented in the user file.
*/
}