This repository has been archived on 2024-12-31. You can view files and clone it, but cannot push or open issues or pull requests.
mfps/Inc/Uart1.h

73 lines
1.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "main.h"
extern uint8_t ttl_receive_flag;
extern uint8_t ttl_receive_cnt;
extern uint8_t ttl_receive_interval;
//微秒延时
extern void DelayUs(unsigned int delay);
//毫秒延时
extern void DelayMs(unsigned int delay);
//接收数据判断(放置串口接收数据内)
extern void Do_Receive_Uart_For_Module(unsigned char ch);
//单独发送
extern void UART1_SendData(uint8_t dat);
//发送数据
extern void UART1_Send_Char(uint8_t dat);
//发送一个字符串
//extern void send_string(uchar *p);
//初始化
extern void InitUart_Data(void);
//接收串口1
extern void start_ttl_receive_timer(uint32_t ms);
extern void over_ttl_receive_timer(void);
extern void clear_ttl_receive_timer(void);
//返回串口屏应答是否接收完成的结果
//0没超时 1超时
extern uint8_t judge_ttl_receive_timer(void);
//放在大循环中的计时器里
extern void process_ttl_receive_timer(void);
//放串口中断内,接收数据
extern void receive_ttl_data(uint8_t rx_data);
//CRC校验
extern unsigned int ModbusCRC16(unsigned char *data_value, unsigned char length);
//异或校验
extern unsigned char VerfiyRC(unsigned char data_value[], unsigned char length);
//发送延时
extern void Uart_Send_Delay(unsigned int delay);
//发送数据
extern void send_set_resp(unsigned int OrderNum, unsigned int addr, unsigned char Num, unsigned char sData[]);
//分析地址是否为本地址
extern uint8_t Check_Resive_Addr(uint16_t addr);
//接收数据判断(放置串口接收数据内)
extern void Do_Receive_Uart_For_Module(unsigned char ch);
//数据长度
extern uint8_t Get_Data_Len(void);
//检查校验
extern unsigned char Check_VerfiyData(void);
//数据接收分析(放置大循环内)
extern void Deal_Uart_Data_For_Module(void);