📄 communication_usart.h
字号:
通讯处理消息任务结构标志的静态存储变量定义:
--------------------------------------------------------------------------------------*/
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
static volatile tasks_comm tcomm_sign0 = tasks_comm_defaults;
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
static volatile tasks_comm tcomm_sign1 = tasks_comm_defaults;
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
static volatile tasks_comm tcomm_sign = tasks_comm_defaults;
#endif // "USE_USART_PORT" 条件编译结束
/*--------------------------------------------------------------------------------------
接收和发送数据缓冲区的静态存储数组变量定义:
--------------------------------------------------------------------------------------*/
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
static unsigned char usart0_rx_buffer[USART0_RXBUF_SIZE];
static unsigned char usart0_tx_buffer[USART0_TXBUF_SIZE];
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
static unsigned char usart1_rx_buffer[USART1_RXBUF_SIZE];
static unsigned char usart1_tx_buffer[USART1_TXBUF_SIZE];
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
static unsigned char usart_rx_buffer[USART_RXBUF_SIZE];
static unsigned char usart_tx_buffer[USART_TXBUF_SIZE];
#endif // "USE_USART_PORT" 条件编译结束
/*--------------------------------------------------------------------------------------
接收和发送数据个数计数器和地址索引的静态存储变量定义:
--------------------------------------------------------------------------------------*/
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
#if USART0_RXBUF_SIZE < 256
static unsigned char usart0_rx_index = 0;
static unsigned char usart0_rx_counter = 0;
#else
static unsigned int usart0_rx_index = 0;
static unsigned int usart0_rx_counter = 0;
#endif
#if USART0_TXBUF_SIZE < 256
static unsigned char usart0_tx_index = 0;
static unsigned char usart0_tx_counter = 0;
#else
static unsigned int usart0_tx_index = 0;
static unsigned int usart0_tx_counter = 0;
#endif
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
#if USART1_RXBUF_SIZE < 256
static unsigned char usart1_rx_index = 0;
static unsigned char usart1_rx_counter = 0;
#else
static unsigned int usart1_rx_index = 0;
static unsigned int usart1_rx_counter = 0;
#endif
#if USART1_TXBUF_SIZE < 256
static unsigned char usart1_tx_index = 0;
static unsigned char usart1_tx_counter = 0;
#else
static unsigned int usart1_tx_index = 0;
static unsigned int usart1_tx_counter = 0;
#endif
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
#if USART_RXBUF_SIZE < 256
static unsigned char usart_rx_index = 0;
static unsigned char usart_rx_counter = 0;
#else
static unsigned int usart_rx_index = 0;
static unsigned int usart_rx_counter = 0;
#endif
#if USART_TXBUF_SIZE < 256
static unsigned char usart_tx_index = 0;
static unsigned char usart_tx_counter = 0;
#else
static unsigned int usart_tx_index = 0;
static unsigned int usart_tx_counter = 0;
#endif
#endif // "USE_USART_PORT" 条件编译结束
/*--------------------------------------------------------------------------------------
接收和发送命令缓冲区的静态存储数组变量定义:
--------------------------------------------------------------------------------------*/
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
static unsigned char usart0_com_rx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart0_com_tx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart0_com_rx_counter = 0;
static unsigned char usart0_com_tx_counter = 0;
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
static unsigned char usart1_com_rx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart1_com_tx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart1_com_rx_counter = 0;
static unsigned char usart1_com_tx_counter = 0;
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
static unsigned char usart_com_rx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart_com_tx_buffer[TCOMM_BUF_SIZE];
static unsigned char usart_com_rx_counter = 0;
static unsigned char usart_com_tx_counter = 0;
#endif // "USE_USART_PORT" 条件编译结束
/*--------------------------------------------------------------------------------------
按组接收和发送命令数据的每批次数和批次最后一次的数据个数计数器的静态存储变量定义:
--------------------------------------------------------------------------------------*/
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
static unsigned int usart0_tx_data_times = 0; // 定义USART0发送数据每批次数变量
#if USART0_TXBUF_SIZE < 256
static unsigned char usart0_tx_end_counter = 0;
#else
static unsigned int usart0_tx_end_counter = 0;
#endif
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
static unsigned int usart1_tx_data_times = 0; // 定义USART1发送数据每批次数变量
#if USART1_TXBUF_SIZE < 256
static unsigned char usart1_tx_end_counter = 0;
#else
static unsigned int usart1_tx_end_counter = 0;
#endif
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
static unsigned int usart_tx_data_times = 0; // 定义USART发送数据每批次数变量
#if USART_TXBUF_SIZE < 256
static unsigned char usart_tx_end_counter = 0;
#else
static unsigned int usart_tx_end_counter = 0;
#endif
#endif // "USE_USART_PORT" 条件编译结束
/*==========================================================================================
Communication_USART.c 源程序文件中的函数原型声明:
==========================================================================================*/
/*--------------------------------------------------------------------------------------
函数功能: 本函数用于通用同步和异步串行接收器和转发器(USART),使用中断方式异步接收和发送
数据通信 USART 端口状态设置的初始化操作。
备注: 本函数仅在主函数中调用一次即可。
--------------------------------------------------------------------------------------*/
void COMM_USART_initialization(void);
/*==========================================================================================
通信数据转储目的地声明和数组变量定义
==========================================================================================*/
#define USART_DATA_TO_FROM_EXTSRAM // 从大于 64 KB 扩展随机存储器中转储通信数据声明
//#define USART_DATA_TO_FROM_EEPROM // 从 EEPROM 中转储通信数据声明
/*--------------------------------------------------------------------------------------
用于测试的通信数据转储目的地为EEPROM数组定义:
--------------------------------------------------------------------------------------*/
#ifdef USART_DATA_TO_FROM_EEPROM // 从 EEPROM 中转储通信数据的条件编译
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
#define USART0_RX_EEPBUF_SIZE 0x01FF // USART0接收转储数据缓冲区大小
#define USART0_TX_EEPBUF_SIZE 0x01FF // USART0发送转储数据缓冲区大小
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
#define USART1_RX_EEPBUF_SIZE 0x01FF // USART1接收转储数据缓冲区大小
#define USART1_TX_EEPBUF_SIZE 0x01FF // USART1发送转储数据缓冲区大小
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
#define USART_RX_EEPBUF_SIZE 0x01FF // USART接收转储数据缓冲区大小
#define USART_TX_EEPBUF_SIZE 0x01FF // USART发送转储数据缓冲区大小
#endif // "USE_USART_PORT" 条件编译结束
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
// 定义USART0的接收和发送从 EEPROM 中转储数据缓冲区存储数组变量
eeprom unsigned char usart0_rx_eepbuf[USART0_RX_EEPBUF_SIZE];
eeprom unsigned char usart0_tx_eepbuf[USART0_TX_EEPBUF_SIZE];
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
// 定义USART1的接收和发送从 EEPROM 中转储数据缓冲区存储数组变量
eeprom unsigned char usart1_rx_eepbuf[USART1_RX_EEPBUF_SIZE];
eeprom unsigned char usart1_tx_eepbuf[USART1_TX_EEPBUF_SIZE];
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
// 定义USART的接收和发送从 EEPROM 中转储数据缓冲区存储数组变量
eeprom unsigned char usart_rx_eepbuf[USART_RX_EEPBUF_SIZE];
eeprom unsigned char usart_tx_eepbuf[USART_TX_EEPBUF_SIZE];
#endif // "USE_USART_PORT" 条件编译结束
#ifdef DUAL_USART_USE_USART0 // 使用USART0的条件编译
// 定义USART0接收和发送转储缓冲区转储数据地址索引变量
#if USART0_RX_EEPBUF_SIZE < 256
eeprom unsigned char usart0_rx_eepbuf_index = 0;
#else
eeprom unsigned int usart0_rx_eepbuf_index = 0;
#endif
#if USART0_TX_EEPBUF_SIZE < 256
eeprom unsigned char usart0_tx_eepbuf_index = 0;
#else
eeprom unsigned int usart0_tx_eepbuf_index = 0;
#endif
#endif // "DUAL_USART_USE_USART0" 条件编译结束
#ifdef DUAL_USART_USE_USART1 // 使用USART1的条件编译
// 定义USART1接收和发送转储缓冲区转储数据地址索引变量
#if USART1_RX_EEPBUF_SIZE < 256
eeprom unsigned char usart1_rx_eepbuf_index = 0;
#else
eeprom unsigned int usart1_rx_eepbuf_index = 0;
#endif
#if USART1_TX_EEPBUF_SIZE < 256
eeprom unsigned char usart1_tx_eepbuf_index = 0;
#else
eeprom unsigned int usart1_tx_eepbuf_index = 0;
#endif
#endif // "DUAL_USART_USE_USART1" 条件编译结束
#ifdef USE_USART_PORT // 使用USART的条件编译
// 定义USART接收和发送转储缓冲区转储数据地址索引变量
#if USART_RX_EEPBUF_SIZE < 256
eeprom unsigned char usart_rx_eepbuf_index = 0;
#else
eeprom unsigned int usart_rx_eepbuf_index = 0;
#endif
#if USART_TX_EEPBUF_SIZE < 256
eeprom unsigned char usart_tx_eepbuf_index = 0;
#else
eeprom unsigned int usart_tx_eepbuf_index = 0;
#endif
#endif // "USE_USART_PORT" 条件编译结束
#endif // "USART_DATA_TO_FROM_EEPROM" 条件编译结束
/*==========================================================================================
下面这三条指令是用于与上面三条区分编译系统为 C++ 或 C 的预处理指令相对应。用于指定
extern "C" 链接指示符作用域,此处的"}"与上面的"{"相对应,为链接指示符作用结束符。
==========================================================================================*/
#ifdef __cplusplus
}
#endif
#endif // "Communication_USART_H" 条件编译结束
/*
********************************************************************************************
本头部文件到此结束
********************************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -