2021-12-13 14:50:34
向STM32串口发送数据的标准函数
例子:1
void UART_Send_Message(u8 *Data,u8 lenth)
{
while(lenth--)
{
USART_SendData(USART2, *Data);
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
Data++;
}
}
void main()
{
u8 Sendbuf[128];
Sendbuf[0]=0xA0;
Sendbuf[1]=0xA0;
Sendbuf[2]=0xA0;
UART_Send_Message(Sendbuf,3);
}
例子2:
void USART3_DMA_Send(u8 *data,u8 num)
{
u8 *temp;
temp=data;
while(num--)
{
USART_SendData(USART1, *temp);
temp++;
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
}
}
void main(void)
{
USART3_DMA_Send("ATrn",4);
}
例子3:
char MachineID_Default[19] = "000000000000000000";
void UART2_Send_Missage(u8 *Data)
{
while(*Data!='