Search
The communication between Nucleo board and PC uses RS232 data link. The C language allows you to use multiple levels of abstraction as it is described in the following figure. The operating system (OS) level uses open, write, read, close function and the C standard library uses fopen, fwrite, fread and fclose functions. While the C standard library provides the same behavior on the all platforms the OS level can vary with implementation.
uint8_t Rx_char[1]; void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { HAL_UART_Receive_IT(&huart2, Rx_char, 1); } int main(){ HAL_UART_Receive_IT (&huart2, Rx_char, 1); while (1) { } }
HAL_UART_RxCpltCallback
#define cRECV_BUFF_MAX 10 typedef struct tRecvBuff { char chArrRecvBuff[cRECV_BUFF_MAX]; int iCnt; } tRecvBuff; tRecvBuff oRecvBuff;
The structure is initialized as:
oRecvBuff.chArrRecvBuff[0] = 0; oRecvBuff.iCnt = 0;
And the reception is performed through:
while (1) { if (Rx_char[0] != prev_Rx_char[0]){ prev_Rx_char[0] = Rx_char[0]; oRecvBuff.chArrRecvBuff[oRecvBuff.iCnt] = (char) Rx_char[0]; oRecvBuff.iCnt++; HAL_UART_Transmit(&huart2, oRecvBuff.chArrRecvBuff , sizeof(oRecvBuff.chArrRecvBuff) ,10); HAL_UART_Transmit(&huart2, enter , sizeof(enter),10); } }