通信协议格式为 [0x03] [0xfc][数据......][0xfc][0x03], 完成一次波形发送.
部分代码:
- void usart1_send_char(u8 c)
- {
- while((USART1->SR&0X40)==0);
- USART1->DR=c;
- }
- void sw_send_data(u8 *data,u8 len)
- {
- u8 i;
- usart1_send_char(ZHENG);
- usart1_send_char(~ZHENG);
- for(i=0;i<len;i++)
- {
- usart1_send_char(*data);
- data++;
- }
- usart1_send_char(~ZHENG);
- usart1_send_char(ZHENG);
- }
PS:~0x03 等价与 0xfc
来源: http://www.bubuko.com/infodetail-3045782.html