Serial Send function:
uint8_t txdata["01234abcde"; Hal_uart_transmit (&huart2,txdata,0xffff); // Send the contents of the TxData through the Uart2, the length is 10,timeout time is the maximum value 0xFFFF
Serial Reception function 1:
uint8_t value='F'; Hal_uart_receive (&huart2, (uint8_t *) &value,1,+); // in this statement stay 1000ms waiting to receive 1 bytes of data, the data stored in value
Serial Reception function 2:
Hal_uart_receive_it (&huart2, (uint8_t *) &value,1); // The program will not stay in this statement, directly according to the interrupt mode to store the received data in value, but this statement can only enable one serial port interrupt. So to re-enable in the Interrupt service function
Serial Reception function 3:
if (Hal_uart_receive_it (&huart2, (uint8_t *) &value,1 )! = HAL_OK) {// This sentence is written in the while (1) of the main function Above. Used to start a program to start an interrupt receive Hal_uart_transmit (&huart2, (uint8_t *) & " error\r\n , 7 , 10 ); while (1
void Hal_uart_rxcpltcallback (Uart_handletypedef *uarthandle) { hal_uart_transmit (&huart2, (uint8_t *) &"\r\ninto hal_uart_rxcpltcallback\r\n",0xffff); // Verify that this function has been entered. Hal_uart_transmit (&huart2, (uint8_t *) &value,1,0xffff); // Send the received data through the serial port Hal_uart_receive_it (&huart2, (uint8_t *) &value,1); // re-open serial interrupt }
Stm32l0 HAL Library UART serial Read and write function