From bf00814a048e11da1bb3c526f12904577824c2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=A1=B00110?= Date: Tue, 26 Sep 2023 22:17:35 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=96=B9=E6=B3=95,=E8=BD=AF=E4=BB=B6=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=99=A8,=E4=B8=B2=E5=8F=A3=E7=AE=A1=E7=90=86=E7=94=A8?= =?UTF-8?q?=E4=BE=8B;=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=BA=94=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=92=8C=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MultiAll.h => common/all_include.h} | 41 +- drivers/modbus/modbus_host.c | 295 ++++---- drivers/modbus/modbus_host.h | 78 +-- drivers/modbus/modbus_slave.c | 21 +- drivers/modbus/modbus_slave.h | 22 +- drivers/modules/command_line.c | 4 +- .../modbus_common.c => modules/data_check.c} | 73 +- .../modbus_common.h => modules/data_check.h} | 19 +- drivers/modules/sync_method.c | 180 ++--- drivers/modules/sync_method.h | 184 +++-- drivers/modules/timer_software.c | 329 ++++----- drivers/modules/timer_software.h | 97 ++- drivers/modules/uart_handler.c | 207 +++--- drivers/modules/uart_handler.h | 77 ++- examples/[base_on_stm32f1]/stm32f1_sys/gpio.c | 56 +- examples/[base_on_stm32f1]/stm32f1_sys/gpio.h | 2 - .../project_template/MDK/use_example.uvoptx | 170 ++++- .../project_template/MDK/use_example.uvprojx | 72 +- examples/project_template/README.txt | 10 +- examples/project_template/SRC/main.c | 4 +- examples/ring_buffer/README.txt | 1 + examples/sync_method/README.txt | 3 +- examples/sync_method/SRC/main.c | 53 +- .../timer_software/MDK/use_example.uvoptx | 640 +++++++++++++++++ .../timer_software/MDK/use_example.uvprojx | 602 ++++++++++++++++ examples/timer_software/README.txt | 44 ++ examples/timer_software/SRC/main.c | 110 +++ examples/uart_handler/MDK/use_example.uvoptx | 652 ++++++++++++++++++ examples/uart_handler/MDK/use_example.uvprojx | 607 ++++++++++++++++ examples/uart_handler/README.txt | 47 ++ examples/uart_handler/SRC/main.c | 145 ++++ 31 files changed, 3988 insertions(+), 857 deletions(-) rename drivers/{modules/MultiAll.h => common/all_include.h} (50%) rename drivers/{modbus/modbus_common.c => modules/data_check.c} (63%) rename drivers/{modbus/modbus_common.h => modules/data_check.h} (73%) create mode 100644 examples/timer_software/MDK/use_example.uvoptx create mode 100644 examples/timer_software/MDK/use_example.uvprojx create mode 100644 examples/timer_software/README.txt create mode 100644 examples/timer_software/SRC/main.c create mode 100644 examples/uart_handler/MDK/use_example.uvoptx create mode 100644 examples/uart_handler/MDK/use_example.uvprojx create mode 100644 examples/uart_handler/README.txt create mode 100644 examples/uart_handler/SRC/main.c diff --git a/drivers/modules/MultiAll.h b/drivers/common/all_include.h similarity index 50% rename from drivers/modules/MultiAll.h rename to drivers/common/all_include.h index 3f3a167..d07db99 100644 --- a/drivers/modules/MultiAll.h +++ b/drivers/common/all_include.h @@ -1,11 +1,10 @@ /** ****************************************************************************** - * @file MultiAll.h + * @file all_include.h * @author ashuai0110 - * @version V2.0 - * @date 2023-07-12 - * @brief 所有模块的头文件 - * 将此文件包含进工程即可使用全部组件 + * @version V2.1 + * @date 2023-09-26 + * @brief 所有组件的头文件 * ****************************************************************************** * @attention @@ -16,8 +15,8 @@ ****************************************************************************** */ -#ifndef __MULTIALL_H -#define __MULTIALL_H +#ifndef __ALL_INCLUDE_H +#define __ALL_INCLUDE_H #ifdef __cplusplus extern "C" { @@ -25,20 +24,20 @@ extern "C" { /* 包含头文件-----------------------------------------------------------------*/ /* 通用头文件 */ -#include "common_include.h" /* 通用接口 */ - +#include "common_include.h" /*!< 通用接口 */ /* 组件头文件 */ -#include "command_line.h" /* 命令行交互 */ -#include "data_convert.h" /* 数据转换 */ -#include "delay_no_block.h" /* 非阻塞延时 */ -#include "input_output.h" /* IO输入输出操作 */ -#include "memory.h" /* 内存管理-小内存管理算法 */ -#include "message_queue.h" /* 消息队列-柔性数组版 */ -#include "MultiQueueS.h" /* 消息队列-指针版 */ -#include "ring_buffer.h" /* 环形缓冲区 */ -#include "ring_queue.h" /* 环形队列 */ -#include "sync_method.h" /* 伪线程同步(信号量,互斥锁,事件集) */ -#include "timer_software.h" /* 软件定时器 */ +#include "command_line.h" /*!< 命令行交互 */ +#include "data_check.h" /*!< 数据校验 */ +#include "data_convert.h" /*!< 数据转换 */ +#include "delay_no_block.h" /*!< 非阻塞延时 */ +#include "input_output.h" /*!< IO输入输出操作 */ +#include "memory.h" /*!< 内存管理-小内存管理算法 */ +#include "message_queue.h" /*!< 消息队列 */ +#include "ring_buffer.h" /*!< 环形缓冲区 */ +#include "ring_queue.h" /*!< 环形队列 */ +#include "sync_method.h" /*!< 伪线程同步(信号量,互斥锁,事件集) */ +#include "timer_software.h" /*!< 软件定时器 */ +#include "uart_handler.h" /*!< 串口管理 */ /* 宏定义---------------------------------------------------------------------*/ @@ -52,4 +51,4 @@ extern "C" { } #endif -#endif /* MultiAll.h */ +#endif /* all_include.h */ diff --git a/drivers/modbus/modbus_host.c b/drivers/modbus/modbus_host.c index 5357363..cef6ae0 100644 --- a/drivers/modbus/modbus_host.c +++ b/drivers/modbus/modbus_host.c @@ -1,49 +1,50 @@ /** ****************************************************************************** * @file modbus_host.c - * @author ashuai0110 + * @author woshiashuai * @version V1.0 * @date 2023-09-01 - * @brief modbus��������(RTU ASCII) + * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** * @attention * - * ��Ȩ����:����Ϊ����ԭ��,��ѭCC4.0BY-SA��ȨЭ��,ʹ���븽�ϳ������Ӻͱ����� - * ��������:htashuai0110.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ -/* ����ͷ�ļ�-----------------------------------------------------------------*/ +/* 包含头文件-----------------------------------------------------------------*/ #include "modbus_host.h" +#include "data_check.h" -/* ˽�к궨��-----------------------------------------------------------------*/ -/* modbus�������������Ч�Լ�� */ +/* 私有宏定义-----------------------------------------------------------------*/ +/* modbus主机管理序号有效性检查 */ #define IS_VALID_CH(x) \ ( ((x) == 0) || \ ((x) > 0) && \ ((x) < MODBUS_HOST_NUM)) -/* ˽�����Ͷ���---------------------------------------------------------------*/ +/* 私有类型定义---------------------------------------------------------------*/ -/* ˽�б���-------------------------------------------------------------------*/ -static mb_host_t mbHostArr[MODBUS_HOST_NUM]; /* modbus������������ */ +/* 私有变量-------------------------------------------------------------------*/ +static mb_host_t mbHostArr[MODBUS_HOST_NUM]; /* modbus主机管理数组 */ -/* ȫ�ֱ���-------------------------------------------------------------------*/ +/* 全局变量-------------------------------------------------------------------*/ -/* ˽�к���ԭ��---------------------------------------------------------------*/ +/* 私有函数原型---------------------------------------------------------------*/ /** - * @brief modbus������ʼ�� + * @brief modbus主机初始化 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param fRead : ���ݶ�ȡ����(���ڽ���) + * @param fRead : 数据读取函数(用于接收) * - * @param fWrite : ����д�뺯��(���ڷ���) + * @param fWrite : 数据写入函数(用于发送) * - * @param timeout : Ӧ��ʱʱ��ms + * @param timeout : 应答超时时间ms * * @retval None */ @@ -61,9 +62,9 @@ void mb_host_init(uint8_t ch, mb_host_rw_fn_t fRead, mb_host_rw_fn_t fWrite, uin } /** - * @brief �ӻ�Ӧ�������ɴ��� + * @brief 从机应答接收完成处理 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * * @retval None */ @@ -77,11 +78,11 @@ void mb_host_rsp_over(uint8_t ch) } /** - * @brief ����Ӧ��ʱʱ�� + * @brief 设置应答超时时间 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param timeout : Ӧ��ʱʱ��ms + * @param timeout : 应答超时时间ms * * @retval None */ @@ -95,18 +96,18 @@ void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout) } /** - * @brief ����ȦӦ����(0x01) + * @brief 读线圈应答处理(0x01) * - * @note �ӻ���ַ | ������ | �ֽ���n | ��Ȧ״̬ | CRC16 - * 1 | 1 | 1 | n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 字节数n | 线圈状态 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ��Ȧ���� 1��Ȧ=1bit + * @param num : 线圈数量 1线圈=1bit * - * @param pData : ��Ȧ���� + * @param pData : 线圈数据 * * @retval None */ @@ -125,18 +126,18 @@ __WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa } /** - * @brief ����ɢ������Ӧ����(0x02) + * @brief 读离散量输入应答处理(0x02) * - * @note �ӻ���ַ | ������ | �ֽ���n | ��ɢ��״̬ | CRC16 - * 1 | 1 | 1 | n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 字节数n | 离散量状态 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ��ɢ���������� 1��ɢ������=1bit + * @param num : 离散量输入数量 1离散量输入=1bit * - * @param pData : ��ɢ���������� + * @param pData : 离散量输入数据 * * @retval None */ @@ -155,18 +156,18 @@ __WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa } /** - * @brief �����ּĴ���Ӧ����(0x03) + * @brief 读保持寄存器应答处理(0x03) * - * @note �ӻ���ַ | ������ | �ֽ���n | ���ּĴ���ֵ | CRC16 - * 1 | 1 | 1 | n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 字节数n | 保持寄存器值 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ���ּĴ������� 1���ּĴ���=16bit + * @param num : 保持寄存器数量 1保持寄存器=16bit * - * @param pData : ���ּĴ������� + * @param pData : 保持寄存器数据 * * @retval None */ @@ -185,18 +186,18 @@ __WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa } /** - * @brief ������Ĵ���Ӧ����(0x04) + * @brief 读输入寄存器应答处理(0x04) * - * @note �ӻ���ַ | ������ | �ֽ���n | ����Ĵ���ֵ | CRC16 - * 1 | 1 | 1 | n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 字节数n | 输入寄存器值 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ����Ĵ������� 1����Ĵ���=16bit + * @param num : 输入寄存器数量 1输入寄存器=16bit * - * @param pData : ����Ĵ������� + * @param pData : 输入寄存器数据 * * @retval None */ @@ -215,10 +216,10 @@ __WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa } /** - * @brief ������0x05 0x06 0x0F 0x10Ӧ���� + * @brief 功能码0x05 0x06 0x0F 0x10应答处理 * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | д��ֵ/���� | CRC16 - * 1 | 1 | 2 | 2 | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 写入值/数量 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * * @param None * @@ -232,14 +233,14 @@ __WEAK void mb_host_rsp_05_10h(uint8_t ch) } /** - * @brief ������Ӧ����(������+0x80) + * @brief 错误码应答处理(功能码+0x80) * - * @note �ӻ���ַ | �������� | ������� | CRC16 - * 1 | 1 | 1 | 2 (ռ���ֽ�) + * @note 从机地址 | 错误功能码 | 错误代码 | CRC16 + * 1 | 1 | 1 | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param pData : ��������(��������ʹ������) + * @param pData : 错误数据(错误功能码和错误代码) * * @retval None */ @@ -251,45 +252,45 @@ __WEAK void mb_host_rsp_err(uint8_t ch, uint8_t *pData) } /** - * @brief ������Ӧ���� + * @brief 功能码应答处理 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * * @retval None */ static void mb_host_rspProcess(uint8_t ch) { - mbHostArr[ch].rspState = RSP_SUCCESS; /* Ӧ����� */ + mbHostArr[ch].rspState = RSP_SUCCESS; /* 应答完成 */ mbHostArr[ch].rspTimeoutCnt = 0; switch(mbHostArr[ch].recvBuf[1]) { - case 0x01: mb_host_rsp_01h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* ����ȦӦ���� */ - case 0x02: mb_host_rsp_02h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* ����ɢ������Ӧ���� */ - case 0x03: mb_host_rsp_03h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* �����ּĴ���Ӧ���� */ - case 0x04: mb_host_rsp_04h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* ������Ĵ���Ӧ���� */ + case 0x01: mb_host_rsp_01h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读线圈应答处理 */ + case 0x02: mb_host_rsp_02h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读离散量输入应答处理 */ + case 0x03: mb_host_rsp_03h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读保持寄存器应答处理 */ + case 0x04: mb_host_rsp_04h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读输入寄存器应答处理 */ case 0x05: case 0x06: case 0x0F: case 0x10: mb_host_rsp_05_10h(ch); break; /* - �û�������д�����������Ӧ���� + 用户在这里写其他功能码的应答处理 */ - default: if(mbHostArr[ch].recvBuf[1] & 0x80) { mb_host_rsp_err(ch, &mbHostArr[ch].recvBuf[1]); } break; /* ��֧�ֵĹ��������󷵻� */ + default: if(mbHostArr[ch].recvBuf[1] & 0x80) { mb_host_rsp_err(ch, &mbHostArr[ch].recvBuf[1]); } break; /* 不支持的功能码或错误返回 */ } } /** - * @brief �ӻ�Ӧ����ѯ����(1ms) + * @brief 从机应答轮询处理(1ms) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * * @retval rsp_state_t - * RSP_NONE : û��Ӧ��״̬ - * RSP_SUCCESS : Ӧ����� - * RSP_TIMEOUT : Ӧ��ʱ - * RSP_LEN_ERR : Ӧ�����ݳ��ȴ��� - * RSP_CRC_ERR : Ӧ������CRC���� + * @arg RSP_NONE : 没有应答状态 + * @arg RSP_SUCCESS : 应答完成 + * @arg RSP_TIMEOUT : 应答超时 + * @arg RSP_LEN_ERR : 应答数据长度错误 + * @arg RSP_CRC_ERR : 应答数据CRC错误 */ rsp_state_t mb_host_poll(uint8_t ch) { @@ -297,14 +298,14 @@ rsp_state_t mb_host_poll(uint8_t ch) ASSERT_PARAM(IS_VALID_CH(ch)); - /* Ӧ��ʱ�ж� */ + /* 应答超时判断 */ if(mbHostArr[ch].rspTimeoutCnt && mbHostArr[ch].rspTimeout < mbHostArr[ch].rspTimeoutCnt++) { - mbHostArr[ch].rspState = RSP_TIMEOUT; /* Ӧ��ʱ */ + mbHostArr[ch].rspState = RSP_TIMEOUT; /* 应答超时 */ mbHostArr[ch].rspTimeoutCnt = 0; goto rspErr; } - /* ��������ж� */ + /* 接收完成判断 */ if(!mbHostArr[ch].rspRecvOver) { mbHostArr[ch].rspState = RSP_NONE; @@ -319,20 +320,20 @@ rsp_state_t mb_host_poll(uint8_t ch) } PRINT_LOG("\n"); #endif - /* Ӧ�����ݳ����ж� */ + /* 应答数据长度判断 */ if(4 > mbHostArr[ch].recvLen) { - mbHostArr[ch].rspState = RSP_LEN_ERR; /* Ӧ�����ݳ��ȴ��� */ + mbHostArr[ch].rspState = RSP_LEN_ERR; /* 应答数据长度错误 */ goto rspErr; } - /* CRCУ���ж� */ - crcValue = mb_com_crc16(mbHostArr[ch].recvBuf, mbHostArr[ch].recvLen); + /* CRC校验判断 */ + crcValue = check_crc16_modbus(mbHostArr[ch].recvBuf, mbHostArr[ch].recvLen); if(0 != crcValue) { - mbHostArr[ch].rspState = RSP_CRC_ERR; /* Ӧ������CRC���� */ + mbHostArr[ch].rspState = RSP_CRC_ERR; /* 应答数据CRC错误 */ goto rspErr; } - /* Ӧ���� */ + /* 应答处理 */ mb_host_rspProcess(ch); rspErr: @@ -341,9 +342,9 @@ rspErr: } /** - * @brief ׷��CRCУ����� + * @brief 追加CRC校验后发送 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * * @retval None */ @@ -351,7 +352,7 @@ static void mb_host_send_crc16(uint8_t ch) { uint16_t crcValue; - crcValue = mb_com_crc16(mbHostArr[ch].sendBuf, mbHostArr[ch].sendLen); + crcValue = check_crc16_modbus(mbHostArr[ch].sendBuf, mbHostArr[ch].sendLen); mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = crcValue >> 8; mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = crcValue; @@ -367,20 +368,20 @@ static void mb_host_send_crc16(uint8_t ch) } /** - * @brief ������0x01 0x02 0x03 0x04���� + * @brief 功能码0x01 0x02 0x03 0x04命令 * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | ���� | CRC16 - * 1 | 1 | 2 | 2 | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 数量 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param funCode : ������ + * @param funCode : 功能码 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ���� + * @param num : 数量 * * @retval None */ @@ -398,18 +399,18 @@ static void mb_host_cmd_01_04h(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, u } /** - * @brief д������Ȧ����(0x05) + * @brief 写单个线圈命令(0x05) * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | д��ֵ | CRC16 - * 1 | 1 | 2 | 2 | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param extend : ��չ����(һ����Ȧ���� 0:ON !0:OFF) + * @param extend : 扩展数据(一个线圈数据 0:ON !0:OFF) * * @retval None */ @@ -420,25 +421,25 @@ static void mb_host_cmd_05h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint8_t mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x05; mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend ? 0xFF : 0x00; /* д��ֵ:0xFF00=ON 0x0000=OFF */ + mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend ? 0xFF : 0x00; /* 写入值:0xFF00=ON 0x0000=OFF */ mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x00; mb_host_send_crc16(ch); } /** - * @brief д�������ּĴ�������(0x06) + * @brief 写单个保持寄存器命令(0x06) * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | д��ֵ | CRC16 - * 1 | 1 | 2 | 2 | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param extend : ��չ����(һ���Ĵ������� 16bit) + * @param extend : 扩展数据(一个寄存器数据 16bit) * * @retval None */ @@ -456,20 +457,20 @@ static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ } /** - * @brief д�����Ȧ����(0x0F) + * @brief 写多个线圈命令(0x0F) * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | ���� | �ֽ���n | д��ֵ | CRC16 - * 1 | 1 | 2 | 2 | 1 | n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 数量 | 字节数n | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 1 | n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ���� + * @param num : 数量 * - * @param extend : ��չ����(�����Ȧ���� 1�ֽ���ָ��) + * @param extend : 扩展数据(多个线圈数据 1字节型指针) * * @retval None */ @@ -494,20 +495,20 @@ static void mb_host_cmd_0Fh(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ } /** - * @brief д����Ĵ�������(0x10) + * @brief 写多个寄存器命令(0x10) * - * @note �ӻ���ַ | ������ | ��ʼ��ַ | ����n | �ֽ���2n | д��ֵ | CRC16 - * 1 | 1 | 2 | 2 | 1 | 2n | 2 (ռ���ֽ�) + * @note 从机地址 | 功能码 | 起始地址 | 数量n | 字节数2n | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 1 | 2n | 2 (占用字节) * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ���� + * @param num : 数量 * - * @param extend : ��չ����(����Ĵ������� 2�ֽ���ָ��) + * @param extend : 扩展数据(多个寄存器数据 2字节型指针) * * @retval None */ @@ -535,25 +536,25 @@ static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ } /** - * @brief ������������ + * @brief 主机发送命令 * - * @note ������ --- ��չ���ݸ�ʽ - * 0x05 --- һ����Ȧ���� 0:ON !0:OFF - * 0x06 --- һ���Ĵ������� 16bit - * 0x0F --- �����Ȧ���� 1�ֽ���ָ�� - * 0x10 --- ����Ĵ������� 2�ֽ���ָ�� + * @note 功能码 --- 扩展数据格式 + * 0x05 --- 一个线圈数据 0:ON !0:OFF + * 0x06 --- 一个寄存器数据 16bit + * 0x0F --- 多个线圈数据 1字节型指针 + * 0x10 --- 多个寄存器数据 2字节型指针 * - * @param ch : modbus�����������(����������) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : �ӻ���ַ + * @param slaveAddr : 从机地址 * - * @param funCode : ������ + * @param funCode : 功能码 * - * @param reg : ��ʼ��ַ + * @param reg : 起始地址 * - * @param num : ���� + * @param num : 数量 * - * @param extend : ��չ����(��ͬ�������Ӧ��ʽ��ͬ) + * @param extend : 扩展数据(不同功能码对应格式不同) * * @retval None */ @@ -566,52 +567,52 @@ void mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t r switch(funCode) { - case 0x01: /* ����Ȧ���� */ + case 0x01: /* 读线圈命令 */ if(2000 >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x02: /* ����ɢ���������� */ + case 0x02: /* 读离散量输入命令 */ if(2000 >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x03: /* �����ּĴ������� */ + case 0x03: /* 读保持寄存器命令 */ if(125 >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x04: /* ������Ĵ������� */ + case 0x04: /* 读输入寄存器命令 */ if(125 >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x05: /* д������Ȧ���� */ + case 0x05: /* 写单个线圈命令 */ mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); break; - case 0x06: /* д�������ּĴ������� */ + case 0x06: /* 写单个保持寄存器命令 */ mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); break; - case 0x0F: /* д�����Ȧ���� */ + case 0x0F: /* 写多个线圈命令 */ if(2000 >= num && num) { mb_host_cmd_0Fh(ch, slaveAddr, reg, num, (uint8_t *)extend); } break; - case 0x10: /* д����Ĵ������� */ + case 0x10: /* 写多个寄存器命令 */ if(125 >= num && num) { mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); } break; /* - �û�������д����������ķ��ʹ��� + 用户在这里写其他功能码的发送处理 */ - default: /* ��֧�ֵ����� */ + default: /* 不支持的命令 */ break; } diff --git a/drivers/modbus/modbus_host.h b/drivers/modbus/modbus_host.h index 34b7610..0a1e01a 100644 --- a/drivers/modbus/modbus_host.h +++ b/drivers/modbus/modbus_host.h @@ -1,16 +1,16 @@ /** ****************************************************************************** * @file modbus_host.h - * @author ashuai0110 + * @author woshiashuai * @version V1.0 * @date 2023-09-01 - * @brief modbus��������(RTU ASCII) + * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** * @attention * - * ��Ȩ����:����Ϊ����ԭ��,��ѭCC4.0BY-SA��ȨЭ��,ʹ���븽�ϳ������Ӻͱ����� - * ��������:htashuai0110.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ @@ -22,40 +22,40 @@ extern "C" { #endif -/* ����ͷ�ļ�-----------------------------------------------------------------*/ -#include "modbus_common.h" +/* 包含头文件-----------------------------------------------------------------*/ +#include "common_include.h" -/* �궨��---------------------------------------------------------------------*/ -#define MODBUS_HOST_NUM (3u) /* modbus������������ */ -#define MODBUS_HOST_BUF_SIZE (512u) /* modbus�����շ���������С */ +/* 宏定义---------------------------------------------------------------------*/ +#define MODBUS_HOST_NUM (3u) /* modbus主机管理数量 */ +#define MODBUS_HOST_BUF_SIZE (300u) /* modbus主机收发缓冲区大小 RTU建议值300 ASCII建议值600 */ -#define _MODBUS_HOST_DEBUG /* ���������Ϣ */ +#define _MODBUS_HOST_DEBUG /* 输出调试信息 */ -/* ���Ͷ���-------------------------------------------------------------------*/ +/* 类型定义-------------------------------------------------------------------*/ /** - * @brief д������ / ��ȡ���� + * @brief 写入数据 / 读取数据 * - * @param pBuf : д�����ݵĴ洢�� / ��ȡ���ݵĴ洢�� + * @param pBuf : 写入数据的存储区 / 读取数据的存储区 * - * @param size : д������ݴ�С / ��ȡ�����ݴ�С byte + * @param size : 写入的数据大小 / 读取的数据大小 byte * - * @retval ʵ��д������ݴ�С / ʵ�ʶ�ȡ�����ݴ�С byte + * @retval 实际写入的数据大小 / 实际读取的数据大小 byte */ typedef uint32_t (* mb_host_rw_fn_t)(void *pBuf, uint32_t size); -/** - * @brief �ӻ�Ӧ��״̬ enumeration +/** + * @brief 从机应答状态 enumeration */ typedef enum rsp_state { - RSP_NONE = 0x00, /* û��Ӧ��״̬ */ - RSP_SUCCESS = 0x01, /* Ӧ����� */ - RSP_TIMEOUT = 0x02, /* Ӧ��ʱ */ - RSP_LEN_ERR = 0x04, /* Ӧ�����ݳ��ȴ��� */ - RSP_CRC_ERR = 0x08, /* Ӧ������CRC���� */ + RSP_NONE = 0x00, /* 没有应答状态 */ + RSP_SUCCESS = 0x01, /* 应答完成 */ + RSP_TIMEOUT = 0x02, /* 应答超时 */ + RSP_LEN_ERR = 0x04, /* 应答数据长度错误 */ + RSP_CRC_ERR = 0x08, /* 应答数据CRC错误 */ } rsp_state_t; -/** - * @brief modbus���� structure definition +/** + * @brief modbus主机 structure definition */ typedef struct mb_host { uint8_t recvBuf[MODBUS_HOST_BUF_SIZE]; @@ -64,27 +64,27 @@ typedef struct mb_host { uint8_t sendBuf[MODBUS_HOST_BUF_SIZE]; uint16_t sendLen; - uint8_t rspRecvOver : 4; /* ���ݽ������ 0:δ��� !0:��� */ + uint8_t rspRecvOver : 4; /* 数据接收完成 0:未完成 !0:完成 */ /* - Ӧ��״̬ - bit0: 0=Ӧ��ʧ�� 1=Ӧ����� - bit1: 0=���� 1=Ӧ��ʱ - bit2: 0=���� 1=Ӧ�����ݳ��ȴ��� - bit3: 0=���� 1=Ӧ������CRC���� + 应答状态 + bit0: 0=应答失败 1=应答完成 + bit1: 0=正常 1=应答超时 + bit2: 0=正常 1=应答数据长度错误 + bit3: 0=正常 1=应答数据CRC错误 */ uint8_t rspState : 4; - uint16_t rspTimeoutCnt; /* Ӧ��ʱ����ms */ - uint16_t rspTimeout; /* Ӧ��ʱʱ��ms */ - uint16_t regTmp; /* ���������е���ʼ��ַ�ݴ� */ - uint16_t numTmp; /* ���������е������ݴ� */ + uint16_t rspTimeoutCnt; /* 应答超时计数ms */ + uint16_t rspTimeout; /* 应答超时时间ms */ + uint16_t regTmp; /* 主机命令中的起始地址暂存 */ + uint16_t numTmp; /* 主机命令中的数量暂存 */ - mb_host_rw_fn_t readDataFn; /* ��ȡ���ݺ��� */ - mb_host_rw_fn_t writeDataFn; /* д�����ݺ��� */ + mb_host_rw_fn_t readDataFn; /* 读取数据函数 */ + mb_host_rw_fn_t writeDataFn; /* 写入数据函数 */ } mb_host_t; -/* ȫ�ֱ���-------------------------------------------------------------------*/ +/* 全局变量-------------------------------------------------------------------*/ -/* ����ԭ��-------------------------------------------------------------------*/ +/* 函数原型-------------------------------------------------------------------*/ void mb_host_init(uint8_t ch, mb_host_rw_fn_t fRead, mb_host_rw_fn_t fWrite, uint16_t timeout); rsp_state_t mb_host_poll(uint8_t ch); @@ -99,4 +99,4 @@ void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout); } #endif -#endif +#endif /* modbus_host.h */ diff --git a/drivers/modbus/modbus_slave.c b/drivers/modbus/modbus_slave.c index 17057e6..7cefd85 100644 --- a/drivers/modbus/modbus_slave.c +++ b/drivers/modbus/modbus_slave.c @@ -1,32 +1,33 @@ /** ****************************************************************************** * @file modbus_slave.c - * @author ashuai0110 + * @author woshiashuai * @version V1.0 * @date 2023-09-01 - * @brief modbus�ӻ����� + * @brief modbus从机程序 * ****************************************************************************** * @attention * - * ��Ȩ����:����Ϊ����ԭ��,��ѭCC4.0BY-SA��ȨЭ��,ʹ���븽�ϳ������Ӻͱ����� - * ��������:htashuai0110.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ -/* ����ͷ�ļ�-----------------------------------------------------------------*/ +/* 包含头文件-----------------------------------------------------------------*/ #include "modbus_slave.h" +#include "data_check.h" -/* ˽�к궨��-----------------------------------------------------------------*/ +/* 私有宏定义-----------------------------------------------------------------*/ -/* ˽�����Ͷ���---------------------------------------------------------------*/ +/* 私有类型定义---------------------------------------------------------------*/ -/* ˽�б���-------------------------------------------------------------------*/ +/* 私有变量-------------------------------------------------------------------*/ -/* ȫ�ֱ���-------------------------------------------------------------------*/ +/* 全局变量-------------------------------------------------------------------*/ -/* ˽�к���ԭ��---------------------------------------------------------------*/ +/* 私有函数原型---------------------------------------------------------------*/ /** * @brief diff --git a/drivers/modbus/modbus_slave.h b/drivers/modbus/modbus_slave.h index f5c75aa..0c0db09 100644 --- a/drivers/modbus/modbus_slave.h +++ b/drivers/modbus/modbus_slave.h @@ -1,16 +1,16 @@ /** ****************************************************************************** * @file modbus_slave.h - * @author ashuai0110 + * @author woshiashuai * @version V1.0 * @date 2023-09-01 - * @brief modbus�ӻ����� + * @brief modbus从机程序 * ****************************************************************************** * @attention * - * ��Ȩ����:����Ϊ����ԭ��,��ѭCC4.0BY-SA��ȨЭ��,ʹ���븽�ϳ������Ӻͱ����� - * ��������:htashuai0110.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ @@ -22,20 +22,20 @@ extern "C" { #endif -/* ����ͷ�ļ�-----------------------------------------------------------------*/ -#include "modbus_common.h" +/* 包含头文件-----------------------------------------------------------------*/ +#include "common_include.h" -/* �궨��---------------------------------------------------------------------*/ +/* 宏定义---------------------------------------------------------------------*/ -/* ���Ͷ���-------------------------------------------------------------------*/ +/* 类型定义-------------------------------------------------------------------*/ -/* ȫ�ֱ���-------------------------------------------------------------------*/ +/* 全局变量-------------------------------------------------------------------*/ -/* ����ԭ��-------------------------------------------------------------------*/ +/* 函数原型-------------------------------------------------------------------*/ #ifdef __cplusplus } #endif -#endif +#endif /* modbus_slave.h */ diff --git a/drivers/modules/command_line.c b/drivers/modules/command_line.c index e6bdad9..cf784dc 100644 --- a/drivers/modules/command_line.c +++ b/drivers/modules/command_line.c @@ -70,8 +70,8 @@ * @{ */ -static cmd_line_t *pCmdLineHead = NULL; /*!< 命令行链表头节点 */ -static cmd_line_item_t cmdNameArr[CMD_LINE_SAVE_MAX]; /* 命令名称列表 */ +static cmd_line_t *pCmdLineHead = NULL; /*!< 命令行链表头节点 */ +static cmd_line_item_t cmdNameArr[CMD_LINE_SAVE_MAX]; /*!< 命令名称列表 */ /** * @} diff --git a/drivers/modbus/modbus_common.c b/drivers/modules/data_check.c similarity index 63% rename from drivers/modbus/modbus_common.c rename to drivers/modules/data_check.c index 6ce6810..467d23c 100644 --- a/drivers/modbus/modbus_common.c +++ b/drivers/modules/data_check.c @@ -1,29 +1,29 @@ /** ****************************************************************************** - * @file modbus_common.c + * @file data_check.c * @author ashuai0110 * @version V1.0 - * @date 2023-09-01 - * @brief modbus�����ļ� + * @date 2023-09-18 + * @brief 数据校验 * ****************************************************************************** * @attention * - * ��Ȩ����:����Ϊ����ԭ��,��ѭCC4.0BY-SA��ȨЭ��,ʹ���븽�ϳ������Ӻͱ����� - * ��������:htashuai0110.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ -/* ����ͷ�ļ�-----------------------------------------------------------------*/ -#include "modbus_common.h" +/* 包含头文件-----------------------------------------------------------------*/ +#include "data_check.h" -/* ˽�к궨��-----------------------------------------------------------------*/ +/* 私有宏定义-----------------------------------------------------------------*/ -/* ˽�����Ͷ���---------------------------------------------------------------*/ +/* 私有类型定义---------------------------------------------------------------*/ -/* ˽�б���-------------------------------------------------------------------*/ -// CRC ��λ�ֽ�ֵ�� +/* 私有变量-------------------------------------------------------------------*/ +// CRC 高位字节值表 static const uint8_t crcHiArr[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, @@ -52,7 +52,7 @@ static const uint8_t crcHiArr[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 }; -// CRC ��λ�ֽ�ֵ�� +// CRC 低位字节值表 const uint8_t crcLoArr[] = { 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, @@ -82,60 +82,27 @@ const uint8_t crcLoArr[] = { 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 }; -/* ȫ�ֱ���-------------------------------------------------------------------*/ +/* 全局变量-------------------------------------------------------------------*/ -/* ˽�к���ԭ��---------------------------------------------------------------*/ +/* 私有函数原型---------------------------------------------------------------*/ /** - * @brief CRC16ѭ������У�� + * @brief CRC16(MODBUS) * @param None * @retval None */ -uint16_t mb_com_crc16(uint8_t *pBuf, uint16_t len) +uint16_t check_crc16_modbus(uint8_t *pBuf, uint16_t len) { - uint8_t CRCHi = 0xFF; /* ��CRC�ֽڳ�ʼ�� */ - uint8_t CRCLo = 0xFF; /* ��CRC �ֽڳ�ʼ�� */ - uint16_t index; /* CRCѭ���е����� */ + uint8_t CRCHi = 0xFF; /* 高CRC字节初始化 */ + uint8_t CRCLo = 0xFF; /* 低CRC 字节初始化 */ + uint16_t index; /* CRC循环中的索引 */ while(len--) { - index = CRCHi ^ *pBuf++; /* ����CRC */ + index = CRCHi ^ *pBuf++; /* 计算CRC */ CRCHi = CRCLo ^ crcHiArr[index]; CRCLo = crcLoArr[index]; } return ((uint16_t)CRCHi << 8 | CRCLo); } - -uint8_t xMBUtilGetBits( uint8_t * ucByteBuf, uint16_t usBitOffset, uint8_t ucNBits ) -{ - uint16_t usWordBuf; - uint16_t usMask; - uint16_t usByteOffset; - uint16_t usNPreBits; - - /* Calculate byte offset for first byte containing the bit values starting - * at usBitOffset. */ - usByteOffset = ( uint16_t )( ( usBitOffset ) / 8 ); - - /* How many bits precede our bits to set. */ - usNPreBits = ( uint16_t )( usBitOffset - usByteOffset * 8 ); - - /* Prepare a mask for setting the new bits. */ - usMask = ( uint16_t )( ( 1 << ( uint16_t ) ucNBits ) - 1 ); - - /* copy bits into temporary storage. */ -// usWordBuf = ucByteBuf[usByteOffset]; -// usWordBuf |= ucByteBuf[usByteOffset + 1] << 8; - - usWordBuf = ucByteBuf[0]; - usWordBuf |= ucByteBuf[1] << 8; - - /* throw away unneeded bits. */ - usWordBuf >>= usNPreBits; - - /* mask away bits above the requested bitfield. */ - usWordBuf &= usMask; - - return ( uint8_t ) usWordBuf; -} diff --git a/drivers/modbus/modbus_common.h b/drivers/modules/data_check.h similarity index 73% rename from drivers/modbus/modbus_common.h rename to drivers/modules/data_check.h index 259056d..19a3424 100644 --- a/drivers/modbus/modbus_common.h +++ b/drivers/modules/data_check.h @@ -1,22 +1,22 @@ /** ****************************************************************************** - * @file modbus_common.h + * @file data_check.h * @author ashuai0110 * @version V1.0 - * @date 2023-09-01 - * @brief modbus共用文件 + * @date 2023-09-18 + * @brief 数据校验 * ****************************************************************************** * @attention * * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_development_module.git + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ -#ifndef __MODBUS_COMMON_H -#define __MODBUS_COMMON_H +#ifndef __DATA_CHECK_H +#define __DATA_CHECK_H #ifdef __cplusplus extern "C" { @@ -26,19 +26,16 @@ extern "C" { #include "common_include.h" /* 宏定义---------------------------------------------------------------------*/ -#ifndef ASSERT_PARAM -#define ASSERT_PARAM(x) (void)(0) -#endif /* 类型定义-------------------------------------------------------------------*/ /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ -uint16_t mb_com_crc16(uint8_t *pBuf, uint16_t len); +uint16_t check_crc16_modbus(uint8_t *pBuf, uint16_t len); #ifdef __cplusplus } #endif -#endif +#endif /* data_check.h */ diff --git a/drivers/modules/sync_method.c b/drivers/modules/sync_method.c index 7edc6c1..23f76df 100644 --- a/drivers/modules/sync_method.c +++ b/drivers/modules/sync_method.c @@ -3,7 +3,7 @@ * @file sync_method.c * @author ashuai0110 * @version V2.1 - * @date 2023-09-19 + * @date 2023-09-26 * @brief 伪线程同步方法(信号量,互斥锁,事件集) * ****************************************************************************** @@ -12,19 +12,32 @@ * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * - * @example - * - * 信号量使用举例sync_method.c:50 - * 互斥锁使用举例sync_method.c:150 - * 事件集使用举例sync_method.c:225 - * ****************************************************************************** */ /* 包含头文件-----------------------------------------------------------------*/ #include "sync_method.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @defgroup sync_method 伪线程同步方法(信号量,互斥锁,事件集) + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ +/** + * @defgroup sync_method_local_macros sync method local macros + * @{ + */ + +/** + * @defgroup sync_method_check_parameters_validity sync method check parameters validity + * @{ + */ /* 事件集集合有效性检查 */ #define IS_VALID_EVENT_BITS(x) \ ( (x) != 0u) @@ -38,6 +51,13 @@ #define IS_VALID_EVENT_ACTION(x) \ ( ((x) == EVENT_CLEAR) || \ ((x) == EVENT_HOLD)) +/** + * @} + */ + +/** + * @} + */ /* 私有类型定义---------------------------------------------------------------*/ @@ -47,33 +67,14 @@ /* 私有函数原型---------------------------------------------------------------*/ -/* 信号量使用举例 -sync_sem_t semTest; - -// 1s定时器 -void TIM1_IRQHandler(void) -{ - sync_sem_put(&semTest); -} -int main() -{ - sync_sem_init(&semTest, 0); - - while(1) - { - if(RET_OK == sync_sem_get(&semTest)) - { - DEBUG_LOG("get sem"); - } - } -} -*/ +/** + * @defgroup sync_method_global_functions sync method global functions + * @{ + */ /** * @brief 信号量初始化 * - * @note None - * * @param _sem : 信号量实例 * * @param value : 初始值 @@ -88,9 +89,7 @@ void sync_sem_init(sync_sem_t *_sem, uint32_t value) } /** - * @brief 释放信号量 - * - * @note 信号量+1 + * @brief 释放信号量(信号量+1) * * @param _sem : 信号量实例 * @@ -107,9 +106,7 @@ void sync_sem_put(sync_sem_t *_sem) } /** - * @brief 获取信号量 - * - * @note 信号量-1 + * @brief 获取信号量(信号量-1) * * @param _sem : 信号量实例 * @@ -134,8 +131,6 @@ uint8_t sync_sem_get(sync_sem_t *_sem) /** * @brief 获取信号量值 * - * @note None - * * @param _sem : 信号量实例 * * @retval 当前信号量值 @@ -147,30 +142,11 @@ uint32_t sync_sem_value(sync_sem_t *_sem) return *_sem; } -/* 互斥锁使用举例 -sync_mutex_t mutexTest; - -int main() -{ - sync_mutex_init(&mutexTest); - - while(1) - { - if(MUTEX_UNLOCK == sync_mutex_get(&mutexTest)) - { - DEBUG_LOG("get mutex"); - sync_mutex_put(&mutexTest); - } - } -} -*/ /** * @brief 互斥锁初始化 * - * @note None - * - * @param _mutex:互斥锁实例 + * @param _mutex : 互斥锁实例 * * @retval None */ @@ -184,8 +160,6 @@ void sync_mutex_init(sync_mutex_t *_mutex) /** * @brief 互斥锁解锁(释放锁) * - * @note None - * * @param _mutex : 互斥锁实例 * * @retval None @@ -200,13 +174,11 @@ void sync_mutex_put(sync_mutex_t *_mutex) /** * @brief 互斥锁上锁(获得锁) * - * @note None - * - * @param _mutex : 互斥锁实例 + * @param _mutex : 互斥锁实例 * * @retval uint8_t - * @arg RET_OK : 上锁成功(获得锁) - * @arg RET_ERR : 上锁失败(锁被占用) + * @arg RET_OK : 上锁成功(获得锁) + * @arg RET_ERR : 上锁失败(锁被占用) */ uint8_t sync_mutex_get(sync_mutex_t *_mutex) { @@ -222,48 +194,10 @@ uint8_t sync_mutex_get(sync_mutex_t *_mutex) return RET_OK; } -/* 事件集使用举例 -#define EVENT1 (EVENT_BIT0) -#define EVENT2 (EVENT_BIT1) - -sync_event_t eventTest; - -// 按键1点击 -void key1_press_callback(void) -{ - sync_event_put(&eventTest, EVENT1); -} -// 按键2点击 -void key2_press_callback(void) -{ - sync_event_put(&eventTest, EVENT2); -} -int main() -{ - sync_event_init(&eventTest); - - while(1) - { -#if 1 - if(RET_OK == sync_event_get(&eventTest, EVENT1 | EVENT2, EVENT_AND, EVENT_CLEAR)) - { - DEBUG_LOG("get event 1 and event 2"); - } -#else - if(RET_OK == sync_event_get(&eventTest, EVENT1 | EVENT2, EVENT_OR, EVENT_CLEAR)) - { - DEBUG_LOG("get event 1 or event 2"); - } -#endif - } -} -*/ /** * @brief 事件集初始化 * - * @note None - * * @param _event : 事件集实例 * * @retval None @@ -276,9 +210,7 @@ void sync_event_init(sync_event_t *_event) } /** - * @brief 事件集设置事件 - * - * @note None + * @brief 设置触发事件 * * @param _event : 事件集实例 * @@ -295,43 +227,41 @@ void sync_event_put(sync_event_t *_event, uint32_t bits) } /** - * @brief 事件集等待触发 - * - * @note None + * @brief 等待事件触发 * * @param _event : 事件集实例 * * @param bits : 关心的事件集(相应bit置1为关心此事件) * - * @param flg : 事件集关心标志 + * @param eventFlg : 事件集关心标志 @ref sync_event_flg * @arg EVENT_OR : 相应bit任一个为1则认为触发 * @arg EVENT_AND : 相应bit全部为1则认为触发 * - * @param action : 事件集触发后动作 + * @param eventAct : 事件集触发后动作 @ref sync_event_act * @arg EVENT_CLEAR : 清除对应事件集合(相应bit置0) * @arg EVENT_HOLD : 保持对应事件集合(相应bit不变) * * @retval uint8_t - * @arg RET_OK : 关心的事件集触发 - * @arg RET_ERR : 未触发 + * @arg RET_OK : 关心的事件集触发 + * @arg RET_ERR : 未触发 */ -uint8_t sync_event_get(sync_event_t *_event, uint32_t bits, sync_event_flg_t flg, sync_event_action_t action) +uint8_t sync_event_get(sync_event_t *_event, uint32_t bits, uint8_t eventFlg, uint8_t eventAct) { uint8_t ret = RET_ERR; ASSERT_PARAM(IS_VALID_POINT(_event)); ASSERT_PARAM(IS_VALID_EVENT_BITS(bits)); - ASSERT_PARAM(IS_VALID_EVENT_FLAG(flg)); - ASSERT_PARAM(IS_VALID_EVENT_ACTION(action)); + ASSERT_PARAM(IS_VALID_EVENT_FLAG(eventFlg)); + ASSERT_PARAM(IS_VALID_EVENT_ACTION(eventAct)); - if(EVENT_OR == flg) + if(EVENT_OR == eventFlg) { if((*_event) & bits) { ret = RET_OK; } } - else if(EVENT_AND == flg) + else if(EVENT_AND == eventFlg) { if(((*_event) & bits) == bits) { @@ -339,10 +269,22 @@ uint8_t sync_event_get(sync_event_t *_event, uint32_t bits, sync_event_flg_t flg } } - if(EVENT_CLEAR == action && RET_OK == ret) + if(EVENT_CLEAR == eventAct && RET_OK == ret) { *_event = *_event & (uint32_t)(~bits); } return ret; } + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modules/sync_method.h b/drivers/modules/sync_method.h index aa2a0da..040544b 100644 --- a/drivers/modules/sync_method.h +++ b/drivers/modules/sync_method.h @@ -3,7 +3,7 @@ * @file sync_method.h * @author ashuai0110 * @version V2.1 - * @date 2023-09-19 + * @date 2023-09-26 * @brief 伪线程同步方法(信号量,互斥锁,事件集) * ****************************************************************************** @@ -12,12 +12,6 @@ * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * - * @example - * - * 信号量使用举例sync_method.c:50 - * 互斥锁使用举例sync_method.c:150 - * 事件集使用举例sync_method.c:225 - * ****************************************************************************** */ @@ -31,9 +25,102 @@ extern "C" { /* 包含头文件-----------------------------------------------------------------*/ #include "common_include.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @addtogroup sync_method + * @{ + */ + /* 宏定义---------------------------------------------------------------------*/ +/** + * @defgroup sync_method_global_macros sync method global macros + * @{ + */ + +/** + * @defgroup sync_mutex_flg sync mutex flag + * @{ + */ +#define MUTEX_UNLOCK (0u) /*!< 互斥锁-未锁 */ +#define MUTEX_LOCK (1u) /*!< 互斥锁-上锁 */ +/** + * @} + */ + +/** + * @defgroup sync_event_flg sync event flag + * @{ + */ +#define EVENT_OR (0u) /*!< 事件集-或 */ +#define EVENT_AND (1u) /*!< 事件集-与 */ +/** + * @} + */ + +/** + * @defgroup sync_event_act sync event action + * @{ + */ +#define EVENT_CLEAR (0u) /*!< 事件集-清除 */ +#define EVENT_HOLD (1u) /*!< 事件集-保持 */ +/** + * @} + */ + +/** + * @defgroup sync_event_bit sync event bit + * @{ + */ +#define EVENT_BIT0 (0x1ul<<0) +#define EVENT_BIT1 (0x1ul<<1) +#define EVENT_BIT2 (0x1ul<<2) +#define EVENT_BIT3 (0x1ul<<3) +#define EVENT_BIT4 (0x1ul<<4) +#define EVENT_BIT5 (0x1ul<<5) +#define EVENT_BIT6 (0x1ul<<6) +#define EVENT_BIT7 (0x1ul<<7) +#define EVENT_BIT8 (0x1ul<<8) +#define EVENT_BIT9 (0x1ul<<9) +#define EVENT_BIT10 (0x1ul<<10) +#define EVENT_BIT11 (0x1ul<<11) +#define EVENT_BIT12 (0x1ul<<12) +#define EVENT_BIT13 (0x1ul<<13) +#define EVENT_BIT14 (0x1ul<<14) +#define EVENT_BIT15 (0x1ul<<15) +#define EVENT_BIT16 (0x1ul<<16) +#define EVENT_BIT17 (0x1ul<<17) +#define EVENT_BIT18 (0x1ul<<18) +#define EVENT_BIT19 (0x1ul<<19) +#define EVENT_BIT20 (0x1ul<<20) +#define EVENT_BIT21 (0x1ul<<21) +#define EVENT_BIT22 (0x1ul<<22) +#define EVENT_BIT23 (0x1ul<<23) +#define EVENT_BIT24 (0x1ul<<24) +#define EVENT_BIT25 (0x1ul<<25) +#define EVENT_BIT26 (0x1ul<<26) +#define EVENT_BIT27 (0x1ul<<27) +#define EVENT_BIT28 (0x1ul<<28) +#define EVENT_BIT29 (0x1ul<<29) +#define EVENT_BIT30 (0x1ul<<30) +#define EVENT_BIT31 (0x1ul<<31) +/** + * @} + */ + +/** + * @} + */ /* 类型定义-------------------------------------------------------------------*/ +/** + * @defgroup sync_method_global_types sync method global types + * @{ + */ + /** * @brief 信号量 type define */ @@ -49,71 +136,18 @@ typedef uint8_t sync_mutex_t; */ typedef uint32_t sync_event_t; -/** - * @brief 互斥锁 flag enumeration - */ -typedef enum sync_mutex_flg { - MUTEX_UNLOCK = 0u, // 互斥锁-未锁 - MUTEX_LOCK = 1u, // 互斥锁-上锁 -} sync_mutex_flg_t; - -/** - * @brief 事件集 flag enumeration - */ -typedef enum sync_event_flg { - EVENT_OR = 0u, // 事件集-或 - EVENT_AND = 1u, // 事件集-与 -} sync_event_flg_t; - -/** - * @brief 事件集 action enumeration - */ -typedef enum sync_event_action { - EVENT_CLEAR = 0u, // 事件集-清除 - EVENT_HOLD = 1u, // 事件集-保持 -} sync_event_action_t; - -/** - * @brief 事件集 bit enumeration - */ -typedef enum sync_event_bit { - EVENT_BIT0 = (0x1ul<<0), - EVENT_BIT1 = (0x1ul<<1), - EVENT_BIT2 = (0x1ul<<2), - EVENT_BIT3 = (0x1ul<<3), - EVENT_BIT4 = (0x1ul<<4), - EVENT_BIT5 = (0x1ul<<5), - EVENT_BIT6 = (0x1ul<<6), - EVENT_BIT7 = (0x1ul<<7), - EVENT_BIT8 = (0x1ul<<8), - EVENT_BIT9 = (0x1ul<<9), - EVENT_BIT10 = (0x1ul<<10), - EVENT_BIT11 = (0x1ul<<11), - EVENT_BIT12 = (0x1ul<<12), - EVENT_BIT13 = (0x1ul<<13), - EVENT_BIT14 = (0x1ul<<14), - EVENT_BIT15 = (0x1ul<<15), - EVENT_BIT16 = (0x1ul<<16), - EVENT_BIT17 = (0x1ul<<17), - EVENT_BIT18 = (0x1ul<<18), - EVENT_BIT19 = (0x1ul<<19), - EVENT_BIT20 = (0x1ul<<20), - EVENT_BIT21 = (0x1ul<<21), - EVENT_BIT22 = (0x1ul<<22), - EVENT_BIT23 = (0x1ul<<23), - EVENT_BIT24 = (0x1ul<<24), - EVENT_BIT25 = (0x1ul<<25), - EVENT_BIT26 = (0x1ul<<26), - EVENT_BIT27 = (0x1ul<<27), - EVENT_BIT28 = (0x1ul<<28), - EVENT_BIT29 = (0x1ul<<29), - EVENT_BIT30 = (0x1ul<<30), -// EVENT_BIT31 = (0x1ul<<31), // 警告不影响使用 -} sync_event_bit_t; +/** + * @} + */ /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ +/** + * @addtogroup sync_method_global_functions + * @{ + */ + void sync_sem_init(sync_sem_t *_sem, uint32_t value); void sync_sem_put(sync_sem_t *_sem); uint8_t sync_sem_get(sync_sem_t *_sem); @@ -125,7 +159,19 @@ uint8_t sync_mutex_get(sync_mutex_t *_mutex); void sync_event_init(sync_event_t *_event); void sync_event_put(sync_event_t *_event, uint32_t bits); -uint8_t sync_event_get(sync_event_t *_event, uint32_t bits, sync_event_flg_t flg, sync_event_action_t action); +uint8_t sync_event_get(sync_event_t *_event, uint32_t bits, uint8_t eventFlg, uint8_t eventAct); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } diff --git a/drivers/modules/timer_software.c b/drivers/modules/timer_software.c index 2e4136d..018ffb7 100644 --- a/drivers/modules/timer_software.c +++ b/drivers/modules/timer_software.c @@ -3,7 +3,7 @@ * @file timer_software.c * @author ashuai0110 * @version V2.1 - * @date 2023-09-19 + * @date 2023-09-26 * @brief 软件定时器 * ****************************************************************************** @@ -12,114 +12,119 @@ * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * - * @example - * - * 软件定时器使用举例timer_software.c:40 - * ****************************************************************************** */ /* 包含头文件-----------------------------------------------------------------*/ #include "timer_software.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @defgroup timer_software 软件定时器 + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ +/** + * @defgroup timer_software_local_macros timer software local macros + * @{ + */ + +/** + * @defgroup timer_software_check_parameters_validity timer software check parameters validity + * @{ + */ /* 软件定时器运行标志有效性检查 */ -#define IS_VALID_TIMER_S_RUN(x) \ -( ((x) == TIMER_S_START) || \ - ((x) == TIMER_S_STOP)) +#define IS_VALID_TIMER_RUN(x) \ +( ((x) == TIMER_RUN_START) || \ + ((x) == TIMER_RUN_STOP)) +/** + * @} + */ + +/** + * @} + */ /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ -static timer_s_t *pTimerSTaskHead = NULL; /* 软件定时器工作链表头节点 */ +/** + * @defgroup timer_software_local_variables timer software local variables + * @{ + */ -/* 全局变量-------------------------------------------------------------------*/ +static timer_s_t *pTimerTaskHead = NULL; /*!< 软件定时器工作链表头节点 */ -/* 私有函数原型---------------------------------------------------------------*/ +/** + * @} + */ -/* 软件定时器使用举例 -timer_s_t ledToggleTS; +/* 全局变量-------------------------------------------------------------------*/ -// LED翻转函数 -void ledToggleProc(void) -{ - // led toggle handle here -} -// 1ms定时器 -void TIM1_IRQHandler1ms(void) -{ - timer_s_poll(); -} -int main() -{ - uint8_t ret = RET_ERR; +/* 私有函数原型---------------------------------------------------------------*/ - ret = timer_s_init(&ledToggleTS, 500/1, ledToggleProc, TIMER_S_START); // 500=500ms/1ms - if(RET_OK != ret) { ERROR_LOG("timer_s_init failure"); } - - while(1) - { - TIMER_S_Loop(); - } -} -*/ +/** + * @defgroup timer_software_global_functions timer software global functions + * @{ + */ /** * @brief 软件定时器任务初始化 * - * @note 创建后的任务默认加入到工作链表中 + * @note 创建后的任务默认加入到工作链表中(如需挂起请使用timer_s_pending) * - * @param _ts : 软件定时器任务实例 + * @param _ts : 软件定时器任务实例 * - * @param targetTicks : 目标计数值 例如定时任务为500ms,调度器周期10ms,则targetTicks=500ms/10ms=50 + * @param targetTicks : 目标计数值 例如定时任务为500ms,调度器周期10ms,则targetTicks=500ms/10ms=50 * - * @param fCallback : 回调函数 + * @param callbackFn : 回调函数 * - * @param run: 运行标志 - * @arg TIMER_S_STOP : 不运行 - * @arg TIMER_S_START : 运行 + * @param runFlg : 运行标志 @ref timer_run_flg + * @arg TIMER_RUN_STOP : 不运行 + * @arg TIMER_RUN_START : 运行 * * @retval uint8_t * @arg RET_OK : 成功 * @arg RET_ERR : 已存在(已被插入) */ -uint8_t timer_s_init(timer_s_t *_ts, uint32_t targetTicks, void (* fCallback)(void), timer_s_run_flg_t run) +uint8_t timer_s_init(timer_s_t *_ts, uint32_t targetTicks, void (* callbackFn)(void), uint8_t runFlg) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - ASSERT_PARAM(IS_VALID_POINT(fCallback)); - ASSERT_PARAM(IS_VALID_TIMER_S_RUN(run)); - - _ts->curTicks = 0; - _ts->targetTicks = targetTicks; - _ts->fCallback = fCallback; - _ts->run = run; - - return timer_s_insert(_ts); + ASSERT_PARAM(IS_VALID_POINT(_ts)); + ASSERT_PARAM(IS_VALID_POINT(callbackFn)); + ASSERT_PARAM(IS_VALID_TIMER_RUN(runFlg)); + + _ts->curTicks = 0; + _ts->targetTicks = targetTicks; + _ts->callbackFn = callbackFn; + _ts->runFlg = runFlg; + + return timer_s_insert(_ts); } /** * @brief 软件定时器任务取消初始化 * - * @note None - * * @param _ts : 软件定时器任务实例 * * @retval None */ void timer_s_de_init(timer_s_t *_ts) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - timer_s_pending(_ts); - memset(_ts, 0, sizeof(timer_s_t)); + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + timer_s_pending(_ts); + memset(_ts, 0, sizeof(timer_s_t)); } /** - * @brief 软件定时器任务插入 - * - * @note 将任务插入到工作链表中 + * @brief 软件定时器任务插入(插入工作链表) * - * @param _ts : 软件定时器任务实例 + * @param _ts : 软件定时器任务实例 * * @retval uint8_t * @arg RET_OK : 成功 @@ -127,27 +132,25 @@ void timer_s_de_init(timer_s_t *_ts) */ uint8_t timer_s_insert(timer_s_t *_ts) { - timer_s_t *tsTarget = pTimerSTaskHead; - - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - while(tsTarget) - { - if(tsTarget == _ts) { return RET_ERR; } - tsTarget = tsTarget->pNext; - } - _ts->pNext = pTimerSTaskHead; - pTimerSTaskHead = _ts; - - return RET_OK; + timer_s_t *tsTarget = pTimerTaskHead; + + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + while(tsTarget) + { + if(tsTarget == _ts) { return RET_ERR; } + tsTarget = tsTarget->pNext; + } + _ts->pNext = pTimerTaskHead; + pTimerTaskHead = _ts; + + return RET_OK; } /** - * @brief 软件定时器任务挂起 - * - * @note 将任务从工作链表中取下 + * @brief 软件定时器任务挂起(从工作链表中取下) * - * @param _ts : 软件定时器任务实例 + * @param _ts : 软件定时器任务实例 * * @retval uint8_t * @arg RET_OK : 成功 @@ -155,42 +158,42 @@ uint8_t timer_s_insert(timer_s_t *_ts) */ uint8_t timer_s_pending(timer_s_t *_ts) { - timer_s_t *tsTarget = pTimerSTaskHead; - timer_s_t *tsLast = NULL; - - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - while(tsTarget) - { - /* 查找任务是否存在 */ - if(tsTarget == _ts) - { - /* 是否在头节点 */ - if(NULL == tsLast) - { - /* 在头节点则将下一个节点作为新的头节点 */ - pTimerSTaskHead = tsTarget->pNext; - } - else - { - /* 不在头节点则将下一个节点链接到上一个节点 */ - tsLast->pNext = tsTarget->pNext; - pTimerSTaskHead = tsLast; - } - - return RET_OK; - } - tsLast = tsTarget; - tsTarget = tsTarget->pNext; - } - - return RET_ERR; + timer_s_t *tsTarget = pTimerTaskHead; + timer_s_t *tsLast = NULL; + + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + while(tsTarget) + { + /* 查找任务是否存在 */ + if(tsTarget == _ts) + { + /* 是否在头节点 */ + if(NULL == tsLast) + { + /* 在头节点则将下一个节点作为新的头节点 */ + pTimerTaskHead = tsTarget->pNext; + } + else + { + /* 不在头节点则将下一个节点链接到上一个节点 */ + tsLast->pNext = tsTarget->pNext; + pTimerTaskHead = tsLast; + } + + return RET_OK; + } + tsLast = tsTarget; + tsTarget = tsTarget->pNext; + } + + return RET_ERR; } /** - * @brief 软件定时器任务时基函数 + * @brief 软件定时器任务轮询处理 * - * @note 此函数加入到调度器(按周期执行的地方)中,此函数执行周期即是软件定时器任务计数值累加周期 + * @note 此函数执行周期即是软件定时器任务计数值累加周期 * * @param None * @@ -198,30 +201,28 @@ uint8_t timer_s_pending(timer_s_t *_ts) */ void timer_s_poll(void) { - timer_s_t *tsTarget; - - for(tsTarget = pTimerSTaskHead; tsTarget; tsTarget = tsTarget->pNext) - { - if(TIMER_S_START == tsTarget->run) - { + timer_s_t *tsTarget; + + for(tsTarget = pTimerTaskHead; tsTarget; tsTarget = tsTarget->pNext) + { + if(TIMER_RUN_START == tsTarget->runFlg) + { if(tsTarget->curTicks < tsTarget->targetTicks) { tsTarget->curTicks++; } - else + else { - tsTarget->fCallback(); + tsTarget->callbackFn(); tsTarget->curTicks = 0; } - } - } + } + } } /** * @brief 设置软件定时器任务的当前计数值 * - * @note None - * * @param _ts : 软件定时器任务实例 * * @param curTicks : 当前计数值 @@ -230,32 +231,28 @@ void timer_s_poll(void) */ void timer_s_set_cur_ticks(timer_s_t *_ts, uint32_t curTicks) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - _ts->curTicks = curTicks; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + _ts->curTicks = curTicks; } /** * @brief 获取软件定时器任务的当前计数值 * - * @note None - * * @param _ts : 软件定时器任务实例 * * @retval 当前计数值 */ uint32_t timer_s_get_cur_ticks(timer_s_t *_ts) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - return _ts->curTicks; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + return _ts->curTicks; } /** * @brief 设置软件定时器任务的目标计数值 * - * @note None - * * @param _ts : 软件定时器任务实例 * * @param targetTicks : 目标计数值 @@ -264,62 +261,68 @@ uint32_t timer_s_get_cur_ticks(timer_s_t *_ts) */ void timer_s_set_target_ticks(timer_s_t *_ts, uint32_t targetTicks) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - _ts->targetTicks = targetTicks; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + _ts->targetTicks = targetTicks; } /** * @brief 获取软件定时器任务的目标计数值 * - * @note None - * * @param _ts : 软件定时器任务实例 * * @retval 目标计数值 */ uint32_t timer_s_get_target_ticks(timer_s_t *_ts) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - return _ts->targetTicks; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + return _ts->targetTicks; } /** * @brief 设置软件定时器任务的运行标志 * - * @note None + * @param _ts : 软件定时器任务实例 * - * @param _ts : 软件定时器任务实例 - * - * @param run : 运行标志 - * @arg TIMER_S_STOP : 不运行 - * @arg TIMER_S_START : 运行 + * @param runFlg : 运行标志 @ref timer_run_flg + * @arg TIMER_RUN_STOP : 不运行 + * @arg TIMER_RUN_START : 运行 * * @retval None */ -void timer_s_set_run(timer_s_t *_ts, timer_s_run_flg_t run) +void timer_s_set_run(timer_s_t *_ts, uint8_t runFlg) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - ASSERT_PARAM(IS_VALID_TIMER_S_RUN(run)); - - _ts->run = run; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + ASSERT_PARAM(IS_VALID_TIMER_RUN(runFlg)); + + _ts->runFlg = runFlg; } /** * @brief 获取软件定时器任务的运行标志 * - * @note None - * - * @param _ts : 软件定时器任务实例 + * @param _ts : 软件定时器任务实例 * - * @retval timer_s_run_flg_t - * @arg TIMER_S_STOP : 不运行 - * @arg TIMER_S_START : 运行 + * @retval uint8_t : 运行标志 @ref timer_run_flg + * @arg TIMER_RUN_STOP : 不运行 + * @arg TIMER_RUN_START : 运行 */ -timer_s_run_flg_t timer_s_get_run(timer_s_t *_ts) +uint8_t timer_s_get_run(timer_s_t *_ts) { - ASSERT_PARAM(IS_VALID_POINT(_ts)); - - return _ts->run; + ASSERT_PARAM(IS_VALID_POINT(_ts)); + + return _ts->runFlg; } + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modules/timer_software.h b/drivers/modules/timer_software.h index 73f4e1f..9f93062 100644 --- a/drivers/modules/timer_software.h +++ b/drivers/modules/timer_software.h @@ -3,7 +3,7 @@ * @file timer_software.h * @author ashuai0110 * @version V2.1 - * @date 2023-09-19 + * @date 2023-09-26 * @brief 软件定时器 * ****************************************************************************** @@ -12,10 +12,6 @@ * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * - * @example - * - * 软件定时器使用举例timer_software.c:40 - * ****************************************************************************** */ @@ -29,47 +25,66 @@ extern "C" { /* 包含头文件-----------------------------------------------------------------*/ #include "common_include.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @addtogroup timer_software + * @{ + */ + /* 宏定义---------------------------------------------------------------------*/ -/* 任务开始运行 */ -#define TIMER_S_START(_ts) do { \ - timer_s_set_run(_ts, 1); \ - }while(0) - -/* 任务停止运行 */ -#define TIMER_S_STOP(_ts) do { \ - timer_s_set_run(_ts, 0); \ - }while(0) - -/* 任务立即执行 */ -#define TIMER_S_WORK(_ts) do { \ - timer_s_set_run(_ts, 1); \ - timer_s_set_cur_ticks(_ts, timer_s_get_cur_ticks(_ts)); \ - }while(0) +/** + * @defgroup timer_software_global_macros timer software global macros + * @{ + */ + +/** + * @defgroup timer_run_flg timer run flag + * @{ + */ +#define TIMER_RUN_STOP (0u) /*!< 不运行 */ +#define TIMER_RUN_START (1u) /*!< 运行 */ +/** + * @} + */ + +/** + * @} + */ /* 类型定义-------------------------------------------------------------------*/ -/** - * @brief 软件定时器任务 run flag enumeration - */ -typedef enum timer_s_run_flg{ - TIMER_S_STOP = 0u, /* 不运行 */ - TIMER_S_START = 1u, /* 运行 */ -} timer_s_run_flg_t; +/** + * @defgroup timer_software_global_types timer software global types + * @{ + */ /** * @brief 软件定时器任务 structrue definition */ typedef struct timer_s { - volatile uint32_t curTicks; /* 当前计数值 */ - uint32_t targetTicks; /* 目标计数值 */ - timer_s_run_flg_t run; /* 运行标志 */ - void(* callbackFn)(void); /* 回调函数 */ - struct timer_s *pNext; + volatile uint32_t curTicks; /*!< 当前计数值 */ + uint32_t targetTicks; /*!< 目标计数值 */ + uint8_t runFlg; /*!< 运行标志 @ref timer_run_flg */ + void(* callbackFn)(void); /*!< 回调函数 */ + struct timer_s *pNext; /*!< 下一节点 */ } timer_s_t; +/** + * @} + */ + /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ -uint8_t timer_s_init(timer_s_t *_ts, uint32_t targetTicks, void (* callbackFn)(void), timer_s_run_flg_t run); +/** + * @addtogroup timer_software_global_functions + * @{ + */ + +uint8_t timer_s_init(timer_s_t *_ts, uint32_t targetTicks, void (* callbackFn)(void), uint8_t runFlg); void timer_s_de_init(timer_s_t *_ts); uint8_t timer_s_insert(timer_s_t *_ts); @@ -81,8 +96,20 @@ void timer_s_set_cur_ticks(timer_s_t *_ts, uint32_t curTicks); uint32_t timer_s_get_cur_ticks(timer_s_t *_ts); void timer_s_set_target_ticks(timer_s_t *_ts, uint32_t targetTicks); uint32_t timer_s_get_target_ticks(timer_s_t *_ts); -void timer_s_set_run(timer_s_t *_ts, timer_s_run_flg_t run); -timer_s_run_flg_t timer_s_get_run(timer_s_t *_ts); +void timer_s_set_run(timer_s_t *_ts, uint8_t runFlg); +uint8_t timer_s_get_run(timer_s_t *_ts); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } diff --git a/drivers/modules/uart_handler.c b/drivers/modules/uart_handler.c index 6b44e3d..38905f7 100644 --- a/drivers/modules/uart_handler.c +++ b/drivers/modules/uart_handler.c @@ -1,9 +1,9 @@ /** ****************************************************************************** * @file uart_handler.c - * @author ashuai0110 - * @version V1.0 - * @date 2023-09-05 + * @author woshiashuai + * @version V2.1 + * @date 2023-09-26 * @brief 串口管理 * (使用帧间隔分帧或现有的分帧方法) * @@ -11,11 +11,7 @@ * @attention * * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_development_module.git - * - * @example - * - * 串口管理使用举例uart_handler.c:42 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ @@ -23,137 +19,127 @@ /* 包含头文件-----------------------------------------------------------------*/ #include "uart_handler.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @defgroup uart_handler 串口管理 + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ +/** + * @defgroup uart_handler_local_macros uart handler local macros + * @{ + */ + +/** + * @defgroup uart_handler_check_parameters_validity uart handler check parameters validity + * @{ + */ /* 串口管理序号有效性检查 */ #define IS_VALID_CH(x) \ ( ((x) == 0) || \ ((x) > 0) && \ ((x) < UART_HANDLER_NUM)) +/** + * @} + */ + +/** + * @} + */ /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ -static uart_handler_t uartHandlerArr[UART_HANDLER_NUM]; /* 串口管理数组 */ - -/* 全局变量-------------------------------------------------------------------*/ - -/* 私有函数原型---------------------------------------------------------------*/ +/** + * @defgroup uart_handler_local_variables uart handler local variables + * @{ + */ -/* 串口管理使用举例 -#define TEST_UART_HR_CH (0u) +static uart_handler_t uartHandlerArr[UART_HANDLER_NUM]; /*!< 串口管理数组 */ -static uint8_t rxBuf[100]; -static uint8_t txBuf[100]; +/** + * @} + */ -// 串口发送前准备函数 -void uart_tx_en(uint8_t enState) -{ - if(enState) - { - // 开启发送相关中断 - } - else - { - // 关闭发送相关中断 - } -} -// 串口接收中断 -void UART_Rx_Int_Callback(void) -{ - static uint8_t rxData = 0; - rxData = UART_ReadData(); - uart_hr_write_rx_buf(TEST_UART_HR_CH, &rxData, 1); -} -// 串口发送中断 -void UART_Tx_Int_Callback(void) -{ - static uint8_t txData = 0; - - if(0 != uart_hr_read_tx_buf(TEST_UART_HR_CH, &txData, 1)) - { - UART_WriteData(txData); - } -} -// 串口初始化 -void uart_init(void) -{ - UART_TEST_Init(); // 串口驱动初始化 波特率19200 - uart_hr_init(TEST_UART_HR_CH, txBuf, sizeof(txBuf), rxBuf, sizeof(rxBuf), uart_tx_en, 19200); -} +/* 全局变量-------------------------------------------------------------------*/ -int main() -{ - uart_init(); - - uint8_t testTxData[] = "hello"; - uart_hr_write_tx_buf(TEST_UART_HR_CH, testTxData, sizeof(testTxData) - 1); +/* 私有函数原型---------------------------------------------------------------*/ - while(1) - { - if(RET_OK == uart_hr_poll(TEST_UART_HR_CH)) - { - uint8_t testRxData[10]; - uart_hr_read_rx_buf(TEST_UART_HR_CH, testRxData, sizeof(testRxData)); - printf("%s\r\n", testRxData); - } - - delay_ms(1); - } -} -*/ +/** + * @defgroup uart_handler_global_functions uart handler global functions + * @{ + */ /** * @brief 串口管理初始化 * - * @param ch : 串口管理序号(即数组索引) + * @param ch : 串口管理序号(即数组索引) * - * @param txBuf : 串口发送缓冲区 + * @param txBuf : 串口发送缓冲区 * - * @param txLen : 串口发送缓冲区大小 + * @param txLen : 串口发送缓冲区大小 * - * @param rxBuf : 串口接收缓冲区 + * @param rxBuf : 串口接收缓冲区 * - * @param rxLen : 串口接收缓冲区大小 + * @param rxLen : 串口接收缓冲区大小 * - * @param txEnFn : 串口发送前准备函数 + * @param txEnFn : 串口发送前准备函数 * - * @param baud : 串口波特率 + * @param baud : 串口波特率 + * + * @param timeout : 接收超时时间ms(无需求可忽略) * * @retval None */ -void uart_hr_init(uint8_t ch, void *txBuf, uint32_t txLen, void *rxBuf, uint32_t rxLen, uart_tx_en_fn_t fTxEn, uint32_t baud) +void uart_hr_init(uint8_t ch, void *txBuf, uint32_t txLen, void *rxBuf, uint32_t rxLen, uart_tx_en_fn_t txEnFn, uint32_t baud, uint16_t timeout) { ASSERT_PARAM(IS_VALID_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(txBuf)); ASSERT_PARAM(IS_VALID_POINT(rxBuf)); - ASSERT_PARAM(IS_VALID_POINT(fTxEn)); + ASSERT_PARAM(IS_VALID_POINT(txEnFn)); - ring_queue_init(&uartHandlerArr[ch].txRQ, txBuf, txLen); - ring_queue_init(&uartHandlerArr[ch].rxRQ, rxBuf, rxLen); - uartHandlerArr[ch].uartTxEnFn = fTxEn; + ring_queue_init(&uartHandlerArr[ch].txRingQueue, txBuf, txLen); + ring_queue_init(&uartHandlerArr[ch].rxRingQueue, rxBuf, rxLen); + uartHandlerArr[ch].uartTxEnFn = txEnFn; if(9600 <= baud) { uartHandlerArr[ch].targetFrameIntv = 3; } else { uartHandlerArr[ch].targetFrameIntv = 10000 / baud * 3.5; } + uartHandlerArr[ch].recTimeout = timeout; } /** * @brief 串口管理轮询处理(1ms) * - * @param ch : 串口管理序号(即数组索引) + * @param ch : 串口管理序号(即数组索引) * * @retval uint8_t - * @arg RET_OK : 帧间隔超时 - * @arg RET_ERR : 帧间隔未超时 + * @arg RET_OK : 接收完成 + * @arg RET_ERR : 接收未完成 + * @arg RET_TIMEOUT : 接收超时(无需求可忽略) */ uint8_t uart_hr_poll(uint8_t ch) { ASSERT_PARAM(IS_VALID_CH(ch)); + /* 帧间隔判断 */ if(uartHandlerArr[ch].curFrameIntv && uartHandlerArr[ch].curFrameIntv++ > uartHandlerArr[ch].targetFrameIntv) { uartHandlerArr[ch].curFrameIntv = 0; + uartHandlerArr[ch].recTimeoutCnt = 0; return RET_OK; } + /* 接收超时判断 */ + if(uartHandlerArr[ch].recTimeoutCnt && uartHandlerArr[ch].recTimeoutCnt++ > uartHandlerArr[ch].recTimeout) + { + uartHandlerArr[ch].recTimeoutCnt = 0; + + return RET_TIMEOUT; + } return RET_ERR; } @@ -174,10 +160,10 @@ uint32_t uart_hr_read_rx_buf(uint8_t ch, void *pBuf, uint32_t len) ASSERT_PARAM(IS_VALID_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - len = (len > ring_queue_can_read(&uartHandlerArr[ch].rxRQ)) ? ring_queue_can_read(&uartHandlerArr[ch].rxRQ) : len; + len = (len > ring_queue_can_read(&uartHandlerArr[ch].rxRingQueue)) ? ring_queue_can_read(&uartHandlerArr[ch].rxRingQueue) : len; if(0 < len) { - ring_queue_read(&uartHandlerArr[ch].rxRQ, pBuf, len); + ring_queue_read(&uartHandlerArr[ch].rxRingQueue, pBuf, len); } return len; @@ -188,11 +174,11 @@ uint32_t uart_hr_read_rx_buf(uint8_t ch, void *pBuf, uint32_t len) * * @note 一般加入到串口接收中断 * - * @param ch : 串口管理序号(即数组索引) + * @param ch : 串口管理序号(即数组索引) * - * @param pBuf : 数据缓存区 + * @param pBuf : 数据缓存区 * - * @param len : 写入长度byte + * @param len : 写入长度byte * * @retval 实际写入的长度 */ @@ -201,10 +187,10 @@ uint32_t uart_hr_write_rx_buf(uint8_t ch, void *pBuf, uint32_t len) ASSERT_PARAM(IS_VALID_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - len = (len > ring_queue_can_write(&uartHandlerArr[ch].rxRQ)) ? ring_queue_can_write(&uartHandlerArr[ch].rxRQ) : len; + len = (len > ring_queue_can_write(&uartHandlerArr[ch].rxRingQueue)) ? ring_queue_can_write(&uartHandlerArr[ch].rxRingQueue) : len; if(0 < len) { - ring_queue_write(&uartHandlerArr[ch].rxRQ, pBuf, len); + ring_queue_write(&uartHandlerArr[ch].rxRingQueue, pBuf, len); uartHandlerArr[ch].curFrameIntv = 1; } @@ -229,14 +215,15 @@ uint32_t uart_hr_read_tx_buf(uint8_t ch, void *pBuf, uint32_t len) ASSERT_PARAM(IS_VALID_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - len = (len > ring_queue_can_read(&uartHandlerArr[ch].txRQ)) ? ring_queue_can_read(&uartHandlerArr[ch].txRQ) : len; + len = (len > ring_queue_can_read(&uartHandlerArr[ch].txRingQueue)) ? ring_queue_can_read(&uartHandlerArr[ch].txRingQueue) : len; if(0 < len) { - ring_queue_read(&uartHandlerArr[ch].txRQ, pBuf, len); + ring_queue_read(&uartHandlerArr[ch].txRingQueue, pBuf, len); } else { uartHandlerArr[ch].uartTxEnFn(0); + uartHandlerArr[ch].recTimeoutCnt = 1; } return len; @@ -258,10 +245,10 @@ uint32_t uart_hr_write_tx_buf(uint8_t ch, void *pBuf, uint32_t len) ASSERT_PARAM(IS_VALID_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - len = (len > ring_queue_can_write(&uartHandlerArr[ch].txRQ)) ? ring_queue_can_write(&uartHandlerArr[ch].txRQ) : len; + len = (len > ring_queue_can_write(&uartHandlerArr[ch].txRingQueue)) ? ring_queue_can_write(&uartHandlerArr[ch].txRingQueue) : len; if(0 < len) { - ring_queue_write(&uartHandlerArr[ch].txRQ, pBuf, len); + ring_queue_write(&uartHandlerArr[ch].txRingQueue, pBuf, len); uartHandlerArr[ch].uartTxEnFn(1); } @@ -282,3 +269,29 @@ void uart_hr_set_frame_intv(uint8_t ch, uint32_t baud) if(9600 <= baud) { uartHandlerArr[ch].targetFrameIntv = 3; } else { uartHandlerArr[ch].targetFrameIntv = 10000 / baud * 3.5; } } + +/** + * @brief 设置串口管理接收超时时间 + * + * @param ch : 串口管理序号(即数组索引) + * + * @param timeout : 接收超时时间 + * + * @retval None + */ +void uart_hr_set_rec_timeout(uint8_t ch, uint16_t timeout) +{ + uartHandlerArr[ch].recTimeout = timeout; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modules/uart_handler.h b/drivers/modules/uart_handler.h index 6069dac..ca50fe6 100644 --- a/drivers/modules/uart_handler.h +++ b/drivers/modules/uart_handler.h @@ -1,9 +1,9 @@ /** ****************************************************************************** * @file uart_handler.h - * @author ashuai0110 - * @version V1.0 - * @date 2023-09-05 + * @author woshiashuai + * @version V2.1 + * @date 2023-09-26 * @brief 串口管理 * (使用帧间隔分帧或现有的分帧方法) * @@ -11,11 +11,7 @@ * @attention * * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_development_module.git - * - * @example - * - * 环形队列使用举例ring_queue.c:42 + * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** */ @@ -31,10 +27,34 @@ extern "C" { #include "common_include.h" #include "ring_queue.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @addtogroup uart_handler + * @{ + */ + /* 宏定义---------------------------------------------------------------------*/ -#define UART_HANDLER_NUM (8u) /* 串口管理数量 */ +/** + * @defgroup uart_handler_global_macros uart handler global macros + * @{ + */ + +#define UART_HANDLER_NUM (1u) /*!< 串口管理数量 */ + +/** + * @} + */ /* 类型定义-------------------------------------------------------------------*/ +/** + * @defgroup uart_handler_global_types uart handler global types + * @{ + */ + /** * @brief 串口发送前准备函数 * @@ -50,19 +70,28 @@ typedef void (* uart_tx_en_fn_t)(uint8_t enState); * @brief 串口管理 structure definition */ typedef struct uart_handler { - uint16_t targetFrameIntv; /* 目标帧间隔 */ - uint16_t curFrameIntv; /* 当前帧间隔 */ - - ring_queue_t txRQ; /* 发送FIFO */ - ring_queue_t rxRQ; /* 接收FIFO */ - - uart_tx_en_fn_t uartTxEnFn; /* 串口发送前准备函数 */ + uint16_t targetFrameIntv; /*!< 目标帧间隔 */ + uint16_t curFrameIntv; /*!< 当前帧间隔 */ + uint16_t recTimeoutCnt; /*!< 接收超时计数 */ + uint16_t recTimeout; /*!< 接收超时时间 */ + ring_queue_t txRingQueue; /*!< 发送环形队列 */ + ring_queue_t rxRingQueue; /*!< 接收环形队列 */ + uart_tx_en_fn_t uartTxEnFn; /*!< 串口发送前准备函数 */ } uart_handler_t; +/** + * @} + */ + /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ -void uart_hr_init(uint8_t ch, void *txBuf, uint32_t txLen, void *rxBuf, uint32_t rxLen, uart_tx_en_fn_t fTxEn, uint32_t baud); +/** + * @addtogroup uart_handler_global_functions + * @{ + */ + +void uart_hr_init(uint8_t ch, void *txBuf, uint32_t txLen, void *rxBuf, uint32_t rxLen, uart_tx_en_fn_t txEnFn, uint32_t baud, uint16_t timeout); uint8_t uart_hr_poll(uint8_t ch); @@ -73,10 +102,22 @@ uint32_t uart_hr_read_tx_buf(uint8_t ch, void *pBuf, uint32_t len); uint32_t uart_hr_write_tx_buf(uint8_t ch, void *pBuf, uint32_t len); void uart_hr_set_frame_intv(uint8_t ch, uint32_t baud); +void uart_hr_set_rec_timeout(uint8_t ch, uint16_t timeout); +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } #endif -#endif /* uart_handler */ +#endif /* uart_handler.h */ diff --git a/examples/[base_on_stm32f1]/stm32f1_sys/gpio.c b/examples/[base_on_stm32f1]/stm32f1_sys/gpio.c index 7fcec3c..7554ba7 100644 --- a/examples/[base_on_stm32f1]/stm32f1_sys/gpio.c +++ b/examples/[base_on_stm32f1]/stm32f1_sys/gpio.c @@ -1,13 +1,13 @@ #include "gpio.h" -// LEDRun -#define LEDRun_GPIO_PORT (GPIOA) -#define LEDRun_GPIO_CLK (RCC_APB2Periph_GPIOA) -#define LEDRun_GPIO_PIN (GPIO_Pin_8) -#define LEDRun_GPIO_TOGGLE (LEDRun_GPIO_PORT->BSRR = ((LEDRun_GPIO_PORT->ODR & LEDRun_GPIO_PIN) << 16) | (~LEDRun_GPIO_PORT->ODR & LEDRun_GPIO_PIN)) -#define LEDRun_GPIO_SET (LEDRun_GPIO_PORT->BSRR = (uint32_t)LEDRun_GPIO_PIN) -#define LEDRun_GPIO_RESET (LEDRun_GPIO_PORT->BSRR = (uint32_t)LEDRun_GPIO_PIN<<16) -#define LEDRun_GPIO_READ ((LEDRun_GPIO_PORT->IDR & LEDRun_GPIO_PIN) != 0) +// LED_RUN +#define LED_RUN_GPIO_PORT (GPIOA) +#define LED_RUN_GPIO_CLK (RCC_APB2Periph_GPIOA) +#define LED_RUN_GPIO_PIN (GPIO_Pin_8) +#define LED_RUN_GPIO_TOGGLE (LED_RUN_GPIO_PORT->BSRR = ((LED_RUN_GPIO_PORT->ODR & LED_RUN_GPIO_PIN) << 16) | (~LED_RUN_GPIO_PORT->ODR & LED_RUN_GPIO_PIN)) +#define LED_RUN_GPIO_SET (LED_RUN_GPIO_PORT->BSRR = (uint32_t)LED_RUN_GPIO_PIN) +#define LED_RUN_GPIO_RESET (LED_RUN_GPIO_PORT->BSRR = (uint32_t)LED_RUN_GPIO_PIN<<16) +#define LED_RUN_GPIO_READ ((LED_RUN_GPIO_PORT->IDR & LED_RUN_GPIO_PIN) != 0) // TEST_IN #define TEST_IN_GPIO_PORT (GPIOA) #define TEST_IN_GPIO_CLK (RCC_APB2Periph_GPIOA) @@ -16,22 +16,6 @@ #define TEST_IN_GPIO_SET (TEST_IN_GPIO_PORT->BSRR = (uint32_t)TEST_IN_GPIO_PIN) #define TEST_IN_GPIO_RESET (TEST_IN_GPIO_PORT->BSRR = (uint32_t)TEST_IN_GPIO_PIN<<16) #define TEST_IN_GPIO_READ ((TEST_IN_GPIO_PORT->IDR & TEST_IN_GPIO_PIN) != 0) -// LED2 -#define LED2_GPIO_PORT (GPIOA) -#define LED2_GPIO_CLK (RCC_APB2Periph_GPIOA) -#define LED2_GPIO_PIN (GPIO_Pin_3) -#define LED2_GPIO_TOGGLE (LED2_GPIO_PORT->BSRR = ((LED2_GPIO_PORT->ODR & LED2_GPIO_PIN) << 16) | (~LED2_GPIO_PORT->ODR & LED2_GPIO_PIN)) -#define LED2_GPIO_SET (LED2_GPIO_PORT->BSRR = (uint32_t)LED2_GPIO_PIN) -#define LED2_GPIO_RESET (LED2_GPIO_PORT->BSRR = (uint32_t)LED2_GPIO_PIN<<16) -#define LED2_GPIO_READ ((LED2_GPIO_PORT->IDR & LED2_GPIO_PIN) != 0) -// LED3 -#define LED3_GPIO_PORT (GPIOA) -#define LED3_GPIO_CLK (RCC_APB2Periph_GPIOA) -#define LED3_GPIO_PIN (GPIO_Pin_4) -#define LED3_GPIO_TOGGLE (LED3_GPIO_PORT->BSRR = ((LED3_GPIO_PORT->ODR & LED3_GPIO_PIN) << 16) | (~LED3_GPIO_PORT->ODR & LED3_GPIO_PIN)) -#define LED3_GPIO_SET (LED3_GPIO_PORT->BSRR = (uint32_t)LED3_GPIO_PIN) -#define LED3_GPIO_RESET (LED3_GPIO_PORT->BSRR = (uint32_t)LED3_GPIO_PIN<<16) -#define LED3_GPIO_READ ((LED3_GPIO_PORT->IDR & LED3_GPIO_PIN) != 0) /** * @brief gpio初始化配置 @@ -43,16 +27,16 @@ void gpio_init_config(void) GPIO_InitTypeDef GPIO_InitStructure; /*开启LED相关的GPIO外设时钟*/ - RCC_APB2PeriphClockCmd(LEDRun_GPIO_CLK, ENABLE); - GPIO_InitStructure.GPIO_Pin = LEDRun_GPIO_PIN; + RCC_APB2PeriphClockCmd(LED_RUN_GPIO_CLK, ENABLE); + GPIO_InitStructure.GPIO_Pin = LED_RUN_GPIO_PIN; /*设置引脚模式为*/ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /*设置引脚速率*/ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /*调用库函数,初始化GPIO*/ - GPIO_Init(LEDRun_GPIO_PORT, &GPIO_InitStructure); + GPIO_Init(LED_RUN_GPIO_PORT, &GPIO_InitStructure); /*关闭*/ - LEDRun_GPIO_SET; + LED_RUN_GPIO_SET; GPIO_InitStructure.GPIO_Pin = TEST_IN_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; @@ -68,10 +52,8 @@ void gpio_set(uint8_t gpiox) { switch(gpiox) { - case LED_RUN: LEDRun_GPIO_SET; break; + case LED_RUN: LED_RUN_GPIO_SET; break; case TEST_IN: TEST_IN_GPIO_SET; break; - case LED2: LED2_GPIO_SET; break; - case LED3: LED3_GPIO_SET; break; } } @@ -84,10 +66,8 @@ void gpio_reset(uint8_t gpiox) { switch(gpiox) { - case LED_RUN: LEDRun_GPIO_RESET; break; + case LED_RUN: LED_RUN_GPIO_RESET; break; case TEST_IN: TEST_IN_GPIO_RESET; break; - case LED2: LED2_GPIO_RESET; break; - case LED3: LED3_GPIO_RESET; break; } } @@ -100,10 +80,8 @@ void gpio_toggle(uint8_t gpiox) { switch(gpiox) { - case LED_RUN: LEDRun_GPIO_TOGGLE; break; + case LED_RUN: LED_RUN_GPIO_TOGGLE; break; case TEST_IN: TEST_IN_GPIO_TOGGLE; break; - case LED2: LED2_GPIO_TOGGLE; break; - case LED3: LED3_GPIO_TOGGLE; break; } } @@ -118,10 +96,8 @@ uint8_t gpio_read(uint8_t gpiox) switch(gpiox) { - case LED_RUN: temp = LEDRun_GPIO_READ; break; + case LED_RUN: temp = LED_RUN_GPIO_READ; break; case TEST_IN: temp = TEST_IN_GPIO_READ; break; - case LED2: temp = LED2_GPIO_READ; break; - case LED3: temp = LED3_GPIO_READ; break; } return temp; diff --git a/examples/[base_on_stm32f1]/stm32f1_sys/gpio.h b/examples/[base_on_stm32f1]/stm32f1_sys/gpio.h index 49f5cb8..a5dfc93 100644 --- a/examples/[base_on_stm32f1]/stm32f1_sys/gpio.h +++ b/examples/[base_on_stm32f1]/stm32f1_sys/gpio.h @@ -19,8 +19,6 @@ PC13,PC14,PC15非必要不使用 typedef enum { LED_RUN = 0, TEST_IN, - LED2, - LED3 } GPIOxEnum; /* 全局变量-------------------------------------------------------------------*/ diff --git a/examples/project_template/MDK/use_example.uvoptx b/examples/project_template/MDK/use_example.uvoptx index 97cb2d3..709c445 100644 --- a/examples/project_template/MDK/use_example.uvoptx +++ b/examples/project_template/MDK/use_example.uvoptx @@ -579,6 +579,174 @@ 0 0 + + 5 + 31 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_host.c + modbus_host.c + 0 + 0 + + + 5 + 32 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_slave.c + modbus_slave.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\command_line.c + command_line.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\data_check.c + data_check.c + 0 + 0 + + + 5 + 35 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\data_convert.c + data_convert.c + 0 + 0 + + + 5 + 36 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\delay_no_block.c + delay_no_block.c + 0 + 0 + + + 5 + 37 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\input_output.c + input_output.c + 0 + 0 + + + 5 + 38 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\memory.c + memory.c + 0 + 0 + + + 5 + 39 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\message_queue.c + message_queue.c + 0 + 0 + + + 5 + 40 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\ring_buffer.c + ring_buffer.c + 0 + 0 + + + 5 + 41 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\ring_queue.c + ring_queue.c + 0 + 0 + + + 5 + 42 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\sync_method.c + sync_method.c + 0 + 0 + + + 5 + 43 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\timer_software.c + timer_software.c + 0 + 0 + + + 5 + 44 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\uart_handler.c + uart_handler.c + 0 + 0 + @@ -589,7 +757,7 @@ 0 6 - 31 + 45 5 0 0 diff --git a/examples/project_template/MDK/use_example.uvprojx b/examples/project_template/MDK/use_example.uvprojx index 8d8819d..6ad06db 100644 --- a/examples/project_template/MDK/use_example.uvprojx +++ b/examples/project_template/MDK/use_example.uvprojx @@ -339,7 +339,7 @@ STM32F10X_MD,USE_STDPERIPH_DRIVER - ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt;..\..\..\drivers\modbus @@ -551,6 +551,76 @@ 1 ..\SRC\main.c + + modbus_host.c + 1 + ..\..\..\drivers\modbus\modbus_host.c + + + modbus_slave.c + 1 + ..\..\..\drivers\modbus\modbus_slave.c + + + command_line.c + 1 + ..\..\..\drivers\modules\command_line.c + + + data_check.c + 1 + ..\..\..\drivers\modules\data_check.c + + + data_convert.c + 1 + ..\..\..\drivers\modules\data_convert.c + + + delay_no_block.c + 1 + ..\..\..\drivers\modules\delay_no_block.c + + + input_output.c + 1 + ..\..\..\drivers\modules\input_output.c + + + memory.c + 1 + ..\..\..\drivers\modules\memory.c + + + message_queue.c + 1 + ..\..\..\drivers\modules\message_queue.c + + + ring_buffer.c + 1 + ..\..\..\drivers\modules\ring_buffer.c + + + ring_queue.c + 1 + ..\..\..\drivers\modules\ring_queue.c + + + sync_method.c + 1 + ..\..\..\drivers\modules\sync_method.c + + + timer_software.c + 1 + ..\..\..\drivers\modules\timer_software.c + + + uart_handler.c + 1 + ..\..\..\drivers\modules\uart_handler.c + diff --git a/examples/project_template/README.txt b/examples/project_template/README.txt index f783cf2..e416d8a 100644 --- a/examples/project_template/README.txt +++ b/examples/project_template/README.txt @@ -2,12 +2,12 @@ 用例使用说明 ================================================================================ Date Author MDK MCU -2023-09-17 ashuai0110 5.35 STM32F1 +2023-09-26 ashuai0110 5.35 STM32F1 ================================================================================ 功能描述 ================================================================================ -本用例展示了非阻塞延时组件的使用方法。 +本用例展示了xxx组件的使用方法。 ================================================================================ 测试环境 @@ -26,15 +26,15 @@ J-Link RTT Viewer 源码文件: --------------------- -delay_no_block.c -delay_no_block.h +xxx.c +xxx.h ================================================================================ 使用步骤 ================================================================================ 1)使用J-Link连接目标板; 2)打开工程,重新编译,启动调试或直接下载程序运行; -3)用J-Link RTT Viewer软件连接,查看单次打印和周期打印消息。 +3)用J-Link RTT Viewer软件连接,查看打印消息。 ================================================================================ 注意 diff --git a/examples/project_template/SRC/main.c b/examples/project_template/SRC/main.c index b67cef8..b70eeba 100644 --- a/examples/project_template/SRC/main.c +++ b/examples/project_template/SRC/main.c @@ -18,6 +18,8 @@ /* 包含头文件-----------------------------------------------------------------*/ #include "stm32f10x.h" +#include "all_include.h" + /* 私有宏定义-----------------------------------------------------------------*/ /* 私有类型定义---------------------------------------------------------------*/ @@ -44,7 +46,5 @@ int main(int argc, char *argv[]) { } - - return 0; } diff --git a/examples/ring_buffer/README.txt b/examples/ring_buffer/README.txt index 9b5d7c9..ea36226 100644 --- a/examples/ring_buffer/README.txt +++ b/examples/ring_buffer/README.txt @@ -19,6 +19,7 @@ Date Author MDK MCU 辅助工具: --------------------- J-Link +串口工具 辅助软件: --------------------- diff --git a/examples/sync_method/README.txt b/examples/sync_method/README.txt index 14d8f70..c10e1a3 100644 --- a/examples/sync_method/README.txt +++ b/examples/sync_method/README.txt @@ -34,11 +34,10 @@ sync_method.h ================================================================================ 1)使用J-Link连接目标板; 2)打开工程,重新编译,启动调试或直接下载程序运行; -3)用J-Link RTT Viewer软件连接,查看单次打印和周期打印消息。 +3)用J-Link RTT Viewer软件连接,查看打印消息。 ================================================================================ 注意 ================================================================================ -1)用户根据需求可前往源码头文件修改宏定义参数 ================================================================================ diff --git a/examples/sync_method/SRC/main.c b/examples/sync_method/SRC/main.c index 22d24a8..e9db980 100644 --- a/examples/sync_method/SRC/main.c +++ b/examples/sync_method/SRC/main.c @@ -3,7 +3,7 @@ * @file main.c * @author ashuai0110 * @version V1.0 - * @date 2023-09-24 + * @date 2023-09-26 * @brief 使用举例-伪线程同步方法(信号量,互斥锁,事件集) * ****************************************************************************** @@ -22,6 +22,8 @@ #include "sync_method.h" /* 私有宏定义-----------------------------------------------------------------*/ +#define TEST_EVENT_1 (EVENT_BIT0) /* 测试事件1 */ +#define TEST_EVENT_2 (EVENT_BIT1) /* 测试事件2 */ /* 私有类型定义---------------------------------------------------------------*/ @@ -31,10 +33,19 @@ static sync_sem_t testSem; /* 测试信号量实例 */ static uint32_t testInt; static sync_mutex_t testMutex; /* 测试互斥锁实例 */ +static sync_event_t testEvent; /* 测试事件集实例 */ + /* 全局变量-------------------------------------------------------------------*/ /* 私有函数原型---------------------------------------------------------------*/ +/** + * @brief 临界区写测试 + * + * @param value : 写入值 + * + * @retval None + */ void critical_write_test(uint32_t value) { /* 获取互斥锁 */ @@ -46,6 +57,13 @@ void critical_write_test(uint32_t value) } } +/** + * @brief 临界区读测试 + * + * @param None + * + * @retval 目标值 + */ uint32_t critical_read_test(void) { uint32_t temp; @@ -71,6 +89,7 @@ uint32_t critical_read_test(void) void TIM1_UP_IRQHandler(void) { static uint16_t cnt = 0; + if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { cnt++; @@ -80,6 +99,14 @@ void TIM1_UP_IRQHandler(void) sync_sem_put(&testSem); critical_write_test(cnt); + + /* 1s周期释放事件1(事件1触发) */ + sync_event_put(&testEvent, TEST_EVENT_1); + } + if(0 == cnt % 5000) + { + /* 5s周期释放事件2(事件2触发) */ + sync_event_put(&testEvent, TEST_EVENT_2); } if(60000 <= cnt) { cnt = 0; } @@ -87,13 +114,6 @@ void TIM1_UP_IRQHandler(void) } } -/** - * @brief - * - * @param None - * - * @retval None - */ int main(int argc, char *argv[]) { VERSION_LOG("example-sync_method", 1, 0, 0); @@ -106,6 +126,9 @@ int main(int argc, char *argv[]) /* 互斥锁初始化 */ sync_mutex_init(&testMutex); + + /* 事件集初始化 */ + sync_event_init(&testEvent); while(1) { @@ -117,7 +140,19 @@ int main(int argc, char *argv[]) DEBUG_LOG("read:%d", critical_read_test()); } - +#if (1) + /* 获取事件1与事件2(等待事件1与事件2触发) */ + if(RET_OK == sync_event_get(&testEvent, TEST_EVENT_1 | TEST_EVENT_2, EVENT_AND, EVENT_CLEAR)) + { + DEBUG_LOG("event1 and event2"); + } +#else + /* 获取事件1或事件2(等待事件1或事件2触发) */ + if(RET_OK == sync_event_get(&testEvent, TEST_EVENT_1 | TEST_EVENT_2, EVENT_OR, EVENT_CLEAR)) + { + DEBUG_LOG("event1 or event2"); + } +#endif } } diff --git a/examples/timer_software/MDK/use_example.uvoptx b/examples/timer_software/MDK/use_example.uvoptx new file mode 100644 index 0000000..1bf747b --- /dev/null +++ b/examples/timer_software/MDK/use_example.uvoptx @@ -0,0 +1,640 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + Target 1 + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U59522627 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 1 + 0 + 2 + 10000000 + + + + + + cmsis + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + core_cm3.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + stm32f10x_it.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + system_stm32f10x.c + 0 + 0 + + + 1 + 4 + 2 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + startup_stm32f10x_md.s + 0 + 0 + + + + + libs + 0 + 0 + 0 + 0 + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + misc.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + stm32f10x_adc.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + stm32f10x_bkp.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + stm32f10x_can.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + stm32f10x_cec.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + stm32f10x_crc.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + stm32f10x_dac.c + 0 + 0 + + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + stm32f10x_dbgmcu.c + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + stm32f10x_dma.c + 0 + 0 + + + 2 + 14 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + stm32f10x_exti.c + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + stm32f10x_flash.c + 0 + 0 + + + 2 + 16 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + stm32f10x_fsmc.c + 0 + 0 + + + 2 + 17 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + stm32f10x_gpio.c + 0 + 0 + + + 2 + 18 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + stm32f10x_i2c.c + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + stm32f10x_iwdg.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + stm32f10x_pwr.c + 0 + 0 + + + 2 + 21 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + stm32f10x_rcc.c + 0 + 0 + + + 2 + 22 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + stm32f10x_rtc.c + 0 + 0 + + + 2 + 23 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + stm32f10x_sdio.c + 0 + 0 + + + 2 + 24 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + stm32f10x_spi.c + 0 + 0 + + + 2 + 25 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + stm32f10x_tim.c + 0 + 0 + + + 2 + 26 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + stm32f10x_usart.c + 0 + 0 + + + 2 + 27 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + stm32f10x_wwdg.c + 0 + 0 + + + + + segger + 0 + 0 + 0 + 0 + + 3 + 28 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + SEGGER_RTT.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + SEGGER_RTT_printf.c + 0 + 0 + + + + + system + 1 + 0 + 0 + 0 + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\gpio.c + gpio.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + tim.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\SRC\main.c + main.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\timer_software.c + timer_software.c + 0 + 0 + + + + + readme + 1 + 0 + 0 + 0 + + 6 + 34 + 5 + 0 + 0 + 0 + ..\README.txt + README.txt + 0 + 0 + + + +
diff --git a/examples/timer_software/MDK/use_example.uvprojx b/examples/timer_software/MDK/use_example.uvprojx new file mode 100644 index 0000000..eab5550 --- /dev/null +++ b/examples/timer_software/MDK/use_example.uvprojx @@ -0,0 +1,602 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + STM32F103C8 + STMicroelectronics + Keil.STM32F1xx_DFP.2.4.1 + https://www.keil.com/pack/ + IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + 0 + $$Device:STM32F103C8$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103C8$SVD\STM32F103xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + use_example + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 1 + 0x8000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + STM32F10X_MD,USE_STDPERIPH_DRIVER + + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + cmsis + + + core_cm3.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + + + stm32f10x_it.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + + + system_stm32f10x.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + + + startup_stm32f10x_md.s + 2 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + + + + + libs + + + misc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + + + stm32f10x_adc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + + + stm32f10x_bkp.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + + + stm32f10x_can.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + + + stm32f10x_cec.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + + + stm32f10x_crc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + + + stm32f10x_dac.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + + + stm32f10x_dbgmcu.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + + + stm32f10x_dma.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + + + stm32f10x_exti.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + + + stm32f10x_flash.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + + + stm32f10x_fsmc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + + + stm32f10x_gpio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + + + stm32f10x_i2c.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + + + stm32f10x_iwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + + + stm32f10x_pwr.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + + + stm32f10x_rcc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + + + stm32f10x_rtc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + + + stm32f10x_sdio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + + + stm32f10x_spi.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + + + stm32f10x_tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + + + stm32f10x_usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + + + stm32f10x_wwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + + + + + segger + + + SEGGER_RTT.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + + + SEGGER_RTT_printf.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + + + + + system + + + gpio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\gpio.c + + + tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + + + + + source + + + main.c + 1 + ..\SRC\main.c + + + timer_software.c + 1 + ..\..\..\drivers\modules\timer_software.c + + + + + readme + + + README.txt + 5 + ..\README.txt + + + + + + + + + + + + + + + + + use_example + 1 + + + + +
diff --git a/examples/timer_software/README.txt b/examples/timer_software/README.txt new file mode 100644 index 0000000..44d9b0e --- /dev/null +++ b/examples/timer_software/README.txt @@ -0,0 +1,44 @@ +================================================================================ + 用例使用说明 +================================================================================ +Date Author MDK MCU +2023-09-26 ashuai0110 5.35 STM32F1 + +================================================================================ +功能描述 +================================================================================ +本用例展示了软件定时器组件的使用方法。 + +================================================================================ +测试环境 +================================================================================ +测试用板: +--------------------- +任意开发板 + +辅助工具: +--------------------- +J-Link + +辅助软件: +--------------------- +J-Link RTT Viewer + +源码文件: +--------------------- +timer_software.c +timer_software.h + +================================================================================ +使用步骤 +================================================================================ +1)使用J-Link连接目标板; +2)打开工程,重新编译,启动调试或直接下载程序运行; +3)查看板载LED周期闪烁现象; +4)用J-Link RTT Viewer软件连接,查看周期打印消息。 + +================================================================================ +注意 +================================================================================ + +================================================================================ diff --git a/examples/timer_software/SRC/main.c b/examples/timer_software/SRC/main.c new file mode 100644 index 0000000..590cea0 --- /dev/null +++ b/examples/timer_software/SRC/main.c @@ -0,0 +1,110 @@ +/** + ****************************************************************************** + * @file main.c + * @author ashuai0110 + * @version V1.0 + * @date 2023-09-26 + * @brief 使用举例-软件定时器 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * + ****************************************************************************** + */ + +/* 包含头文件-----------------------------------------------------------------*/ +#include "stm32f10x.h" +#include "gpio.h" +#include "tim.h" + +#include "timer_software.h" + +/* 私有宏定义-----------------------------------------------------------------*/ +#define TIMER_S_PERIOD (1u) /* 软件定时器调度周期1ms */ + +/* 私有类型定义---------------------------------------------------------------*/ + +/* 私有变量-------------------------------------------------------------------*/ +static timer_s_t ledBlinkTimerS; /* led闪烁任务 */ +static timer_s_t printTimerS; /* 打印任务 */ + +/* 全局变量-------------------------------------------------------------------*/ + +/* 私有函数原型---------------------------------------------------------------*/ + +/** + * @brief 定时器1中断函数 + * + * @param None + * + * @retval None + */ +void TIM1_UP_IRQHandler(void) +{ + if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) + { + /* 软件定时器轮询处理 */ + timer_s_poll(); + + TIM_ClearITPendingBit(TIM1, TIM_FLAG_Update); + } +} + +/** + * @brief led闪烁任务回调函数 + * + * @param None + * + * @retval None + */ +void led_blink_callback(void) +{ + gpio_toggle(LED_RUN); +} + +/** + * @brief 打印任务回调函数 + * + * @param None + * + * @retval None + */ +void print_callback(void) +{ + DEBUG_LOG("print task"); +} + +/** + * @brief + * + * @param None + * + * @retval None + */ +int main(int argc, char *argv[]) +{ + VERSION_LOG("example-timer_software", 1, 0, 0); + + /* led初始化 */ + gpio_init_config(); + /* 定时器初始化 1ms */ + tim1_init_config(100-1, 720-1); + + uint8_t ret = 0; + /* 软件定时器初始化 */ + /* led闪烁任务 500ms周期 */ + ret = timer_s_init(&ledBlinkTimerS, 500/TIMER_S_PERIOD, led_blink_callback, TIMER_RUN_START); + if(RET_OK != ret) { ERROR_LOG("timer_s_init failure"); } + /* 打印任务 1000ms周期 */ + ret = timer_s_init(&printTimerS, 1000/TIMER_S_PERIOD, print_callback, TIMER_RUN_START); + if(RET_OK != ret) { ERROR_LOG("timer_s_init failure"); } + + while(1) + { + + } +} + diff --git a/examples/uart_handler/MDK/use_example.uvoptx b/examples/uart_handler/MDK/use_example.uvoptx new file mode 100644 index 0000000..6a61e91 --- /dev/null +++ b/examples/uart_handler/MDK/use_example.uvoptx @@ -0,0 +1,652 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + Target 1 + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U59522627 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 1 + 0 + 2 + 10000000 + + + + + + cmsis + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + core_cm3.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + stm32f10x_it.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + system_stm32f10x.c + 0 + 0 + + + 1 + 4 + 2 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + startup_stm32f10x_md.s + 0 + 0 + + + + + libs + 0 + 0 + 0 + 0 + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + misc.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + stm32f10x_adc.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + stm32f10x_bkp.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + stm32f10x_can.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + stm32f10x_cec.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + stm32f10x_crc.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + stm32f10x_dac.c + 0 + 0 + + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + stm32f10x_dbgmcu.c + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + stm32f10x_dma.c + 0 + 0 + + + 2 + 14 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + stm32f10x_exti.c + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + stm32f10x_flash.c + 0 + 0 + + + 2 + 16 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + stm32f10x_fsmc.c + 0 + 0 + + + 2 + 17 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + stm32f10x_gpio.c + 0 + 0 + + + 2 + 18 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + stm32f10x_i2c.c + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + stm32f10x_iwdg.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + stm32f10x_pwr.c + 0 + 0 + + + 2 + 21 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + stm32f10x_rcc.c + 0 + 0 + + + 2 + 22 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + stm32f10x_rtc.c + 0 + 0 + + + 2 + 23 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + stm32f10x_sdio.c + 0 + 0 + + + 2 + 24 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + stm32f10x_spi.c + 0 + 0 + + + 2 + 25 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + stm32f10x_tim.c + 0 + 0 + + + 2 + 26 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + stm32f10x_usart.c + 0 + 0 + + + 2 + 27 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + stm32f10x_wwdg.c + 0 + 0 + + + + + segger + 0 + 0 + 0 + 0 + + 3 + 28 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + SEGGER_RTT.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + SEGGER_RTT_printf.c + 0 + 0 + + + + + system + 1 + 0 + 0 + 0 + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + tim.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + usart.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\SRC\main.c + main.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\uart_handler.c + uart_handler.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\ring_queue.c + ring_queue.c + 0 + 0 + + + + + readme + 1 + 0 + 0 + 0 + + 6 + 35 + 5 + 0 + 0 + 0 + ..\README.txt + README.txt + 0 + 0 + + + +
diff --git a/examples/uart_handler/MDK/use_example.uvprojx b/examples/uart_handler/MDK/use_example.uvprojx new file mode 100644 index 0000000..c4249e3 --- /dev/null +++ b/examples/uart_handler/MDK/use_example.uvprojx @@ -0,0 +1,607 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + STM32F103C8 + STMicroelectronics + Keil.STM32F1xx_DFP.2.4.1 + https://www.keil.com/pack/ + IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + 0 + $$Device:STM32F103C8$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103C8$SVD\STM32F103xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + use_example + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 1 + 0x8000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + STM32F10X_MD,USE_STDPERIPH_DRIVER + + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + cmsis + + + core_cm3.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + + + stm32f10x_it.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + + + system_stm32f10x.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + + + startup_stm32f10x_md.s + 2 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + + + + + libs + + + misc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + + + stm32f10x_adc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + + + stm32f10x_bkp.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + + + stm32f10x_can.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + + + stm32f10x_cec.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + + + stm32f10x_crc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + + + stm32f10x_dac.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + + + stm32f10x_dbgmcu.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + + + stm32f10x_dma.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + + + stm32f10x_exti.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + + + stm32f10x_flash.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + + + stm32f10x_fsmc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + + + stm32f10x_gpio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + + + stm32f10x_i2c.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + + + stm32f10x_iwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + + + stm32f10x_pwr.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + + + stm32f10x_rcc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + + + stm32f10x_rtc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + + + stm32f10x_sdio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + + + stm32f10x_spi.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + + + stm32f10x_tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + + + stm32f10x_usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + + + stm32f10x_wwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + + + + + segger + + + SEGGER_RTT.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + + + SEGGER_RTT_printf.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + + + + + system + + + tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + + + usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + + + + + source + + + main.c + 1 + ..\SRC\main.c + + + uart_handler.c + 1 + ..\..\..\drivers\modules\uart_handler.c + + + ring_queue.c + 1 + ..\..\..\drivers\modules\ring_queue.c + + + + + readme + + + README.txt + 5 + ..\README.txt + + + + + + + + + + + + + + + + + use_example + 1 + + + + +
diff --git a/examples/uart_handler/README.txt b/examples/uart_handler/README.txt new file mode 100644 index 0000000..1474eaf --- /dev/null +++ b/examples/uart_handler/README.txt @@ -0,0 +1,47 @@ +================================================================================ + 用例使用说明 +================================================================================ +Date Author MDK MCU +2023-09-26 ashuai0110 5.35 STM32F1 + +================================================================================ +功能描述 +================================================================================ +本用例展示了串口管理组件的使用方法。 + +================================================================================ +测试环境 +================================================================================ +测试用板: +--------------------- +任意开发板 + +辅助工具: +--------------------- +J-Link +串口工具 + +辅助软件: +--------------------- +J-Link RTT Viewer +串口调试软件 + +源码文件: +--------------------- +uart_handler.c +uart_handler.h + +================================================================================ +使用步骤 +================================================================================ +1)使用J-Link连接目标板; +2)打开工程,重新编译,启动调试或直接下载程序运行; +3) 打开串口调试软件,重启开发板查看接收内容,再发送任意数据 +4)用J-Link RTT Viewer软件连接,查看打印消息。 + +================================================================================ +注意 +================================================================================ +1)用户根据需求可前往源码头文件修改宏定义参数 + +================================================================================ diff --git a/examples/uart_handler/SRC/main.c b/examples/uart_handler/SRC/main.c new file mode 100644 index 0000000..1a75a98 --- /dev/null +++ b/examples/uart_handler/SRC/main.c @@ -0,0 +1,145 @@ +/** + ****************************************************************************** + * @file main.c + * @author ashuai0110 + * @version V1.0 + * @date 2023-09-26 + * @brief 使用举例-串口管理 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * + ****************************************************************************** + */ + +/* 包含头文件-----------------------------------------------------------------*/ +#include "stm32f10x.h" +#include "tim.h" +#include "usart.h" + +#include "uart_handler.h" + +/* 私有宏定义-----------------------------------------------------------------*/ +#define USART1_UART_HR_CH (0u) /* 串口管理序号 */ + +/* 私有类型定义---------------------------------------------------------------*/ + +/* 私有变量-------------------------------------------------------------------*/ +static uint8_t txBuf[128]; /* 串口管理所需发送缓冲区 */ +static uint8_t rxBuf[128]; /* 串口管理所需接收缓冲区 */ + +/* 全局变量-------------------------------------------------------------------*/ + +/* 私有函数原型---------------------------------------------------------------*/ + +/** + * @brief 定时器中断函数 + * + * @param None + * + * @retval None + */ +void TIM1_UP_IRQHandler(void) +{ + static uint8_t ret; + static uint8_t rxBufTmp[100]; + + if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) + { + /* 串口管理轮询处理 */ + ret = uart_hr_poll(USART1_UART_HR_CH); + /* 接收完成 */ + if(RET_OK == ret) + { + /* 串口管理读取数据 */ + uint16_t dataLen = uart_hr_read_rx_buf(USART1_UART_HR_CH, rxBufTmp, sizeof(rxBufTmp)); + rxBufTmp[dataLen] = '\0'; + DEBUG_LOG("uart rec:%s", rxBufTmp); + } /* 接收超时 无需求可忽略此返回值 */ + else if(RET_TIMEOUT == ret) + { + WARN_LOG("uart rec timeout"); + } + + TIM_ClearITPendingBit(TIM1, TIM_FLAG_Update); + } +} + +/** + * @brief 串口中断函数 + * + * @param None + * + * @retval None + */ +void USART1_IRQHandler(void) +{ + static uint8_t rxData, txData; + + if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) + { + rxData = USART_ReceiveData(USART1); + /* 写入接收缓存 */ + uart_hr_write_rx_buf(USART1_UART_HR_CH, &rxData, 1); + + USART_ClearITPendingBit(USART1, USART_IT_RXNE); + } + + if(USART_GetITStatus(USART1, USART_IT_TC) != RESET) + { + /* 读出发送缓存 */ + if(0 != uart_hr_read_tx_buf(USART1_UART_HR_CH, &txData, 1)) + { + USART_SendData(USART1, txData); + } + + USART_ClearITPendingBit(USART1, USART_IT_TC); + } +} + +/** + * @brief 串口发送中断开关函数 + * + * @param None + * + * @retval None + */ +void uart_tx_en(uint8_t enState) +{ + if(enState) + { + /* 使能发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, ENABLE); + } + else + { + /* 关闭发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, DISABLE); + } +} + +int main(int argc, char *argv[]) +{ + VERSION_LOG("example-uart_handler", 1, 0, 0); + + /* 定时器初始化 1ms */ + tim1_init_config(100-1, 720-1); + /* 串口初始化 115200 */ + usart1_init_config(115200); + + /* 串口管理初始化 */ + uart_hr_init(USART1_UART_HR_CH, txBuf, sizeof(txBuf), rxBuf, sizeof(rxBuf), uart_tx_en, 115200, 2000); + + uint8_t mes[] = "uart handler"; + /* 串口管理发送数据 */ + uart_hr_write_tx_buf(USART1_UART_HR_CH, mes, sizeof(mes)); + + while(1) + { + + } +} + -- Gitee From 4003b19750ef378256d7c9f13f6fb1a2c7094748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=A1=B00110?= Date: Tue, 17 Oct 2023 20:51:26 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9modbus=5Fhost=E7=BB=84?= =?UTF-8?q?=E4=BB=B6,=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94=E4=BE=8B?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/common/common_include.h | 9 +- drivers/modbus/modbus_host.c | 1103 ++++++---- drivers/modbus/modbus_host.h | 158 +- drivers/modules/data_check.c | 84 +- drivers/modules/data_check.h | 32 +- drivers/modules/delay_no_block.c | 30 +- drivers/modules/delay_no_block.h | 2 +- .../Target_1_STM32F103C8_1.0.0.dbgconf | 36 + .../command_line/MDK/use_example.uvguix.yansj | 1878 +++++++++++++++++ .../delay_no_block/MDK/use_example.uvoptx | 2 +- examples/delay_no_block/SRC/main.c | 4 +- examples/modbus_host/MDK/use_example.uvoptx | 652 ++++++ examples/modbus_host/MDK/use_example.uvprojx | 607 ++++++ examples/modbus_host/README.txt | 49 + examples/modbus_host/SRC/main.c | 287 +++ 15 files changed, 4477 insertions(+), 456 deletions(-) create mode 100644 examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf create mode 100644 examples/command_line/MDK/use_example.uvguix.yansj create mode 100644 examples/modbus_host/MDK/use_example.uvoptx create mode 100644 examples/modbus_host/MDK/use_example.uvprojx create mode 100644 examples/modbus_host/README.txt create mode 100644 examples/modbus_host/SRC/main.c diff --git a/drivers/common/common_include.h b/drivers/common/common_include.h index c5fafea..5d1d391 100644 --- a/drivers/common/common_include.h +++ b/drivers/common/common_include.h @@ -3,7 +3,7 @@ * @file common_include.h * @author ashuai0110 * @version V2.1 - * @date 2023-09-24 + * @date 2023-10-17 * @brief 通用头文件(所有组件都需包含此文件) * ****************************************************************************** @@ -57,6 +57,7 @@ extern "C" { #define RET_FULL (4u) /*!< 已满 */ #define RET_LEN_ERR (5u) /*!< 长度错误 */ #define RET_CHECK_ERR (6u) /*!< 校验错误 */ +#define RET_FRAME_ERR (7u) /*!< 格式错误 */ /** * @} */ @@ -225,9 +226,9 @@ extern "C" { #ifndef BIT_TOGGLE #define BIT_TOGGLE(val, bitx) ((val) ^ (1u << (bitx))) #endif -/* 替换位 BIT_SPLIT(0xF0,0x03,1)=0xF1 BIT_SPLIT(0x0F,0xF7,4)=0x07 */ -#ifndef BIT_SPLIT - #define BIT_SPLIT(sVal, dVal, num) (((sVal) & (~((1u << (num)) - 1u))) | ((dVal) & ((1u << (num)) - 1u))) +/* 替换位 BIT_REPLACE(0xF0,0x03,1)=0xF1 BIT_REPLACE(0x0F,0xF7,4)=0x07 */ +#ifndef BIT_REPLACE + #define BIT_REPLACE(sVal, dVal, num) (((sVal) & (~((1u << (num)) - 1u))) | ((dVal) & ((1u << (num)) - 1u))) #endif /** * @} diff --git a/drivers/modbus/modbus_host.c b/drivers/modbus/modbus_host.c index cef6ae0..7380e8f 100644 --- a/drivers/modbus/modbus_host.c +++ b/drivers/modbus/modbus_host.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file modbus_host.c * @author woshiashuai - * @version V1.0 - * @date 2023-09-01 + * @version V2.1 + * @date 2023-10-17 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** @@ -19,605 +19,962 @@ #include "modbus_host.h" #include "data_check.h" +/** + * @addtogroup modbus + * @{ + */ + +/** + * @defgroup modbus_host modbus主机程序 + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ +/** + * @defgroup modbus_host_local_macros modbus host local macros + * @{ + */ + +/** + * @defgroup modbus_host_check_parameters_validity modbus host check parameters validity + * @{ + */ /* modbus主机管理序号有效性检查 */ #define IS_VALID_CH(x) \ ( ((x) == 0) || \ ((x) > 0) && \ - ((x) < MODBUS_HOST_NUM)) + ((x) < MBH_NUM)) + +/* modbus主机协议类型有效性检查 */ +#define IS_VALID_PROTOCOL(x) \ +( (x) == MBH_RTU || \ + (x) == MBH_ASCII) +/** + * @} + */ + +#define MBH_PDU_SIZE_MIN (4u) /*!< modbus PDU最小4byte */ +#define MBH_ADDR_OFF (0u) /*!< modbus从站地址偏移 */ +#define MBH_CODE_OFF (1u) /*!< modbus功能码偏移 */ +#define MBH_RSP_DATA_OFF (3u) /*!< modbus应答数据值偏移 */ + +/** + * @} + */ /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ -static mb_host_t mbHostArr[MODBUS_HOST_NUM]; /* modbus主机管理数组 */ +/** + * @defgroup modbus_host_local_variables modbus host local variables + * @{ + */ + +/* HEX转ASCII */ +const char HEX_TO_ASCII[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0X41,0X42,0X43,0X44,0X45,0X46}; +/* ASCII转HEX */ +const char ASCII_TO_HEX[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15,0,0,0,0,0,0}; + +static mb_host_t mbHostArr[MBH_NUM]; /*!< modbus主机管理数组 */ + +/** + * @} + */ /* 全局变量-------------------------------------------------------------------*/ /* 私有函数原型---------------------------------------------------------------*/ +/** + * @defgroup modbus_host_local_functions modbus host local functions + * @{ + */ /** - * @brief modbus主机初始化 - * - * @param ch : modbus主机管理序号(即数组索引) - * - * @param fRead : 数据读取函数(用于接收) - * - * @param fWrite : 数据写入函数(用于发送) + * @brief 功能码应答处理 * - * @param timeout : 应答超时时间ms + * @param ch : modbus主机管理序号(即数组索引) * * @retval None */ -void mb_host_init(uint8_t ch, mb_host_rw_fn_t fRead, mb_host_rw_fn_t fWrite, uint16_t timeout) +static void mb_host_rspProcess(uint8_t ch) { - ASSERT_PARAM(IS_VALID_CH(ch)); - ASSERT_PARAM(IS_VALID_POINT(fRead)); - ASSERT_PARAM(IS_VALID_POINT(fWrite)); - - if(timeout == 0) { timeout = 100; } - - mbHostArr[ch].readDataFn = fRead; - mbHostArr[ch].writeDataFn = fWrite; - mbHostArr[ch].rspTimeout = timeout; + if(mbHostArr[ch].slaveTmp != mbHostArr[ch].dataBuf[MBH_ADDR_OFF]) { return ; } + switch(mbHostArr[ch].dataBuf[MBH_CODE_OFF]) + { + case 0x01: mb_host_rsp_01h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读线圈应答处理 */ + case 0x02: mb_host_rsp_02h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读离散量输入应答处理 */ + case 0x03: mb_host_rsp_03h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读保持寄存器应答处理 */ + case 0x04: mb_host_rsp_04h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读输入寄存器应答处理 */ + case 0x05: + case 0x06: + case 0x0F: + case 0x10: mb_host_rsp_05_10h(ch); break; /* 写命令应答处理 */ + /* + 用户在这里写其他功能码的应答处理 + */ + default: if(mbHostArr[ch].dataBuf[MBH_CODE_OFF] & 0x80) { mb_host_rsp_err(ch, &mbHostArr[ch].dataBuf[MBH_CODE_OFF]); } break; /* 不支持的功能码或错误返回 */ + } } /** - * @brief 从机应答接收完成处理 + * @brief 追加校验后发送 * * @param ch : modbus主机管理序号(即数组索引) * * @retval None */ -void mb_host_rsp_over(uint8_t ch) +static void mb_host_send_with_check(uint8_t ch) { - ASSERT_PARAM(IS_VALID_CH(ch)); - ASSERT_PARAM(IS_VALID_POINT(mbHostArr[ch].readDataFn)); + uint16_t checkVal; - mbHostArr[ch].recvLen = mbHostArr[ch].readDataFn((void *)mbHostArr[ch].recvBuf, sizeof(mbHostArr[ch].recvBuf)); - mbHostArr[ch].rspRecvOver = 1; + /* ASCII协议 */ + if(MBH_ASCII == mbHostArr[ch].protocol) + { + int16_t index = 0; + /* 追加LRC校验结果 */ + checkVal = check_lrc(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen); + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal; + /* HEX转ASCII */ + for(index = mbHostArr[ch].dataLen - 1; index >= 0; index--) + { + mbHostArr[ch].dataBuf[(index << 1) + 1] = HEX_TO_ASCII[mbHostArr[ch].dataBuf[index] >> 4]; + mbHostArr[ch].dataBuf[(index << 1) + 2] = HEX_TO_ASCII[mbHostArr[ch].dataBuf[index] & 0xF]; + } + mbHostArr[ch].dataLen = (mbHostArr[ch].dataLen << 1) + 3; + mbHostArr[ch].dataBuf[0] = 0x3A; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 2] = 0x0D; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1] = 0x0A; + } /* RTU协议 */ + else + { + /* 追加CRC校验结果 */ + checkVal = check_crc16_modbus(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen); + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal; + } +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] send: ", ch); + for(uint16_t i = 0; i < mbHostArr[ch].dataLen; i++) + { + PRINT_LOG("%02X ", mbHostArr[ch].dataBuf[i]); + } + PRINT_LOG("\n"); +#endif + mbHostArr[ch].txEnFn(1); /* 开启发送 */ } /** - * @brief 设置应答超时时间 + * @brief 功能码0x01 0x02 0x03 0x04命令 * - * @param ch : modbus主机管理序号(即数组索引) + * @note 从机地址 | 功能码 | 起始地址 | 数量 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param timeout : 应答超时时间ms + * @param ch : modbus主机管理序号(即数组索引) + * + * @param slaveAddr : 从机地址 + * + * @param funCode : 功能码 + * + * @param reg : 起始地址 + * + * @param num : 数量 * * @retval None */ -void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout) +static void mb_host_cmd_01_04h(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num) { - ASSERT_PARAM(IS_VALID_CH(ch)); - - if(timeout == 0) { timeout = 100; } + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = funCode; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; - mbHostArr[ch].rspTimeout = timeout; + mb_host_send_with_check(ch); } /** - * @brief 读线圈应答处理(0x01) + * @brief 写单个线圈命令(0x05) * - * @note 从机地址 | 功能码 | 字节数n | 线圈状态 | CRC16 - * 1 | 1 | 1 | n | 2 (占用字节) + * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : 起始地址 + * @param slaveAddr : 从机地址 * - * @param num : 线圈数量 1线圈=1bit + * @param reg : 起始地址 * - * @param pData : 线圈数据 + * @param extend : 扩展数据(一个线圈数据 0:OFF 1:ON) * * @retval None */ -__WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +static void mb_host_cmd_05h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint8_t extend) { -#ifdef _MODBUS_HOST_DEBUG - uint8_t bytes = (num + 7) >> 3; + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x05; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend ? 0xFF : 0x00; /* 写入值:0xFF00=ON 0x0000=OFF */ + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x00; - PRINT_LOG("modbus host[%d] rsp01H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); - for(uint8_t i = 0; i < bytes; i++) - { - PRINT_LOG("%02X ", pData[i]); - } - PRINT_LOG("\n"); -#endif + mb_host_send_with_check(ch); } /** - * @brief 读离散量输入应答处理(0x02) + * @brief 写单个保持寄存器命令(0x06) * - * @note 从机地址 | 功能码 | 字节数n | 离散量状态 | CRC16 - * 1 | 1 | 1 | n | 2 (占用字节) + * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : 起始地址 + * @param slaveAddr : 从机地址 * - * @param num : 离散量输入数量 1离散量输入=1bit + * @param reg : 起始地址 * - * @param pData : 离散量输入数据 + * @param extend : 扩展数据(一个寄存器数据 16bit) * * @retval None */ -__WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t extend) { -#ifdef _MODBUS_HOST_DEBUG - uint8_t bytes = (num + 7) >> 3; + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x06; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend; - PRINT_LOG("modbus host[%d] rsp02H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); - for(uint8_t i = 0; i < bytes; i++) - { - PRINT_LOG("%02X ", pData[i]); - } - PRINT_LOG("\n"); -#endif + mb_host_send_with_check(ch); } /** - * @brief 读保持寄存器应答处理(0x03) + * @brief 写多个线圈命令(0x0f) * - * @note 从机地址 | 功能码 | 字节数n | 保持寄存器值 | CRC16 - * 1 | 1 | 1 | n | 2 (占用字节) + * @note 从机地址 | 功能码 | 起始地址 | 数量 | 字节数n | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 1 | n | 2 (占用字节) * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : 起始地址 + * @param slaveAddr : 从机地址 * - * @param num : 保持寄存器数量 1保持寄存器=16bit + * @param reg : 起始地址 * - * @param pData : 保持寄存器数据 + * @param num : 数量 + * + * @param extend : 扩展数据(多个线圈数据 1字节型指针) * * @retval None */ -__WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +static void mb_host_cmd_0fh(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint8_t *extend) { -#ifdef _MODBUS_HOST_DEBUG - uint8_t bytes = num << 1; + uint16_t bytes; + + bytes = (num + 7) >> 3; - PRINT_LOG("modbus host[%d] rsp03H> regAddr:%04X, regNum:%d, data:", ch, reg, num); - for(uint8_t i = 0; i < bytes; i++) - { - PRINT_LOG("%02X ", pData[i]); - } - PRINT_LOG("\n"); -#endif + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x0F; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = bytes; + num = num % 8; + if(num) { extend[bytes - 1] = extend[bytes - 1] & ((1u << num) - 1); } /* 未使用bit填0 */ + memcpy(&mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen], extend, bytes); + mbHostArr[ch].dataLen += bytes; + + mb_host_send_with_check(ch); } /** - * @brief 读输入寄存器应答处理(0x04) + * @brief 写多个寄存器命令(0x10) * - * @note 从机地址 | 功能码 | 字节数n | 输入寄存器值 | CRC16 - * 1 | 1 | 1 | n | 2 (占用字节) + * @note 从机地址 | 功能码 | 起始地址 | 数量n | 字节数2n | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 1 | 2n | 2 (占用字节) * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : 起始地址 + * @param slaveAddr : 从机地址 * - * @param num : 输入寄存器数量 1输入寄存器=16bit + * @param reg : 起始地址 * - * @param pData : 输入寄存器数据 + * @param num : 数量 + * + * @param extend : 扩展数据(多个寄存器数据 2字节型指针) * * @retval None */ -__WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint16_t *extend) { -#ifdef _MODBUS_HOST_DEBUG - uint8_t bytes = num << 1; + uint16_t bytes; + + bytes = num << 1; - PRINT_LOG("modbus host[%d] rsp04H> regAddr:%04X, regNum:%d, data:", ch, reg, num); - for(uint8_t i = 0; i < bytes; i++) + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x10; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = bytes; + for(uint16_t cnt = 0; cnt < num; cnt++) { - PRINT_LOG("%02X ", pData[i]); + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend[cnt] >> 8; + mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend[cnt]; } - PRINT_LOG("\n"); -#endif + + mb_host_send_with_check(ch); } /** - * @brief 功能码0x05 0x06 0x0F 0x10应答处理 + * @} + */ + +/** + * @defgroup modbus_host_global_functions modbus host global functions + * @{ + */ + +/** + * @brief modbus主机初始化 * - * @note 从机地址 | 功能码 | 起始地址 | 写入值/数量 | CRC16 - * 1 | 1 | 2 | 2 | 2 (占用字节) + * @param ch : modbus主机管理序号(即数组索引) * - * @param None + * @param protocol : 协议类型 @ref modbus_host_protocol + * @arg MBH_RTU : RTU协议 + * @arg MBH_ASCII : ASCII协议 + * + * @param pBuf : 接收数据缓存区 + * + * @param bufLen : 接收数据缓存区长度 + * + * @param txEnFn : 主机发送前(串口)准备函数 + * + * @param baud : 波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0)) + * + * @param rspTimeout : 应答超时时间ms * * @retval None */ -__WEAK void mb_host_rsp_05_10h(uint8_t ch) +void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, mb_host_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout) { -#ifdef _MODBUS_HOST_DEBUG - PRINT_LOG("modbus host[%d] rsp05H_06H_0FH_10H> success\n", ch); -#endif + ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_PROTOCOL(protocol)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); + ASSERT_PARAM(IS_VALID_POINT(txEnFn)); + + mbHostArr[ch].dataBuf = (uint8_t *)pBuf; + mbHostArr[ch].dataBufLen = bufLen; + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].readLen = 0; + + mbHostArr[ch].protocol = protocol; + mbHostArr[ch].state = MBH_TX_IDLE; + mbHostArr[ch].broadcast = 0; + + mb_host_set_frame_intv(ch, baud); + mbHostArr[ch].curFrameIntv = 0; + mbHostArr[ch].rspTimeout = rspTimeout; + mbHostArr[ch].rspTimeoutCnt = 0; + + mbHostArr[ch].txEnFn = txEnFn; } /** - * @brief 错误码应答处理(功能码+0x80) - * - * @note 从机地址 | 错误功能码 | 错误代码 | CRC16 - * 1 | 1 | 1 | 2 (占用字节) + * @brief modbus主机轮询处理 * - * @param ch : modbus主机管理序号(即数组索引) + * @note 轮询周期1ms * - * @param pData : 错误数据(错误功能码和错误代码) + * @param ch : modbus主机管理序号(即数组索引) * - * @retval None + * @retval uint8_t + * @arg RET_OK : 处理完成 + * @arg RET_ING : 进行中 + * @arg RET_TIMEOUT : 超时 + * @arg RET_LEN_ERR : 数据长度错误 + * @arg RET_CHECK_ERR : 数据校验错误 + * @arg RET_FRAME_ERR : 数据格式错误 */ -__WEAK void mb_host_rsp_err(uint8_t ch, uint8_t *pData) +uint8_t mb_host_poll(uint8_t ch) { -#ifdef _MODBUS_HOST_DEBUG - PRINT_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X\n", ch, pData[0], pData[1]); + uint8_t ret = RET_ING; /* 进行中 */ + + ASSERT_PARAM(IS_VALID_CH(ch)); + + if(MBH_RX_IDLE == mbHostArr[ch].state) + { + /* 应答超时判断 */ + if(mbHostArr[ch].rspTimeoutCnt && mbHostArr[ch].rspTimeoutCnt++ > mbHostArr[ch].rspTimeout) + { + mbHostArr[ch].rspTimeoutCnt = 0; + ret = RET_TIMEOUT; /* 应答超时 */ + goto rspErr; + } + /* 帧间隔超时判断 */ + if(mbHostArr[ch].curFrameIntv && mbHostArr[ch].curFrameIntv++ > mbHostArr[ch].targetFrameIntv) + { + mbHostArr[ch].curFrameIntv = 0; + mbHostArr[ch].state = MBH_RX_BUSY; /* 切换状态 */ +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] recv: ", ch); + for(uint16_t i = 0; i < mbHostArr[ch].dataLen; i++) + { + PRINT_LOG("%02X ", mbHostArr[ch].dataBuf[i]); + } + PRINT_LOG("\n"); #endif + } + } + + if(MBH_RX_BUSY == mbHostArr[ch].state) + { + uint16_t checkVal; + + /* ASCII协议数据检查和转换 */ + if(MBH_ASCII == mbHostArr[ch].protocol) + { + uint16_t startIndex, stopIndex; + + /* 寻找起始符0x3A */ + for(startIndex = 0; startIndex < mbHostArr[ch].dataLen; startIndex++) + { + if(0x3A == mbHostArr[ch].dataBuf[startIndex]) { break; } + } + /* 起始符索引检查 */ + if((mbHostArr[ch].dataLen - startIndex - 1) < 10) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + /* 寻找结束符0x0D 0x0A */ + for(stopIndex = startIndex + 1; stopIndex < mbHostArr[ch].dataLen; stopIndex += 2) + { + if(0x0D == mbHostArr[ch].dataBuf[stopIndex] && 0x0A == mbHostArr[ch].dataBuf[stopIndex + 1]) { break; } + } + /* 结束符索引检查 */ + if(stopIndex >= mbHostArr[ch].dataLen) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + mbHostArr[ch].dataLen = stopIndex - startIndex - 1; + /* ASCII转HEX */ + for(uint16_t cnt = 0; cnt < mbHostArr[ch].dataLen; cnt += 2) + { + mbHostArr[ch].dataBuf[cnt >> 1] = (ASCII_TO_HEX[mbHostArr[ch].dataBuf[cnt + startIndex + 1]] << 4) + ASCII_TO_HEX[mbHostArr[ch].dataBuf[cnt + startIndex + 2]]; + } + mbHostArr[ch].dataLen >>= 1; + } + /* 应答数据长度判断 */ + if(MBH_PDU_SIZE_MIN > mbHostArr[ch].dataLen) + { + ret = RET_LEN_ERR; /* 应答数据长度错误 */ + goto rspErr; + } + /* ASCII协议 */ + if(MBH_ASCII == mbHostArr[ch].protocol) + { + /* LRC校验判断 */ + checkVal = check_lrc(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen - 1); + if(checkVal != mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1]) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } + } /* RTU协议 */ + else + { + /* CRC校验判断 */ + checkVal = check_crc16_modbus(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen - 2); + if(checkVal != ((mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 2] << 8) | mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1])) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } + } + /* 应答处理 */ + mb_host_rspProcess(ch); + ret = RET_OK; /* 应答处理完成 */ +rspErr: + mbHostArr[ch].state = MBH_TX_IDLE; /* 切换状态 */ + } + + return ret; } /** - * @brief 功能码应答处理 + * @brief 主机发送命令 * - * @param ch : modbus主机管理序号(即数组索引) + * @note 功能码 --- 扩展数据格式 + * 0x05 --- 一个线圈数据 1byte 0:OFF 1:ON + * 0x06 --- 一个寄存器数据 2byte + * 0x0F --- 多个线圈数据 1byte型指针 + * 0x10 --- 多个寄存器数据 2byte型指针 * - * @retval None + * @param ch : modbus主机管理序号(即数组索引) + * + * @param slaveAddr : 从机地址 + * + * @param funCode : 功能码 + * + * @param reg : 起始地址 + * + * @param num : 数量 + * + * @param extend : 扩展数据(不同功能码对应格式不同) + * + * @retval uint8_t + * @arg RET_OK : 成功 + * @arg RET_ERR : 失败 */ -static void mb_host_rspProcess(uint8_t ch) +uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend) { - mbHostArr[ch].rspState = RSP_SUCCESS; /* 应答完成 */ - mbHostArr[ch].rspTimeoutCnt = 0; + ASSERT_PARAM(IS_VALID_CH(ch)); - switch(mbHostArr[ch].recvBuf[1]) + if(MBH_TX_IDLE == mbHostArr[ch].state) { - case 0x01: mb_host_rsp_01h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读线圈应答处理 */ - case 0x02: mb_host_rsp_02h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读离散量输入应答处理 */ - case 0x03: mb_host_rsp_03h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读保持寄存器应答处理 */ - case 0x04: mb_host_rsp_04h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].recvBuf[3]); break; /* 读输入寄存器应答处理 */ - case 0x05: - case 0x06: - case 0x0F: - case 0x10: mb_host_rsp_05_10h(ch); break; - /* - 用户在这里写其他功能码的应答处理 - */ - default: if(mbHostArr[ch].recvBuf[1] & 0x80) { mb_host_rsp_err(ch, &mbHostArr[ch].recvBuf[1]); } break; /* 不支持的功能码或错误返回 */ + mbHostArr[ch].slaveTmp = slaveAddr; + mbHostArr[ch].numTmp = num; + mbHostArr[ch].regTmp = reg; + if(slaveAddr) { mbHostArr[ch].broadcast = 0; } + else { mbHostArr[ch].broadcast = 1; } + + switch(funCode) + { + case 0x01: /* 读线圈命令 */ + case 0x02: /* 读离散量输入命令 */ + if(2000 >= num && num) + { + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); + } + break; + case 0x03: /* 读保持寄存器命令 */ + case 0x04: /* 读输入寄存器命令 */ + if(125 >= num && num) + { + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); + } + break; + case 0x05: /* 写单个线圈命令 */ + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); + break; + case 0x06: /* 写单个保持寄存器命令 */ + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); + break; + case 0x0F: /* 写多个线圈命令 */ + if(2000 >= num && num) + { + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_0fh(ch, slaveAddr, reg, num, (uint8_t *)extend); + } + break; + case 0x10: /* 写多个寄存器命令 */ + if(125 >= num && num) + { + mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ + mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); + } + break; + /* + 用户在这里写其他功能码的发送处理 + */ + default: /* 不支持的命令 */ + break; + } } + + return (mbHostArr[ch].state == MBH_TX_BUSY) ? RET_OK : RET_ERR; } /** - * @brief 从机应答轮询处理(1ms) + * @brief 写入数据到接收缓冲区 * - * @param ch : modbus主机管理序号(即数组索引) + * @note 一般加入到(串口)接收中断 + * + * @param ch : modbus主机管理序号(即数组索引) * - * @retval rsp_state_t - * @arg RSP_NONE : 没有应答状态 - * @arg RSP_SUCCESS : 应答完成 - * @arg RSP_TIMEOUT : 应答超时 - * @arg RSP_LEN_ERR : 应答数据长度错误 - * @arg RSP_CRC_ERR : 应答数据CRC错误 + * @param pBuf : 数据缓存区 + * + * @param len : 写入长度byte + * + * @retval uint8_t + * @arg RET_OK : 成功 + * @arg RET_ERR : 失败(状态不对或写入已满) */ -rsp_state_t mb_host_poll(uint8_t ch) +uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) { - uint16_t crcValue; + uint16_t unusedLen; ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); - /* 应答超时判断 */ - if(mbHostArr[ch].rspTimeoutCnt && mbHostArr[ch].rspTimeout < mbHostArr[ch].rspTimeoutCnt++) - { - mbHostArr[ch].rspState = RSP_TIMEOUT; /* 应答超时 */ - mbHostArr[ch].rspTimeoutCnt = 0; - goto rspErr; - } - /* 接收完成判断 */ - if(!mbHostArr[ch].rspRecvOver) - { - mbHostArr[ch].rspState = RSP_NONE; - goto rspErr; - } - mbHostArr[ch].rspRecvOver = 0; -#ifdef _MODBUS_HOST_DEBUG - PRINT_LOG("modbus host[%d] recv: ", ch); - for(uint16_t i = 0; i < mbHostArr[ch].recvLen; i++) - { - PRINT_LOG("%02X ", mbHostArr[ch].recvBuf[i]); - } - PRINT_LOG("\n"); -#endif - /* 应答数据长度判断 */ - if(4 > mbHostArr[ch].recvLen) - { - mbHostArr[ch].rspState = RSP_LEN_ERR; /* 应答数据长度错误 */ - goto rspErr; - } - /* CRC校验判断 */ - crcValue = check_crc16_modbus(mbHostArr[ch].recvBuf, mbHostArr[ch].recvLen); - if(0 != crcValue) + if(MBH_RX_IDLE == mbHostArr[ch].state) { - mbHostArr[ch].rspState = RSP_CRC_ERR; /* 应答数据CRC错误 */ - goto rspErr; + unusedLen = mbHostArr[ch].dataBufLen - mbHostArr[ch].dataLen; + len = (len > unusedLen) ? unusedLen : len; + + if(0 < len) + { + memcpy((void *)&mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen], pBuf, len); + mbHostArr[ch].dataLen += len; + mbHostArr[ch].curFrameIntv = 1; /* 开启帧间隔超时计数 */ + mbHostArr[ch].rspTimeoutCnt = 0; /* 关闭应答超时计数 */ + + return RET_OK; + } } - /* 应答处理 */ - mb_host_rspProcess(ch); -rspErr: - - return mbHostArr[ch].rspState; + return RET_ERR; } /** - * @brief 追加CRC校验后发送 + * @brief 读出数据从发送缓冲区 * - * @param ch : modbus主机管理序号(即数组索引) + * @note 一般加入到(串口)发送中断 * - * @retval None + * @param ch : modbus主机管理序号(即数组索引) + * + * @param pBuf : 数据存储区 + * + * @param len : 读出长度byte + * + * @retval uint8_t + * @arg RET_OK : 成功 + * @arg RET_ERR : 失败(状态不对或读出完毕) */ -static void mb_host_send_crc16(uint8_t ch) +uint8_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) { - uint16_t crcValue; + uint16_t unusedLen; - crcValue = check_crc16_modbus(mbHostArr[ch].sendBuf, mbHostArr[ch].sendLen); - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = crcValue >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = crcValue; + ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); - mbHostArr[ch].writeDataFn((void *)mbHostArr[ch].sendBuf, mbHostArr[ch].sendLen); -#ifdef _MODBUS_HOST_DEBUG - PRINT_LOG("modbus host[%d] send: ", ch); - for(uint16_t i = 0; i < mbHostArr[ch].sendLen; i++) + if(MBH_TX_BUSY == mbHostArr[ch].state) { - PRINT_LOG("%02X ", mbHostArr[ch].sendBuf[i]); + unusedLen = mbHostArr[ch].dataLen - mbHostArr[ch].readLen; + len = (len > unusedLen) ? unusedLen : len; + + if(0 < len) + { + memcpy(pBuf, (void *)&mbHostArr[ch].dataBuf[mbHostArr[ch].readLen], len); + mbHostArr[ch].readLen += len; + + return RET_OK; + } + else + { + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].readLen = 0; + if(mbHostArr[ch].broadcast) + { + mbHostArr[ch].state = MBH_TX_IDLE; /* 切换状态 */ + } + else + { + mbHostArr[ch].rspTimeoutCnt = 1; /* 开启应答超时计数 */ + mbHostArr[ch].state = MBH_RX_IDLE; /* 切换状态 */ + } + } } - PRINT_LOG("\n"); -#endif + mbHostArr[ch].txEnFn(0); /* 关闭发送 */ + + return RET_ERR; } /** - * @brief 功能码0x01 0x02 0x03 0x04命令 + * @brief 设置协议类型 * - * @note 从机地址 | 功能码 | 起始地址 | 数量 | CRC16 - * 1 | 1 | 2 | 2 | 2 (占用字节) + * @note 初始化后仍可修改,需保持通信协议与设定协议一致,不然无法解析成功 * * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : 从机地址 - * - * @param funCode : 功能码 - * - * @param reg : 起始地址 - * - * @param num : 数量 + * @param protocol : 协议类型 @ref modbus_host_protocol + * @arg MBH_RTU : RTU协议 + * @arg MBH_ASCII : ASCII协议 * * @retval None */ -static void mb_host_cmd_01_04h(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num) +void mb_host_set_protocol(uint8_t ch, uint8_t protocol) { - mbHostArr[ch].sendLen = 0; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = slaveAddr; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = funCode; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num; + ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_PROTOCOL(protocol)); - mb_host_send_crc16(ch); + mbHostArr[ch].protocol = protocol; } /** - * @brief 写单个线圈命令(0x05) - * - * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 - * 1 | 1 | 2 | 2 | 2 (占用字节) + * @brief 获取协议类型 * * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : 从机地址 + * @retval uint8_t : 协议类型 @ref modbus_host_protocol + * @arg MBH_RTU : RTU协议 + * @arg MBH_ASCII : ASCII协议 + */ +uint8_t mb_host_get_protocol(uint8_t ch) +{ + ASSERT_PARAM(IS_VALID_CH(ch)); + + return mbHostArr[ch].protocol; +} + +/** + * @brief 设置帧间隔超时时间 * - * @param reg : 起始地址 + * @param ch : modbus主机管理序号(即数组索引) * - * @param extend : 扩展数据(一个线圈数据 0:ON !0:OFF) + * @param baud : 波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0) * * @retval None */ -static void mb_host_cmd_05h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint8_t extend) +void mb_host_set_frame_intv(uint8_t ch, uint32_t baud) { - mbHostArr[ch].sendLen = 0; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = slaveAddr; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x05; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend ? 0xFF : 0x00; /* 写入值:0xFF00=ON 0x0000=OFF */ - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x00; - - mb_host_send_crc16(ch); + if(9600 < baud) + { + mbHostArr[ch].targetFrameIntv = 3; + } + else if(0 == baud) + { + mbHostArr[ch].targetFrameIntv = 0; + } + else + { + mbHostArr[ch].targetFrameIntv = 10000 / baud * 3.5; + } } /** - * @brief 写单个保持寄存器命令(0x06) - * - * @note 从机地址 | 功能码 | 起始地址 | 写入值 | CRC16 - * 1 | 1 | 2 | 2 | 2 (占用字节) + * @brief 获取帧间隔超时时间 * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : 从机地址 + * @retval 帧间隔超时时间ms + */ +uint16_t mb_host_get_frame_intv(uint8_t ch) +{ + return mbHostArr[ch].targetFrameIntv; +} + +/** + * @brief 设置应答超时时间 * - * @param reg : 起始地址 + * @param ch : modbus主机管理序号(即数组索引) * - * @param extend : 扩展数据(一个寄存器数据 16bit) + * @param timeout : 应答超时时间ms * * @retval None */ -static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t extend) +void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout) { - mbHostArr[ch].sendLen = 0; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = slaveAddr; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x06; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend; + ASSERT_PARAM(IS_VALID_CH(ch)); - mb_host_send_crc16(ch); + mbHostArr[ch].rspTimeout = (timeout < 10) ? 10 : timeout; } /** - * @brief 写多个线圈命令(0x0F) + * @brief 获取应答超时时间 * - * @note 从机地址 | 功能码 | 起始地址 | 数量 | 字节数n | 写入值 | CRC16 - * 1 | 1 | 2 | 2 | 1 | n | 2 (占用字节) + * @param ch : modbus主机管理序号(即数组索引) * - * @param ch : modbus主机管理序号(即数组索引) + * @retval 应答超时时间ms + */ +uint16_t mb_host_get_rsp_timeout(uint8_t ch) +{ + ASSERT_PARAM(IS_VALID_CH(ch)); + + return mbHostArr[ch].rspTimeout; +} + +/** + * @brief 读线圈应答处理(0x01) * - * @param slaveAddr : 从机地址 + * @note 从机地址 | 功能码 | 字节数n | 线圈状态 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param reg : 起始地址 + * @param ch : modbus主机管理序号(即数组索引) * - * @param num : 数量 + * @param reg : 起始地址 * - * @param extend : 扩展数据(多个线圈数据 1字节型指针) + * @param num : 线圈数量 1线圈=1bit + * + * @param pData : 线圈数据 * * @retval None */ -static void mb_host_cmd_0Fh(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint8_t *extend) +__WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - uint16_t bytes; - - bytes = (num + 7) >> 3; +#if _MBH_DEBUG + uint8_t bytes = (num + 7) >> 3; - mbHostArr[ch].sendLen = 0; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = slaveAddr; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x0F; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = bytes; - memcpy(&mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen], extend, bytes); - mbHostArr[ch].sendLen += bytes; - - mb_host_send_crc16(ch); + PRINT_LOG("modbus host[%d] rsp01H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < bytes; i++) + { + PRINT_LOG("%02X ", pData[i]); + } + PRINT_LOG("\n"); +#endif } /** - * @brief 写多个寄存器命令(0x10) - * - * @note 从机地址 | 功能码 | 起始地址 | 数量n | 字节数2n | 写入值 | CRC16 - * 1 | 1 | 2 | 2 | 1 | 2n | 2 (占用字节) + * @brief 读离散量输入应答处理(0x02) * - * @param ch : modbus主机管理序号(即数组索引) + * @note 从机地址 | 功能码 | 字节数n | 离散量状态 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param slaveAddr : 从机地址 + * @param ch : modbus主机管理序号(即数组索引) * - * @param reg : 起始地址 + * @param reg : 起始地址 * - * @param num : 数量 + * @param num : 离散量输入数量 1离散量输入=1bit * - * @param extend : 扩展数据(多个寄存器数据 2字节型指针) + * @param pData : 离散量输入数据 * * @retval None */ -static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint16_t *extend) +__WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - uint16_t bytes; - - bytes = num << 1; +#if _MBH_DEBUG + uint8_t bytes = (num + 7) >> 3; - mbHostArr[ch].sendLen = 0; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = slaveAddr; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = 0x10; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = reg; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = num; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = bytes; - for(uint16_t cnt = 0; cnt < num; cnt++) + PRINT_LOG("modbus host[%d] rsp02H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < bytes; i++) { - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend[cnt] >> 8; - mbHostArr[ch].sendBuf[mbHostArr[ch].sendLen++] = extend[cnt]; + PRINT_LOG("%02X ", pData[i]); } - - mb_host_send_crc16(ch); + PRINT_LOG("\n"); +#endif } /** - * @brief 主机发送命令 + * @brief 读保持寄存器应答处理(0x03) * - * @note 功能码 --- 扩展数据格式 - * 0x05 --- 一个线圈数据 0:ON !0:OFF - * 0x06 --- 一个寄存器数据 16bit - * 0x0F --- 多个线圈数据 1字节型指针 - * 0x10 --- 多个寄存器数据 2字节型指针 + * @note 从机地址 | 功能码 | 字节数n | 保持寄存器值 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param slaveAddr : 从机地址 + * @param reg : 起始地址 * - * @param funCode : 功能码 + * @param num : 保持寄存器数量 1保持寄存器=16bit * - * @param reg : 起始地址 + * @param pData : 保持寄存器数据 * - * @param num : 数量 + * @retval None + */ +__WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ +#if _MBH_DEBUG + uint8_t bytes = num << 1; + + PRINT_LOG("modbus host[%d] rsp03H> regAddr:%04X, regNum:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < bytes; i++) + { + PRINT_LOG("%02X ", pData[i]); + } + PRINT_LOG("\n"); +#endif +} + +/** + * @brief 读输入寄存器应答处理(0x04) * - * @param extend : 扩展数据(不同功能码对应格式不同) + * @note 从机地址 | 功能码 | 字节数n | 输入寄存器值 | CRC16 + * 1 | 1 | 1 | n | 2 (占用字节) + * + * @param ch : modbus主机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 输入寄存器数量 1输入寄存器=16bit + * + * @param pData : 输入寄存器数据 * * @retval None */ -void mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend) +__WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - ASSERT_PARAM(IS_VALID_CH(ch)); - - mbHostArr[ch].numTmp = num; - mbHostArr[ch].regTmp = reg; +#if _MBH_DEBUG + uint8_t bytes = num << 1; - switch(funCode) + PRINT_LOG("modbus host[%d] rsp04H> regAddr:%04X, regNum:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < bytes; i++) { - case 0x01: /* 读线圈命令 */ - if(2000 >= num && num) - { - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x02: /* 读离散量输入命令 */ - if(2000 >= num && num) - { - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x03: /* 读保持寄存器命令 */ - if(125 >= num && num) - { - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x04: /* 读输入寄存器命令 */ - if(125 >= num && num) - { - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x05: /* 写单个线圈命令 */ - mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); - break; - case 0x06: /* 写单个保持寄存器命令 */ - mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); - break; - case 0x0F: /* 写多个线圈命令 */ - if(2000 >= num && num) - { - mb_host_cmd_0Fh(ch, slaveAddr, reg, num, (uint8_t *)extend); - } - break; - case 0x10: /* 写多个寄存器命令 */ - if(125 >= num && num) - { - mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); - } - break; - /* - 用户在这里写其他功能码的发送处理 - */ - default: /* 不支持的命令 */ - break; + PRINT_LOG("%02X ", pData[i]); } - - mbHostArr[ch].rspState = RSP_NONE; - mbHostArr[ch].rspTimeoutCnt = 1; + PRINT_LOG("\n"); +#endif } +/** + * @brief 功能码0x05 0x06 0x0F 0x10应答处理 + * + * @note 从机地址 | 功能码 | 起始地址 | 写入值/数量 | CRC16 + * 1 | 1 | 2 | 2 | 2 (占用字节) + * + * @param None + * + * @retval None + */ +__WEAK void mb_host_rsp_05_10h(uint8_t ch) +{ +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] rsp05H_06H_0FH_10H> success\n", ch); +#endif +} +/** + * @brief 错误码应答处理(功能码+0x80) + * + * @note 从机地址 | 错误功能码 | 错误代码 | CRC16 + * 1 | 1 | 1 | 2 (占用字节) + * + * @param ch : modbus主机管理序号(即数组索引) + * + * @param pData : 错误数据(错误功能码和错误代码) + * + * @retval None + */ +__WEAK void mb_host_rsp_err(uint8_t ch, uint8_t *pData) +{ +/* + 错误代码释义: + 01 - 功能码不能被从机识别 + 02 - 从机的单元标识符不正确 + 03 - 值不被从机接受 + 04 - 当从机试图执行请求的操作时,发生了不可恢复的错误 + 05 - 从机已接受请求并正在处理,但需要很长时间.返回此响应是为了防止在主机中发生超时错误, + 主机可以在下一个轮询程序中发出一个完整的消息,以确定处理是否完成 + 06 - 从机正在处理长时间命令,主机应该稍后重试 + 07 - 从机不能执行程序功能,主机应该向从机请求诊断或错误信息 + 08 - 从机在内存中检测到奇偶校验错误,主机可以重试请求,但从设备上可能需要服务 + 10 - 专门用于modbus网关,表示配置错误的网关 + 11 - 专门用于modbus网关的响应,当从机无法响应时发送 +*/ +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X\n", ch, pData[0], pData[1]); +#endif +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modbus/modbus_host.h b/drivers/modbus/modbus_host.h index 0a1e01a..4eb4b06 100644 --- a/drivers/modbus/modbus_host.h +++ b/drivers/modbus/modbus_host.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file modbus_host.h * @author woshiashuai - * @version V1.0 - * @date 2023-09-01 + * @version V2.1 + * @date 2023-10-17 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** @@ -25,75 +25,141 @@ extern "C" { /* 包含头文件-----------------------------------------------------------------*/ #include "common_include.h" +/** + * @addtogroup modbus + * @{ + */ + +/** + * @addtogroup modbus_host + * @{ + */ + /* 宏定义---------------------------------------------------------------------*/ -#define MODBUS_HOST_NUM (3u) /* modbus主机管理数量 */ -#define MODBUS_HOST_BUF_SIZE (300u) /* modbus主机收发缓冲区大小 RTU建议值300 ASCII建议值600 */ +/** + * @defgroup modbus_host_global_macros modbus host global macros + * @{ + */ + +#define _MBH_DEBUG (0u) /*!< modbus主机调试信息打印开关 0:关闭 1:开启 */ + +#define MBH_NUM (3u) /*!< modbus主机管理数量 用户根据需求自行修改 */ +#define MBH_BUF_SIZE_MAX (256u) /*!< modbus主机缓存区最大256byte 不可修改 */ + +/** + * @defgroup modbus_host_protocol modbus host protocol + * @{ + */ +#define MBH_RTU (0u) /*!< RTU协议 */ +#define MBH_ASCII (1u) /*!< ASCII协议 */ +/** + * @} + */ + +/** + * @defgroup modbus_host_state modbus host state + * @{ + */ +#define MBH_TX_IDLE (0u) /*!< 发送空闲状态-仅允许发送 */ +#define MBH_TX_BUSY (1u) /*!< 发送忙碌状态-禁止操作 */ +#define MBH_RX_IDLE (2u) /*!< 接收空闲状态-仅允许接收 */ +#define MBH_RX_BUSY (3u) /*!< 接收忙碌状态-禁止操作 */ +/** + * @} + */ -#define _MODBUS_HOST_DEBUG /* 输出调试信息 */ +/** + * @} + */ /* 类型定义-------------------------------------------------------------------*/ /** - * @brief 写入数据 / 读取数据 + * @defgroup modbus_host_global_types modbus host global types + * @{ + */ + +/** + * @brief 主机发送前(串口)准备函数 * - * @param pBuf : 写入数据的存储区 / 读取数据的存储区 + * @note 如:使用串口中断发送时需使能发送相关中断/使用串口DMA发送时需配置使能DMA * - * @param size : 写入的数据大小 / 读取的数据大小 byte + * @param enState : 0-关闭(失能) 1-开启(使能) * - * @retval 实际写入的数据大小 / 实际读取的数据大小 byte + * @retval None */ -typedef uint32_t (* mb_host_rw_fn_t)(void *pBuf, uint32_t size); +typedef void (* mb_host_tx_en_t)(uint8_t enState); -/** - * @brief 从机应答状态 enumeration - */ -typedef enum rsp_state { - RSP_NONE = 0x00, /* 没有应答状态 */ - RSP_SUCCESS = 0x01, /* 应答完成 */ - RSP_TIMEOUT = 0x02, /* 应答超时 */ - RSP_LEN_ERR = 0x04, /* 应答数据长度错误 */ - RSP_CRC_ERR = 0x08, /* 应答数据CRC错误 */ -} rsp_state_t; - -/** +/** * @brief modbus主机 structure definition */ typedef struct mb_host { - uint8_t recvBuf[MODBUS_HOST_BUF_SIZE]; - uint16_t recvLen; + uint8_t *dataBuf; /*!< 数据缓存区 */ + uint16_t dataBufLen; /*!< 数据缓存区长度 */ + uint16_t dataLen; /*!< 数据长度 */ + uint16_t readLen; /*!< 读出数据长度 */ - uint8_t sendBuf[MODBUS_HOST_BUF_SIZE]; - uint16_t sendLen; + uint8_t protocol : 2; /*!< 协议类型 @ref modbus_host_protocol */ + uint8_t state : 2; /*!< 应答状态 @ref modbus_host_state */ + uint8_t broadcast : 1; /*!< 广播标志 0:非广播 1:广播 */ - uint8_t rspRecvOver : 4; /* 数据接收完成 0:未完成 !0:完成 */ - /* - 应答状态 - bit0: 0=应答失败 1=应答完成 - bit1: 0=正常 1=应答超时 - bit2: 0=正常 1=应答数据长度错误 - bit3: 0=正常 1=应答数据CRC错误 - */ - uint8_t rspState : 4; - uint16_t rspTimeoutCnt; /* 应答超时计数ms */ - uint16_t rspTimeout; /* 应答超时时间ms */ - uint16_t regTmp; /* 主机命令中的起始地址暂存 */ - uint16_t numTmp; /* 主机命令中的数量暂存 */ - - mb_host_rw_fn_t readDataFn; /* 读取数据函数 */ - mb_host_rw_fn_t writeDataFn; /* 写入数据函数 */ + uint16_t targetFrameIntv; /*!< 目标帧间隔ms */ + uint16_t curFrameIntv; /*!< 当前帧间隔ms */ + uint16_t rspTimeoutCnt; /*!< 应答超时计数ms */ + uint16_t rspTimeout; /*!< 应答超时时间ms */ + uint8_t slaveTmp; /*!< 主机命令中的从机地址暂存 */ + uint16_t regTmp; /*!< 主机命令中的起始地址暂存 */ + uint16_t numTmp; /*!< 主机命令中的数量暂存 */ + + mb_host_tx_en_t txEnFn; /*!< 主机发送前(串口)准备函数 */ } mb_host_t; +/** + * @} + */ + /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ -void mb_host_init(uint8_t ch, mb_host_rw_fn_t fRead, mb_host_rw_fn_t fWrite, uint16_t timeout); +/** + * @addtogroup modbus_host_global_functions + * @{ + */ + +void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, mb_host_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout); -rsp_state_t mb_host_poll(uint8_t ch); +uint8_t mb_host_poll(uint8_t ch); -void mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend); +uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend); -void mb_host_rsp_over(uint8_t ch); +uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len); +uint8_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len); +void mb_host_set_protocol(uint8_t ch, uint8_t protocol); +uint8_t mb_host_get_protocol(uint8_t ch); +void mb_host_set_frame_intv(uint8_t ch, uint32_t baud); +uint16_t mb_host_get_frame_intv(uint8_t ch); void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout); +uint16_t mb_host_get_rsp_timeout(uint8_t ch); + +/* 弱定义函数 */ +void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_host_rsp_05_10h(uint8_t ch); +void mb_host_rsp_err(uint8_t ch, uint8_t *pData); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } diff --git a/drivers/modules/data_check.c b/drivers/modules/data_check.c index 467d23c..895f213 100644 --- a/drivers/modules/data_check.c +++ b/drivers/modules/data_check.c @@ -2,8 +2,8 @@ ****************************************************************************** * @file data_check.c * @author ashuai0110 - * @version V1.0 - * @date 2023-09-18 + * @version V2.1 + * @date 2023-10-17 * @brief 数据校验 * ****************************************************************************** @@ -18,11 +18,26 @@ /* 包含头文件-----------------------------------------------------------------*/ #include "data_check.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @defgroup data_check 数据校验 + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ +/** + * @defgroup data_check_local_variables data check local variables + * @{ + */ + // CRC 高位字节值表 static const uint8_t crcHiArr[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, @@ -82,27 +97,74 @@ const uint8_t crcLoArr[] = { 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 }; +/** + * @} + */ + /* 全局变量-------------------------------------------------------------------*/ /* 私有函数原型---------------------------------------------------------------*/ +/** + * @defgroup data_check_global_functions data check global functions + * @{ + */ /** - * @brief CRC16(MODBUS) - * @param None - * @retval None + * @brief CRC16校验(MODBUS) + * + * @param pBuf : 校验数据 + * + * @param len : 校验数据长度 + * + * @retval 校验结果 */ uint16_t check_crc16_modbus(uint8_t *pBuf, uint16_t len) { - uint8_t CRCHi = 0xFF; /* 高CRC字节初始化 */ - uint8_t CRCLo = 0xFF; /* 低CRC 字节初始化 */ + uint8_t crcHi = 0xFF; /* 高CRC字节初始化 */ + uint8_t crcLo = 0xFF; /* 低CRC 字节初始化 */ uint16_t index; /* CRC循环中的索引 */ while(len--) { - index = CRCHi ^ *pBuf++; /* 计算CRC */ - CRCHi = CRCLo ^ crcHiArr[index]; - CRCLo = crcLoArr[index]; + index = crcHi ^ *pBuf++; /* 计算CRC */ + crcHi = crcLo ^ crcHiArr[index]; + crcLo = crcLoArr[index]; } - return ((uint16_t)CRCHi << 8 | CRCLo); + return ((uint16_t)crcHi << 8 | crcLo); } + +/** + * @brief LRC校验 + * + * @param pBuf : 校验数据 + * + * @param len : 校验数据长度 + * + * @retval 校验结果 + */ +uint8_t check_lrc(uint8_t *pBuf, uint16_t len) +{ + uint8_t lrc = 0; + + for(uint16_t index = 0; index < len; index++) + { + lrc += pBuf[index]; + } + + lrc = (~lrc) + 1; + + return lrc; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modules/data_check.h b/drivers/modules/data_check.h index 19a3424..e73264f 100644 --- a/drivers/modules/data_check.h +++ b/drivers/modules/data_check.h @@ -2,8 +2,8 @@ ****************************************************************************** * @file data_check.h * @author ashuai0110 - * @version V1.0 - * @date 2023-09-18 + * @version V2.1 + * @date 2023-10-17 * @brief 数据校验 * ****************************************************************************** @@ -25,6 +25,16 @@ extern "C" { /* 包含头文件-----------------------------------------------------------------*/ #include "common_include.h" +/** + * @addtogroup modules + * @{ + */ + +/** + * @addtogroup data_check + * @{ + */ + /* 宏定义---------------------------------------------------------------------*/ /* 类型定义-------------------------------------------------------------------*/ @@ -32,7 +42,25 @@ extern "C" { /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ +/** + * @addtogroup data_check_global_functions + * @{ + */ + uint16_t check_crc16_modbus(uint8_t *pBuf, uint16_t len); +uint8_t check_lrc(uint8_t *pBuf, uint16_t len); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } diff --git a/drivers/modules/delay_no_block.c b/drivers/modules/delay_no_block.c index ce220e2..4154caf 100644 --- a/drivers/modules/delay_no_block.c +++ b/drivers/modules/delay_no_block.c @@ -66,7 +66,7 @@ * @{ */ -static delay_item_t delayTaskArray[DELAY_TASK_SIZE]; /* 延时任务工作数组 */ +static delay_item_t delayTaskArr[DELAY_TASK_SIZE]; /* 延时任务工作数组 */ volatile static uint32_t delayBaseTicks; /* 基本计数值 */ /** @@ -91,7 +91,7 @@ volatile static uint32_t delayBaseTicks; /* 基本计数值 */ * * @retval uint8_t * @arg RET_OK : 创建成功 - * @arg RET_ERR : 任务已满 + * @arg RET_ERR : 任务已满(创建失败) */ uint8_t delay_init(delay_id_t *_id, uint32_t delayTicks) { @@ -105,10 +105,10 @@ uint8_t delay_init(delay_id_t *_id, uint32_t delayTicks) { for(idCnt = 0; idCnt < DELAY_TASK_SIZE; idCnt++) { - if(0 == delayTaskArray[idCnt].ticks && 0 == delayTaskArray[idCnt].run) + if(0 == delayTaskArr[idCnt].ticks && 0 == delayTaskArr[idCnt].run) { - delayTaskArray[idCnt].ticks = delayBaseTicks + delayTicks; - delayTaskArray[idCnt].run = 1; + delayTaskArr[idCnt].ticks = delayBaseTicks + delayTicks; + delayTaskArr[idCnt].run = 1; *_id = idCnt + 1; break; @@ -117,8 +117,8 @@ uint8_t delay_init(delay_id_t *_id, uint32_t delayTicks) } else { - delayTaskArray[*_id - 1].ticks = delayBaseTicks + delayTicks; - delayTaskArray[*_id - 1].run = 1; + delayTaskArr[*_id - 1].ticks = delayBaseTicks + delayTicks; + delayTaskArr[*_id - 1].run = 1; } return *_id ? RET_OK : RET_ERR; @@ -136,14 +136,12 @@ void delay_de_init(delay_id_t *_id) ASSERT_PARAM(IS_VALID_POINT(_id)); ASSERT_PARAM(IS_VALID_DELAY_ID(*_id)); - memset(&delayTaskArray[*_id - 1], 0, sizeof(delay_item_t)); + memset(&delayTaskArr[*_id - 1], 0, sizeof(delay_item_t)); *_id = 0; } /** - * @brief 等待延时任务 - * - * @note None + * @brief 等待延时任务返回完成 * * @param _id : 延时任务ID * @@ -157,14 +155,14 @@ uint8_t delay_wait(delay_id_t *_id) ASSERT_PARAM(IS_VALID_POINT(_id)); ASSERT_PARAM(IS_VALID_DELAY_ID(*_id)); - if(0 == delayTaskArray[*_id - 1].ticks || 0 == delayTaskArray[*_id - 1].run) + if(0 == delayTaskArr[*_id - 1].ticks || 0 == delayTaskArr[*_id - 1].run) { return RET_ERR; } - if(delayBaseTicks > delayTaskArray[*_id - 1].ticks) + if(delayBaseTicks > delayTaskArr[*_id - 1].ticks) { - delayTaskArray[*_id - 1].ticks = 0; + delayTaskArr[*_id - 1].ticks = 0; return RET_OK; } @@ -193,9 +191,9 @@ void delay_poll(void) for(idCnt = 0; idCnt < DELAY_TASK_SIZE; idCnt++) { - if(DELAY_TICKS_MAX < delayTaskArray[idCnt].ticks) + if(DELAY_TICKS_MAX < delayTaskArr[idCnt].ticks) { - delayTaskArray[idCnt].ticks = delayTaskArray[idCnt].ticks - DELAY_TICKS_MAX; + delayTaskArr[idCnt].ticks = delayTaskArr[idCnt].ticks - DELAY_TICKS_MAX; } } } diff --git a/drivers/modules/delay_no_block.h b/drivers/modules/delay_no_block.h index 3c66d73..b97b5a0 100644 --- a/drivers/modules/delay_no_block.h +++ b/drivers/modules/delay_no_block.h @@ -63,7 +63,7 @@ extern "C" { /** * @brief 延时任务ID type define */ -typedef uint16_t delay_id_t; +typedef unsigned short delay_id_t; /** * @brief 延时任务 structure definition diff --git a/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf b/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf new file mode 100644 index 0000000..66e10b6 --- /dev/null +++ b/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf @@ -0,0 +1,36 @@ +// File: STM32F101_102_103_105_107.dbgconf +// Version: 1.0.0 +// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008) +// STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets + +// <<< Use Configuration Wizard in Context Menu >>> + +// Debug MCU configuration register (DBGMCU_CR) +// Reserved bits must be kept at reset value +// DBG_TIM11_STOP TIM11 counter stopped when core is halted +// DBG_TIM10_STOP TIM10 counter stopped when core is halted +// DBG_TIM9_STOP TIM9 counter stopped when core is halted +// DBG_TIM14_STOP TIM14 counter stopped when core is halted +// DBG_TIM13_STOP TIM13 counter stopped when core is halted +// DBG_TIM12_STOP TIM12 counter stopped when core is halted +// DBG_CAN2_STOP Debug CAN2 stopped when core is halted +// DBG_TIM7_STOP TIM7 counter stopped when core is halted +// DBG_TIM6_STOP TIM6 counter stopped when core is halted +// DBG_TIM5_STOP TIM5 counter stopped when core is halted +// DBG_TIM8_STOP TIM8 counter stopped when core is halted +// DBG_I2C2_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted +// DBG_I2C1_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted +// DBG_CAN1_STOP Debug CAN1 stopped when Core is halted +// DBG_TIM4_STOP TIM4 counter stopped when core is halted +// DBG_TIM3_STOP TIM3 counter stopped when core is halted +// DBG_TIM2_STOP TIM2 counter stopped when core is halted +// DBG_TIM1_STOP TIM1 counter stopped when core is halted +// DBG_WWDG_STOP Debug window watchdog stopped when core is halted +// DBG_IWDG_STOP Debug independent watchdog stopped when core is halted +// DBG_STANDBY Debug standby mode +// DBG_STOP Debug stop mode +// DBG_SLEEP Debug sleep mode +// +DbgMCU_CR = 0x00000007; + +// <<< end of configuration section >>> diff --git a/examples/command_line/MDK/use_example.uvguix.yansj b/examples/command_line/MDK/use_example.uvguix.yansj new file mode 100644 index 0000000..2aea7a8 --- /dev/null +++ b/examples/command_line/MDK/use_example.uvguix.yansj @@ -0,0 +1,1878 @@ + + + + -6.1 + +
### uVision Project, (C) Keil Software
+ + + + + + + + + + 38003 + Registers + 140 90 + + + 346 + Code Coverage + 1010 160 + + + 204 + Performance Analyzer + 1170 + + + + + + 35141 + Event Statistics + + 200 50 700 + + + 1506 + Symbols + + 80 80 80 + + + 1936 + Watch 1 + + 200 133 133 + + + 1937 + Watch 2 + + 200 133 133 + + + 1935 + Call Stack + Locals + + 200 133 133 + + + 2506 + Trace Data + + 75 135 130 95 70 230 200 150 + + + 466 + Source Browser + 500 + 300 + + + + + + + + 1 + 1 + 0 + 0 + -1 + + + + + + + 44 + 2 + 3 + + -1 + -1 + + + -1 + -1 + + + -6 + 42 + 1139 + 610 + + + + 0 + + 312 + 0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000000100000000000000010000006C443A5C415350726F6A6563745C6D637550726F6A6563745C6D63755F646576656C6F706D656E745F74656D706C6174655C6D63755F72657573655F646576656C6F706D656E745F6D6F64756C655C647269766572735C6D6F64756C65735C636F6D6D616E645F6C696E652E63000000000E636F6D6D616E645F6C696E652E6300000000C5D4F200FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F4000000660000008007000063030000 + + + + 0 + Build + + -1 + -1 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F40000004F00000090050000DD000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1005 + 1005 + 1 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 0300000066000000ED00000033030000 + + + 16 + 22000000390000001201000002010000 + + + + 109 + 109 + 1 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 0300000066000000ED00000033030000 + + + 16 + 22000000390000003E01000075020000 + + + + 1465 + 1465 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 000000002902000090050000B7020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1466 + 1466 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1467 + 1467 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1468 + 1468 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1506 + 1506 + 0 + 0 + 0 + 0 + 32767 + 0 + 16384 + 0 + + 16 + A3040000660000008D050000FF000000 + + + 16 + 22000000390000001201000002010000 + + + + 1913 + 1913 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1935 + 1935 + 0 + 0 + 0 + 0 + 32767 + 0 + 32768 + 0 + + 16 + 030000002C0200008D0500009E020000 + + + 16 + 22000000390000001201000002010000 + + + + 1936 + 1936 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 22000000390000001201000002010000 + + + + 1937 + 1937 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 22000000390000001201000002010000 + + + + 1939 + 1939 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1940 + 1940 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1941 + 1941 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 1942 + 1942 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 195 + 195 + 1 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 0300000066000000ED00000033030000 + + + 16 + 22000000390000003E01000075020000 + + + + 196 + 196 + 1 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 0300000066000000ED00000033030000 + + + 16 + 22000000390000003E01000075020000 + + + + 197 + 197 + 1 + 0 + 0 + 0 + 32767 + 0 + 32768 + 0 + + 16 + 000000006403000080070000DE030000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 198 + 198 + 0 + 0 + 0 + 0 + 32767 + 0 + 32768 + 0 + + 16 + 000000001502000090050000B7020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 199 + 199 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 03000000670300008D050000C5030000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 203 + 203 + 0 + 0 + 0 + 0 + 32767 + 0 + 8192 + 0 + + 16 + F40000006300000090050000DD000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 204 + 204 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 221 + 221 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 00000000000000000000000000000000 + + + 16 + 0A0000000A0000006E0000006E000000 + + + + 2506 + 2506 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A0040000630000009005000025020000 + + + 16 + 22000000390000001201000002010000 + + + + 2507 + 2507 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 000000002902000090050000A3020000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 343 + 343 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 346 + 346 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 35141 + 35141 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F40000006300000090050000DD000000 + + + 16 + 22000000390000001201000002010000 + + + + 35824 + 35824 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 35885 + 35885 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35886 + 35886 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35887 + 35887 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35888 + 35888 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35889 + 35889 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35890 + 35890 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35891 + 35891 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35892 + 35892 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35893 + 35893 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35894 + 35894 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35895 + 35895 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35896 + 35896 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35897 + 35897 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35898 + 35898 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35899 + 35899 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35900 + 35900 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35901 + 35901 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35902 + 35902 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35903 + 35903 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35904 + 35904 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 35905 + 35905 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 38003 + 38003 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 0300000066000000ED0000009E020000 + + + 16 + 22000000390000003E01000075020000 + + + + 38007 + 38007 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 000000006403000090050000DE030000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 436 + 436 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 03000000670300008D050000C5030000 + + + 16 + 22000000390000003E01000075020000 + + + + 437 + 437 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 22000000390000001201000002010000 + + + + 440 + 440 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 22000000390000001201000002010000 + + + + 463 + 463 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 03000000670300008D050000C5030000 + + + 16 + 22000000390000003E01000075020000 + + + + 466 + 466 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 03000000670300008D050000C5030000 + + + 16 + 22000000390000003E01000075020000 + + + + 470 + 470 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + F7000000660000008D050000C4000000 + + + 16 + 2200000039000000EA020000C7000000 + + + + 50000 + 50000 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50001 + 50001 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50002 + 50002 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50003 + 50003 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50004 + 50004 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50005 + 50005 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50006 + 50006 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50007 + 50007 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50008 + 50008 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50009 + 50009 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50010 + 50010 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50011 + 50011 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50012 + 50012 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50013 + 50013 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50014 + 50014 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50015 + 50015 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50016 + 50016 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50017 + 50017 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50018 + 50018 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 50019 + 50019 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + A3040000660000008D0500007A010000 + + + 16 + 22000000390000001201000002010000 + + + + 59392 + 59392 + 1 + 0 + 0 + 0 + 32767 + 0 + 8192 + 0 + + 16 + 0000000000000000D10300001C000000 + + + 16 + 0A0000000A0000006E0000006E000000 + + + + 59393 + 0 + 1 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 00000000DE03000080070000F1030000 + + + 16 + 0A0000000A0000006E0000006E000000 + + + + 59399 + 59399 + 1 + 0 + 0 + 0 + 32767 + 0 + 8192 + 1 + + 16 + 000000001C000000E701000038000000 + + + 16 + 0A0000000A0000006E0000006E000000 + + + + 59400 + 59400 + 0 + 0 + 0 + 0 + 32767 + 0 + 8192 + 2 + + 16 + 00000000380000006F02000054000000 + + + 16 + 0A0000000A0000006E0000006E000000 + + + + 824 + 824 + 0 + 0 + 0 + 0 + 32767 + 0 + 4096 + 0 + + 16 + 030000002C0200008D0500008A020000 + + + 16 + 22000000390000001201000002010000 + + + + 3312 + 000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DD00000090050000E1000000000000000100001004000000010000000000000000000000FFFFFFFF08000000CB00000057010000CC000000F08B00005A01000079070000D601000045890000FFFF02000B004354616262656450616E6500200000000000002200000039000000EA020000C7000000F40000004F00000090050000DD0000000000000040280046080000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF0F53797374656D20416E616C797A657200000000D601000001000000FFFFFFFFFFFFFFFF104576656E742053746174697374696373000000004589000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000025020000000000000200001004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C300000180004000000000000022000000390000001201000002010000A00400004F000000900500002502000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFFF00000004F000000F40000004C030000010000000200001004000000010000000000000000000000FFFFFFFF05000000ED0300006D000000C3000000C4000000739400000180001000000100000022000000390000001201000002010000000000004F000000F00000004C0300000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000100400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0F0000008F070000930700009407000095070000960700009007000091070000B5010000B801000038030000B9050000BA050000BB050000BC050000CB0900000180008000000000000022000000390000001201000002010000000000001502000090050000B702000000000000404100460F0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF09554C494E4B706C7573000000003803000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF000000004C0300008007000050030000010000000100001004000000010000000000000000000000FFFFFFFF06000000C5000000C7000000B4010000D2010000CF01000077940000018000800000010000002200000039000000EA020000C7000000000000005003000080070000DE0300000000000040820056060000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0E536F757263652042726F7773657200000000D201000001000000FFFFFFFFFFFFFFFF0E416C6C205265666572656E63657300000000CF01000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000 + + + 59392 + File + + 2813 + 00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000004000700000000000000000000000000000000010000000100000001802CE10000000000000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE803000000000000000000000000000000000000000000000001000000010000009600000002002050000000000109960000000000000014000109125F5F7363686564756C655F626172726965720F5345474745525F5254545F4C4F434B067465737452421149535F56414C49445F44454C41595F6964035F696F06696F4C6173740B70494F5461736B4865616408696F546172676574044C454431074C45445F52756E0377686F0F54494D325F49525148616E646C6572047765616B065F5F5745414B0A53454E534F525F4E554D064341524E554D0B504F5356414C55454D41580C504F5356414C55454D494E4C0C504F5356414C55454D494E480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E2280000002000000150000002153746172742F53746F70202644656275672053657373696F6E094374726C2B46350000000000000000000000000100000001000000000000000000000001000000020021802280000000000000150000002153746172742F53746F70202644656275672053657373696F6E094374726C2B4635000000000000000000000000010000000100000000000000000000000100000000002180E0010000000000007500000021456E65726779204D6561737572656D656E742026776974686F75742044656275670000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000002180C8880000000000001700000027264B696C6C20416C6C20427265616B706F696E747320696E2043757272656E7420546172676574000000000000000000000000010000000100000000000000000000000100000003002180C8880000000000001700000027264B696C6C20416C6C20427265616B706F696E747320696E2043757272656E7420546172676574000000000000000000000000010000000100000000000000000000000100000000002180E50100000000000078000000264B696C6C20416C6C20427265616B706F696E747320696E204163746976652050726F6A656374000000000000000000000000010000000100000000000000000000000100000000002180E601000000000000790000002F4B696C6C20416C6C20427265616B706F696E747320696E204D756C74692D50726F6A65637420576F726B73706163650000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000021804C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002180DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002180DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002180E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002180E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000218018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000021800000000000000400FFFFFFFF00000000000000000000000000010000000100000000000000000000000100000000002180D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002180E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65FF7F0000 + + + 1423 + 2800FFFF01001100434D4643546F6F6C426172427574746F6E00E1000000000000FFFFFFFF000100000000000000010000000000000001000000018001E1000000000000FFFFFFFF000100000000000000010000000000000001000000018003E1000000000000FFFFFFFF0001000000000000000100000000000000010000000180CD7F000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF000000000000000000010000000000000001000000018023E1000000000000FFFFFFFF000100000000000000010000000000000001000000018022E1000000000000FFFFFFFF000100000000000000010000000000000001000000018025E1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001802BE1000000000000FFFFFFFF00010000000000000001000000000000000100000001802CE1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001807A8A000000000000FFFFFFFF00010000000000000001000000000000000100000001807B8A000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180D3B0000000000000FFFFFFFF000100000000000000010000000000000001000000018015B1000000000000FFFFFFFF0001000000000000000100000000000000010000000180F4B0000000000000FFFFFFFF000100000000000000010000000000000001000000018036B1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180FF88000000000000FFFFFFFF0001000000000000000100000000000000010000000180FE88000000000000FFFFFFFF00010000000000000001000000000000000100000001800B81000000000000FFFFFFFF00010000000000000001000000000000000100000001800C81000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180F088000000000000FFFFFFFF0001000000000000000100000000000000010000000180EE7F000000000000FFFFFFFF000100000000000000010000000000000001000000018024E1000000000000FFFFFFFF00010000000000000001000000000000000100000001800A81000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001802280000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180C488000000000000FFFFFFFF0001000000000000000100000000000000010000000180C988000000000000FFFFFFFF0001000000000000000100000000000000010000000180C788000000000000FFFFFFFF0001000000000000000100000000000000010000000180C888000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180DD88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180FB7F000000000000FFFFFFFF000100000000000000010000000000000001000000 + + + 1423 + 2800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000000004000000000000000000000000000000000100000001000000018022E100000000000005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000000000700000000000000000000000000000000010000000100000001802CE10000000000000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000000000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000000000C0000000000000000000000000000000001000000010000000180F4B00000000000000D000000000000000000000000000000000100000001000000018036B10000000000000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF880000000000000F0000000000000000000000000000000001000000010000000180FE880000000000001000000000000000000000000000000000010000000100000001800B810000000000001100000000000000000000000000000000010000000100000001800C810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F088000000000000130000000000000000000000000000000001000000010000000180EE7F00000000000014000000000000000000000000000000000100000001000000018024E10000000000001500000000000000000000000000000000010000000100000001800A810000000000001600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000180000000000000000000000000000000001000000010000000180C988000000000000190000000000000000000000000000000001000000010000000180C7880000000000001A0000000000000000000000000000000001000000010000000180C8880000000000001B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180DD880000000000001C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001D000000000000000000000000000000000100000001000000 + + + + 59399 + Build + + 976 + 00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000000001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000000001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64FF7F0000 + + + 583 + 1000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F000000000000FFFFFFFF0001000000000000000100000000000000010000000180D07F000000000000FFFFFFFF00010000000000000001000000000000000100000001803080000000000000FFFFFFFF00010000000000000001000000000000000100000001809E8A000000000000FFFFFFFF0001000000000000000100000000000000010000000180D17F000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001804C8A000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001806680000000000000FFFFFFFF0001000000000000000100000000000000010000000180EB88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180C07F000000000000FFFFFFFF0001000000000000000100000000000000010000000180B08A000000000000FFFFFFFF0001000000000000000100000000000000010000000180A801000000000000FFFFFFFF00010000000000000001000000000000000100000001807202000000000000FFFFFFFF0001000000000000000100000000000000010000000180BE01000000000000FFFFFFFF000100000000000000010000000000000001000000 + + + 583 + 1000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F000000000000000000000000000000000000000000000001000000010000000180D07F00000000000001000000000000000000000000000000000100000001000000018030800000000000000200000000000000000000000000000000010000000100000001809E8A000000000000030000000000000000000000000000000001000000010000000180D17F0000000000000400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000000500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001806680000000000000060000000000000000000000000000000001000000010000000180EB880000000000000700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000080000000000000000000000000000000001000000010000000180B08A000000000000090000000000000000000000000000000001000000010000000180A8010000000000000A000000000000000000000000000000000100000001000000018072020000000000000B0000000000000000000000000000000001000000010000000180BE010000000000000C000000000000000000000000000000000100000001000000 + + + + 59400 + Debug + + 2373 + 00200000000000001900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000002500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000002600000000000000000000000000000000010000000100000001801D800000000000002700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000002800000000000000000000000000000000010000000100000001801B80000000000000290000000000000000000000000000000001000000010000000180E57F0000000000002A00000000000000000000000000000000010000000100000001801C800000000000002B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000002C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B0000000000002D0000000000000000000000000000000001000000010000000180F07F0000000000002E0000000000000000000000000000000001000000010000000180E8880000000000003700000000000000000000000000000000010000000100000001803B010000000000002F0000000000000000000000000000000001000000010000000180BB8A00000000000030000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E0E01000000000000310000000D57617463682057696E646F7773000000000000000000000000010000000100000000000000000000000100000003001380D88B00000000000031000000085761746368202631000000000000000000000000010000000100000000000000000000000100000000001380D98B00000000000031000000085761746368202632000000000000000000000000010000000100000000000000000000000100000000001380CE01000000000000FFFFFFFF0C576174636820416E63686F720100000000000000000000000100000001000000000000000000000001000000000013800F01000000000000320000000E4D656D6F72792057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380D28B00000000000032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000000001380D38B00000000000032000000094D656D6F7279202632000000000000000000000000010000000100000000000000000000000100000000001380D48B00000000000032000000094D656D6F7279202633000000000000000000000000010000000100000000000000000000000100000000001380D58B00000000000032000000094D656D6F72792026340000000000000000000000000100000001000000000000000000000001000000000013801001000000000000330000000E53657269616C2057696E646F77730000000000000000000000000100000001000000000000000000000001000000040013809307000000000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000000013809407000000000000330000000855415254202326320000000000000000000000000100000001000000000000000000000001000000000013809507000000000000330000000855415254202326330000000000000000000000000100000001000000000000000000000001000000000013809607000000000000330000001626446562756720287072696E746629205669657765720000000000000000000000000100000001000000000000000000000001000000000013803C010000000000007200000010416E616C797369732057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380658A000000000000340000000F264C6F67696320416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380DC7F0000000000003E0000001526506572666F726D616E636520416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380E788000000000000380000000E26436F646520436F766572616765000000000000000000000000010000000100000000000000000000000100000000001380CD01000000000000FFFFFFFF0F416E616C7973697320416E63686F7201000000000000000000000001000000010000000000000000000000010000000000138053010000000000003F0000000D54726163652057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013805401000000000000FFFFFFFF115472616365204D656E7520416E63686F720100000000000000000000000100000001000000000000000000000001000000000013802901000000000000350000001553797374656D205669657765722057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013804B01000000000000FFFFFFFF1453797374656D2056696577657220416E63686F720100000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000013800189000000000000360000000F26546F6F6C626F782057696E646F7700000000000000000000000001000000010000000000000000000000010000000300138044C5000000000000FFFFFFFF0E5570646174652057696E646F77730100000000000000000000000100000001000000000000000000000001000000000013800000000000000400FFFFFFFF000000000000000000000000000100000001000000000000000000000001000000000013805B01000000000000FFFFFFFF12546F6F6C626F78204D656E75416E63686F720100000000000000000000000100000001000000000000000000000001000000000000000000054465627567FF7F0000 + + + 898 + 1900FFFF01001100434D4643546F6F6C426172427574746F6ECC88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001801780000000000000FFFFFFFF00010000000000000001000000000000000100000001801D80000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001801A80000000000000FFFFFFFF00010000000000000001000000000000000100000001801B80000000000000FFFFFFFF0001000000000000000100000000000000010000000180E57F000000000000FFFFFFFF00010000000000000001000000000000000100000001801C80000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001800089000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180E48B000000000000FFFFFFFF0001000000000000000100000000000000010000000180F07F000000000000FFFFFFFF0001000000000000000100000000000000010000000180E888000000000000FFFFFFFF00010000000000000001000000000000000100000001803B01000000000000FFFFFFFF0001000000000000000100000000000000010000000180BB8A000000000000FFFFFFFF0001000000000000000100000000000000010000000180D88B000000000000FFFFFFFF0001000000000000000100000000000000010000000180D28B000000000000FFFFFFFF00010000000000000001000000000000000100000001809307000000000000FFFFFFFF0001000000000000000100000000000000010000000180658A000000000000FFFFFFFF0001000000000000000100000000000000010000000180C18A000000000000FFFFFFFF0001000000000000000100000000000000010000000180EE8B000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001800189000000000000FFFFFFFF000100000000000000010000000000000001000000 + + + 898 + 1900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000000000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000000100000000000000000000000000000000010000000100000001801D800000000000000200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000000300000000000000000000000000000000010000000100000001801B80000000000000040000000000000000000000000000000001000000010000000180E57F0000000000000500000000000000000000000000000000010000000100000001801C800000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000000700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B000000000000080000000000000000000000000000000001000000010000000180F07F000000000000090000000000000000000000000000000001000000010000000180E8880000000000000A00000000000000000000000000000000010000000100000001803B010000000000000B0000000000000000000000000000000001000000010000000180BB8A0000000000000C0000000000000000000000000000000001000000010000000180D88B0000000000000D0000000000000000000000000000000001000000010000000180D28B0000000000000E000000000000000000000000000000000100000001000000018093070000000000000F0000000000000000000000000000000001000000010000000180658A000000000000100000000000000000000000000000000001000000010000000180C18A000000000000110000000000000000000000000000000001000000010000000180EE8B0000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180018900000000000013000000000000000000000000000000000100000001000000 + + + + 0 + 1920 + 1080 + + + + + + 1 + 0 + + 100 + 0 + + ..\..\..\drivers\modules\command_line.c + 60 + 91 + 101 + 1 + + 0 + + + + +
diff --git a/examples/delay_no_block/MDK/use_example.uvoptx b/examples/delay_no_block/MDK/use_example.uvoptx index b0e0d3d..5958fb9 100644 --- a/examples/delay_no_block/MDK/use_example.uvoptx +++ b/examples/delay_no_block/MDK/use_example.uvoptx @@ -239,7 +239,7 @@ libs - 0 + 1 0 0 0 diff --git a/examples/delay_no_block/SRC/main.c b/examples/delay_no_block/SRC/main.c index 9d6ada0..58b57b7 100644 --- a/examples/delay_no_block/SRC/main.c +++ b/examples/delay_no_block/SRC/main.c @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) while(1) { - /* 等待延时任务处理 */ + /* 等待延时任务返回完成 */ if(RET_OK == delay_wait(&singleDelay)) { PRINT_LOG("single delay\r\n"); @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) if(RET_OK == delay_wait(&cycleDelay)) { PRINT_LOG("cycle delay\r\n"); - /* 延时重配置 */ + /* 延时重新配置 */ delay_init(&cycleDelay, 500/DELAY_TIM_PERIOD); } } diff --git a/examples/modbus_host/MDK/use_example.uvoptx b/examples/modbus_host/MDK/use_example.uvoptx new file mode 100644 index 0000000..305095e --- /dev/null +++ b/examples/modbus_host/MDK/use_example.uvoptx @@ -0,0 +1,652 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + Target 1 + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + JL2CM3 + -U59522627 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 1 + 0 + 2 + 10000000 + + + + + + cmsis + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + core_cm3.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + stm32f10x_it.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + system_stm32f10x.c + 0 + 0 + + + 1 + 4 + 2 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + startup_stm32f10x_md.s + 0 + 0 + + + + + libs + 0 + 0 + 0 + 0 + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + misc.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + stm32f10x_adc.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + stm32f10x_bkp.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + stm32f10x_can.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + stm32f10x_cec.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + stm32f10x_crc.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + stm32f10x_dac.c + 0 + 0 + + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + stm32f10x_dbgmcu.c + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + stm32f10x_dma.c + 0 + 0 + + + 2 + 14 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + stm32f10x_exti.c + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + stm32f10x_flash.c + 0 + 0 + + + 2 + 16 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + stm32f10x_fsmc.c + 0 + 0 + + + 2 + 17 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + stm32f10x_gpio.c + 0 + 0 + + + 2 + 18 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + stm32f10x_i2c.c + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + stm32f10x_iwdg.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + stm32f10x_pwr.c + 0 + 0 + + + 2 + 21 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + stm32f10x_rcc.c + 0 + 0 + + + 2 + 22 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + stm32f10x_rtc.c + 0 + 0 + + + 2 + 23 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + stm32f10x_sdio.c + 0 + 0 + + + 2 + 24 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + stm32f10x_spi.c + 0 + 0 + + + 2 + 25 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + stm32f10x_tim.c + 0 + 0 + + + 2 + 26 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + stm32f10x_usart.c + 0 + 0 + + + 2 + 27 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + stm32f10x_wwdg.c + 0 + 0 + + + + + segger + 0 + 0 + 0 + 0 + + 3 + 28 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + SEGGER_RTT.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + SEGGER_RTT_printf.c + 0 + 0 + + + + + system + 1 + 0 + 0 + 0 + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + tim.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + usart.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\SRC\main.c + main.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_host.c + modbus_host.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modules\data_check.c + data_check.c + 0 + 0 + + + + + readme + 1 + 0 + 0 + 0 + + 6 + 35 + 5 + 0 + 0 + 0 + ..\README.txt + README.txt + 0 + 0 + + + +
diff --git a/examples/modbus_host/MDK/use_example.uvprojx b/examples/modbus_host/MDK/use_example.uvprojx new file mode 100644 index 0000000..84daf6d --- /dev/null +++ b/examples/modbus_host/MDK/use_example.uvprojx @@ -0,0 +1,607 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + STM32F103C8 + STMicroelectronics + Keil.STM32F1xx_DFP.2.4.1 + https://www.keil.com/pack/ + IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + 0 + $$Device:STM32F103C8$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103C8$SVD\STM32F103xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + use_example + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 1 + 0x8000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + STM32F10X_MD,USE_STDPERIPH_DRIVER + + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt;..\..\..\drivers\modbus + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + cmsis + + + core_cm3.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + + + stm32f10x_it.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + + + system_stm32f10x.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + + + startup_stm32f10x_md.s + 2 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + + + + + libs + + + misc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + + + stm32f10x_adc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + + + stm32f10x_bkp.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + + + stm32f10x_can.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + + + stm32f10x_cec.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + + + stm32f10x_crc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + + + stm32f10x_dac.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + + + stm32f10x_dbgmcu.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + + + stm32f10x_dma.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + + + stm32f10x_exti.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + + + stm32f10x_flash.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + + + stm32f10x_fsmc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + + + stm32f10x_gpio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + + + stm32f10x_i2c.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + + + stm32f10x_iwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + + + stm32f10x_pwr.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + + + stm32f10x_rcc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + + + stm32f10x_rtc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + + + stm32f10x_sdio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + + + stm32f10x_spi.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + + + stm32f10x_tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + + + stm32f10x_usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + + + stm32f10x_wwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + + + + + segger + + + SEGGER_RTT.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + + + SEGGER_RTT_printf.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + + + + + system + + + tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + + + usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + + + + + source + + + main.c + 1 + ..\SRC\main.c + + + modbus_host.c + 1 + ..\..\..\drivers\modbus\modbus_host.c + + + data_check.c + 1 + ..\..\..\drivers\modules\data_check.c + + + + + readme + + + README.txt + 5 + ..\README.txt + + + + + + + + + + + + + + + + + use_example + 1 + + + + +
diff --git a/examples/modbus_host/README.txt b/examples/modbus_host/README.txt new file mode 100644 index 0000000..1b3e8bd --- /dev/null +++ b/examples/modbus_host/README.txt @@ -0,0 +1,49 @@ +================================================================================ + 用例使用说明 +================================================================================ +Date Author MDK MCU +2023-10-17 ashuai0110 5.35 STM32F1 + +================================================================================ +功能描述 +================================================================================ +本用例展示了modbus主机程序组件的使用方法。 + +================================================================================ +测试环境 +================================================================================ +测试用板: +--------------------- +任意开发板 + +辅助工具: +--------------------- +J-Link +usb转串口 + +辅助软件: +--------------------- +J-Link RTT Viewer +Modbus Slave + +源码文件: +--------------------- +modbus_host.c +modbus_host.h + +================================================================================ +使用步骤 +================================================================================ +1)使用J-Link连接目标板; +2)使用usb转串口连接电脑; +3)打开工程,逐次打开注释内容,重新编译,打开的是发送读命令时应打开Modbus Slave软件设置好对应参数打开连接, + 并用J-Link RTT Viewer软件连接,重启或重新下载程序后查看打印消息; +4)打开工程,逐次打开注释内容,重新编译,发送写命令时应打开Modbus Slave软件设置好对应参数打开连接, + 重启或重新下载程序后查看Modbus Slave软件对应线圈或寄存器值是否变化。 + +================================================================================ +注意 +================================================================================ +1)用户根据需求可前往源码头文件修改宏定义参数 + +================================================================================ diff --git a/examples/modbus_host/SRC/main.c b/examples/modbus_host/SRC/main.c new file mode 100644 index 0000000..a8852ba --- /dev/null +++ b/examples/modbus_host/SRC/main.c @@ -0,0 +1,287 @@ +/** + ****************************************************************************** + * @file main.c + * @author ashuai0110 + * @version V1.0 + * @date 2023-10-17 + * @brief 使用举例-MODBUS主机程序 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * + ****************************************************************************** + */ + +/* 包含头文件-----------------------------------------------------------------*/ +#include "stm32f10x.h" +#include "tim.h" +#include "usart.h" + +#include "modbus_host.h" + +#include + +/* 私有宏定义-----------------------------------------------------------------*/ +#define USART1_MBH_CH (0u) /* modbus主机管理序号 */ + +/* 私有类型定义---------------------------------------------------------------*/ + +/* 私有变量-------------------------------------------------------------------*/ +const static char *modbusErrorStr[] = { + "response message length error!", + "response message check error!", + "response message frame error!", +}; + +static uint8_t modbusBuf[MBH_BUF_SIZE_MAX]; /* modbus所需缓存区 */ + +/* 全局变量-------------------------------------------------------------------*/ +uint8_t coilStatus[8]; /* 线圈 */ +uint8_t inputStatus[8]; /* 输入线圈 */ +uint16_t holdingRegister[8]; /* 保持寄存器 */ +uint16_t inputRegister[8]; /* 输入寄存器 */ + +/* 私有函数原型---------------------------------------------------------------*/ + +/** + * @brief 定时器中断函数 + * + * @param None + * + * @retval None + */ +void TIM1_UP_IRQHandler(void) +{ + static uint8_t ret; + + if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) + { + /* modbus主机轮询处理 */ + ret = mb_host_poll(USART1_MBH_CH); + /* 处理中 */ + if(RET_ING == ret) + { + } /* 应答完成 */ + else if(RET_OK == ret) + { + DEBUG_LOG("response success"); + } /* 应答超时 */ + else if(RET_TIMEOUT == ret) + { + WARN_LOG("response timeout"); + } /* 应答错误 */ + else + { + ERROR_LOG("response error: %s", modbusErrorStr[ret - RET_LEN_ERR]); + } + + TIM_ClearITPendingBit(TIM1, TIM_FLAG_Update); + } +} + +/** + * @brief 串口中断函数 + * + * @param None + * + * @retval None + */ +void USART1_IRQHandler(void) +{ + static uint8_t rxData, txData, ret; + + if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) + { + rxData = USART_ReceiveData(USART1); + /* 写入接收缓存 */ + ret = mb_host_write_rx_buf(USART1_MBH_CH, &rxData, 1); + if(RET_OK != ret) + { + WARN_LOG("mb_host_write_rx_buf failure"); + } + + USART_ClearITPendingBit(USART1, USART_IT_RXNE); + } + + if(USART_GetITStatus(USART1, USART_IT_TC) != RESET) + { + /* 读出发送缓存 */ + ret = mb_host_read_tx_buf(USART1_MBH_CH, &txData, 1); + if(RET_OK == ret) + { + USART_SendData(USART1, txData); + } + + USART_ClearITPendingBit(USART1, USART_IT_TC); + } +} + +/** + * @brief 串口发送中断开关函数 + * + * @param None + * + * @retval None + */ +void uart_tx_en(uint8_t enState) +{ + if(enState) + { + /* 使能发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, ENABLE); + } + else + { + /* 关闭发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, DISABLE); + } +} + +int main(int argc, char *argv[]) +{ + VERSION_LOG("example-modbus_host", 1, 0, 0); + + /* 定时器初始化 1ms */ + tim1_init_config(100-1, 720-1); + /* 串口初始化 9600 */ + usart1_init_config(9600); + + /* modbus主机初始化 */ + mb_host_init(USART1_MBH_CH, MBH_RTU, modbusBuf, sizeof(modbusBuf), uart_tx_en, 9600, 500); + + /* 发送读取线圈命令 */ + mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x1, 0x0, 8, NULL); + /* 发送读取离散输入命令 */ +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x2, 0x0, 8, NULL); + /* 发送读取保持寄存器命令 */ +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x3, 0x0, 2, NULL); + /* 发送读取输入寄存器命令 */ +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x4, 0x0, 2, NULL); + + /* 发送写入单个线圈命令 */ +// uint8_t coilVal = 1; +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x5, 0x0, 0, &coilVal); + /* 发送写入单个寄存器命令 */ +// uint16_t regVal = 0x1357; +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x6, 0x0, 0, ®Val); + /* 发送写入多个线圈命令 */ +// uint8_t coilVal[2] = {0xAA, 0xFF}; +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0xF, 0x0, 10, &coilVal[0]); + /* 发送写入多个寄存器命令 */ +// uint16_t regVal[2] = {0x1122, 0x5566}; +// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x10, 0x0, 2, ®Val[0]); + + while(1) + { + + } +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + uint8_t bytes = ceil((double)num / 8.0); /* 向上取整计算字节数 */ + uint8_t dataTmp; + + DEBUG_LOG("before-coilStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", coilStatus[0], \ + coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); + + /* 判断序号 */ + if(USART1_MBH_CH == ch) + { + /* 循环赋值 */ + for(uint8_t i = 0; i < bytes; i++) + { + /* 不满8bit进行位替换 */ + if(8 > num) + { + dataTmp = BIT_REPLACE(coilStatus[reg + i], pData[i], num); + } /* 满8bit直接赋值 */ + else + { + dataTmp = pData[i]; + } + coilStatus[reg + i] = dataTmp; /* 假设请求时的线圈地址 == 本地线圈地址 */ + num -= 8; + } + } + + DEBUG_LOG("after-coilStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", coilStatus[0], \ + coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + uint8_t bytes = ceil((double)num / 8.0); /* 向上取整计算字节数 */ + uint8_t dataTmp; + + DEBUG_LOG("before-inputStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputStatus[0], \ + inputStatus[1], inputStatus[2], inputStatus[3], inputStatus[4], inputStatus[5], inputStatus[6], inputStatus[7]); + + /* 判断序号 */ + if(USART1_MBH_CH == ch) + { + /* 循环赋值 */ + for(uint8_t i = 0; i < bytes; i++) + { + /* 不满8bit进行位替换 */ + if(8 > num) + { + dataTmp = BIT_REPLACE(inputStatus[reg + i], pData[i], num); + } /* 满8bit直接赋值 */ + else + { + dataTmp = pData[i]; + } + inputStatus[reg + i] = dataTmp; /* 假设请求时的线圈地址 == 本地线圈地址 */ + num -= 8; + } + } + + DEBUG_LOG("after-inputStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputStatus[0], \ + inputStatus[1], inputStatus[2], inputStatus[3], inputStatus[4], inputStatus[5], inputStatus[6], inputStatus[7]); +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + DEBUG_LOG("before-holdingRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", holdingRegister[0], holdingRegister[1], \ + holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); + + /* 循环赋值 */ + for(uint8_t i = 0; i < num; i++) + { + /* 假设请求时的寄存器地址 == 本地寄存器地址 */ + holdingRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + } + + DEBUG_LOG("after-holdingRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", holdingRegister[0], holdingRegister[1], \ + holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + DEBUG_LOG("before-inputRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputRegister[0], inputRegister[1], \ + inputRegister[2], inputRegister[3], inputRegister[4], inputRegister[5], inputRegister[6], inputRegister[7]); + + /* 循环赋值 */ + for(uint8_t i = 0; i < num; i++) + { + /* 假设请求时的寄存器地址 == 本地寄存器地址 */ + inputRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + } + + DEBUG_LOG("after-inputRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputRegister[0], inputRegister[1], \ + inputRegister[2], inputRegister[3], inputRegister[4], inputRegister[5], inputRegister[6], inputRegister[7]); +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_err(uint8_t ch, uint8_t *pData) +{ + DEBUG_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X", ch, pData[0], pData[1]); +} -- Gitee From b9262703974e7a09ca22b474ef30dfcd8cf46d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=A1=B00110?= Date: Sat, 21 Oct 2023 18:15:32 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BC=98=E5=8C=96modbus=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=EF=BC=8C=E6=96=B0=E5=A2=9Emodbus=E4=BB=8E?= =?UTF-8?q?=E6=9C=BA=E7=A8=8B=E5=BA=8F=E5=86=85=E5=AE=B9=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B3=A8=E9=87=8A=E5=92=8C=E6=8F=90=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 +- drivers/common/all_include.h | 20 +- drivers/common/common_include.h | 2 +- drivers/modbus/modbus_common.c | 233 ++ drivers/modbus/modbus_common.h | 138 ++ drivers/modbus/modbus_host.c | 612 +++--- drivers/modbus/modbus_host.h | 60 +- drivers/modbus/modbus_slave.c | 496 ++++- drivers/modbus/modbus_slave.h | 100 +- drivers/modules/command_line.c | 4 +- drivers/modules/command_line.h | 4 +- drivers/modules/data_check.c | 4 +- drivers/modules/data_check.h | 4 +- drivers/modules/data_convert.c | 6 +- drivers/modules/data_convert.h | 6 +- drivers/modules/delay_no_block.c | 4 +- drivers/modules/delay_no_block.h | 4 +- drivers/modules/input_output.c | 4 +- drivers/modules/input_output.h | 4 +- drivers/modules/memory.c | 4 +- drivers/modules/memory.h | 4 +- drivers/modules/message_queue.c | 4 +- drivers/modules/message_queue.h | 4 +- drivers/modules/ring_buffer.c | 4 +- drivers/modules/ring_buffer.h | 4 +- drivers/modules/ring_queue.c | 4 +- drivers/modules/ring_queue.h | 4 +- drivers/modules/sync_method.c | 4 +- drivers/modules/sync_method.h | 4 +- drivers/modules/timer_software.c | 4 +- drivers/modules/timer_software.h | 4 +- drivers/modules/uart_handler.c | 49 +- drivers/modules/uart_handler.h | 4 +- .../Target_1_STM32F103C8_1.0.0.dbgconf | 36 - .../command_line/MDK/use_example.uvguix.yansj | 1878 ----------------- examples/modbus_host/MDK/use_example.uvoptx | 47 +- examples/modbus_host/MDK/use_example.uvprojx | 4 +- examples/modbus_host/README.txt | 2 +- examples/modbus_host/SRC/main.c | 38 +- .../project_template/MDK/use_example.uvoptx | 154 +- .../project_template/MDK/use_example.uvprojx | 50 +- examples/project_template/SRC/main.c | 6 +- examples/uart_handler/README.txt | 2 +- examples/uart_handler/SRC/main.c | 13 +- 44 files changed, 1615 insertions(+), 2457 deletions(-) create mode 100644 drivers/modbus/modbus_common.c create mode 100644 drivers/modbus/modbus_common.h delete mode 100644 examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf delete mode 100644 examples/command_line/MDK/use_example.uvguix.yansj diff --git a/README.md b/README.md index 9eb003d..3a74d73 100644 --- a/README.md +++ b/README.md @@ -2,41 +2,47 @@ * ./documents/存放文档 * ./drivers/存放所有组件源程序 -* ./examples/存放所有示例工程 +* ./examples/存放所有示例工程(使用必看) ### drivers/common -common_include.h:通用头文件(所有组件都需包含此文件) +all_include.h: 所有组件头文件集合 + +common_include.h: 通用头文件(所有组件都需包含此文件) ### drivers/modbus -modbus_host.c/.h: modbus主机程序(RTU, ASCII) +modbus_common.c/.h: modbus通用文件 + +modbus_host.c/.h: modbus主机程序(RTU ASCII) -modbus_slave.c/.h: modbus从机程序(RTU, ASCII) +modbus_slave.c/.h: modbus从机程序(RTU ASCII) ### drivers/modules/ -command_line.c/.h:命令行交互 +command_line.c/.h: 命令行交互 + +data_check.c/.h: 数据校验方法集合 -data_convert.c/.h:数据转换 +data_convert.c/.h: 数据转换方法集合 -delay_no_block.c/.h:非阻塞延时 +delay_no_block.c/.h: 非阻塞延时 -input_output.c/.h:IO输入输出操作 +input_output.c/.h: IO输入输出操作 -memory.c/.h:内存管理-小内存管理算法 +memory.c/.h: 内存管理-小内存管理算法 -message_queue.c/.h:消息队列 +message_queue.c/.h: 消息队列 -ring_buffer.c/.h:环形缓冲区 +ring_buffer.c/.h: 环形缓冲区 -ring_queue.c/.h:环形队列 +ring_queue.c/.h: 环形队列 -sync_method.c/.h:伪线程同步方法(信号量,互斥锁,事件集) +sync_method.c/.h: 伪线程同步方法(信号量,互斥锁,事件集) -timer_software.c/.h:软件定时器 +timer_software.c/.h: 软件定时器 -uart_handler.c/.h:串口管理 +uart_handler.c/.h: 串口管理 ### drivers/segger_rtt diff --git a/drivers/common/all_include.h b/drivers/common/all_include.h index d07db99..9cfa636 100644 --- a/drivers/common/all_include.h +++ b/drivers/common/all_include.h @@ -3,14 +3,14 @@ * @file all_include.h * @author ashuai0110 * @version V2.1 - * @date 2023-09-26 - * @brief 所有组件的头文件 + * @date 2023-10-21 + * @brief 所有组件头文件集合 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ @@ -23,12 +23,16 @@ extern "C" { #endif /* 包含头文件-----------------------------------------------------------------*/ -/* 通用头文件 */ +/* common */ #include "common_include.h" /*!< 通用接口 */ -/* 组件头文件 */ +/* modbus */ +#include "modbus_common.h" /*!< modbus通用文件 */ +#include "modbus_host.h" /*!< modbus主机程序(RTU ASCII) */ +#include "modbus_slave.h" /*!< modbus从机程序(RTU ASCII) */ +/* modules */ #include "command_line.h" /*!< 命令行交互 */ -#include "data_check.h" /*!< 数据校验 */ -#include "data_convert.h" /*!< 数据转换 */ +#include "data_check.h" /*!< 数据校验方法集合 */ +#include "data_convert.h" /*!< 数据转换方法集合 */ #include "delay_no_block.h" /*!< 非阻塞延时 */ #include "input_output.h" /*!< IO输入输出操作 */ #include "memory.h" /*!< 内存管理-小内存管理算法 */ diff --git a/drivers/common/common_include.h b/drivers/common/common_include.h index 5d1d391..64d2580 100644 --- a/drivers/common/common_include.h +++ b/drivers/common/common_include.h @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** diff --git a/drivers/modbus/modbus_common.c b/drivers/modbus/modbus_common.c new file mode 100644 index 0000000..91d3323 --- /dev/null +++ b/drivers/modbus/modbus_common.c @@ -0,0 +1,233 @@ +/** + ****************************************************************************** + * @file modbus_common.c + * @author ashuai0110 + * @version V2.1 + * @date 2023-10-19 + * @brief modbus通用文件 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git + * + ****************************************************************************** + */ + +/* 包含头文件-----------------------------------------------------------------*/ +#include "modbus_common.h" + +/** + * @addtogroup modbus + * @{ + */ + +/** + * @defgroup modbus_common modbus通用文件 + * @{ + */ + +/* 私有宏定义-----------------------------------------------------------------*/ + +/* 私有类型定义---------------------------------------------------------------*/ + +/* 私有变量-------------------------------------------------------------------*/ +/** + * @defgroup modbus_common_local_variables modbus common local variables + * @{ + */ + +/* CRC 高位字节值表 */ +static const uint8_t crcHiArr[] = { + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, + 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, + 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, +}; +/* CRC 低位字节值表 */ +static const uint8_t crcLoArr[] = { + 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, + 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, + 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, + 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, + 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, + 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, + 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, + 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, + 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, + 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, + 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, + 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, + 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, + 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, + 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, + 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, + 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, + 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, + 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, + 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, + 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, + 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, + 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, + 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, + 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, + 0x43, 0x83, 0x41, 0x81, 0x80, 0x40, +}; + +/* HEX转ASCII */ +static const char HEX_TO_ASCII[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0X41,0X42,0X43,0X44,0X45,0X46}; + +/** + * @} + */ + +/* 全局变量-------------------------------------------------------------------*/ + +/* 私有函数原型---------------------------------------------------------------*/ +/** + * @defgroup modbus_common_global_functions modbus common global functions + * @{ + */ + +/** + * @brief CRC16校验(MODBUS) + * + * @param pBuf : 校验数据 + * + * @param len : 校验数据长度 + * + * @retval 校验结果 + */ +uint16_t mb_check_crc16(uint8_t *pBuf, uint16_t len) +{ + uint8_t crcHi = 0xFF; /* 高CRC字节初始化 */ + uint8_t crcLo = 0xFF; /* 低CRC 字节初始化 */ + uint16_t index; /* CRC循环中的索引 */ + + while(len--) + { + index = crcHi ^ *pBuf++; /* 计算CRC */ + crcHi = crcLo ^ crcHiArr[index]; + crcLo = crcLoArr[index]; + } + + return ((uint16_t)crcHi << 8 | crcLo); +} + +/** + * @brief LRC校验 + * + * @param pBuf : 校验数据 + * + * @param len : 校验数据长度 + * + * @retval 校验结果 + */ +uint8_t mb_check_lrc(uint8_t *pBuf, uint16_t len) +{ + uint8_t lrc = 0; + + for(uint16_t index = 0; index < len; index++) + { + lrc += pBuf[index]; + } + + lrc = (~lrc) + 1; + + return lrc; +} + +/** + * @brief hex转ascii(modbus) + * + * @param pHex : hex数据缓存区 + * + * @param num : hex数据数量 + * + * @param pAscii : ascii数据存储区 + * + * @retval None + */ +void mb_hex_to_ascii(uint8_t *pHex, uint16_t num, uint8_t *pAscii) +{ + /* 从后往前转换 */ + for(int16_t index = num - 1; index >= 0; index--) + { + pAscii[(index << 1) + 1] = HEX_TO_ASCII[pHex[index] >> 4]; + pAscii[(index << 1) + 2] = HEX_TO_ASCII[pHex[index] & 0xF]; + } +} + +/** + * @brief ascii转hex(modbus) + * + * @param pAscii : ascii数据缓存区 + * + * @param num : ascii数据数量 + * + * @param pHex : hex数据存储区 + * + * @retval None + */ +void mb_ascii_to_hex(uint8_t *pAscii, uint16_t num, uint8_t *pHex) +{ + uint8_t index1, index2; + /* 从前往后转换 */ + for(uint8_t i = 0; i < (num >> 1); i++) + { + index1 = i << 1; + index2 = index1 + 1; + pHex[i] = ((pAscii[index1] > '9' ? (pAscii[index1] + 0x9) : pAscii[index1]) << 4) | ((pAscii[index2] > '9' ? (pAscii[index2] + 0x9) : pAscii[index2]) & 0xF); + } +} + +uint8_t mb_get_bits(uint8_t *srcBuf, uint16_t bitOffset, uint8_t bitNum) +{ + uint8_t byteOffset; + uint8_t preBitNum; + uint8_t retVal; + + byteOffset = bitOffset / 8; /* 数据索引 */ + preBitNum = bitOffset % 8; /* bit开始的位数 */ + + retVal = (srcBuf[byteOffset] >> preBitNum) | (srcBuf[byteOffset + 1] << (8 - preBitNum)); /* 组合数据 */ + retVal = retVal & ((1 << (uint16_t)bitNum) - 1); /* 保留有效位 */ + + return retVal; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + diff --git a/drivers/modbus/modbus_common.h b/drivers/modbus/modbus_common.h new file mode 100644 index 0000000..49f54ae --- /dev/null +++ b/drivers/modbus/modbus_common.h @@ -0,0 +1,138 @@ +/** + ****************************************************************************** + * @file modbus_common.h + * @author ashuai0110 + * @version V2.1 + * @date 2023-10-19 + * @brief modbus通用文件 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git + * + ****************************************************************************** + */ + +#ifndef __MODBUS_COMMON_H +#define __MODBUS_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* 包含头文件-----------------------------------------------------------------*/ +#include "common_include.h" + +/** + * @addtogroup modbus + * @{ + */ + +/** + * @addtogroup modbus_common + * @{ + */ + +/* 宏定义---------------------------------------------------------------------*/ +/** + * @defgroup modbus_common_global_macros modbus common global macros + * @{ + */ + +#define MB_BUF_SIZE_MAX (256u) /*!< modbus缓存区最大256byte 不可修改 */ +#define MB_PDU_SIZE_MIN (4u) /*!< modbus PDU最小4byte */ + +#define MB_ADDR_OFF (0u) /*!< modbus从站地址偏移 */ +#define MB_CODE_OFF (1u) /*!< modbus功能码偏移 */ +#define MB_REG_ADDR_HI_OFF (2u) /*!< modbus寄存器地址高八位偏移 */ +#define MB_REG_ADDR_LO_OFF (3u) /*!< modbus寄存器地址低八位偏移 */ +#define MB_NUM_HI_OFF (4u) /*!< modbus读/写数量高八位偏移 */ +#define MB_NUM_LO_OFF (5u) /*!< modbus读/写数量低八位偏移 */ + +#define MB_RSP_BYTE_OFF (2u) /*!< modbus应答(读请求的应答)字节数偏移 */ +#define MB_RSP_DATA_OFF (3u) /*!< modbus应答(读请求的应答)数据值偏移 */ + +/** + * @defgroup modbus_common_protocol modbus common protocol + * @{ + */ +#define MB_RTU (0u) /*!< RTU协议 */ +#define MB_ASCII (1u) /*!< ASCII协议 */ +/* modbus协议类型有效性检查 */ +#define IS_VALID_MB_PROTOCOL(x) \ +( (x) == MB_RTU || \ + (x) == MB_ASCII) +/** + * @} + */ + +/** + * @defgroup modbus_common_state modbus common state + * @{ + */ +#define MB_TX_IDLE (0u) /*!< 发送空闲状态-仅允许发送 */ +#define MB_TX_BUSY (1u) /*!< 发送忙碌状态-禁止操作 */ +#define MB_RX_IDLE (2u) /*!< 接收空闲状态-仅允许接收 */ +#define MB_RX_BUSY (3u) /*!< 接收忙碌状态-禁止操作 */ +/** + * @} + */ + +/** + * @} + */ + +/* 类型定义-------------------------------------------------------------------*/ +/** + * @defgroup modbus_common_global_types modbus common global types + * @{ + */ + +/** + * @brief modbus发送前(串口)准备函数 + * + * @note 如:使用串口中断发送时需使能发送相关中断/使用串口DMA发送时需配置使能DMA + * + * @param enState : 0-关闭(失能) 1-开启(使能) + * + * @retval None + */ +typedef void (* modbus_tx_en_t)(uint8_t enState); + +/** + * @} + */ + +/* 全局变量-------------------------------------------------------------------*/ + +/* 函数原型-------------------------------------------------------------------*/ +/** + * @addtogroup modbus_common_global_functions + * @{ + */ + +uint16_t mb_check_crc16(uint8_t *pBuf, uint16_t len); +uint8_t mb_check_lrc(uint8_t *pBuf, uint16_t len); + +void mb_hex_to_ascii(uint8_t *pHex, uint16_t num, uint8_t *pAscii); +void mb_ascii_to_hex(uint8_t *pAscii, uint16_t num, uint8_t *pHex); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* modbus_common.h */ diff --git a/drivers/modbus/modbus_host.c b/drivers/modbus/modbus_host.c index 7380e8f..3f79f23 100644 --- a/drivers/modbus/modbus_host.c +++ b/drivers/modbus/modbus_host.c @@ -1,23 +1,22 @@ /** ****************************************************************************** * @file modbus_host.c - * @author woshiashuai + * @author ashuai0110 * @version V2.1 - * @date 2023-10-17 + * @date 2023-10-19 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ /* 包含头文件-----------------------------------------------------------------*/ #include "modbus_host.h" -#include "data_check.h" /** * @addtogroup modbus @@ -40,24 +39,14 @@ * @{ */ /* modbus主机管理序号有效性检查 */ -#define IS_VALID_CH(x) \ +#define IS_VALID_MBH_CH(x) \ ( ((x) == 0) || \ ((x) > 0) && \ ((x) < MBH_NUM)) - -/* modbus主机协议类型有效性检查 */ -#define IS_VALID_PROTOCOL(x) \ -( (x) == MBH_RTU || \ - (x) == MBH_ASCII) /** * @} */ -#define MBH_PDU_SIZE_MIN (4u) /*!< modbus PDU最小4byte */ -#define MBH_ADDR_OFF (0u) /*!< modbus从站地址偏移 */ -#define MBH_CODE_OFF (1u) /*!< modbus功能码偏移 */ -#define MBH_RSP_DATA_OFF (3u) /*!< modbus应答数据值偏移 */ - /** * @} */ @@ -70,12 +59,6 @@ * @{ */ -/* HEX转ASCII */ -const char HEX_TO_ASCII[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0X41,0X42,0X43,0X44,0X45,0X46}; -/* ASCII转HEX */ -const char ASCII_TO_HEX[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15,0,0,0,0,0,0}; - static mb_host_t mbHostArr[MBH_NUM]; /*!< modbus主机管理数组 */ /** @@ -91,7 +74,7 @@ static mb_host_t mbHostArr[MBH_NUM]; /*!< modbus主机管理数组 */ */ /** - * @brief 功能码应答处理 + * @brief 从机应答处理 * * @param ch : modbus主机管理序号(即数组索引) * @@ -99,13 +82,14 @@ static mb_host_t mbHostArr[MBH_NUM]; /*!< modbus主机管理数组 */ */ static void mb_host_rspProcess(uint8_t ch) { - if(mbHostArr[ch].slaveTmp != mbHostArr[ch].dataBuf[MBH_ADDR_OFF]) { return ; } - switch(mbHostArr[ch].dataBuf[MBH_CODE_OFF]) + mb_host_t *_mb_host = &mbHostArr[ch]; + + switch(_mb_host->dataBuf[MB_CODE_OFF]) { - case 0x01: mb_host_rsp_01h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读线圈应答处理 */ - case 0x02: mb_host_rsp_02h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读离散量输入应答处理 */ - case 0x03: mb_host_rsp_03h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读保持寄存器应答处理 */ - case 0x04: mb_host_rsp_04h(ch, mbHostArr[ch].regTmp, mbHostArr[ch].numTmp, &mbHostArr[ch].dataBuf[MBH_RSP_DATA_OFF]); break; /* 读输入寄存器应答处理 */ + case 0x01: mb_host_rsp_01h(ch, _mb_host->regTmp, _mb_host->numTmp, &_mb_host->dataBuf[MB_RSP_DATA_OFF]); break; /* 读线圈应答处理 */ + case 0x02: mb_host_rsp_02h(ch, _mb_host->regTmp, _mb_host->numTmp, &_mb_host->dataBuf[MB_RSP_DATA_OFF]); break; /* 读离散量输入应答处理 */ + case 0x03: mb_host_rsp_03h(ch, _mb_host->regTmp, _mb_host->numTmp, &_mb_host->dataBuf[MB_RSP_DATA_OFF]); break; /* 读保持寄存器应答处理 */ + case 0x04: mb_host_rsp_04h(ch, _mb_host->regTmp, _mb_host->numTmp, &_mb_host->dataBuf[MB_RSP_DATA_OFF]); break; /* 读输入寄存器应答处理 */ case 0x05: case 0x06: case 0x0F: @@ -113,7 +97,7 @@ static void mb_host_rspProcess(uint8_t ch) /* 用户在这里写其他功能码的应答处理 */ - default: if(mbHostArr[ch].dataBuf[MBH_CODE_OFF] & 0x80) { mb_host_rsp_err(ch, &mbHostArr[ch].dataBuf[MBH_CODE_OFF]); } break; /* 不支持的功能码或错误返回 */ + default: if(_mb_host->dataBuf[MB_CODE_OFF] & 0x80) { mb_host_rsp_err(ch, &_mb_host->dataBuf[MB_CODE_OFF]); } break; /* 不支持的功能码或错误返回 */ } } @@ -126,42 +110,39 @@ static void mb_host_rspProcess(uint8_t ch) */ static void mb_host_send_with_check(uint8_t ch) { + mb_host_t *_mb_host = &mbHostArr[ch]; uint16_t checkVal; /* ASCII协议 */ - if(MBH_ASCII == mbHostArr[ch].protocol) + if(MB_ASCII == _mb_host->protocol) { - int16_t index = 0; /* 追加LRC校验结果 */ - checkVal = check_lrc(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen); - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal; + checkVal = mb_check_lrc(_mb_host->dataBuf, _mb_host->dataLen); + _mb_host->dataBuf[_mb_host->dataLen++] = checkVal; /* HEX转ASCII */ - for(index = mbHostArr[ch].dataLen - 1; index >= 0; index--) - { - mbHostArr[ch].dataBuf[(index << 1) + 1] = HEX_TO_ASCII[mbHostArr[ch].dataBuf[index] >> 4]; - mbHostArr[ch].dataBuf[(index << 1) + 2] = HEX_TO_ASCII[mbHostArr[ch].dataBuf[index] & 0xF]; - } - mbHostArr[ch].dataLen = (mbHostArr[ch].dataLen << 1) + 3; - mbHostArr[ch].dataBuf[0] = 0x3A; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 2] = 0x0D; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1] = 0x0A; + mb_hex_to_ascii(&_mb_host->dataBuf[0], _mb_host->dataLen, &_mb_host->dataBuf[0]); + _mb_host->dataLen = (_mb_host->dataLen << 1) + 3; + _mb_host->dataBuf[0] = 0x3A; + _mb_host->dataBuf[_mb_host->dataLen - 2] = 0x0D; + _mb_host->dataBuf[_mb_host->dataLen - 1] = 0x0A; } /* RTU协议 */ else { /* 追加CRC校验结果 */ - checkVal = check_crc16_modbus(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen); - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = checkVal; + checkVal = mb_check_crc16(_mb_host->dataBuf, _mb_host->dataLen); + _mb_host->dataBuf[_mb_host->dataLen++] = checkVal >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = checkVal; } #if _MBH_DEBUG PRINT_LOG("modbus host[%d] send: ", ch); - for(uint16_t i = 0; i < mbHostArr[ch].dataLen; i++) + for(uint16_t i = 0; i < _mb_host->dataLen; i++) { - PRINT_LOG("%02X ", mbHostArr[ch].dataBuf[i]); + PRINT_LOG("%02X ", _mb_host->dataBuf[i]); } - PRINT_LOG("\n"); + PRINT_LOG("\r\n"); #endif - mbHostArr[ch].txEnFn(1); /* 开启发送 */ + _mb_host->state = MB_TX_BUSY; /* 切换状态 */ + _mb_host->txEnFn(1); /* 开启发送 */ } /** @@ -184,13 +165,15 @@ static void mb_host_send_with_check(uint8_t ch) */ static void mb_host_cmd_01_04h(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num) { - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = funCode; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; + mb_host_t *_mb_host = &mbHostArr[ch]; + + _mb_host->dataLen = 0; + _mb_host->dataBuf[_mb_host->dataLen++] = slaveAddr; + _mb_host->dataBuf[_mb_host->dataLen++] = funCode; + _mb_host->dataBuf[_mb_host->dataLen++] = reg >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = reg; + _mb_host->dataBuf[_mb_host->dataLen++] = num >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = num; mb_host_send_with_check(ch); } @@ -213,13 +196,15 @@ static void mb_host_cmd_01_04h(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, u */ static void mb_host_cmd_05h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint8_t extend) { - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x05; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend ? 0xFF : 0x00; /* 写入值:0xFF00=ON 0x0000=OFF */ - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x00; + mb_host_t *_mb_host = &mbHostArr[ch]; + + _mb_host->dataLen = 0; + _mb_host->dataBuf[_mb_host->dataLen++] = slaveAddr; + _mb_host->dataBuf[_mb_host->dataLen++] = 0x05; + _mb_host->dataBuf[_mb_host->dataLen++] = reg >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = reg; + _mb_host->dataBuf[_mb_host->dataLen++] = extend ? 0xFF : 0x00; /* 写入值:0xFF00=ON 0x0000=OFF */ + _mb_host->dataBuf[_mb_host->dataLen++] = 0x00; mb_host_send_with_check(ch); } @@ -242,13 +227,15 @@ static void mb_host_cmd_05h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint8_t */ static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t extend) { - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x06; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend; + mb_host_t *_mb_host = &mbHostArr[ch]; + + _mb_host->dataLen = 0; + _mb_host->dataBuf[_mb_host->dataLen++] = slaveAddr; + _mb_host->dataBuf[_mb_host->dataLen++] = 0x06; + _mb_host->dataBuf[_mb_host->dataLen++] = reg >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = reg; + _mb_host->dataBuf[_mb_host->dataLen++] = extend >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = extend; mb_host_send_with_check(ch); } @@ -256,8 +243,8 @@ static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ /** * @brief 写多个线圈命令(0x0f) * - * @note 从机地址 | 功能码 | 起始地址 | 数量 | 字节数n | 写入值 | CRC16 - * 1 | 1 | 2 | 2 | 1 | n | 2 (占用字节) + * @note 从机地址 | 功能码 | 起始地址 | 数量n | 字节数2n | 写入值 | CRC16 + * 1 | 1 | 2 | 2 | 1 | 2n | 2 (占用字节) * * @param ch : modbus主机管理序号(即数组索引) * @@ -273,22 +260,21 @@ static void mb_host_cmd_06h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ */ static void mb_host_cmd_0fh(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint8_t *extend) { - uint16_t bytes; - - bytes = (num + 7) >> 3; - - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x0F; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = bytes; + mb_host_t *_mb_host = &mbHostArr[ch]; + uint16_t bytes = (num + 7) >> 3; + + _mb_host->dataLen = 0; + _mb_host->dataBuf[_mb_host->dataLen++] = slaveAddr; + _mb_host->dataBuf[_mb_host->dataLen++] = 0x0F; + _mb_host->dataBuf[_mb_host->dataLen++] = reg >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = reg; + _mb_host->dataBuf[_mb_host->dataLen++] = num >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = num; + _mb_host->dataBuf[_mb_host->dataLen++] = bytes; num = num % 8; if(num) { extend[bytes - 1] = extend[bytes - 1] & ((1u << num) - 1); } /* 未使用bit填0 */ - memcpy(&mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen], extend, bytes); - mbHostArr[ch].dataLen += bytes; + memcpy(&_mb_host->dataBuf[_mb_host->dataLen], extend, bytes); + _mb_host->dataLen += bytes; mb_host_send_with_check(ch); } @@ -313,22 +299,21 @@ static void mb_host_cmd_0fh(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ */ static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_t num, uint16_t *extend) { - uint16_t bytes; - - bytes = num << 1; - - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = slaveAddr; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = 0x10; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = reg; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = num; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = bytes; + mb_host_t *_mb_host = &mbHostArr[ch]; + uint16_t bytes = num << 1; + + _mb_host->dataLen = 0; + _mb_host->dataBuf[_mb_host->dataLen++] = slaveAddr; + _mb_host->dataBuf[_mb_host->dataLen++] = 0x10; + _mb_host->dataBuf[_mb_host->dataLen++] = reg >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = reg; + _mb_host->dataBuf[_mb_host->dataLen++] = num >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = num; + _mb_host->dataBuf[_mb_host->dataLen++] = bytes; for(uint16_t cnt = 0; cnt < num; cnt++) { - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend[cnt] >> 8; - mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen++] = extend[cnt]; + _mb_host->dataBuf[_mb_host->dataLen++] = extend[cnt] >> 8; + _mb_host->dataBuf[_mb_host->dataLen++] = extend[cnt]; } mb_host_send_with_check(ch); @@ -348,9 +333,9 @@ static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ * * @param ch : modbus主机管理序号(即数组索引) * - * @param protocol : 协议类型 @ref modbus_host_protocol - * @arg MBH_RTU : RTU协议 - * @arg MBH_ASCII : ASCII协议 + * @param protocol : 协议类型 @ref modbus_common_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 * * @param pBuf : 接收数据缓存区 * @@ -364,28 +349,30 @@ static void mb_host_cmd_10h(uint8_t ch, uint8_t slaveAddr, uint16_t reg, uint16_ * * @retval None */ -void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, mb_host_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout) +void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, modbus_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout) { - ASSERT_PARAM(IS_VALID_CH(ch)); - ASSERT_PARAM(IS_VALID_PROTOCOL(protocol)); + mb_host_t *_mb_host = &mbHostArr[ch]; + + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); + ASSERT_PARAM(IS_VALID_MB_PROTOCOL(protocol)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); ASSERT_PARAM(IS_VALID_POINT(txEnFn)); - mbHostArr[ch].dataBuf = (uint8_t *)pBuf; - mbHostArr[ch].dataBufLen = bufLen; - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].readLen = 0; + _mb_host->dataBuf = (uint8_t *)pBuf; + _mb_host->dataBufLen = bufLen; + _mb_host->dataLen = 0; + _mb_host->readLen = 0; - mbHostArr[ch].protocol = protocol; - mbHostArr[ch].state = MBH_TX_IDLE; - mbHostArr[ch].broadcast = 0; + _mb_host->protocol = protocol; + _mb_host->state = MB_TX_IDLE; + _mb_host->broadcast = 0; mb_host_set_frame_intv(ch, baud); - mbHostArr[ch].curFrameIntv = 0; - mbHostArr[ch].rspTimeout = rspTimeout; - mbHostArr[ch].rspTimeoutCnt = 0; + _mb_host->curFrameIntv = 0; + _mb_host->rspTimeout = rspTimeout; + _mb_host->rspTimeoutCnt = 0; - mbHostArr[ch].txEnFn = txEnFn; + _mb_host->txEnFn = txEnFn; } /** @@ -405,106 +392,118 @@ void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, mb_ */ uint8_t mb_host_poll(uint8_t ch) { + uint16_t checkVal, startIndex, stopIndex; uint8_t ret = RET_ING; /* 进行中 */ + mb_host_t *_mb_host = &mbHostArr[ch]; - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); - if(MBH_RX_IDLE == mbHostArr[ch].state) + switch(_mb_host->state) { - /* 应答超时判断 */ - if(mbHostArr[ch].rspTimeoutCnt && mbHostArr[ch].rspTimeoutCnt++ > mbHostArr[ch].rspTimeout) - { - mbHostArr[ch].rspTimeoutCnt = 0; - ret = RET_TIMEOUT; /* 应答超时 */ - goto rspErr; - } - /* 帧间隔超时判断 */ - if(mbHostArr[ch].curFrameIntv && mbHostArr[ch].curFrameIntv++ > mbHostArr[ch].targetFrameIntv) - { - mbHostArr[ch].curFrameIntv = 0; - mbHostArr[ch].state = MBH_RX_BUSY; /* 切换状态 */ -#if _MBH_DEBUG - PRINT_LOG("modbus host[%d] recv: ", ch); - for(uint16_t i = 0; i < mbHostArr[ch].dataLen; i++) + case MB_TX_IDLE: break; + case MB_TX_BUSY: break; + case MB_RX_IDLE: + /* 应答超时判断 */ + if(_mb_host->rspTimeoutCnt && _mb_host->rspTimeoutCnt++ > _mb_host->rspTimeout) { - PRINT_LOG("%02X ", mbHostArr[ch].dataBuf[i]); - } - PRINT_LOG("\n"); -#endif - } - } - - if(MBH_RX_BUSY == mbHostArr[ch].state) - { - uint16_t checkVal; - - /* ASCII协议数据检查和转换 */ - if(MBH_ASCII == mbHostArr[ch].protocol) - { - uint16_t startIndex, stopIndex; - - /* 寻找起始符0x3A */ - for(startIndex = 0; startIndex < mbHostArr[ch].dataLen; startIndex++) - { - if(0x3A == mbHostArr[ch].dataBuf[startIndex]) { break; } - } - /* 起始符索引检查 */ - if((mbHostArr[ch].dataLen - startIndex - 1) < 10) - { - ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + _mb_host->rspTimeoutCnt = 0; + ret = RET_TIMEOUT; /* 应答超时 */ goto rspErr; } - /* 寻找结束符0x0D 0x0A */ - for(stopIndex = startIndex + 1; stopIndex < mbHostArr[ch].dataLen; stopIndex += 2) + /* 帧间隔超时判断 */ + if(_mb_host->curFrameIntv && _mb_host->curFrameIntv++ > _mb_host->targetFrameIntv) { - if(0x0D == mbHostArr[ch].dataBuf[stopIndex] && 0x0A == mbHostArr[ch].dataBuf[stopIndex + 1]) { break; } + _mb_host->curFrameIntv = 0; + _mb_host->state = MB_RX_BUSY; /* 切换状态 */ +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] recv raw data: ", ch); + for(uint16_t i = 0; i < _mb_host->dataLen; i++) + { + PRINT_LOG("%02X ", _mb_host->dataBuf[i]); + } + PRINT_LOG("\r\n"); +#endif } - /* 结束符索引检查 */ - if(stopIndex >= mbHostArr[ch].dataLen) + break; + case MB_RX_BUSY: + /* ASCII协议数据检查和转换 */ + if(MB_ASCII == _mb_host->protocol) { - ret = RET_FRAME_ERR; /* 应答数据格式错误 */ - goto rspErr; + /* 寻找起始符0x3A */ + for(startIndex = 0; startIndex < _mb_host->dataLen; startIndex++) + { + if(0x3A == _mb_host->dataBuf[startIndex]) { break; } + } + /* 起始符索引检查 */ + if((_mb_host->dataLen - startIndex - 1) < 10) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + /* 寻找结束符0x0D 0x0A */ + for(stopIndex = startIndex + 1; stopIndex < _mb_host->dataLen; stopIndex += 2) + { + if(0x0D == _mb_host->dataBuf[stopIndex] && 0x0A == _mb_host->dataBuf[stopIndex + 1]) { break; } + } + /* 结束符索引检查 */ + if(stopIndex >= _mb_host->dataLen) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + _mb_host->dataLen = stopIndex - startIndex - 1; + /* ASCII转HEX */ + mb_ascii_to_hex(&_mb_host->dataBuf[startIndex + 1], _mb_host->dataLen, &_mb_host->dataBuf[0]); + _mb_host->dataLen >>= 1; +#if _MBH_DEBUG + PRINT_LOG("modbus host[%d] convert data: ", ch); + for(uint16_t i = 0; i < _mb_host->dataLen; i++) + { + PRINT_LOG("%02X ", _mb_host->dataBuf[i]); + } + PRINT_LOG("\r\n"); +#endif } - mbHostArr[ch].dataLen = stopIndex - startIndex - 1; - /* ASCII转HEX */ - for(uint16_t cnt = 0; cnt < mbHostArr[ch].dataLen; cnt += 2) + /* 应答的从机地址与请求时不同 */ + if(_mb_host->dataBuf[0] != _mb_host->slaveTmp) { - mbHostArr[ch].dataBuf[cnt >> 1] = (ASCII_TO_HEX[mbHostArr[ch].dataBuf[cnt + startIndex + 1]] << 4) + ASCII_TO_HEX[mbHostArr[ch].dataBuf[cnt + startIndex + 2]]; + ret = RET_ING; /* 进行中 */ + goto rspErr; } - mbHostArr[ch].dataLen >>= 1; - } - /* 应答数据长度判断 */ - if(MBH_PDU_SIZE_MIN > mbHostArr[ch].dataLen) - { - ret = RET_LEN_ERR; /* 应答数据长度错误 */ - goto rspErr; - } - /* ASCII协议 */ - if(MBH_ASCII == mbHostArr[ch].protocol) - { - /* LRC校验判断 */ - checkVal = check_lrc(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen - 1); - if(checkVal != mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1]) + /* 应答数据长度判断 */ + if(MB_PDU_SIZE_MIN > _mb_host->dataLen) { - ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + ret = RET_LEN_ERR; /* 应答数据长度错误 */ goto rspErr; } - } /* RTU协议 */ - else - { - /* CRC校验判断 */ - checkVal = check_crc16_modbus(mbHostArr[ch].dataBuf, mbHostArr[ch].dataLen - 2); - if(checkVal != ((mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 2] << 8) | mbHostArr[ch].dataBuf[mbHostArr[ch].dataLen - 1])) + /* ASCII协议 */ + if(MB_ASCII == _mb_host->protocol) { - ret = RET_CHECK_ERR; /* 应答数据校验错误 */ - goto rspErr; + /* LRC校验判断 */ + checkVal = mb_check_lrc(&_mb_host->dataBuf[0], _mb_host->dataLen - 1); + if(checkVal != _mb_host->dataBuf[_mb_host->dataLen - 1]) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } + } /* RTU协议 */ + else + { + /* CRC校验判断 */ + checkVal = mb_check_crc16(&_mb_host->dataBuf[0], _mb_host->dataLen - 2); + if(checkVal != ((_mb_host->dataBuf[_mb_host->dataLen - 2] << 8) | _mb_host->dataBuf[_mb_host->dataLen - 1])) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } } - } - /* 应答处理 */ - mb_host_rspProcess(ch); - ret = RET_OK; /* 应答处理完成 */ + /* 应答处理 */ + mb_host_rspProcess(ch); + ret = RET_OK; /* 应答处理完成 */ rspErr: - mbHostArr[ch].state = MBH_TX_IDLE; /* 切换状态 */ + _mb_host->state = MB_TX_IDLE; /* 切换状态 */ + break; + default: break; } return ret; @@ -537,65 +536,60 @@ rspErr: */ uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend) { - ASSERT_PARAM(IS_VALID_CH(ch)); + mb_host_t *_mb_host = &mbHostArr[ch]; + + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); + + if(MB_TX_IDLE != _mb_host->state) { return RET_ERR; } + + _mb_host->slaveTmp = slaveAddr; + _mb_host->numTmp = num; + _mb_host->regTmp = reg; + if(slaveAddr) { _mb_host->broadcast = 0; } + else { _mb_host->broadcast = 1; } - if(MBH_TX_IDLE == mbHostArr[ch].state) + switch(funCode) { - mbHostArr[ch].slaveTmp = slaveAddr; - mbHostArr[ch].numTmp = num; - mbHostArr[ch].regTmp = reg; - if(slaveAddr) { mbHostArr[ch].broadcast = 0; } - else { mbHostArr[ch].broadcast = 1; } - - switch(funCode) - { - case 0x01: /* 读线圈命令 */ - case 0x02: /* 读离散量输入命令 */ - if(2000 >= num && num) - { - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x03: /* 读保持寄存器命令 */ - case 0x04: /* 读输入寄存器命令 */ - if(125 >= num && num) - { - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); - } - break; - case 0x05: /* 写单个线圈命令 */ - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); - break; - case 0x06: /* 写单个保持寄存器命令 */ - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); - break; - case 0x0F: /* 写多个线圈命令 */ - if(2000 >= num && num) - { - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_0fh(ch, slaveAddr, reg, num, (uint8_t *)extend); - } - break; - case 0x10: /* 写多个寄存器命令 */ - if(125 >= num && num) - { - mbHostArr[ch].state = MBH_TX_BUSY; /* 切换状态 */ - mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); - } - break; - /* - 用户在这里写其他功能码的发送处理 - */ - default: /* 不支持的命令 */ - break; - } + case 0x01: /* 读线圈命令 */ + case 0x02: /* 读离散量输入命令 */ + if(2000 >= num && num) + { + mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); + } + break; + case 0x03: /* 读保持寄存器命令 */ + case 0x04: /* 读输入寄存器命令 */ + if(125 >= num && num) + { + mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); + } + break; + case 0x05: /* 写单个线圈命令 */ + mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); + break; + case 0x06: /* 写单个保持寄存器命令 */ + mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); + break; + case 0x0F: /* 写多个线圈命令 */ + if(1920 >= num && num) + { + mb_host_cmd_0fh(ch, slaveAddr, reg, num, (uint8_t *)extend); + } + break; + case 0x10: /* 写多个寄存器命令 */ + if(120 >= num && num) + { + mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); + } + break; + /* + 用户在这里写其他功能码的发送处理 + */ + default: /* 不支持的命令 */ + break; } - return (mbHostArr[ch].state == MBH_TX_BUSY) ? RET_OK : RET_ERR; + return (_mb_host->state == MB_TX_BUSY) ? RET_OK : RET_ERR; } /** @@ -609,18 +603,18 @@ uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_ * * @param len : 写入长度byte * - * @retval uint8_t - * @arg RET_OK : 成功 - * @arg RET_ERR : 失败(状态不对或写入已满) + * @retval uint16_t + * @arg !0 : 成功写入的数据数量 + * @arg 0 : 失败(状态不对或写入已满) */ -uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) +uint16_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) { uint16_t unusedLen; - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - if(MBH_RX_IDLE == mbHostArr[ch].state) + if(MB_RX_IDLE == mbHostArr[ch].state) { unusedLen = mbHostArr[ch].dataBufLen - mbHostArr[ch].dataLen; len = (len > unusedLen) ? unusedLen : len; @@ -632,11 +626,11 @@ uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) mbHostArr[ch].curFrameIntv = 1; /* 开启帧间隔超时计数 */ mbHostArr[ch].rspTimeoutCnt = 0; /* 关闭应答超时计数 */ - return RET_OK; + return len; } } - return RET_ERR; + return 0; } /** @@ -650,47 +644,47 @@ uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) * * @param len : 读出长度byte * - * @retval uint8_t - * @arg RET_OK : 成功 - * @arg RET_ERR : 失败(状态不对或读出完毕) + * @retval uint16_t + * @arg !0 : 成功读出的数据数量 + * @arg 0 : 失败(状态不对或无数据可读) */ -uint8_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) +uint16_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) { - uint16_t unusedLen; + uint16_t unreadLen; - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); - if(MBH_TX_BUSY == mbHostArr[ch].state) + if(MB_TX_BUSY == mbHostArr[ch].state) { - unusedLen = mbHostArr[ch].dataLen - mbHostArr[ch].readLen; - len = (len > unusedLen) ? unusedLen : len; + unreadLen = mbHostArr[ch].dataLen - mbHostArr[ch].readLen; + len = (len > unreadLen) ? unreadLen : len; if(0 < len) { memcpy(pBuf, (void *)&mbHostArr[ch].dataBuf[mbHostArr[ch].readLen], len); mbHostArr[ch].readLen += len; - - return RET_OK; - } - else - { - mbHostArr[ch].dataLen = 0; - mbHostArr[ch].readLen = 0; - if(mbHostArr[ch].broadcast) - { - mbHostArr[ch].state = MBH_TX_IDLE; /* 切换状态 */ - } - else + if(0 >= (mbHostArr[ch].dataLen - mbHostArr[ch].readLen)) { - mbHostArr[ch].rspTimeoutCnt = 1; /* 开启应答超时计数 */ - mbHostArr[ch].state = MBH_RX_IDLE; /* 切换状态 */ + mbHostArr[ch].dataLen = 0; + mbHostArr[ch].readLen = 0; + if(mbHostArr[ch].broadcast) + { + mbHostArr[ch].state = MB_TX_IDLE; /* 切换状态 */ + } + else + { + mbHostArr[ch].rspTimeoutCnt = 1; /* 开启应答超时计数 */ + mbHostArr[ch].state = MB_RX_IDLE; /* 切换状态 */ + } } + + return len; } } mbHostArr[ch].txEnFn(0); /* 关闭发送 */ - return RET_ERR; + return 0; } /** @@ -698,18 +692,18 @@ uint8_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) * * @note 初始化后仍可修改,需保持通信协议与设定协议一致,不然无法解析成功 * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @param protocol : 协议类型 @ref modbus_host_protocol - * @arg MBH_RTU : RTU协议 - * @arg MBH_ASCII : ASCII协议 + * @param protocol : 协议类型 @ref modbus_common_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 * * @retval None */ void mb_host_set_protocol(uint8_t ch, uint8_t protocol) { - ASSERT_PARAM(IS_VALID_CH(ch)); - ASSERT_PARAM(IS_VALID_PROTOCOL(protocol)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); + ASSERT_PARAM(IS_VALID_MB_PROTOCOL(protocol)); mbHostArr[ch].protocol = protocol; } @@ -717,15 +711,15 @@ void mb_host_set_protocol(uint8_t ch, uint8_t protocol) /** * @brief 获取协议类型 * - * @param ch : modbus主机管理序号(即数组索引) + * @param ch : modbus主机管理序号(即数组索引) * - * @retval uint8_t : 协议类型 @ref modbus_host_protocol - * @arg MBH_RTU : RTU协议 - * @arg MBH_ASCII : ASCII协议 + * @retval uint8_t : 协议类型 @ref modbus_common_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 */ uint8_t mb_host_get_protocol(uint8_t ch) { - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); return mbHostArr[ch].protocol; } @@ -778,7 +772,7 @@ uint16_t mb_host_get_frame_intv(uint8_t ch) */ void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout) { - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); mbHostArr[ch].rspTimeout = (timeout < 10) ? 10 : timeout; } @@ -792,7 +786,7 @@ void mb_host_set_rsp_timeout(uint8_t ch, uint16_t timeout) */ uint16_t mb_host_get_rsp_timeout(uint8_t ch) { - ASSERT_PARAM(IS_VALID_CH(ch)); + ASSERT_PARAM(IS_VALID_MBH_CH(ch)); return mbHostArr[ch].rspTimeout; } @@ -818,12 +812,12 @@ __WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = (num + 7) >> 3; - PRINT_LOG("modbus host[%d] rsp01H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp01h> coilAddr:0x%x, coilNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { PRINT_LOG("%02X ", pData[i]); } - PRINT_LOG("\n"); + PRINT_LOG("\r\n"); #endif } @@ -848,12 +842,12 @@ __WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = (num + 7) >> 3; - PRINT_LOG("modbus host[%d] rsp02H> coilAddr:%04X, coilNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp02h> coilAddr:0x%x, coilNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { PRINT_LOG("%02X ", pData[i]); } - PRINT_LOG("\n"); + PRINT_LOG("\r\n"); #endif } @@ -878,12 +872,12 @@ __WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = num << 1; - PRINT_LOG("modbus host[%d] rsp03H> regAddr:%04X, regNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp03h> regAddr:0x%x, regNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { PRINT_LOG("%02X ", pData[i]); } - PRINT_LOG("\n"); + PRINT_LOG("\r\n"); #endif } @@ -908,12 +902,12 @@ __WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = num << 1; - PRINT_LOG("modbus host[%d] rsp04H> regAddr:%04X, regNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp04h> regAddr:0x%x, regNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { PRINT_LOG("%02X ", pData[i]); } - PRINT_LOG("\n"); + PRINT_LOG("\r\n"); #endif } @@ -930,7 +924,7 @@ __WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa __WEAK void mb_host_rsp_05_10h(uint8_t ch) { #if _MBH_DEBUG - PRINT_LOG("modbus host[%d] rsp05H_06H_0FH_10H> success\n", ch); + PRINT_LOG("modbus host[%d] rsp05h_06h_0fh_10h> success\r\n", ch); #endif } @@ -963,7 +957,7 @@ __WEAK void mb_host_rsp_err(uint8_t ch, uint8_t *pData) 11 - 专门用于modbus网关的响应,当从机无法响应时发送 */ #if _MBH_DEBUG - PRINT_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X\n", ch, pData[0], pData[1]); + PRINT_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X\r\n", ch, pData[0], pData[1]); #endif } diff --git a/drivers/modbus/modbus_host.h b/drivers/modbus/modbus_host.h index 4eb4b06..96190b5 100644 --- a/drivers/modbus/modbus_host.h +++ b/drivers/modbus/modbus_host.h @@ -1,16 +1,16 @@ /** ****************************************************************************** * @file modbus_host.h - * @author woshiashuai + * @author ashuai0110 * @version V2.1 - * @date 2023-10-17 + * @date 2023-10-19 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ @@ -23,7 +23,7 @@ extern "C" { #endif /* 包含头文件-----------------------------------------------------------------*/ -#include "common_include.h" +#include "modbus_common.h" /** * @addtogroup modbus @@ -41,32 +41,9 @@ extern "C" { * @{ */ -#define _MBH_DEBUG (0u) /*!< modbus主机调试信息打印开关 0:关闭 1:开启 */ +#define _MBH_DEBUG (0u) /*!< modbus主机调试信息打印开关 0:关闭 1:开启 */ -#define MBH_NUM (3u) /*!< modbus主机管理数量 用户根据需求自行修改 */ -#define MBH_BUF_SIZE_MAX (256u) /*!< modbus主机缓存区最大256byte 不可修改 */ - -/** - * @defgroup modbus_host_protocol modbus host protocol - * @{ - */ -#define MBH_RTU (0u) /*!< RTU协议 */ -#define MBH_ASCII (1u) /*!< ASCII协议 */ -/** - * @} - */ - -/** - * @defgroup modbus_host_state modbus host state - * @{ - */ -#define MBH_TX_IDLE (0u) /*!< 发送空闲状态-仅允许发送 */ -#define MBH_TX_BUSY (1u) /*!< 发送忙碌状态-禁止操作 */ -#define MBH_RX_IDLE (2u) /*!< 接收空闲状态-仅允许接收 */ -#define MBH_RX_BUSY (3u) /*!< 接收忙碌状态-禁止操作 */ -/** - * @} - */ +#define MBH_NUM (3u) /*!< modbus主机管理数量 用户根据需求自行修改 */ /** * @} @@ -78,17 +55,6 @@ extern "C" { * @{ */ -/** - * @brief 主机发送前(串口)准备函数 - * - * @note 如:使用串口中断发送时需使能发送相关中断/使用串口DMA发送时需配置使能DMA - * - * @param enState : 0-关闭(失能) 1-开启(使能) - * - * @retval None - */ -typedef void (* mb_host_tx_en_t)(uint8_t enState); - /** * @brief modbus主机 structure definition */ @@ -98,8 +64,8 @@ typedef struct mb_host { uint16_t dataLen; /*!< 数据长度 */ uint16_t readLen; /*!< 读出数据长度 */ - uint8_t protocol : 2; /*!< 协议类型 @ref modbus_host_protocol */ - uint8_t state : 2; /*!< 应答状态 @ref modbus_host_state */ + uint8_t protocol : 2; /*!< 协议类型 @ref modbus_common_protocol */ + uint8_t state : 2; /*!< 应答状态 @ref modbus_common_state */ uint8_t broadcast : 1; /*!< 广播标志 0:非广播 1:广播 */ uint16_t targetFrameIntv; /*!< 目标帧间隔ms */ @@ -110,7 +76,7 @@ typedef struct mb_host { uint16_t regTmp; /*!< 主机命令中的起始地址暂存 */ uint16_t numTmp; /*!< 主机命令中的数量暂存 */ - mb_host_tx_en_t txEnFn; /*!< 主机发送前(串口)准备函数 */ + modbus_tx_en_t txEnFn; /*!< 主机发送前(串口)准备函数 */ } mb_host_t; /** @@ -125,14 +91,14 @@ typedef struct mb_host { * @{ */ -void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, mb_host_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout); +void mb_host_init(uint8_t ch, uint8_t protocol, void *pBuf, uint16_t bufLen, modbus_tx_en_t txEnFn, uint32_t baud, uint16_t rspTimeout); uint8_t mb_host_poll(uint8_t ch); uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend); -uint8_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len); -uint8_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len); +uint16_t mb_host_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len); +uint16_t mb_host_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len); void mb_host_set_protocol(uint8_t ch, uint8_t protocol); uint8_t mb_host_get_protocol(uint8_t ch); diff --git a/drivers/modbus/modbus_slave.c b/drivers/modbus/modbus_slave.c index 7cefd85..9101c4c 100644 --- a/drivers/modbus/modbus_slave.c +++ b/drivers/modbus/modbus_slave.c @@ -1,37 +1,515 @@ /** ****************************************************************************** * @file modbus_slave.c - * @author woshiashuai - * @version V1.0 - * @date 2023-09-01 - * @brief modbus从机程序 + * @author ashuai0110 + * @version V2.1 + * @date 2023-10-19 + * @brief modbus从机程序(RTU ASCII) * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ /* 包含头文件-----------------------------------------------------------------*/ #include "modbus_slave.h" -#include "data_check.h" /* 私有宏定义-----------------------------------------------------------------*/ +/* modbus从机管理序号有效性检查 */ +#define IS_VALID_MBS_CH(x) \ +( ((x) == 0) || \ + ((x) > 0) && \ + ((x) < MBS_NUM)) /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ +static mb_slave_t mbSlaveArr[MBS_NUM]; /* modbus从机管理数组 */ /* 全局变量-------------------------------------------------------------------*/ /* 私有函数原型---------------------------------------------------------------*/ + +__WEAK void mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req01h> read coil status reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif +} + +__WEAK void mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req02h> read input status reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif +} + +__WEAK void mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req03h> read holding registers reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif +} + +__WEAK void mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req04h> read input registers reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif +} + +/** + * @brief 追加校验后发送 + * + * @param ch : modbus主机管理序号(即数组索引) + * + * @retval None + */ +static void mb_slave_send_with_check(uint8_t ch) +{ + mb_slave_t *_mb_slave = &mbSlaveArr[ch]; + uint16_t checkVal; + + /* ASCII协议 */ + if(MB_ASCII == _mb_slave->protocol) + { + /* 追加LRC校验结果 */ + checkVal = mb_check_lrc(_mb_slave->dataBuf, _mb_slave->dataLen); + _mb_slave->dataBuf[_mb_slave->dataLen++] = checkVal; + /* HEX转ASCII */ + mb_hex_to_ascii(&_mb_slave->dataBuf[0], _mb_slave->dataLen, &_mb_slave->dataBuf[0]); + _mb_slave->dataLen = (_mb_slave->dataLen << 1) + 3; + _mb_slave->dataBuf[0] = 0x3A; + _mb_slave->dataBuf[_mb_slave->dataLen - 2] = 0x0D; + _mb_slave->dataBuf[_mb_slave->dataLen - 1] = 0x0A; + } /* RTU协议 */ + else + { + /* 追加CRC校验结果 */ + checkVal = mb_check_crc16(_mb_slave->dataBuf, _mb_slave->dataLen); + _mb_slave->dataBuf[_mb_slave->dataLen++] = checkVal >> 8; + _mb_slave->dataBuf[_mb_slave->dataLen++] = checkVal; + } +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] send: ", ch); + for(uint16_t i = 0; i < _mb_slave->dataLen; i++) + { + PRINT_LOG("%02X ", _mb_slave->dataBuf[i]); + } + PRINT_LOG("\r\n"); +#endif + _mb_slave->state = MB_TX_BUSY; /* 切换状态 */ + _mb_slave->txEnFn(1); /* 开启发送 */ +} + /** - * @brief - * @param None + * @brief 主机请求处理 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @retval None + */ +static void mb_slave_reqProcess(uint8_t ch) +{ + mb_slave_t *_mb_slave = &mbSlaveArr[ch]; + uint16_t reg = (_mb_slave->dataBuf[MB_REG_ADDR_HI_OFF] << 8) | _mb_slave->dataBuf[MB_REG_ADDR_LO_OFF]; + uint16_t num = (_mb_slave->dataBuf[MB_NUM_HI_OFF] << 8) | _mb_slave->dataBuf[MB_NUM_LO_OFF]; + + switch(_mb_slave->dataBuf[MB_CODE_OFF]) + { + case 0x01: /* 读线圈请求处理 */ + mb_slave_req_01h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + _mb_slave->dataBuf[MB_RSP_BYTE_OFF] = (num + 7) >> 3; + _mb_slave->dataLen = 3 + _mb_slave->dataBuf[MB_RSP_BYTE_OFF]; + break; + case 0x02: /* 读离散量输入应答处理 */ + mb_slave_req_02h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + break; + case 0x03: /* 读保持寄存器应答处理 */ + mb_slave_req_03h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + break; + case 0x04: /* 读输入寄存器应答处理 */ + mb_slave_req_04h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + break; + case 0x05: + case 0x06: + case 0x0F: + case 0x10: /* 写命令应答处理 */ + default: break; + } + + mb_slave_send_with_check(ch); +} + + +/** + * @brief modbus从机初始化 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param slaveAddr : 从站地址 1~247 + * + * @param protocol : 协议类型 @ref modbus_slave_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 + * + * @param pBuf : 接收数据缓存区 + * + * @param bufLen : 接收数据缓存区长度 + * + * @param txEnFn : 从机发送前(串口)准备函数 + * + * @param baud : 波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0)) + * * @retval None */ +void mb_slave_init(uint8_t ch, uint8_t slaveAddr, uint8_t protocol, void *pBuf, uint16_t bufLen, modbus_tx_en_t txEnFn, uint32_t baud) +{ + mb_slave_t *_mb_slave = &mbSlaveArr[ch]; + + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_MB_PROTOCOL(protocol)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); + ASSERT_PARAM(IS_VALID_POINT(txEnFn)); + + _mb_slave->dataBuf = (uint8_t *)pBuf; + _mb_slave->dataBufLen = bufLen; + _mb_slave->dataLen = 0; + _mb_slave->readLen = 0; + + _mb_slave->slaveAddr = slaveAddr; + _mb_slave->protocol = protocol; + _mb_slave->state = MB_RX_IDLE; + + mb_slave_set_frame_intv(ch, baud); + _mb_slave->curFrameIntv = 0; + + _mb_slave->txEnFn = txEnFn; +} + +/** + * @brief modbus从机轮询处理 + * + * @note 轮询周期1ms + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @retval uint8_t + * @arg RET_OK : 处理完成 + * @arg RET_ING : 进行中 + * @arg RET_TIMEOUT : 超时 + * @arg RET_LEN_ERR : 数据长度错误 + * @arg RET_CHECK_ERR : 数据校验错误 + * @arg RET_FRAME_ERR : 数据格式错误 + */ +uint8_t mb_slave_poll(uint8_t ch) +{ + uint16_t checkVal, startIndex, stopIndex; + uint8_t ret = RET_ING; /* 进行中 */ + mb_slave_t *_mb_slave = &mbSlaveArr[ch]; + + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + + switch(_mb_slave->state) + { + case MB_TX_IDLE: break; + case MB_TX_BUSY: break; + case MB_RX_IDLE: + /* 帧间隔超时判断 */ + if(_mb_slave->curFrameIntv && _mb_slave->curFrameIntv++ > _mb_slave->targetFrameIntv) + { + _mb_slave->curFrameIntv = 0; + _mb_slave->state = MB_RX_BUSY; /* 切换状态 */ +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] recv raw data: ", ch); + for(uint16_t i = 0; i < _mb_slave->dataLen; i++) + { + PRINT_LOG("%02X ", _mb_slave->dataBuf[i]); + } + PRINT_LOG("\r\n"); +#endif + } + break; + case MB_RX_BUSY: + /* ASCII协议数据检查和转换 */ + if(MB_ASCII == _mb_slave->protocol) + { + /* 寻找起始符0x3A */ + for(startIndex = 0; startIndex < _mb_slave->dataLen; startIndex++) + { + if(0x3A == _mb_slave->dataBuf[startIndex]) { break; } + } + /* 起始符索引检查 */ + if((_mb_slave->dataLen - startIndex - 1) < 10) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + /* 寻找结束符0x0D 0x0A */ + for(stopIndex = startIndex + 1; stopIndex < _mb_slave->dataLen; stopIndex += 2) + { + if(0x0D == _mb_slave->dataBuf[stopIndex] && 0x0A == _mb_slave->dataBuf[stopIndex + 1]) { break; } + } + /* 结束符索引检查 */ + if(stopIndex >= _mb_slave->dataLen) + { + ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + goto rspErr; + } + _mb_slave->dataLen = stopIndex - startIndex - 1; + /* ASCII转HEX */ + mb_ascii_to_hex(&_mb_slave->dataBuf[startIndex + 1], _mb_slave->dataLen, &_mb_slave->dataBuf[0]); + _mb_slave->dataLen >>= 1; +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] convert data: ", ch); + for(uint16_t i = 0; i < _mb_slave->dataLen; i++) + { + PRINT_LOG("%02X ", _mb_slave->dataBuf[i]); + } + PRINT_LOG("\r\n"); +#endif + } + /* 请求的从机地址与本站地址不相同 */ + if(_mb_slave->dataBuf[0] != _mb_slave->slaveAddr) + { + ret = RET_ING; /* 进行中 */ + goto rspErr; + } + /* 应答数据长度判断 */ + if(MB_PDU_SIZE_MIN > _mb_slave->dataLen) + { + ret = RET_LEN_ERR; /* 应答数据长度错误 */ + goto rspErr; + } + /* ASCII协议 */ + if(MB_ASCII == _mb_slave->protocol) + { + /* LRC校验判断 */ + checkVal = mb_check_lrc(&_mb_slave->dataBuf[0], _mb_slave->dataLen - 1); + if(checkVal != _mb_slave->dataBuf[_mb_slave->dataLen - 1]) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } + } /* RTU协议 */ + else + { + /* CRC校验判断 */ + checkVal = mb_check_crc16(&_mb_slave->dataBuf[0], _mb_slave->dataLen - 2); + if(checkVal != ((_mb_slave->dataBuf[_mb_slave->dataLen - 2] << 8) | _mb_slave->dataBuf[_mb_slave->dataLen - 1])) + { + ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + goto rspErr; + } + } + _mb_slave->state = MB_TX_IDLE; /* 切换状态 */ + /* 请求处理 */ + mb_slave_reqProcess(ch); + ret = RET_OK; /* 请求处理完成 */ + break; + } + + return ret; + +rspErr: + _mb_slave->state = MB_RX_IDLE; /* 切换状态 */ + + return ret; +} + +/** + * @brief 写入数据到接收缓冲区 + * + * @note 一般加入到(串口)接收中断 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param pBuf : 数据缓存区 + * + * @param len : 写入长度byte + * + * @retval uint16_t + * @arg !0 : 成功写入的数据数量 + * @arg 0 : 失败(状态不对或写入已满) + */ +uint16_t mb_slave_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len) +{ + uint16_t unusedLen; + + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); + + if(MB_RX_IDLE == mbSlaveArr[ch].state) + { + unusedLen = mbSlaveArr[ch].dataBufLen - mbSlaveArr[ch].dataLen; + len = (len > unusedLen) ? unusedLen : len; + + if(0 < len) + { + memcpy((void *)&mbSlaveArr[ch].dataBuf[mbSlaveArr[ch].dataLen], pBuf, len); + mbSlaveArr[ch].dataLen += len; + mbSlaveArr[ch].curFrameIntv = 1; /* 开启帧间隔超时计数 */ + + return len; + } + } + + return 0; +} +/** + * @brief 读出数据从发送缓冲区 + * + * @note 一般加入到(串口)发送中断 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param pBuf : 数据存储区 + * + * @param len : 读出长度byte + * + * @retval uint16_t + * @arg !0 : 成功读出的数据数量 + * @arg 0 : 失败(状态不对或无数据可读) + */ +uint16_t mb_slave_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) +{ + uint16_t unreadLen; + + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_POINT(pBuf)); + + if(MB_TX_BUSY == mbSlaveArr[ch].state) + { + unreadLen = mbSlaveArr[ch].dataLen - mbSlaveArr[ch].readLen; + len = (len > unreadLen) ? unreadLen : len; + + if(0 < len) + { + memcpy(pBuf, (void *)&mbSlaveArr[ch].dataBuf[mbSlaveArr[ch].readLen], len); + mbSlaveArr[ch].readLen += len; + if(0 >= (mbSlaveArr[ch].dataLen - mbSlaveArr[ch].readLen)) + { + mbSlaveArr[ch].dataLen = 0; + mbSlaveArr[ch].readLen = 0; + mbSlaveArr[ch].state = MB_RX_IDLE; /* 切换状态 */ + } + + return len; + } + } + mbSlaveArr[ch].txEnFn(0); /* 关闭发送 */ + + return 0; +} + +/** + * @brief 设置从站地址 + * + * @note 初始化后仍可修改,通信进行中切勿修改 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param slaveAddr : 从站地址 1~247 + * + * @retval None + */ +void mb_slave_set_slave_addr(uint8_t ch, uint8_t slaveAddr) +{ + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + + mbSlaveArr[ch].slaveAddr = slaveAddr; +} + +/** + * @brief 获取从站地址 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @retval 从站地址 + */ +uint8_t mb_slave_get_slave_addr(uint8_t ch) +{ + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + + return mbSlaveArr[ch].slaveAddr; +} + +/** + * @brief 设置协议类型 + * + * @note 初始化后仍可修改,需保持通信协议与设定协议一致,不然无法解析成功 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param protocol : 协议类型 @ref modbus_common_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 + * + * @retval None + */ +void mb_slave_set_protocol(uint8_t ch, uint8_t protocol) +{ + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_MB_PROTOCOL(protocol)); + + mbSlaveArr[ch].protocol = protocol; +} + +/** + * @brief 获取协议类型 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @retval uint8_t : 协议类型 @ref modbus_common_protocol + * @arg MB_RTU : RTU协议 + * @arg MB_ASCII : ASCII协议 + */ +uint8_t mb_slave_get_protocol(uint8_t ch) +{ + ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + + return mbSlaveArr[ch].protocol; +} + +/** + * @brief 设置帧间隔超时时间 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param baud : 波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0) + * + * @retval None + */ +void mb_slave_set_frame_intv(uint8_t ch, uint32_t baud) +{ + if(9600 < baud) + { + mbSlaveArr[ch].targetFrameIntv = 3; + } + else if(0 == baud) + { + mbSlaveArr[ch].targetFrameIntv = 0; + } + else + { + mbSlaveArr[ch].targetFrameIntv = 10000 / baud * 3.5; + } +} + +/** + * @brief 获取帧间隔超时时间 + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @retval 帧间隔超时时间ms + */ +uint16_t mb_slave_get_frame_intv(uint8_t ch) +{ + return mbSlaveArr[ch].targetFrameIntv; +} diff --git a/drivers/modbus/modbus_slave.h b/drivers/modbus/modbus_slave.h index 0c0db09..d27065e 100644 --- a/drivers/modbus/modbus_slave.h +++ b/drivers/modbus/modbus_slave.h @@ -1,16 +1,16 @@ /** ****************************************************************************** * @file modbus_slave.h - * @author woshiashuai - * @version V1.0 - * @date 2023-09-01 - * @brief modbus从机程序 + * @author ashuai0110 + * @version V2.1 + * @date 2023-10-19 + * @brief modbus从机程序(RTU ASCII) * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ @@ -23,16 +23,102 @@ extern "C" { #endif /* 包含头文件-----------------------------------------------------------------*/ -#include "common_include.h" +#include "modbus_common.h" + +/** + * @addtogroup modbus + * @{ + */ + +/** + * @addtogroup modbus_slave + * @{ + */ /* 宏定义---------------------------------------------------------------------*/ +/** + * @defgroup modbus_slave_global_macros modbus slave global macros + * @{ + */ + +#define _MBS_DEBUG (1u) /*!< modbus从机调试信息打印开关 0:关闭 1:开启 */ + +#define MBS_NUM (3u) /*!< modbus从机管理数量 用户根据需求自行修改 */ + +/** + * @} + */ /* 类型定义-------------------------------------------------------------------*/ +/** + * @defgroup modbus_slave_global_types modbus slave global types + * @{ + */ + +/** + * @brief modbus从机 structure definition + */ +typedef struct mb_slave { + uint8_t *dataBuf; /*!< 数据缓存区 */ + uint16_t dataBufLen; /*!< 数据缓存区长度 */ + uint16_t dataLen; /*!< 数据长度 */ + uint16_t readLen; /*!< 读出数据长度 */ + + uint8_t slaveAddr; /*!< 从机地址 1~247 */ + uint8_t protocol : 2; /*!< 协议类型 @ref modbus_slave_protocol */ + uint8_t state : 2; /*!< 应答状态 @ref modbus_slave_state */ + + uint16_t targetFrameIntv; /*!< 目标帧间隔ms */ + uint16_t curFrameIntv; /*!< 当前帧间隔ms */ + uint16_t regTmp; /*!< 从机命令中的起始地址暂存 */ + uint16_t numTmp; /*!< 从机命令中的数量暂存 */ + + modbus_tx_en_t txEnFn; /*!< 从机发送前(串口)准备函数 */ +} mb_slave_t; + +/** + * @} + */ /* 全局变量-------------------------------------------------------------------*/ /* 函数原型-------------------------------------------------------------------*/ +/** + * @addtogroup modbus_slave_global_functions + * @{ + */ + +void mb_slave_init(uint8_t ch, uint8_t slaveAddr, uint8_t protocol, void *pBuf, uint16_t bufLen, modbus_tx_en_t txEnFn, uint32_t baud); + +uint8_t mb_slave_poll(uint8_t ch); + +uint16_t mb_slave_write_rx_buf(uint8_t ch, void *pBuf, uint16_t len); +uint16_t mb_slave_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len); + +void mb_slave_set_slave_addr(uint8_t ch, uint8_t slaveAddr); +uint8_t mb_slave_get_slave_addr(uint8_t ch); +void mb_slave_set_protocol(uint8_t ch, uint8_t protocol); +uint8_t mb_slave_get_protocol(uint8_t ch); +void mb_slave_set_frame_intv(uint8_t ch, uint32_t baud); +uint16_t mb_slave_get_frame_intv(uint8_t ch); +/* 弱定义函数 */ +void mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +void mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ #ifdef __cplusplus } diff --git a/drivers/modules/command_line.c b/drivers/modules/command_line.c index cf784dc..045ede4 100644 --- a/drivers/modules/command_line.c +++ b/drivers/modules/command_line.c @@ -11,8 +11,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/command_line.h b/drivers/modules/command_line.h index 2272125..1c5ae3c 100644 --- a/drivers/modules/command_line.h +++ b/drivers/modules/command_line.h @@ -11,8 +11,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/data_check.c b/drivers/modules/data_check.c index 895f213..5aa3476 100644 --- a/drivers/modules/data_check.c +++ b/drivers/modules/data_check.c @@ -4,12 +4,12 @@ * @author ashuai0110 * @version V2.1 * @date 2023-10-17 - * @brief 数据校验 + * @brief 数据校验方法集合 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** diff --git a/drivers/modules/data_check.h b/drivers/modules/data_check.h index e73264f..f437b82 100644 --- a/drivers/modules/data_check.h +++ b/drivers/modules/data_check.h @@ -4,12 +4,12 @@ * @author ashuai0110 * @version V2.1 * @date 2023-10-17 - * @brief 数据校验 + * @brief 数据校验方法集合 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** diff --git a/drivers/modules/data_convert.c b/drivers/modules/data_convert.c index 3204244..caa2929 100644 --- a/drivers/modules/data_convert.c +++ b/drivers/modules/data_convert.c @@ -4,13 +4,13 @@ * @author ashuai0110 * @version V2.1 * @date 2023-09-19 - * @brief 数据转换 + * @brief 数据转换方法集合 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/data_convert.h b/drivers/modules/data_convert.h index 560862e..0bd639d 100644 --- a/drivers/modules/data_convert.h +++ b/drivers/modules/data_convert.h @@ -4,13 +4,13 @@ * @author ashuai0110 * @version V2.1 * @date 2023-09-19 - * @brief 数据转换 + * @brief 数据转换方法集合 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/delay_no_block.c b/drivers/modules/delay_no_block.c index 4154caf..d3256c2 100644 --- a/drivers/modules/delay_no_block.c +++ b/drivers/modules/delay_no_block.c @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/delay_no_block.h b/drivers/modules/delay_no_block.h index b97b5a0..0f459d1 100644 --- a/drivers/modules/delay_no_block.h +++ b/drivers/modules/delay_no_block.h @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/input_output.c b/drivers/modules/input_output.c index 6dfb558..0863300 100644 --- a/drivers/modules/input_output.c +++ b/drivers/modules/input_output.c @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/input_output.h b/drivers/modules/input_output.h index 3df9939..49aa355 100644 --- a/drivers/modules/input_output.h +++ b/drivers/modules/input_output.h @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/memory.c b/drivers/modules/memory.c index 8427db9..276c8c9 100644 --- a/drivers/modules/memory.c +++ b/drivers/modules/memory.c @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/memory.h b/drivers/modules/memory.h index ab20f7d..4ffc255 100644 --- a/drivers/modules/memory.h +++ b/drivers/modules/memory.h @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/message_queue.c b/drivers/modules/message_queue.c index 6440655..1a654e2 100644 --- a/drivers/modules/message_queue.c +++ b/drivers/modules/message_queue.c @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/message_queue.h b/drivers/modules/message_queue.h index 597be5d..71d063a 100644 --- a/drivers/modules/message_queue.h +++ b/drivers/modules/message_queue.h @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/ring_buffer.c b/drivers/modules/ring_buffer.c index 6922b12..8ea4306 100644 --- a/drivers/modules/ring_buffer.c +++ b/drivers/modules/ring_buffer.c @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/ring_buffer.h b/drivers/modules/ring_buffer.h index 10d0487..b30a27a 100644 --- a/drivers/modules/ring_buffer.h +++ b/drivers/modules/ring_buffer.h @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/ring_queue.c b/drivers/modules/ring_queue.c index 2d0a777..e59a653 100644 --- a/drivers/modules/ring_queue.c +++ b/drivers/modules/ring_queue.c @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * * @example * diff --git a/drivers/modules/ring_queue.h b/drivers/modules/ring_queue.h index 0ef0b97..db4eeec 100644 --- a/drivers/modules/ring_queue.h +++ b/drivers/modules/ring_queue.h @@ -10,8 +10,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * * @example * diff --git a/drivers/modules/sync_method.c b/drivers/modules/sync_method.c index 23f76df..6814821 100644 --- a/drivers/modules/sync_method.c +++ b/drivers/modules/sync_method.c @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/sync_method.h b/drivers/modules/sync_method.h index 040544b..aee6268 100644 --- a/drivers/modules/sync_method.h +++ b/drivers/modules/sync_method.h @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/timer_software.c b/drivers/modules/timer_software.c index 018ffb7..ec94dbb 100644 --- a/drivers/modules/timer_software.c +++ b/drivers/modules/timer_software.c @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/timer_software.h b/drivers/modules/timer_software.h index 9f93062..6271d49 100644 --- a/drivers/modules/timer_software.h +++ b/drivers/modules/timer_software.h @@ -9,8 +9,8 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 - * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module.git * ****************************************************************************** */ diff --git a/drivers/modules/uart_handler.c b/drivers/modules/uart_handler.c index 38905f7..c2f0b59 100644 --- a/drivers/modules/uart_handler.c +++ b/drivers/modules/uart_handler.c @@ -10,7 +10,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** @@ -90,7 +90,7 @@ static uart_handler_t uartHandlerArr[UART_HANDLER_NUM]; /*!< 串口管理数组 * * @param txEnFn : 串口发送前准备函数 * - * @param baud : 串口波特率 + * @param baud : 串口波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0) * * @param timeout : 接收超时时间ms(无需求可忽略) * @@ -106,8 +106,7 @@ void uart_hr_init(uint8_t ch, void *txBuf, uint32_t txLen, void *rxBuf, uint32_t ring_queue_init(&uartHandlerArr[ch].txRingQueue, txBuf, txLen); ring_queue_init(&uartHandlerArr[ch].rxRingQueue, rxBuf, rxLen); uartHandlerArr[ch].uartTxEnFn = txEnFn; - if(9600 <= baud) { uartHandlerArr[ch].targetFrameIntv = 3; } - else { uartHandlerArr[ch].targetFrameIntv = 10000 / baud * 3.5; } + uart_hr_set_frame_intv(ch, baud); uartHandlerArr[ch].recTimeout = timeout; } @@ -256,18 +255,40 @@ uint32_t uart_hr_write_tx_buf(uint8_t ch, void *pBuf, uint32_t len) } /** - * @brief 设置串口管理帧间隔 + * @brief 设置串口管理帧间隔超时时间 * * @param ch : 串口管理序号(即数组索引) * - * @param baud : 波特率 + * @param baud : 波特率(内部转换为帧间隔超时时间,填0则帧间隔超时时间为0) * * @retval None */ void uart_hr_set_frame_intv(uint8_t ch, uint32_t baud) { - if(9600 <= baud) { uartHandlerArr[ch].targetFrameIntv = 3; } - else { uartHandlerArr[ch].targetFrameIntv = 10000 / baud * 3.5; } + if(9600 < baud) + { + uartHandlerArr[ch].targetFrameIntv = 3; + } + else if(0 == baud) + { + uartHandlerArr[ch].targetFrameIntv = 0; + } + else + { + uartHandlerArr[ch].targetFrameIntv = 10000 / baud * 3.5; + } +} + +/** + * @brief 获取串口管理帧间隔超时时间 + * + * @param ch : 串口管理序号(即数组索引) + * + * @retval 帧间隔超时时间ms + */ +uint16_t uart_hr_get_frame_intv(uint8_t ch) +{ + return uartHandlerArr[ch].targetFrameIntv; } /** @@ -284,6 +305,18 @@ void uart_hr_set_rec_timeout(uint8_t ch, uint16_t timeout) uartHandlerArr[ch].recTimeout = timeout; } +/** + * @brief 获取串口管理接收超时时间 + * + * @param ch : 串口管理序号(即数组索引) + * + * @retval 串口管理接收超时时间 + */ +uint16_t uart_hr_get_rec_timeout(uint8_t ch) +{ + return uartHandlerArr[ch].recTimeout; +} + /** * @} */ diff --git a/drivers/modules/uart_handler.h b/drivers/modules/uart_handler.h index ca50fe6..4d47b0b 100644 --- a/drivers/modules/uart_handler.h +++ b/drivers/modules/uart_handler.h @@ -10,7 +10,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/woshiashuai/mcu_development_module.git * ****************************************************************************** @@ -102,7 +102,9 @@ uint32_t uart_hr_read_tx_buf(uint8_t ch, void *pBuf, uint32_t len); uint32_t uart_hr_write_tx_buf(uint8_t ch, void *pBuf, uint32_t len); void uart_hr_set_frame_intv(uint8_t ch, uint32_t baud); +uint16_t uart_hr_get_frame_intv(uint8_t ch); void uart_hr_set_rec_timeout(uint8_t ch, uint16_t timeout); +uint16_t uart_hr_get_rec_timeout(uint8_t ch); /** * @} diff --git a/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf b/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf deleted file mode 100644 index 66e10b6..0000000 --- a/examples/command_line/MDK/DebugConfig/Target_1_STM32F103C8_1.0.0.dbgconf +++ /dev/null @@ -1,36 +0,0 @@ -// File: STM32F101_102_103_105_107.dbgconf -// Version: 1.0.0 -// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008) -// STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets - -// <<< Use Configuration Wizard in Context Menu >>> - -// Debug MCU configuration register (DBGMCU_CR) -// Reserved bits must be kept at reset value -// DBG_TIM11_STOP TIM11 counter stopped when core is halted -// DBG_TIM10_STOP TIM10 counter stopped when core is halted -// DBG_TIM9_STOP TIM9 counter stopped when core is halted -// DBG_TIM14_STOP TIM14 counter stopped when core is halted -// DBG_TIM13_STOP TIM13 counter stopped when core is halted -// DBG_TIM12_STOP TIM12 counter stopped when core is halted -// DBG_CAN2_STOP Debug CAN2 stopped when core is halted -// DBG_TIM7_STOP TIM7 counter stopped when core is halted -// DBG_TIM6_STOP TIM6 counter stopped when core is halted -// DBG_TIM5_STOP TIM5 counter stopped when core is halted -// DBG_TIM8_STOP TIM8 counter stopped when core is halted -// DBG_I2C2_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted -// DBG_I2C1_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted -// DBG_CAN1_STOP Debug CAN1 stopped when Core is halted -// DBG_TIM4_STOP TIM4 counter stopped when core is halted -// DBG_TIM3_STOP TIM3 counter stopped when core is halted -// DBG_TIM2_STOP TIM2 counter stopped when core is halted -// DBG_TIM1_STOP TIM1 counter stopped when core is halted -// DBG_WWDG_STOP Debug window watchdog stopped when core is halted -// DBG_IWDG_STOP Debug independent watchdog stopped when core is halted -// DBG_STANDBY Debug standby mode -// DBG_STOP Debug stop mode -// DBG_SLEEP Debug sleep mode -// -DbgMCU_CR = 0x00000007; - -// <<< end of configuration section >>> diff --git a/examples/command_line/MDK/use_example.uvguix.yansj b/examples/command_line/MDK/use_example.uvguix.yansj deleted file mode 100644 index 2aea7a8..0000000 --- a/examples/command_line/MDK/use_example.uvguix.yansj +++ /dev/null @@ -1,1878 +0,0 @@ - - - - -6.1 - -
### uVision Project, (C) Keil Software
- - - - - - - - - - 38003 - Registers - 140 90 - - - 346 - Code Coverage - 1010 160 - - - 204 - Performance Analyzer - 1170 - - - - - - 35141 - Event Statistics - - 200 50 700 - - - 1506 - Symbols - - 80 80 80 - - - 1936 - Watch 1 - - 200 133 133 - - - 1937 - Watch 2 - - 200 133 133 - - - 1935 - Call Stack + Locals - - 200 133 133 - - - 2506 - Trace Data - - 75 135 130 95 70 230 200 150 - - - 466 - Source Browser - 500 - 300 - - - - - - - - 1 - 1 - 0 - 0 - -1 - - - - - - - 44 - 2 - 3 - - -1 - -1 - - - -1 - -1 - - - -6 - 42 - 1139 - 610 - - - - 0 - - 312 - 0100000004000000010000000100000001000000010000000000000002000000000000000100000001000000000000002800000028000000010000000100000000000000010000006C443A5C415350726F6A6563745C6D637550726F6A6563745C6D63755F646576656C6F706D656E745F74656D706C6174655C6D63755F72657573655F646576656C6F706D656E745F6D6F64756C655C647269766572735C6D6F64756C65735C636F6D6D616E645F6C696E652E63000000000E636F6D6D616E645F6C696E652E6300000000C5D4F200FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F4000000660000008007000063030000 - - - - 0 - Build - - -1 - -1 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F40000004F00000090050000DD000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1005 - 1005 - 1 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 0300000066000000ED00000033030000 - - - 16 - 22000000390000001201000002010000 - - - - 109 - 109 - 1 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 0300000066000000ED00000033030000 - - - 16 - 22000000390000003E01000075020000 - - - - 1465 - 1465 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 000000002902000090050000B7020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1466 - 1466 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1467 - 1467 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1468 - 1468 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1506 - 1506 - 0 - 0 - 0 - 0 - 32767 - 0 - 16384 - 0 - - 16 - A3040000660000008D050000FF000000 - - - 16 - 22000000390000001201000002010000 - - - - 1913 - 1913 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1935 - 1935 - 0 - 0 - 0 - 0 - 32767 - 0 - 32768 - 0 - - 16 - 030000002C0200008D0500009E020000 - - - 16 - 22000000390000001201000002010000 - - - - 1936 - 1936 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 22000000390000001201000002010000 - - - - 1937 - 1937 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 22000000390000001201000002010000 - - - - 1939 - 1939 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1940 - 1940 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1941 - 1941 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 1942 - 1942 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 195 - 195 - 1 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 0300000066000000ED00000033030000 - - - 16 - 22000000390000003E01000075020000 - - - - 196 - 196 - 1 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 0300000066000000ED00000033030000 - - - 16 - 22000000390000003E01000075020000 - - - - 197 - 197 - 1 - 0 - 0 - 0 - 32767 - 0 - 32768 - 0 - - 16 - 000000006403000080070000DE030000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 198 - 198 - 0 - 0 - 0 - 0 - 32767 - 0 - 32768 - 0 - - 16 - 000000001502000090050000B7020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 199 - 199 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 03000000670300008D050000C5030000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 203 - 203 - 0 - 0 - 0 - 0 - 32767 - 0 - 8192 - 0 - - 16 - F40000006300000090050000DD000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 204 - 204 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 221 - 221 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 00000000000000000000000000000000 - - - 16 - 0A0000000A0000006E0000006E000000 - - - - 2506 - 2506 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A0040000630000009005000025020000 - - - 16 - 22000000390000001201000002010000 - - - - 2507 - 2507 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 000000002902000090050000A3020000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 343 - 343 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 346 - 346 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 35141 - 35141 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F40000006300000090050000DD000000 - - - 16 - 22000000390000001201000002010000 - - - - 35824 - 35824 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 35885 - 35885 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35886 - 35886 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35887 - 35887 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35888 - 35888 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35889 - 35889 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35890 - 35890 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35891 - 35891 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35892 - 35892 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35893 - 35893 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35894 - 35894 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35895 - 35895 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35896 - 35896 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35897 - 35897 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35898 - 35898 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35899 - 35899 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35900 - 35900 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35901 - 35901 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35902 - 35902 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35903 - 35903 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35904 - 35904 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 35905 - 35905 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 38003 - 38003 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 0300000066000000ED0000009E020000 - - - 16 - 22000000390000003E01000075020000 - - - - 38007 - 38007 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 000000006403000090050000DE030000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 436 - 436 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 03000000670300008D050000C5030000 - - - 16 - 22000000390000003E01000075020000 - - - - 437 - 437 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 22000000390000001201000002010000 - - - - 440 - 440 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 22000000390000001201000002010000 - - - - 463 - 463 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 03000000670300008D050000C5030000 - - - 16 - 22000000390000003E01000075020000 - - - - 466 - 466 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 03000000670300008D050000C5030000 - - - 16 - 22000000390000003E01000075020000 - - - - 470 - 470 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - F7000000660000008D050000C4000000 - - - 16 - 2200000039000000EA020000C7000000 - - - - 50000 - 50000 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50001 - 50001 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50002 - 50002 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50003 - 50003 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50004 - 50004 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50005 - 50005 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50006 - 50006 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50007 - 50007 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50008 - 50008 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50009 - 50009 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50010 - 50010 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50011 - 50011 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50012 - 50012 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50013 - 50013 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50014 - 50014 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50015 - 50015 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50016 - 50016 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50017 - 50017 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50018 - 50018 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 50019 - 50019 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - A3040000660000008D0500007A010000 - - - 16 - 22000000390000001201000002010000 - - - - 59392 - 59392 - 1 - 0 - 0 - 0 - 32767 - 0 - 8192 - 0 - - 16 - 0000000000000000D10300001C000000 - - - 16 - 0A0000000A0000006E0000006E000000 - - - - 59393 - 0 - 1 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 00000000DE03000080070000F1030000 - - - 16 - 0A0000000A0000006E0000006E000000 - - - - 59399 - 59399 - 1 - 0 - 0 - 0 - 32767 - 0 - 8192 - 1 - - 16 - 000000001C000000E701000038000000 - - - 16 - 0A0000000A0000006E0000006E000000 - - - - 59400 - 59400 - 0 - 0 - 0 - 0 - 32767 - 0 - 8192 - 2 - - 16 - 00000000380000006F02000054000000 - - - 16 - 0A0000000A0000006E0000006E000000 - - - - 824 - 824 - 0 - 0 - 0 - 0 - 32767 - 0 - 4096 - 0 - - 16 - 030000002C0200008D0500008A020000 - - - 16 - 22000000390000001201000002010000 - - - - 3312 - 000000000B000000000000000020000000000000FFFFFFFFFFFFFFFFF4000000DD00000090050000E1000000000000000100001004000000010000000000000000000000FFFFFFFF08000000CB00000057010000CC000000F08B00005A01000079070000D601000045890000FFFF02000B004354616262656450616E6500200000000000002200000039000000EA020000C7000000F40000004F00000090050000DD0000000000000040280046080000000B446973617373656D626C7900000000CB00000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A6572000000005701000001000000FFFFFFFFFFFFFFFF14506572666F726D616E636520416E616C797A657200000000CC00000001000000FFFFFFFFFFFFFFFF0E4C6F67696320416E616C797A657200000000F08B000001000000FFFFFFFFFFFFFFFF0D436F646520436F766572616765000000005A01000001000000FFFFFFFFFFFFFFFF11496E737472756374696F6E205472616365000000007907000001000000FFFFFFFFFFFFFFFF0F53797374656D20416E616C797A657200000000D601000001000000FFFFFFFFFFFFFFFF104576656E742053746174697374696373000000004589000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFCB00000001000000FFFFFFFFCB000000000000000040000000000000FFFFFFFFFFFFFFFF9C0400004F000000A004000025020000000000000200001004000000010000000000000000000000FFFFFFFF2B000000E2050000CA0900002D8C00002E8C00002F8C0000308C0000318C0000328C0000338C0000348C0000358C0000368C0000378C0000388C0000398C00003A8C00003B8C00003C8C00003D8C00003E8C00003F8C0000408C0000418C000050C3000051C3000052C3000053C3000054C3000055C3000056C3000057C3000058C3000059C300005AC300005BC300005CC300005DC300005EC300005FC3000060C3000061C3000062C3000063C300000180004000000000000022000000390000001201000002010000A00400004F000000900500002502000000000000404100462B0000000753796D626F6C7300000000E205000001000000FFFFFFFFFFFFFFFF0A5472616365204461746100000000CA09000001000000FFFFFFFFFFFFFFFF00000000002D8C000001000000FFFFFFFFFFFFFFFF00000000002E8C000001000000FFFFFFFFFFFFFFFF00000000002F8C000001000000FFFFFFFFFFFFFFFF0000000000308C000001000000FFFFFFFFFFFFFFFF0000000000318C000001000000FFFFFFFFFFFFFFFF0000000000328C000001000000FFFFFFFFFFFFFFFF0000000000338C000001000000FFFFFFFFFFFFFFFF0000000000348C000001000000FFFFFFFFFFFFFFFF0000000000358C000001000000FFFFFFFFFFFFFFFF0000000000368C000001000000FFFFFFFFFFFFFFFF0000000000378C000001000000FFFFFFFFFFFFFFFF0000000000388C000001000000FFFFFFFFFFFFFFFF0000000000398C000001000000FFFFFFFFFFFFFFFF00000000003A8C000001000000FFFFFFFFFFFFFFFF00000000003B8C000001000000FFFFFFFFFFFFFFFF00000000003C8C000001000000FFFFFFFFFFFFFFFF00000000003D8C000001000000FFFFFFFFFFFFFFFF00000000003E8C000001000000FFFFFFFFFFFFFFFF00000000003F8C000001000000FFFFFFFFFFFFFFFF0000000000408C000001000000FFFFFFFFFFFFFFFF0000000000418C000001000000FFFFFFFFFFFFFFFF000000000050C3000001000000FFFFFFFFFFFFFFFF000000000051C3000001000000FFFFFFFFFFFFFFFF000000000052C3000001000000FFFFFFFFFFFFFFFF000000000053C3000001000000FFFFFFFFFFFFFFFF000000000054C3000001000000FFFFFFFFFFFFFFFF000000000055C3000001000000FFFFFFFFFFFFFFFF000000000056C3000001000000FFFFFFFFFFFFFFFF000000000057C3000001000000FFFFFFFFFFFFFFFF000000000058C3000001000000FFFFFFFFFFFFFFFF000000000059C3000001000000FFFFFFFFFFFFFFFF00000000005AC3000001000000FFFFFFFFFFFFFFFF00000000005BC3000001000000FFFFFFFFFFFFFFFF00000000005CC3000001000000FFFFFFFFFFFFFFFF00000000005DC3000001000000FFFFFFFFFFFFFFFF00000000005EC3000001000000FFFFFFFFFFFFFFFF00000000005FC3000001000000FFFFFFFFFFFFFFFF000000000060C3000001000000FFFFFFFFFFFFFFFF000000000061C3000001000000FFFFFFFFFFFFFFFF000000000062C3000001000000FFFFFFFFFFFFFFFF000000000063C3000001000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000000000001000000FFFFFFFFE205000001000000FFFFFFFFE2050000000000000010000001000000FFFFFFFFFFFFFFFFF00000004F000000F40000004C030000010000000200001004000000010000000000000000000000FFFFFFFF05000000ED0300006D000000C3000000C4000000739400000180001000000100000022000000390000001201000002010000000000004F000000F00000004C0300000000000040410056050000000750726F6A65637401000000ED03000001000000FFFFFFFFFFFFFFFF05426F6F6B73010000006D00000001000000FFFFFFFFFFFFFFFF0946756E6374696F6E7301000000C300000001000000FFFFFFFFFFFFFFFF0954656D706C6174657301000000C400000001000000FFFFFFFFFFFFFFFF09526567697374657273000000007394000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFED03000001000000FFFFFFFFED030000000000000080000000000000FFFFFFFFFFFFFFFF0000000011020000900500001502000000000000010000100400000001000000000000000000000000000000000000000000000001000000C6000000FFFFFFFF0F0000008F070000930700009407000095070000960700009007000091070000B5010000B801000038030000B9050000BA050000BB050000BC050000CB0900000180008000000000000022000000390000001201000002010000000000001502000090050000B702000000000000404100460F0000001343616C6C20537461636B202B204C6F63616C73000000008F07000001000000FFFFFFFFFFFFFFFF0755415254202331000000009307000001000000FFFFFFFFFFFFFFFF0755415254202332000000009407000001000000FFFFFFFFFFFFFFFF0755415254202333000000009507000001000000FFFFFFFFFFFFFFFF15446562756720287072696E74662920566965776572000000009607000001000000FFFFFFFFFFFFFFFF0757617463682031000000009007000001000000FFFFFFFFFFFFFFFF0757617463682032000000009107000001000000FFFFFFFFFFFFFFFF10547261636520457863657074696F6E7300000000B501000001000000FFFFFFFFFFFFFFFF0E4576656E7420436F756E7465727300000000B801000001000000FFFFFFFFFFFFFFFF09554C494E4B706C7573000000003803000001000000FFFFFFFFFFFFFFFF084D656D6F7279203100000000B905000001000000FFFFFFFFFFFFFFFF084D656D6F7279203200000000BA05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203300000000BB05000001000000FFFFFFFFFFFFFFFF084D656D6F7279203400000000BC05000001000000FFFFFFFFFFFFFFFF105472616365204E617669676174696F6E00000000CB09000001000000FFFFFFFFFFFFFFFFFFFFFFFF0000000001000000000000000000000001000000FFFFFFFFC802000015020000CC020000B702000000000000020000000400000000000000000000000000000000000000000000000000000002000000C6000000FFFFFFFF8F07000001000000FFFFFFFF8F07000001000000C6000000000000000080000001000000FFFFFFFFFFFFFFFF000000004C0300008007000050030000010000000100001004000000010000000000000000000000FFFFFFFF06000000C5000000C7000000B4010000D2010000CF01000077940000018000800000010000002200000039000000EA020000C7000000000000005003000080070000DE0300000000000040820056060000000C4275696C64204F757470757401000000C500000001000000FFFFFFFFFFFFFFFF0D46696E6420496E2046696C657300000000C700000001000000FFFFFFFFFFFFFFFF0A4572726F72204C69737400000000B401000001000000FFFFFFFFFFFFFFFF0E536F757263652042726F7773657200000000D201000001000000FFFFFFFFFFFFFFFF0E416C6C205265666572656E63657300000000CF01000001000000FFFFFFFFFFFFFFFF0742726F77736572000000007794000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFFC500000001000000FFFFFFFFC5000000000000000000000000000000 - - - 59392 - File - - 2813 - 00200000010000002800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000040004000000000000000000000000000000000100000001000000018022E100000000040005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000004000700000000000000000000000000000000010000000100000001802CE10000000000000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000004000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000004000C0000000000000000000000000000000001000000010000000180F4B00000000004000D000000000000000000000000000000000100000001000000018036B10000000004000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF88000000000400460000000000000000000000000000000001000000010000000180FE880000000004004500000000000000000000000000000000010000000100000001800B810000000004001300000000000000000000000000000000010000000100000001800C810000000004001400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F0880000020000000F000000000000000000000000000000000100000001000000FFFF0100120043555646696E64436F6D626F427574746F6EE803000000000000000000000000000000000000000000000001000000010000009600000002002050000000000109960000000000000014000109125F5F7363686564756C655F626172726965720F5345474745525F5254545F4C4F434B067465737452421149535F56414C49445F44454C41595F6964035F696F06696F4C6173740B70494F5461736B4865616408696F546172676574044C454431074C45445F52756E0377686F0F54494D325F49525148616E646C6572047765616B065F5F5745414B0A53454E534F525F4E554D064341524E554D0B504F5356414C55454D41580C504F5356414C55454D494E4C0C504F5356414C55454D494E480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018024E10000000000001100000000000000000000000000000000010000000100000001800A810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E2280000002000000150000002153746172742F53746F70202644656275672053657373696F6E094374726C2B46350000000000000000000000000100000001000000000000000000000001000000020021802280000000000000150000002153746172742F53746F70202644656275672053657373696F6E094374726C2B4635000000000000000000000000010000000100000000000000000000000100000000002180E0010000000000007500000021456E65726779204D6561737572656D656E742026776974686F75742044656275670000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000160000000000000000000000000000000001000000010000000180C988000000000400180000000000000000000000000000000001000000010000000180C788000000000000190000000000000000000000000000000001000000010000002180C8880000000000001700000027264B696C6C20416C6C20427265616B706F696E747320696E2043757272656E7420546172676574000000000000000000000000010000000100000000000000000000000100000003002180C8880000000000001700000027264B696C6C20416C6C20427265616B706F696E747320696E2043757272656E7420546172676574000000000000000000000000010000000100000000000000000000000100000000002180E50100000000000078000000264B696C6C20416C6C20427265616B706F696E747320696E204163746976652050726F6A656374000000000000000000000000010000000100000000000000000000000100000000002180E601000000000000790000002F4B696C6C20416C6C20427265616B706F696E747320696E204D756C74692D50726F6A65637420576F726B73706163650000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000021804C010000020001001A0000000F2650726F6A6563742057696E646F77000000000000000000000000010000000100000000000000000000000100000008002180DD880000000000001A0000000750726F6A656374000000000000000000000000010000000100000000000000000000000100000000002180DC8B0000000000003A00000005426F6F6B73000000000000000000000000010000000100000000000000000000000100000000002180E18B0000000000003B0000000946756E6374696F6E73000000000000000000000000010000000100000000000000000000000100000000002180E28B000000000000400000000954656D706C6174657300000000000000000000000001000000010000000000000000000000010000000000218018890000000000003D0000000E536F757263652042726F777365720000000000000000000000000100000001000000000000000000000001000000000021800000000000000400FFFFFFFF00000000000000000000000000010000000100000000000000000000000100000000002180D988000000000000390000000C4275696C64204F7574707574000000000000000000000000010000000100000000000000000000000100000000002180E38B000000000000410000000B46696E64204F75747075740000000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001B000000000000000000000000000000000100000001000000000000000446696C65FF7F0000 - - - 1423 - 2800FFFF01001100434D4643546F6F6C426172427574746F6E00E1000000000000FFFFFFFF000100000000000000010000000000000001000000018001E1000000000000FFFFFFFF000100000000000000010000000000000001000000018003E1000000000000FFFFFFFF0001000000000000000100000000000000010000000180CD7F000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF000000000000000000010000000000000001000000018023E1000000000000FFFFFFFF000100000000000000010000000000000001000000018022E1000000000000FFFFFFFF000100000000000000010000000000000001000000018025E1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001802BE1000000000000FFFFFFFF00010000000000000001000000000000000100000001802CE1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001807A8A000000000000FFFFFFFF00010000000000000001000000000000000100000001807B8A000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180D3B0000000000000FFFFFFFF000100000000000000010000000000000001000000018015B1000000000000FFFFFFFF0001000000000000000100000000000000010000000180F4B0000000000000FFFFFFFF000100000000000000010000000000000001000000018036B1000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180FF88000000000000FFFFFFFF0001000000000000000100000000000000010000000180FE88000000000000FFFFFFFF00010000000000000001000000000000000100000001800B81000000000000FFFFFFFF00010000000000000001000000000000000100000001800C81000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180F088000000000000FFFFFFFF0001000000000000000100000000000000010000000180EE7F000000000000FFFFFFFF000100000000000000010000000000000001000000018024E1000000000000FFFFFFFF00010000000000000001000000000000000100000001800A81000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001802280000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180C488000000000000FFFFFFFF0001000000000000000100000000000000010000000180C988000000000000FFFFFFFF0001000000000000000100000000000000010000000180C788000000000000FFFFFFFF0001000000000000000100000000000000010000000180C888000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180DD88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180FB7F000000000000FFFFFFFF000100000000000000010000000000000001000000 - - - 1423 - 2800FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000000000000000000000000000000000000000100000001000000018001E100000000000001000000000000000000000000000000000100000001000000018003E1000000000000020000000000000000000000000000000001000000010000000180CD7F0000000000000300000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018023E100000000000004000000000000000000000000000000000100000001000000018022E100000000000005000000000000000000000000000000000100000001000000018025E10000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001802BE10000000000000700000000000000000000000000000000010000000100000001802CE10000000000000800000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001807A8A0000000000000900000000000000000000000000000000010000000100000001807B8A0000000000000A00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180D3B00000000000000B000000000000000000000000000000000100000001000000018015B10000000000000C0000000000000000000000000000000001000000010000000180F4B00000000000000D000000000000000000000000000000000100000001000000018036B10000000000000E00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FF880000000000000F0000000000000000000000000000000001000000010000000180FE880000000000001000000000000000000000000000000000010000000100000001800B810000000000001100000000000000000000000000000000010000000100000001800C810000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180F088000000000000130000000000000000000000000000000001000000010000000180EE7F00000000000014000000000000000000000000000000000100000001000000018024E10000000000001500000000000000000000000000000000010000000100000001800A810000000000001600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018022800000000000001700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C488000000000000180000000000000000000000000000000001000000010000000180C988000000000000190000000000000000000000000000000001000000010000000180C7880000000000001A0000000000000000000000000000000001000000010000000180C8880000000000001B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180DD880000000000001C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180FB7F0000000000001D000000000000000000000000000000000100000001000000 - - - - 59399 - Build - - 976 - 00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000000001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000000001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64FF7F0000 - - - 583 - 1000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F000000000000FFFFFFFF0001000000000000000100000000000000010000000180D07F000000000000FFFFFFFF00010000000000000001000000000000000100000001803080000000000000FFFFFFFF00010000000000000001000000000000000100000001809E8A000000000000FFFFFFFF0001000000000000000100000000000000010000000180D17F000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001804C8A000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001806680000000000000FFFFFFFF0001000000000000000100000000000000010000000180EB88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180C07F000000000000FFFFFFFF0001000000000000000100000000000000010000000180B08A000000000000FFFFFFFF0001000000000000000100000000000000010000000180A801000000000000FFFFFFFF00010000000000000001000000000000000100000001807202000000000000FFFFFFFF0001000000000000000100000000000000010000000180BE01000000000000FFFFFFFF000100000000000000010000000000000001000000 - - - 583 - 1000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F000000000000000000000000000000000000000000000001000000010000000180D07F00000000000001000000000000000000000000000000000100000001000000018030800000000000000200000000000000000000000000000000010000000100000001809E8A000000000000030000000000000000000000000000000001000000010000000180D17F0000000000000400000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000000500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001806680000000000000060000000000000000000000000000000001000000010000000180EB880000000000000700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000080000000000000000000000000000000001000000010000000180B08A000000000000090000000000000000000000000000000001000000010000000180A8010000000000000A000000000000000000000000000000000100000001000000018072020000000000000B0000000000000000000000000000000001000000010000000180BE010000000000000C000000000000000000000000000000000100000001000000 - - - - 59400 - Debug - - 2373 - 00200000000000001900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000002500000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000002600000000000000000000000000000000010000000100000001801D800000000000002700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000002800000000000000000000000000000000010000000100000001801B80000000000000290000000000000000000000000000000001000000010000000180E57F0000000000002A00000000000000000000000000000000010000000100000001801C800000000000002B00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000002C00000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B0000000000002D0000000000000000000000000000000001000000010000000180F07F0000000000002E0000000000000000000000000000000001000000010000000180E8880000000000003700000000000000000000000000000000010000000100000001803B010000000000002F0000000000000000000000000000000001000000010000000180BB8A00000000000030000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6E0E01000000000000310000000D57617463682057696E646F7773000000000000000000000000010000000100000000000000000000000100000003001380D88B00000000000031000000085761746368202631000000000000000000000000010000000100000000000000000000000100000000001380D98B00000000000031000000085761746368202632000000000000000000000000010000000100000000000000000000000100000000001380CE01000000000000FFFFFFFF0C576174636820416E63686F720100000000000000000000000100000001000000000000000000000001000000000013800F01000000000000320000000E4D656D6F72792057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380D28B00000000000032000000094D656D6F7279202631000000000000000000000000010000000100000000000000000000000100000000001380D38B00000000000032000000094D656D6F7279202632000000000000000000000000010000000100000000000000000000000100000000001380D48B00000000000032000000094D656D6F7279202633000000000000000000000000010000000100000000000000000000000100000000001380D58B00000000000032000000094D656D6F72792026340000000000000000000000000100000001000000000000000000000001000000000013801001000000000000330000000E53657269616C2057696E646F77730000000000000000000000000100000001000000000000000000000001000000040013809307000000000000330000000855415254202326310000000000000000000000000100000001000000000000000000000001000000000013809407000000000000330000000855415254202326320000000000000000000000000100000001000000000000000000000001000000000013809507000000000000330000000855415254202326330000000000000000000000000100000001000000000000000000000001000000000013809607000000000000330000001626446562756720287072696E746629205669657765720000000000000000000000000100000001000000000000000000000001000000000013803C010000000000007200000010416E616C797369732057696E646F7773000000000000000000000000010000000100000000000000000000000100000004001380658A000000000000340000000F264C6F67696320416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380DC7F0000000000003E0000001526506572666F726D616E636520416E616C797A6572000000000000000000000000010000000100000000000000000000000100000000001380E788000000000000380000000E26436F646520436F766572616765000000000000000000000000010000000100000000000000000000000100000000001380CD01000000000000FFFFFFFF0F416E616C7973697320416E63686F7201000000000000000000000001000000010000000000000000000000010000000000138053010000000000003F0000000D54726163652057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013805401000000000000FFFFFFFF115472616365204D656E7520416E63686F720100000000000000000000000100000001000000000000000000000001000000000013802901000000000000350000001553797374656D205669657765722057696E646F77730000000000000000000000000100000001000000000000000000000001000000010013804B01000000000000FFFFFFFF1453797374656D2056696577657220416E63686F720100000000000000000000000100000001000000000000000000000001000000000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000013800189000000000000360000000F26546F6F6C626F782057696E646F7700000000000000000000000001000000010000000000000000000000010000000300138044C5000000000000FFFFFFFF0E5570646174652057696E646F77730100000000000000000000000100000001000000000000000000000001000000000013800000000000000400FFFFFFFF000000000000000000000000000100000001000000000000000000000001000000000013805B01000000000000FFFFFFFF12546F6F6C626F78204D656E75416E63686F720100000000000000000000000100000001000000000000000000000001000000000000000000054465627567FF7F0000 - - - 898 - 1900FFFF01001100434D4643546F6F6C426172427574746F6ECC88000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001801780000000000000FFFFFFFF00010000000000000001000000000000000100000001801D80000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001801A80000000000000FFFFFFFF00010000000000000001000000000000000100000001801B80000000000000FFFFFFFF0001000000000000000100000000000000010000000180E57F000000000000FFFFFFFF00010000000000000001000000000000000100000001801C80000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001800089000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF0000000000000000000100000000000000010000000180E48B000000000000FFFFFFFF0001000000000000000100000000000000010000000180F07F000000000000FFFFFFFF0001000000000000000100000000000000010000000180E888000000000000FFFFFFFF00010000000000000001000000000000000100000001803B01000000000000FFFFFFFF0001000000000000000100000000000000010000000180BB8A000000000000FFFFFFFF0001000000000000000100000000000000010000000180D88B000000000000FFFFFFFF0001000000000000000100000000000000010000000180D28B000000000000FFFFFFFF00010000000000000001000000000000000100000001809307000000000000FFFFFFFF0001000000000000000100000000000000010000000180658A000000000000FFFFFFFF0001000000000000000100000000000000010000000180C18A000000000000FFFFFFFF0001000000000000000100000000000000010000000180EE8B000000000000FFFFFFFF00010000000000000001000000000000000100000001800000000000000000FFFFFFFF00000000000000000001000000000000000100000001800189000000000000FFFFFFFF000100000000000000010000000000000001000000 - - - 898 - 1900FFFF01001100434D4643546F6F6C426172427574746F6ECC880000000000000000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018017800000000000000100000000000000000000000000000000010000000100000001801D800000000000000200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001801A800000000000000300000000000000000000000000000000010000000100000001801B80000000000000040000000000000000000000000000000001000000010000000180E57F0000000000000500000000000000000000000000000000010000000100000001801C800000000000000600000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000018000890000000000000700000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180E48B000000000000080000000000000000000000000000000001000000010000000180F07F000000000000090000000000000000000000000000000001000000010000000180E8880000000000000A00000000000000000000000000000000010000000100000001803B010000000000000B0000000000000000000000000000000001000000010000000180BB8A0000000000000C0000000000000000000000000000000001000000010000000180D88B0000000000000D0000000000000000000000000000000001000000010000000180D28B0000000000000E000000000000000000000000000000000100000001000000018093070000000000000F0000000000000000000000000000000001000000010000000180658A000000000000100000000000000000000000000000000001000000010000000180C18A000000000000110000000000000000000000000000000001000000010000000180EE8B0000000000001200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180018900000000000013000000000000000000000000000000000100000001000000 - - - - 0 - 1920 - 1080 - - - - - - 1 - 0 - - 100 - 0 - - ..\..\..\drivers\modules\command_line.c - 60 - 91 - 101 - 1 - - 0 - - - - -
diff --git a/examples/modbus_host/MDK/use_example.uvoptx b/examples/modbus_host/MDK/use_example.uvoptx index 305095e..e576e49 100644 --- a/examples/modbus_host/MDK/use_example.uvoptx +++ b/examples/modbus_host/MDK/use_example.uvoptx @@ -117,6 +117,26 @@ Segger\JL2CM3.dll + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + DLGUARM + d + 0 JL2CM3 @@ -128,19 +148,36 @@ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) - + + + 0 + 0 + 112 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\SRC\main.c + + +
+
0 0 1 - 0 + 1 0 0 0 0 - 0 + 1 0 0 0 @@ -622,8 +659,8 @@ 0 0 0 - ..\..\..\drivers\modules\data_check.c - data_check.c + ..\..\..\drivers\modbus\modbus_common.c + modbus_common.c 0 0 diff --git a/examples/modbus_host/MDK/use_example.uvprojx b/examples/modbus_host/MDK/use_example.uvprojx index 84daf6d..02fb4f8 100644 --- a/examples/modbus_host/MDK/use_example.uvprojx +++ b/examples/modbus_host/MDK/use_example.uvprojx @@ -569,9 +569,9 @@ ..\..\..\drivers\modbus\modbus_host.c - data_check.c + modbus_common.c 1 - ..\..\..\drivers\modules\data_check.c + ..\..\..\drivers\modbus\modbus_common.c
diff --git a/examples/modbus_host/README.txt b/examples/modbus_host/README.txt index 1b3e8bd..71ff945 100644 --- a/examples/modbus_host/README.txt +++ b/examples/modbus_host/README.txt @@ -2,7 +2,7 @@ 用例使用说明 ================================================================================ Date Author MDK MCU -2023-10-17 ashuai0110 5.35 STM32F1 +2023-10-21 ashuai0110 5.35 STM32F1 ================================================================================ 功能描述 diff --git a/examples/modbus_host/SRC/main.c b/examples/modbus_host/SRC/main.c index a8852ba..7397b6b 100644 --- a/examples/modbus_host/SRC/main.c +++ b/examples/modbus_host/SRC/main.c @@ -3,7 +3,7 @@ * @file main.c * @author ashuai0110 * @version V1.0 - * @date 2023-10-17 + * @date 2023-10-21 * @brief 使用举例-MODBUS主机程序 * ****************************************************************************** @@ -25,7 +25,7 @@ #include /* 私有宏定义-----------------------------------------------------------------*/ -#define USART1_MBH_CH (0u) /* modbus主机管理序号 */ +#define USART1_MB_CH (0u) /* modbus主机管理序号 */ /* 私有类型定义---------------------------------------------------------------*/ @@ -36,7 +36,7 @@ const static char *modbusErrorStr[] = { "response message frame error!", }; -static uint8_t modbusBuf[MBH_BUF_SIZE_MAX]; /* modbus所需缓存区 */ +static uint8_t modbusBuf[MB_BUF_SIZE_MAX]; /* modbus所需缓存区 */ /* 全局变量-------------------------------------------------------------------*/ uint8_t coilStatus[8]; /* 线圈 */ @@ -60,7 +60,7 @@ void TIM1_UP_IRQHandler(void) if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { /* modbus主机轮询处理 */ - ret = mb_host_poll(USART1_MBH_CH); + ret = mb_host_poll(USART1_MB_CH); /* 处理中 */ if(RET_ING == ret) { @@ -97,8 +97,8 @@ void USART1_IRQHandler(void) { rxData = USART_ReceiveData(USART1); /* 写入接收缓存 */ - ret = mb_host_write_rx_buf(USART1_MBH_CH, &rxData, 1); - if(RET_OK != ret) + ret = mb_host_write_rx_buf(USART1_MB_CH, &rxData, 1); + if(0 == ret) { WARN_LOG("mb_host_write_rx_buf failure"); } @@ -109,8 +109,8 @@ void USART1_IRQHandler(void) if(USART_GetITStatus(USART1, USART_IT_TC) != RESET) { /* 读出发送缓存 */ - ret = mb_host_read_tx_buf(USART1_MBH_CH, &txData, 1); - if(RET_OK == ret) + ret = mb_host_read_tx_buf(USART1_MB_CH, &txData, 1); + if(0 != ret) { USART_SendData(USART1, txData); } @@ -150,29 +150,29 @@ int main(int argc, char *argv[]) usart1_init_config(9600); /* modbus主机初始化 */ - mb_host_init(USART1_MBH_CH, MBH_RTU, modbusBuf, sizeof(modbusBuf), uart_tx_en, 9600, 500); + mb_host_init(USART1_MB_CH, MB_RTU, modbusBuf, sizeof(modbusBuf), uart_tx_en, 9600, 500); /* 发送读取线圈命令 */ - mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x1, 0x0, 8, NULL); + mb_host_send_cmd(USART1_MB_CH, 0x1, 0x1, 0x0, 8, NULL); /* 发送读取离散输入命令 */ -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x2, 0x0, 8, NULL); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x2, 0x0, 8, NULL); /* 发送读取保持寄存器命令 */ -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x3, 0x0, 2, NULL); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x3, 0x0, 2, NULL); /* 发送读取输入寄存器命令 */ -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x4, 0x0, 2, NULL); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x4, 0x0, 2, NULL); /* 发送写入单个线圈命令 */ // uint8_t coilVal = 1; -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x5, 0x0, 0, &coilVal); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x5, 0x0, 0, &coilVal); /* 发送写入单个寄存器命令 */ // uint16_t regVal = 0x1357; -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x6, 0x0, 0, ®Val); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x6, 0x0, 0, ®Val); /* 发送写入多个线圈命令 */ // uint8_t coilVal[2] = {0xAA, 0xFF}; -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0xF, 0x0, 10, &coilVal[0]); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0xF, 0x0, 10, &coilVal[0]); /* 发送写入多个寄存器命令 */ // uint16_t regVal[2] = {0x1122, 0x5566}; -// mb_host_send_cmd(USART1_MBH_CH, 0x1, 0x10, 0x0, 2, ®Val[0]); +// mb_host_send_cmd(USART1_MB_CH, 0x1, 0x10, 0x0, 2, ®Val[0]); while(1) { @@ -190,7 +190,7 @@ void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); /* 判断序号 */ - if(USART1_MBH_CH == ch) + if(USART1_MB_CH == ch) { /* 循环赋值 */ for(uint8_t i = 0; i < bytes; i++) @@ -223,7 +223,7 @@ void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) inputStatus[1], inputStatus[2], inputStatus[3], inputStatus[4], inputStatus[5], inputStatus[6], inputStatus[7]); /* 判断序号 */ - if(USART1_MBH_CH == ch) + if(USART1_MB_CH == ch) { /* 循环赋值 */ for(uint8_t i = 0; i < bytes; i++) diff --git a/examples/project_template/MDK/use_example.uvoptx b/examples/project_template/MDK/use_example.uvoptx index 709c445..f262c89 100644 --- a/examples/project_template/MDK/use_example.uvoptx +++ b/examples/project_template/MDK/use_example.uvoptx @@ -579,9 +579,81 @@ 0 0 +
+ + + readme + 1 + 0 + 0 + 0 - 5 + 6 31 + 5 + 0 + 0 + 0 + ..\README.txt + README.txt + 0 + 0 + + + + + drivers/common + 1 + 0 + 0 + 0 + + 7 + 32 + 5 + 0 + 0 + 0 + ..\..\..\drivers\common\all_include.h + all_include.h + 0 + 0 + + + 7 + 33 + 5 + 0 + 0 + 0 + ..\..\..\drivers\common\common_include.h + common_include.h + 0 + 0 + + + + + drivers/modbus + 1 + 0 + 0 + 0 + + 8 + 34 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_common.c + modbus_common.c + 0 + 0 + + + 8 + 35 1 0 0 @@ -592,8 +664,8 @@ 0 - 5 - 32 + 8 + 36 1 0 0 @@ -603,9 +675,17 @@ 0 0 + + + + drivers/modules + 1 + 0 + 0 + 0 - 5 - 33 + 9 + 37 1 0 0 @@ -616,8 +696,8 @@ 0 - 5 - 34 + 9 + 38 1 0 0 @@ -628,8 +708,8 @@ 0 - 5 - 35 + 9 + 39 1 0 0 @@ -640,8 +720,8 @@ 0 - 5 - 36 + 9 + 40 1 0 0 @@ -652,8 +732,8 @@ 0 - 5 - 37 + 9 + 41 1 0 0 @@ -664,8 +744,8 @@ 0 - 5 - 38 + 9 + 42 1 0 0 @@ -676,8 +756,8 @@ 0 - 5 - 39 + 9 + 43 1 0 0 @@ -688,8 +768,8 @@ 0 - 5 - 40 + 9 + 44 1 0 0 @@ -700,8 +780,8 @@ 0 - 5 - 41 + 9 + 45 1 0 0 @@ -712,8 +792,8 @@ 0 - 5 - 42 + 9 + 46 1 0 0 @@ -724,8 +804,8 @@ 0 - 5 - 43 + 9 + 47 1 0 0 @@ -736,8 +816,8 @@ 0 - 5 - 44 + 9 + 48 1 0 0 @@ -749,24 +829,4 @@ - - readme - 1 - 0 - 0 - 0 - - 6 - 45 - 5 - 0 - 0 - 0 - ..\README.txt - README.txt - 0 - 0 - - - diff --git a/examples/project_template/MDK/use_example.uvprojx b/examples/project_template/MDK/use_example.uvprojx index 6ad06db..0cafe1c 100644 --- a/examples/project_template/MDK/use_example.uvprojx +++ b/examples/project_template/MDK/use_example.uvprojx @@ -551,6 +551,41 @@ 1 ..\SRC\main.c + + + + readme + + + README.txt + 5 + ..\README.txt + + + + + drivers/common + + + all_include.h + 5 + ..\..\..\drivers\common\all_include.h + + + common_include.h + 5 + ..\..\..\drivers\common\common_include.h + + + + + drivers/modbus + + + modbus_common.c + 1 + ..\..\..\drivers\modbus\modbus_common.c + modbus_host.c 1 @@ -561,6 +596,11 @@ 1 ..\..\..\drivers\modbus\modbus_slave.c + + + + drivers/modules + command_line.c 1 @@ -623,16 +663,6 @@ - - readme - - - README.txt - 5 - ..\README.txt - - - diff --git a/examples/project_template/SRC/main.c b/examples/project_template/SRC/main.c index b70eeba..5b2b02a 100644 --- a/examples/project_template/SRC/main.c +++ b/examples/project_template/SRC/main.c @@ -3,8 +3,8 @@ * @file main.c * @author ashuai0110 * @version V1.0 - * @date 2023-09-19 - * @brief 使用举例- + * @date 2023-10-21 + * @brief 使用举例-xxx * ****************************************************************************** * @attention @@ -40,7 +40,7 @@ */ int main(int argc, char *argv[]) { - VERSION_LOG("example-delay_no_block", 1, 0, 0); + VERSION_LOG("example-xxx", 1, 0, 0); while(1) { diff --git a/examples/uart_handler/README.txt b/examples/uart_handler/README.txt index 1474eaf..45c22f0 100644 --- a/examples/uart_handler/README.txt +++ b/examples/uart_handler/README.txt @@ -2,7 +2,7 @@ 用例使用说明 ================================================================================ Date Author MDK MCU -2023-09-26 ashuai0110 5.35 STM32F1 +2023-10-21 ashuai0110 5.35 STM32F1 ================================================================================ 功能描述 diff --git a/examples/uart_handler/SRC/main.c b/examples/uart_handler/SRC/main.c index 1a75a98..7a9c343 100644 --- a/examples/uart_handler/SRC/main.c +++ b/examples/uart_handler/SRC/main.c @@ -3,7 +3,7 @@ * @file main.c * @author ashuai0110 * @version V1.0 - * @date 2023-09-26 + * @date 2023-10-21 * @brief 使用举例-串口管理 * ****************************************************************************** @@ -77,13 +77,17 @@ void TIM1_UP_IRQHandler(void) */ void USART1_IRQHandler(void) { - static uint8_t rxData, txData; + static uint8_t rxData, txData, ret; if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { rxData = USART_ReceiveData(USART1); /* 写入接收缓存 */ - uart_hr_write_rx_buf(USART1_UART_HR_CH, &rxData, 1); + ret = uart_hr_write_rx_buf(USART1_UART_HR_CH, &rxData, 1); + if(0 == ret) + { + WARN_LOG("uart_hr_write_rx_buf failure"); + } USART_ClearITPendingBit(USART1, USART_IT_RXNE); } @@ -91,7 +95,8 @@ void USART1_IRQHandler(void) if(USART_GetITStatus(USART1, USART_IT_TC) != RESET) { /* 读出发送缓存 */ - if(0 != uart_hr_read_tx_buf(USART1_UART_HR_CH, &txData, 1)) + ret = uart_hr_read_tx_buf(USART1_UART_HR_CH, &txData, 1); + if(0 != ret) { USART_SendData(USART1, txData); } -- Gitee From 5aff9b237adf12ff663b581f4a170b817a4c8fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E5=B8=85=E6=9D=B0?= Date: Wed, 25 Oct 2023 17:57:57 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=98=E5=8C=96modbus?= =?UTF-8?q?=5Fhost=E4=BD=BF=E7=94=A8=E4=B8=BE=E4=BE=8B=E5=92=8C=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=BA=90=E7=A0=81,=E6=96=B0=E5=A2=9Emodbus=5Fslave?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=B8=BE=E4=BE=8B=E5=92=8C=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- drivers/modbus/modbus_common.c | 51 +- drivers/modbus/modbus_common.h | 45 +- drivers/modbus/modbus_host.c | 87 +-- drivers/modbus/modbus_host.h | 4 +- drivers/modbus/modbus_slave.c | 420 +++++++++-- drivers/modbus/modbus_slave.h | 22 +- examples/command_line/SRC/main.c | 2 +- examples/delay_no_block/SRC/main.c | 2 +- examples/input_output/SRC/main.c | 2 +- examples/memory/SRC/main.c | 2 +- examples/message_queue/SRC/main.c | 2 +- examples/modbus_host/MDK/use_example.uvoptx | 19 +- examples/modbus_host/MDK/use_example.uvprojx | 4 +- examples/modbus_host/README.txt | 4 +- examples/modbus_host/SRC/main.c | 113 ++- examples/modbus_slave/MDK/use_example.uvoptx | 672 ++++++++++++++++++ examples/modbus_slave/MDK/use_example.uvprojx | 607 ++++++++++++++++ examples/modbus_slave/README.txt | 50 ++ examples/modbus_slave/SRC/main.c | 344 +++++++++ examples/project_template/SRC/main.c | 2 +- examples/ring_buffer/SRC/main.c | 2 +- examples/ring_queue/SRC/main.c | 2 +- examples/sync_method/SRC/main.c | 2 +- examples/timer_software/SRC/main.c | 2 +- examples/uart_handler/SRC/main.c | 2 +- 26 files changed, 2248 insertions(+), 222 deletions(-) create mode 100644 examples/modbus_slave/MDK/use_example.uvoptx create mode 100644 examples/modbus_slave/MDK/use_example.uvprojx create mode 100644 examples/modbus_slave/README.txt create mode 100644 examples/modbus_slave/SRC/main.c diff --git a/README.md b/README.md index 3a74d73..bf37a91 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # 单片机可复用,可通用开发组件 -* ./documents/存放文档 +* ./documents/存放组件使用文档 * ./drivers/存放所有组件源程序 -* ./examples/存放所有示例工程(使用必看) +* ./examples/存放所有组件的使用举例(使用必看) ### drivers/common @@ -18,7 +18,7 @@ modbus_host.c/.h: modbus主机程序(RTU ASCII) modbus_slave.c/.h: modbus从机程序(RTU ASCII) -### drivers/modules/ +### drivers/modules command_line.c/.h: 命令行交互 diff --git a/drivers/modbus/modbus_common.c b/drivers/modbus/modbus_common.c index 91d3323..0d24871 100644 --- a/drivers/modbus/modbus_common.c +++ b/drivers/modbus/modbus_common.c @@ -3,7 +3,7 @@ * @file modbus_common.c * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-24 * @brief modbus通用文件 * ****************************************************************************** @@ -161,7 +161,7 @@ uint8_t mb_check_lrc(uint8_t *pBuf, uint16_t len) } /** - * @brief hex转ascii(modbus) + * @brief HEX转ASCII * * @param pHex : hex数据缓存区 * @@ -182,7 +182,7 @@ void mb_hex_to_ascii(uint8_t *pHex, uint16_t num, uint8_t *pAscii) } /** - * @brief ascii转hex(modbus) + * @brief ASCII转HEX * * @param pAscii : ascii数据缓存区 * @@ -204,17 +204,58 @@ void mb_ascii_to_hex(uint8_t *pAscii, uint16_t num, uint8_t *pHex) } } +/** + * @brief 设置对应位(一般用于线圈和离散量) + * + * @param srcBuf : 源数据地址 + * + * @param bitOffset : 位偏移量 + * + * @param bitNum : 位数量 + * + * @param bitVal : 位数据 + * + * @retval None + */ +void mb_set_bits(uint8_t *srcBuf, uint16_t bitOffset, uint8_t bitNum, uint8_t bitVal) +{ + uint8_t byteOffset; + uint8_t preBitNum; + uint16_t bitMask; + uint16_t bitValTmp; + + byteOffset = bitOffset / 8; /* 数据索引 */ + preBitNum = bitOffset % 8; /* bit开始的位数 */ + bitMask = ((1 << bitNum) - 1) << preBitNum; /* 掩码位 */ + bitValTmp = bitVal << preBitNum; /* 数据偏移后 */ + + *(uint16_t *)&srcBuf[byteOffset] = (*(uint16_t *)&srcBuf[byteOffset] & (~bitMask)) | bitValTmp; /* 修改对应位 */ +} + +/** + * @brief 获取对应位(一般用于线圈和离散量) + * + * @param srcBuf : 源数据地址 + * + * @param bitOffset : 位偏移量 + * + * @param bitNum : 位数量 + * + * @retval 返回对应位 + */ uint8_t mb_get_bits(uint8_t *srcBuf, uint16_t bitOffset, uint8_t bitNum) { uint8_t byteOffset; uint8_t preBitNum; + uint8_t bitMask; uint8_t retVal; byteOffset = bitOffset / 8; /* 数据索引 */ preBitNum = bitOffset % 8; /* bit开始的位数 */ + bitMask = (1 << bitNum) - 1; /* 掩码位 */ - retVal = (srcBuf[byteOffset] >> preBitNum) | (srcBuf[byteOffset + 1] << (8 - preBitNum)); /* 组合数据 */ - retVal = retVal & ((1 << (uint16_t)bitNum) - 1); /* 保留有效位 */ + retVal = *(uint16_t *)&srcBuf[byteOffset] >> preBitNum; /* 获取对应位 */ + retVal = retVal & bitMask; /* 保留有效位 */ return retVal; } diff --git a/drivers/modbus/modbus_common.h b/drivers/modbus/modbus_common.h index 49f54ae..0da400f 100644 --- a/drivers/modbus/modbus_common.h +++ b/drivers/modbus/modbus_common.h @@ -3,7 +3,7 @@ * @file modbus_common.h * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-24 * @brief modbus通用文件 * ****************************************************************************** @@ -41,18 +41,25 @@ extern "C" { * @{ */ -#define MB_BUF_SIZE_MAX (256u) /*!< modbus缓存区最大256byte 不可修改 */ -#define MB_PDU_SIZE_MIN (4u) /*!< modbus PDU最小4byte */ +#define MB_BUF_SIZE_MAX (256u) /*!< modbus缓存区最大长度byte */ +#define MB_PDU_SIZE_MIN (4u) /*!< modbus PDU最小长度byte */ +#define MB_RD_COIL_NUM_MAX (2000u) /*!< modbus读线圈最大数量 */ +#define MB_RD_REG_NUM_MAX (125u) /*!< modbus读寄存器最大数量 */ +#define MB_WR_COIL_NUM_MAX (1968u) /*!< modbus写线圈最大数量 */ +#define MB_WR_REG_NUM_MAX (123u) /*!< modbus读寄存器最大数量 */ -#define MB_ADDR_OFF (0u) /*!< modbus从站地址偏移 */ -#define MB_CODE_OFF (1u) /*!< modbus功能码偏移 */ -#define MB_REG_ADDR_HI_OFF (2u) /*!< modbus寄存器地址高八位偏移 */ -#define MB_REG_ADDR_LO_OFF (3u) /*!< modbus寄存器地址低八位偏移 */ -#define MB_NUM_HI_OFF (4u) /*!< modbus读/写数量高八位偏移 */ -#define MB_NUM_LO_OFF (5u) /*!< modbus读/写数量低八位偏移 */ +#define MB_ADDR_OFF (0u) /*!< modbus从站地址偏移 */ +#define MB_CODE_OFF (1u) /*!< modbus功能码偏移 */ +#define MB_REG_ADDR_HI_OFF (2u) /*!< modbus寄存器地址高八位偏移 */ +#define MB_REG_ADDR_LO_OFF (3u) /*!< modbus寄存器地址低八位偏移 */ +#define MB_NUM_HI_OFF (4u) /*!< modbus读/写数量高八位偏移 */ +#define MB_NUM_LO_OFF (5u) /*!< modbus读/写数量低八位偏移 */ -#define MB_RSP_BYTE_OFF (2u) /*!< modbus应答(读请求的应答)字节数偏移 */ -#define MB_RSP_DATA_OFF (3u) /*!< modbus应答(读请求的应答)数据值偏移 */ +#define MB_RSP_ERR_CODE_OFF (2u) /*!< modbus应答错误代码偏移 */ +#define MB_RSP_BYTE_OFF (2u) /*!< modbus应答(读请求的应答)字节数偏移 */ +#define MB_RSP_DATA_OFF (3u) /*!< modbus应答(读请求的应答)数据值偏移 */ + +#define MB_REQ_MULTI_DATA_OFF (7u) /*!< modbus请求(写多个的请求)数据值偏移 */ /** * @defgroup modbus_common_protocol modbus common protocol @@ -80,6 +87,19 @@ extern "C" { * @} */ +/** + * @defgroup modbus_common_errno modbus common errno + * @{ + */ +#define MB_ERRNO_OK (0u) /*!< 无错误代码 - 正常 */ +#define MB_ERRNO_CODE (1u) /*!< 错误代码0x01 - 非法功能 : 功能码无效 */ +#define MB_ERRNO_ADDR (2u) /*!< 错误代码0x02 - 非法数据地址 : 地址无效或地址和数量的组合无效 */ +#define MB_ERRNO_DATA (3u) /*!< 错误代码0x03 - 非法数据值 : 数据值无效或数量无效 */ +#define MB_ERRNO_FAULT (4u) /*!< 错误代码0x04 - 从机故障 : 当从机试图执行请求的操作时,发生了不可恢复的错误 */ +/** + * @} + */ + /** * @} */ @@ -119,6 +139,9 @@ uint8_t mb_check_lrc(uint8_t *pBuf, uint16_t len); void mb_hex_to_ascii(uint8_t *pHex, uint16_t num, uint8_t *pAscii); void mb_ascii_to_hex(uint8_t *pAscii, uint16_t num, uint8_t *pHex); +void mb_set_bits(uint8_t *srcBuf, uint16_t bitOffset, uint8_t bitNum, uint8_t bitVal); +uint8_t mb_get_bits(uint8_t *srcBuf, uint16_t bitOffset, uint8_t bitNum); + /** * @} */ diff --git a/drivers/modbus/modbus_host.c b/drivers/modbus/modbus_host.c index 3f79f23..52247c5 100644 --- a/drivers/modbus/modbus_host.c +++ b/drivers/modbus/modbus_host.c @@ -3,7 +3,7 @@ * @file modbus_host.c * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-25 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** @@ -40,9 +40,7 @@ */ /* modbus主机管理序号有效性检查 */ #define IS_VALID_MBH_CH(x) \ -( ((x) == 0) || \ - ((x) > 0) && \ - ((x) < MBH_NUM)) +( (x) < MBH_NUM) /** * @} */ @@ -510,7 +508,7 @@ rspErr: } /** - * @brief 主机发送命令 + * @brief 主机发送请求 * * @note 功能码 --- 扩展数据格式 * 0x05 --- 一个线圈数据 1byte 0:OFF 1:ON @@ -532,7 +530,7 @@ rspErr: * * @retval uint8_t * @arg RET_OK : 成功 - * @arg RET_ERR : 失败 + * @arg RET_ERR : 失败(不支持的功能码或数量超出合理范围) */ uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_t reg, uint16_t num, void *extend) { @@ -550,34 +548,34 @@ uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_ switch(funCode) { - case 0x01: /* 读线圈命令 */ - case 0x02: /* 读离散量输入命令 */ - if(2000 >= num && num) + case 0x01: /* 读线圈请求 */ + case 0x02: /* 读离散量输入请求 */ + if(MB_RD_COIL_NUM_MAX >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x03: /* 读保持寄存器命令 */ - case 0x04: /* 读输入寄存器命令 */ - if(125 >= num && num) + case 0x03: /* 读保持寄存器请求 */ + case 0x04: /* 读输入寄存器请求 */ + if(MB_RD_REG_NUM_MAX >= num && num) { mb_host_cmd_01_04h(ch, slaveAddr, funCode, reg, num); } break; - case 0x05: /* 写单个线圈命令 */ + case 0x05: /* 写单个线圈请求 */ mb_host_cmd_05h(ch, slaveAddr, reg, *(uint8_t *)extend); break; - case 0x06: /* 写单个保持寄存器命令 */ + case 0x06: /* 写单个保持寄存器请求 */ mb_host_cmd_06h(ch, slaveAddr, reg, *(uint16_t *)extend); break; - case 0x0F: /* 写多个线圈命令 */ - if(1920 >= num && num) + case 0x0F: /* 写多个线圈请求 */ + if(MB_WR_COIL_NUM_MAX >= num && num) { mb_host_cmd_0fh(ch, slaveAddr, reg, num, (uint8_t *)extend); } break; - case 0x10: /* 写多个寄存器命令 */ - if(120 >= num && num) + case 0x10: /* 写多个寄存器请求 */ + if(MB_WR_REG_NUM_MAX >= num && num) { mb_host_cmd_10h(ch, slaveAddr, reg, num, (uint16_t *)extend); } @@ -585,7 +583,7 @@ uint8_t mb_host_send_cmd(uint8_t ch, uint8_t slaveAddr, uint8_t funCode, uint16_ /* 用户在这里写其他功能码的发送处理 */ - default: /* 不支持的命令 */ + default: /* 不支持的请求 */ break; } @@ -803,7 +801,7 @@ uint16_t mb_host_get_rsp_timeout(uint8_t ch) * * @param num : 线圈数量 1线圈=1bit * - * @param pData : 线圈数据 + * @param pData : 线圈状态 * * @retval None */ @@ -812,10 +810,10 @@ __WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = (num + 7) >> 3; - PRINT_LOG("modbus host[%d] rsp01h> coilAddr:0x%x, coilNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp01h> coilAddr:0x%X, coilNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { - PRINT_LOG("%02X ", pData[i]); + PRINT_LOG("%X ", pData[i]); } PRINT_LOG("\r\n"); #endif @@ -831,9 +829,9 @@ __WEAK void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa * * @param reg : 起始地址 * - * @param num : 离散量输入数量 1离散量输入=1bit + * @param num : 离散量数量 1离散量=1bit * - * @param pData : 离散量输入数据 + * @param pData : 离散量状态 * * @retval None */ @@ -842,10 +840,10 @@ __WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = (num + 7) >> 3; - PRINT_LOG("modbus host[%d] rsp02h> coilAddr:0x%x, coilNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp02h> coilAddr:0x%X, coilNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { - PRINT_LOG("%02X ", pData[i]); + PRINT_LOG("%X ", pData[i]); } PRINT_LOG("\r\n"); #endif @@ -861,9 +859,9 @@ __WEAK void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa * * @param reg : 起始地址 * - * @param num : 保持寄存器数量 1保持寄存器=16bit + * @param num : 寄存器数量 1寄存器=16bit * - * @param pData : 保持寄存器数据 + * @param pData : 保持寄存器值 * * @retval None */ @@ -872,10 +870,10 @@ __WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa #if _MBH_DEBUG uint8_t bytes = num << 1; - PRINT_LOG("modbus host[%d] rsp03h> regAddr:0x%x, regNum:%d, data:", ch, reg, num); + PRINT_LOG("modbus host[%d] rsp03h> regAddr:0x%X, regNum:%d, data:", ch, reg, num); for(uint8_t i = 0; i < bytes; i++) { - PRINT_LOG("%02X ", pData[i]); + PRINT_LOG("%X ", pData[i]); } PRINT_LOG("\r\n"); #endif @@ -893,19 +891,17 @@ __WEAK void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pDa * * @param num : 输入寄存器数量 1输入寄存器=16bit * - * @param pData : 输入寄存器数据 + * @param pData : 输入寄存器值 * * @retval None */ __WEAK void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { #if _MBH_DEBUG - uint8_t bytes = num << 1; - - PRINT_LOG("modbus host[%d] rsp04h> regAddr:0x%x, regNum:%d, data:", ch, reg, num); - for(uint8_t i = 0; i < bytes; i++) + PRINT_LOG("modbus host[%d] rsp04h> regAddr:0x%X, regNum:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < num; i++) { - PRINT_LOG("%02X ", pData[i]); + PRINT_LOG("%X ", (pData[i << 1] << 8) | pData[(i << 1) + 1]); } PRINT_LOG("\r\n"); #endif @@ -943,21 +939,14 @@ __WEAK void mb_host_rsp_05_10h(uint8_t ch) __WEAK void mb_host_rsp_err(uint8_t ch, uint8_t *pData) { /* - 错误代码释义: - 01 - 功能码不能被从机识别 - 02 - 从机的单元标识符不正确 - 03 - 值不被从机接受 - 04 - 当从机试图执行请求的操作时,发生了不可恢复的错误 - 05 - 从机已接受请求并正在处理,但需要很长时间.返回此响应是为了防止在主机中发生超时错误, - 主机可以在下一个轮询程序中发出一个完整的消息,以确定处理是否完成 - 06 - 从机正在处理长时间命令,主机应该稍后重试 - 07 - 从机不能执行程序功能,主机应该向从机请求诊断或错误信息 - 08 - 从机在内存中检测到奇偶校验错误,主机可以重试请求,但从设备上可能需要服务 - 10 - 专门用于modbus网关,表示配置错误的网关 - 11 - 专门用于modbus网关的响应,当从机无法响应时发送 + 部分错误代码释义: + 0x01 - 非法功能 : 功能码无效 + 0x02 - 非法数据地址 : 地址无效或地址和数量的组合无效 + 0x03 - 非法数据值 : 数据值无效 + 0x04 - 从机故障 : 当从机试图执行请求的操作时,发生了不可恢复的错误 */ #if _MBH_DEBUG - PRINT_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X\r\n", ch, pData[0], pData[1]); + PRINT_LOG("modbus host[%d] rspErr> errFunCode:0x%X, errCode:0x%X\r\n", ch, pData[0], pData[1]); #endif } diff --git a/drivers/modbus/modbus_host.h b/drivers/modbus/modbus_host.h index 96190b5..87e4a3a 100644 --- a/drivers/modbus/modbus_host.h +++ b/drivers/modbus/modbus_host.h @@ -3,7 +3,7 @@ * @file modbus_host.h * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-25 * @brief modbus主机程序(RTU ASCII) * ****************************************************************************** @@ -64,7 +64,7 @@ typedef struct mb_host { uint16_t dataLen; /*!< 数据长度 */ uint16_t readLen; /*!< 读出数据长度 */ - uint8_t protocol : 2; /*!< 协议类型 @ref modbus_common_protocol */ + uint8_t protocol : 1; /*!< 协议类型 @ref modbus_common_protocol */ uint8_t state : 2; /*!< 应答状态 @ref modbus_common_state */ uint8_t broadcast : 1; /*!< 广播标志 0:非广播 1:广播 */ diff --git a/drivers/modbus/modbus_slave.c b/drivers/modbus/modbus_slave.c index 9101c4c..414e665 100644 --- a/drivers/modbus/modbus_slave.c +++ b/drivers/modbus/modbus_slave.c @@ -3,7 +3,7 @@ * @file modbus_slave.c * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-25 * @brief modbus从机程序(RTU ASCII) * ****************************************************************************** @@ -18,50 +18,62 @@ /* 包含头文件-----------------------------------------------------------------*/ #include "modbus_slave.h" +/** + * @addtogroup modbus + * @{ + */ + +/** + * @defgroup modbus_slave modbus通用文件 + * @{ + */ + /* 私有宏定义-----------------------------------------------------------------*/ +/** + * @defgroup modbus_slave_local_macros modbus slave local macros + * @{ + */ + +/** + * @defgroup modbus_slave_check_parameters_validity modbus slave check parameters validity + * @{ + */ /* modbus从机管理序号有效性检查 */ #define IS_VALID_MBS_CH(x) \ -( ((x) == 0) || \ - ((x) > 0) && \ - ((x) < MBS_NUM)) +( (x) < MBS_NUM) +/* modbus从机地址有效性检查 */ +#define IS_VALID_MBS_ADDR(x) \ +( ((x) >= 1u) && \ + ((x) <= 247u)) +/** + * @} + */ + +/** + * @} + */ /* 私有类型定义---------------------------------------------------------------*/ /* 私有变量-------------------------------------------------------------------*/ +/** + * @defgroup modbus_slave_local_variables modbus slave local variables + * @{ + */ + static mb_slave_t mbSlaveArr[MBS_NUM]; /* modbus从机管理数组 */ +/** + * @} + */ + /* 全局变量-------------------------------------------------------------------*/ /* 私有函数原型---------------------------------------------------------------*/ - - -__WEAK void mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) -{ -#if _MBS_DEBUG - PRINT_LOG("modbus slave[%d] req01h> read coil status reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); -#endif -} - -__WEAK void mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) -{ -#if _MBS_DEBUG - PRINT_LOG("modbus slave[%d] req02h> read input status reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); -#endif -} - -__WEAK void mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) -{ -#if _MBS_DEBUG - PRINT_LOG("modbus slave[%d] req03h> read holding registers reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); -#endif -} - -__WEAK void mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) -{ -#if _MBS_DEBUG - PRINT_LOG("modbus slave[%d] req04h> read input registers reg:0x%x, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); -#endif -} +/** + * @defgroup modbus_slave_local_functions modbus slave local functions + * @{ + */ /** * @brief 追加校验后发送 @@ -119,33 +131,77 @@ static void mb_slave_reqProcess(uint8_t ch) mb_slave_t *_mb_slave = &mbSlaveArr[ch]; uint16_t reg = (_mb_slave->dataBuf[MB_REG_ADDR_HI_OFF] << 8) | _mb_slave->dataBuf[MB_REG_ADDR_LO_OFF]; uint16_t num = (_mb_slave->dataBuf[MB_NUM_HI_OFF] << 8) | _mb_slave->dataBuf[MB_NUM_LO_OFF]; + uint8_t errCodeTmp = MB_ERRNO_OK; switch(_mb_slave->dataBuf[MB_CODE_OFF]) { case 0x01: /* 读线圈请求处理 */ - mb_slave_req_01h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + errCodeTmp = mb_slave_req_01h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + _mb_slave->dataBuf[MB_RSP_BYTE_OFF] = (num + 7) >> 3; + _mb_slave->dataLen = 3 + _mb_slave->dataBuf[MB_RSP_BYTE_OFF]; + break; + case 0x02: /* 读离散量输入请求处理 */ + errCodeTmp = mb_slave_req_02h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); _mb_slave->dataBuf[MB_RSP_BYTE_OFF] = (num + 7) >> 3; _mb_slave->dataLen = 3 + _mb_slave->dataBuf[MB_RSP_BYTE_OFF]; break; - case 0x02: /* 读离散量输入应答处理 */ - mb_slave_req_02h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + case 0x03: /* 读保持寄存器请求处理 */ + errCodeTmp = mb_slave_req_03h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + _mb_slave->dataBuf[MB_RSP_BYTE_OFF] = num << 1; + _mb_slave->dataLen = 3 + _mb_slave->dataBuf[MB_RSP_BYTE_OFF]; + break; + case 0x04: /* 读输入寄存器请求处理 */ + errCodeTmp = mb_slave_req_04h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + _mb_slave->dataBuf[MB_RSP_BYTE_OFF] = num << 1; + _mb_slave->dataLen = 3 + _mb_slave->dataBuf[MB_RSP_BYTE_OFF]; + break; + case 0x05: /* 写单个线圈请求处理 */ + /* num的计算正好与此请求的数据计算对应 故直接使用 */ + if(0xFF00 == num || 0x0 == num) + { + errCodeTmp = mb_slave_req_05h(ch, reg, num ? 1 : 0); + _mb_slave->dataLen = 6; + } + else + { + errCodeTmp = MB_ERRNO_DATA; + } + break; + case 0x06: /* 写单个寄存器请求处理 */ + /* num的计算正好与此请求的数据计算对应 故直接使用 */ + errCodeTmp = mb_slave_req_06h(ch, reg, num); + _mb_slave->dataLen = 6; break; - case 0x03: /* 读保持寄存器应答处理 */ - mb_slave_req_03h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + case 0x0F: /* 写多个线圈请求处理 */ + errCodeTmp = mb_slave_req_0fh(ch, reg, num, &_mb_slave->dataBuf[MB_REQ_MULTI_DATA_OFF]); + _mb_slave->dataLen = 6; break; - case 0x04: /* 读输入寄存器应答处理 */ - mb_slave_req_04h(ch, reg, num, &_mb_slave->dataBuf[MB_RSP_DATA_OFF]); + case 0x10: /* 写多个寄存器请求处理 */ + errCodeTmp = mb_slave_req_10h(ch, reg, num, &_mb_slave->dataBuf[MB_REQ_MULTI_DATA_OFF]); + _mb_slave->dataLen = 6; + break; + default: /* 无效功能码 */ + errCodeTmp = MB_ERRNO_CODE; break; - case 0x05: - case 0x06: - case 0x0F: - case 0x10: /* 写命令应答处理 */ - default: break; } + if(MB_ERRNO_OK != errCodeTmp) + { + _mb_slave->dataBuf[MB_CODE_OFF] |= 0x80; + _mb_slave->dataBuf[MB_RSP_ERR_CODE_OFF] = errCodeTmp; + _mb_slave->dataLen = 3; + } mb_slave_send_with_check(ch); } +/** + * @} + */ + +/** + * @defgroup modbus_slave_global_functions modbus slave global functions + * @{ + */ /** * @brief modbus从机初始化 @@ -154,7 +210,7 @@ static void mb_slave_reqProcess(uint8_t ch) * * @param slaveAddr : 从站地址 1~247 * - * @param protocol : 协议类型 @ref modbus_slave_protocol + * @param protocol : 协议类型 @ref modbus_common_protocol * @arg MB_RTU : RTU协议 * @arg MB_ASCII : ASCII协议 * @@ -173,6 +229,7 @@ void mb_slave_init(uint8_t ch, uint8_t slaveAddr, uint8_t protocol, void *pBuf, mb_slave_t *_mb_slave = &mbSlaveArr[ch]; ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_MBS_ADDR(slaveAddr)); ASSERT_PARAM(IS_VALID_MB_PROTOCOL(protocol)); ASSERT_PARAM(IS_VALID_POINT(pBuf)); ASSERT_PARAM(IS_VALID_POINT(txEnFn)); @@ -202,7 +259,6 @@ void mb_slave_init(uint8_t ch, uint8_t slaveAddr, uint8_t protocol, void *pBuf, * @retval uint8_t * @arg RET_OK : 处理完成 * @arg RET_ING : 进行中 - * @arg RET_TIMEOUT : 超时 * @arg RET_LEN_ERR : 数据长度错误 * @arg RET_CHECK_ERR : 数据校验错误 * @arg RET_FRAME_ERR : 数据格式错误 @@ -247,7 +303,7 @@ uint8_t mb_slave_poll(uint8_t ch) /* 起始符索引检查 */ if((_mb_slave->dataLen - startIndex - 1) < 10) { - ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + ret = RET_FRAME_ERR; /* 请求数据格式错误 */ goto rspErr; } /* 寻找结束符0x0D 0x0A */ @@ -258,7 +314,7 @@ uint8_t mb_slave_poll(uint8_t ch) /* 结束符索引检查 */ if(stopIndex >= _mb_slave->dataLen) { - ret = RET_FRAME_ERR; /* 应答数据格式错误 */ + ret = RET_FRAME_ERR; /* 请求数据格式错误 */ goto rspErr; } _mb_slave->dataLen = stopIndex - startIndex - 1; @@ -280,10 +336,10 @@ uint8_t mb_slave_poll(uint8_t ch) ret = RET_ING; /* 进行中 */ goto rspErr; } - /* 应答数据长度判断 */ + /* 请求数据长度判断 */ if(MB_PDU_SIZE_MIN > _mb_slave->dataLen) { - ret = RET_LEN_ERR; /* 应答数据长度错误 */ + ret = RET_LEN_ERR; /* 请求数据长度错误 */ goto rspErr; } /* ASCII协议 */ @@ -293,7 +349,7 @@ uint8_t mb_slave_poll(uint8_t ch) checkVal = mb_check_lrc(&_mb_slave->dataBuf[0], _mb_slave->dataLen - 1); if(checkVal != _mb_slave->dataBuf[_mb_slave->dataLen - 1]) { - ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + ret = RET_CHECK_ERR; /* 请求数据校验错误 */ goto rspErr; } } /* RTU协议 */ @@ -303,7 +359,7 @@ uint8_t mb_slave_poll(uint8_t ch) checkVal = mb_check_crc16(&_mb_slave->dataBuf[0], _mb_slave->dataLen - 2); if(checkVal != ((_mb_slave->dataBuf[_mb_slave->dataLen - 2] << 8) | _mb_slave->dataBuf[_mb_slave->dataLen - 1])) { - ret = RET_CHECK_ERR; /* 应答数据校验错误 */ + ret = RET_CHECK_ERR; /* 请求数据校验错误 */ goto rspErr; } } @@ -317,6 +373,7 @@ uint8_t mb_slave_poll(uint8_t ch) return ret; rspErr: + _mb_slave->dataLen = 0; _mb_slave->state = MB_RX_IDLE; /* 切换状态 */ return ret; @@ -422,6 +479,7 @@ uint16_t mb_slave_read_tx_buf(uint8_t ch, void *pBuf, uint16_t len) void mb_slave_set_slave_addr(uint8_t ch, uint8_t slaveAddr) { ASSERT_PARAM(IS_VALID_MBS_CH(ch)); + ASSERT_PARAM(IS_VALID_MBS_ADDR(slaveAddr)); mbSlaveArr[ch].slaveAddr = slaveAddr; } @@ -513,3 +571,259 @@ uint16_t mb_slave_get_frame_intv(uint8_t ch) { return mbSlaveArr[ch].targetFrameIntv; } + +/** + * @brief 读线圈请求处理(0x01) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 线圈数量 1线圈=1bit + * + * @param pData : 线圈状态(用户需将本地的线圈状态放进去) + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_RD_COIL_NUM_MAX */ + if(MB_RD_COIL_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req01h> read coils reg:0x%X, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 读离散量输入请求处理(0x02) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 离散量数量 1离散量=1bit + * + * @param pData : 离散量状态(用户需将本地的离散量状态放进去) + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_RD_COIL_NUM_MAX */ + if(MB_RD_COIL_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req02h> read discrete inputs reg:0x%X, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 读保持寄存器请求处理(0x03) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 寄存器数量 1寄存器=16bit + * + * @param pData : 保持寄存器值(用户需将本地的保持寄存器值放进去) + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_RD_REG_NUM_MAX */ + if(MB_RD_REG_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req03h> read holding registers reg:0x%X, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 读输入寄存器请求处理(0x04) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 寄存器数量 1寄存器=16bit + * + * @param pData : 输入寄存器值(用户需将本地的输入寄存器值放进去) + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_RD_REG_NUM_MAX */ + if(MB_RD_REG_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req04h> read input registers reg:0x%X, num:%d, we should put the data in parameter pData\r\n", ch, reg, num); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 写单个线圈请求处理(0x05) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param bit : 线圈值 0/1 + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + */ +__WEAK uint8_t mb_slave_req_05h(uint8_t ch, uint16_t reg, uint8_t bit) +{ + /* 单次写入请求无需数量检查 */ + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + 1)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req05h> write single coil reg:0x%X, status:%d\r\n", ch, reg, bit); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 写单个寄存器请求处理(0x06) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param data : 寄存器值 + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + */ +__WEAK uint8_t mb_slave_req_06h(uint8_t ch, uint16_t reg, uint16_t data) +{ + /* 单次写入请求无需数量检查 */ + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + 1)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req06h> write single register reg:0x%X, data:%X\r\n", ch, reg, data); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 写多个线圈请求处理(0x0f) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 线圈数量 1线圈=1bit + * + * @param pData : 线圈状态 + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_0fh(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_WR_COIL_NUM_MAX */ + if(MB_WR_COIL_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + uint8_t bytes = (num + 7) >> 3; + + PRINT_LOG("modbus slave[%d] req0fh> write multiple coils reg:0x%X, num:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < bytes; i++) + { + PRINT_LOG("%X ", pData[i]); + } + PRINT_LOG("\r\n"); +#endif + + return MB_ERRNO_OK; +} + +/** + * @brief 写多个寄存器请求处理(0x10) + * + * @param ch : modbus从机管理序号(即数组索引) + * + * @param reg : 起始地址 + * + * @param num : 寄存器数量 1寄存器=16bit + * + * @param pData : 寄存器状态 + * + * @retval uint8_t + * @arg MB_ERRNO_OK : 处理完成 + * @arg MB_ERRNO_ADDR : 处理错误,返回错误代码02 + * @arg MB_ERRNO_DATA : 处理错误,返回错误代码03 + */ +__WEAK uint8_t mb_slave_req_10h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 数量检查 仅为示例用户根据情况修改但不应超过最大限制MB_WR_REG_NUM_MAX */ + if(MB_WR_REG_NUM_MAX < num) { return MB_ERRNO_DATA; } + /* 地址检查 仅为示例用户根据情况修改 */ + if(0x1000 < (reg + num)) { return MB_ERRNO_ADDR; } + +#if _MBS_DEBUG + PRINT_LOG("modbus slave[%d] req10h> write multiple registers reg:0x%X, num:%d, data:", ch, reg, num); + for(uint8_t i = 0; i < num; i++) + { + PRINT_LOG("%X ", (pData[i << 1] << 8) | pData[(i << 1) + 1]); + } + PRINT_LOG("\r\n"); +#endif + + return MB_ERRNO_OK; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ diff --git a/drivers/modbus/modbus_slave.h b/drivers/modbus/modbus_slave.h index d27065e..0263df2 100644 --- a/drivers/modbus/modbus_slave.h +++ b/drivers/modbus/modbus_slave.h @@ -3,7 +3,7 @@ * @file modbus_slave.h * @author ashuai0110 * @version V2.1 - * @date 2023-10-19 + * @date 2023-10-25 * @brief modbus从机程序(RTU ASCII) * ****************************************************************************** @@ -41,7 +41,7 @@ extern "C" { * @{ */ -#define _MBS_DEBUG (1u) /*!< modbus从机调试信息打印开关 0:关闭 1:开启 */ +#define _MBS_DEBUG (0u) /*!< modbus从机调试信息打印开关 0:关闭 1:开启 */ #define MBS_NUM (3u) /*!< modbus从机管理数量 用户根据需求自行修改 */ @@ -65,13 +65,11 @@ typedef struct mb_slave { uint16_t readLen; /*!< 读出数据长度 */ uint8_t slaveAddr; /*!< 从机地址 1~247 */ - uint8_t protocol : 2; /*!< 协议类型 @ref modbus_slave_protocol */ - uint8_t state : 2; /*!< 应答状态 @ref modbus_slave_state */ + uint8_t protocol : 1; /*!< 协议类型 @ref modbus_common_protocol */ + uint8_t state : 2; /*!< 请求状态 @ref modbus_common_state */ uint16_t targetFrameIntv; /*!< 目标帧间隔ms */ uint16_t curFrameIntv; /*!< 当前帧间隔ms */ - uint16_t regTmp; /*!< 从机命令中的起始地址暂存 */ - uint16_t numTmp; /*!< 从机命令中的数量暂存 */ modbus_tx_en_t txEnFn; /*!< 从机发送前(串口)准备函数 */ } mb_slave_t; @@ -103,10 +101,14 @@ void mb_slave_set_frame_intv(uint8_t ch, uint32_t baud); uint16_t mb_slave_get_frame_intv(uint8_t ch); /* 弱定义函数 */ -void mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); -void mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); -void mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); -void mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_05h(uint8_t ch, uint16_t reg, uint8_t bit); +uint8_t mb_slave_req_06h(uint8_t ch, uint16_t reg, uint16_t data); +uint8_t mb_slave_req_0fh(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); +uint8_t mb_slave_req_10h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData); /** * @} diff --git a/examples/command_line/SRC/main.c b/examples/command_line/SRC/main.c index d3caf91..a297692 100644 --- a/examples/command_line/SRC/main.c +++ b/examples/command_line/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/delay_no_block/SRC/main.c b/examples/delay_no_block/SRC/main.c index 58b57b7..233039a 100644 --- a/examples/delay_no_block/SRC/main.c +++ b/examples/delay_no_block/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/input_output/SRC/main.c b/examples/input_output/SRC/main.c index 3afb696..d19fd3a 100644 --- a/examples/input_output/SRC/main.c +++ b/examples/input_output/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/memory/SRC/main.c b/examples/memory/SRC/main.c index 63e41eb..789ceb7 100644 --- a/examples/memory/SRC/main.c +++ b/examples/memory/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/message_queue/SRC/main.c b/examples/message_queue/SRC/main.c index 73cf01e..13aa2a9 100644 --- a/examples/message_queue/SRC/main.c +++ b/examples/message_queue/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/modbus_host/MDK/use_example.uvoptx b/examples/modbus_host/MDK/use_example.uvoptx index e576e49..4e72eb1 100644 --- a/examples/modbus_host/MDK/use_example.uvoptx +++ b/examples/modbus_host/MDK/use_example.uvoptx @@ -148,24 +148,7 @@ UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) - - - 0 - 0 - 112 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - ..\SRC\main.c - - -
-
+ 0 diff --git a/examples/modbus_host/MDK/use_example.uvprojx b/examples/modbus_host/MDK/use_example.uvprojx index 02fb4f8..582b760 100644 --- a/examples/modbus_host/MDK/use_example.uvprojx +++ b/examples/modbus_host/MDK/use_example.uvprojx @@ -16,8 +16,8 @@ STM32F103C8 STMicroelectronics - Keil.STM32F1xx_DFP.2.4.1 - https://www.keil.com/pack/ + Keil.STM32F1xx_DFP.2.4.0 + http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE diff --git a/examples/modbus_host/README.txt b/examples/modbus_host/README.txt index 71ff945..8bf433e 100644 --- a/examples/modbus_host/README.txt +++ b/examples/modbus_host/README.txt @@ -2,7 +2,7 @@ 用例使用说明 ================================================================================ Date Author MDK MCU -2023-10-21 ashuai0110 5.35 STM32F1 +2023-10-25 ashuai0110 5.35 STM32F1 ================================================================================ 功能描述 @@ -28,6 +28,8 @@ Modbus Slave 源码文件: --------------------- +modbus_common.c +modbus_common.h modbus_host.c modbus_host.h diff --git a/examples/modbus_host/SRC/main.c b/examples/modbus_host/SRC/main.c index 7397b6b..c54242e 100644 --- a/examples/modbus_host/SRC/main.c +++ b/examples/modbus_host/SRC/main.c @@ -3,13 +3,13 @@ * @file main.c * @author ashuai0110 * @version V1.0 - * @date 2023-10-21 + * @date 2023-10-25 * @brief 使用举例-MODBUS主机程序 * ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** @@ -22,8 +22,6 @@ #include "modbus_host.h" -#include - /* 私有宏定义-----------------------------------------------------------------*/ #define USART1_MB_CH (0u) /* modbus主机管理序号 */ @@ -39,10 +37,15 @@ const static char *modbusErrorStr[] = { static uint8_t modbusBuf[MB_BUF_SIZE_MAX]; /* modbus所需缓存区 */ /* 全局变量-------------------------------------------------------------------*/ -uint8_t coilStatus[8]; /* 线圈 */ -uint8_t inputStatus[8]; /* 输入线圈 */ -uint16_t holdingRegister[8]; /* 保持寄存器 */ -uint16_t inputRegister[8]; /* 输入寄存器 */ +/* +注意: +本例应答处理中的线圈地址和寄存器地址均与本地线圈地址和本地寄存器地址一一对应, +若用户的存在偏移关系需自行修改添加. +*/ +uint8_t coilStatus[8]; /* 线圈 共8*8=64个 地址0~63 */ +uint8_t inputStatus[8]; /* 输入线圈 共8*8=64个 地址0~63 */ +uint16_t holdingRegister[8]; /* 保持寄存器 共8*1=8个 地址0~7 */ +uint16_t inputRegister[8]; /* 输入寄存器 共8*1=8个 地址0~7 */ /* 私有函数原型---------------------------------------------------------------*/ @@ -64,7 +67,7 @@ void TIM1_UP_IRQHandler(void) /* 处理中 */ if(RET_ING == ret) { - } /* 应答完成 */ + } /* 应答处理完成 */ else if(RET_OK == ret) { DEBUG_LOG("response success"); @@ -149,7 +152,7 @@ int main(int argc, char *argv[]) /* 串口初始化 9600 */ usart1_init_config(9600); - /* modbus主机初始化 */ + /* modbus主机初始化 协议RTU 波特率9600bps 接收超时500ms */ mb_host_init(USART1_MB_CH, MB_RTU, modbusBuf, sizeof(modbusBuf), uart_tx_en, 9600, 500); /* 发送读取线圈命令 */ @@ -183,105 +186,101 @@ int main(int argc, char *argv[]) /* 此为弱定义函数的重定义 函数解释可在源码中查看 */ void mb_host_rsp_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - uint8_t bytes = ceil((double)num / 8.0); /* 向上取整计算字节数 */ - uint8_t dataTmp; + int16_t numTmp; - DEBUG_LOG("before-coilStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", coilStatus[0], \ + DEBUG_LOG("before-coilStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", coilStatus[0], \ coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); /* 判断序号 */ if(USART1_MB_CH == ch) { - /* 循环赋值 */ - for(uint8_t i = 0; i < bytes; i++) + numTmp = num; + while(0 < numTmp) { - /* 不满8bit进行位替换 */ - if(8 > num) - { - dataTmp = BIT_REPLACE(coilStatus[reg + i], pData[i], num); - } /* 满8bit直接赋值 */ - else - { - dataTmp = pData[i]; - } - coilStatus[reg + i] = dataTmp; /* 假设请求时的线圈地址 == 本地线圈地址 */ - num -= 8; + /* 设置线圈状态 */ + mb_set_bits(&coilStatus[0], reg, numTmp > 8 ? 8 : numTmp, *pData++); + numTmp -= 8; + reg += 8; } } - DEBUG_LOG("after-coilStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", coilStatus[0], \ + DEBUG_LOG("after-coilStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", coilStatus[0], \ coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); } /* 此为弱定义函数的重定义 函数解释可在源码中查看 */ void mb_host_rsp_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - uint8_t bytes = ceil((double)num / 8.0); /* 向上取整计算字节数 */ - uint8_t dataTmp; + int16_t numTmp; - DEBUG_LOG("before-inputStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputStatus[0], \ + DEBUG_LOG("before-inputStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", inputStatus[0], \ inputStatus[1], inputStatus[2], inputStatus[3], inputStatus[4], inputStatus[5], inputStatus[6], inputStatus[7]); /* 判断序号 */ if(USART1_MB_CH == ch) { - /* 循环赋值 */ - for(uint8_t i = 0; i < bytes; i++) + numTmp = num; + while(0 < numTmp) { - /* 不满8bit进行位替换 */ - if(8 > num) - { - dataTmp = BIT_REPLACE(inputStatus[reg + i], pData[i], num); - } /* 满8bit直接赋值 */ - else - { - dataTmp = pData[i]; - } - inputStatus[reg + i] = dataTmp; /* 假设请求时的线圈地址 == 本地线圈地址 */ - num -= 8; + /* 设置线圈状态 */ + mb_set_bits(&inputStatus[0], reg, numTmp > 8 ? 8 : numTmp, *pData++); + numTmp -= 8; + reg += 8; } } - DEBUG_LOG("after-inputStatus: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputStatus[0], \ + DEBUG_LOG("after-inputStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", inputStatus[0], \ inputStatus[1], inputStatus[2], inputStatus[3], inputStatus[4], inputStatus[5], inputStatus[6], inputStatus[7]); } /* 此为弱定义函数的重定义 函数解释可在源码中查看 */ void mb_host_rsp_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - DEBUG_LOG("before-holdingRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", holdingRegister[0], holdingRegister[1], \ + DEBUG_LOG("before-holdingRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", holdingRegister[0], holdingRegister[1], \ holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); - /* 循环赋值 */ - for(uint8_t i = 0; i < num; i++) + /* 判断序号 */ + if(USART1_MB_CH == ch) { - /* 假设请求时的寄存器地址 == 本地寄存器地址 */ - holdingRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + for(uint8_t i = 0; i < num; i++) + { + /* 设置寄存器值 */ + holdingRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + } } - DEBUG_LOG("after-holdingRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", holdingRegister[0], holdingRegister[1], \ + DEBUG_LOG("after-holdingRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", holdingRegister[0], holdingRegister[1], \ holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); } /* 此为弱定义函数的重定义 函数解释可在源码中查看 */ void mb_host_rsp_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) { - DEBUG_LOG("before-inputRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputRegister[0], inputRegister[1], \ + DEBUG_LOG("before-inputRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", inputRegister[0], inputRegister[1], \ inputRegister[2], inputRegister[3], inputRegister[4], inputRegister[5], inputRegister[6], inputRegister[7]); - /* 循环赋值 */ - for(uint8_t i = 0; i < num; i++) + /* 判断序号 */ + if(USART1_MB_CH == ch) { - /* 假设请求时的寄存器地址 == 本地寄存器地址 */ - inputRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + for(uint8_t i = 0; i < num; i++) + { + /* 设置寄存器值 */ + inputRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + } } - DEBUG_LOG("after-inputRegister: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", inputRegister[0], inputRegister[1], \ + DEBUG_LOG("after-inputRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", inputRegister[0], inputRegister[1], \ inputRegister[2], inputRegister[3], inputRegister[4], inputRegister[5], inputRegister[6], inputRegister[7]); } +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +void mb_host_rsp_05_10h(uint8_t ch) +{ + DEBUG_LOG("modbus host[%d]: write data success"); +} + /* 此为弱定义函数的重定义 函数解释可在源码中查看 */ void mb_host_rsp_err(uint8_t ch, uint8_t *pData) { - DEBUG_LOG("modbus host[%d] rspErr> errFunCode:%02X, errCode:%02X", ch, pData[0], pData[1]); + DEBUG_LOG("modbus host[%d]: errFunCode:0x%X, errCode:0x%X", ch, pData[0], pData[1]); } diff --git a/examples/modbus_slave/MDK/use_example.uvoptx b/examples/modbus_slave/MDK/use_example.uvoptx new file mode 100644 index 0000000..3107cef --- /dev/null +++ b/examples/modbus_slave/MDK/use_example.uvoptx @@ -0,0 +1,672 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp; *.cc; *.cxx + 0 + + + + 0 + 0 + + + + Target 1 + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + + + Segger\JL2CM3.dll + + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + DLGUARM + d + + + 0 + JL2CM3 + -U59522627 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + + + + + 0 + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 1 + 0 + 2 + 10000000 + + + + + + cmsis + 0 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + core_cm3.c + 0 + 0 + + + 1 + 2 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + stm32f10x_it.c + 0 + 0 + + + 1 + 3 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + system_stm32f10x.c + 0 + 0 + + + 1 + 4 + 2 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + startup_stm32f10x_md.s + 0 + 0 + + + + + libs + 0 + 0 + 0 + 0 + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + misc.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + stm32f10x_adc.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + stm32f10x_bkp.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + stm32f10x_can.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + stm32f10x_cec.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + stm32f10x_crc.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + stm32f10x_dac.c + 0 + 0 + + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + stm32f10x_dbgmcu.c + 0 + 0 + + + 2 + 13 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + stm32f10x_dma.c + 0 + 0 + + + 2 + 14 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + stm32f10x_exti.c + 0 + 0 + + + 2 + 15 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + stm32f10x_flash.c + 0 + 0 + + + 2 + 16 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + stm32f10x_fsmc.c + 0 + 0 + + + 2 + 17 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + stm32f10x_gpio.c + 0 + 0 + + + 2 + 18 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + stm32f10x_i2c.c + 0 + 0 + + + 2 + 19 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + stm32f10x_iwdg.c + 0 + 0 + + + 2 + 20 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + stm32f10x_pwr.c + 0 + 0 + + + 2 + 21 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + stm32f10x_rcc.c + 0 + 0 + + + 2 + 22 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + stm32f10x_rtc.c + 0 + 0 + + + 2 + 23 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + stm32f10x_sdio.c + 0 + 0 + + + 2 + 24 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + stm32f10x_spi.c + 0 + 0 + + + 2 + 25 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + stm32f10x_tim.c + 0 + 0 + + + 2 + 26 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + stm32f10x_usart.c + 0 + 0 + + + 2 + 27 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + stm32f10x_wwdg.c + 0 + 0 + + + + + segger + 0 + 0 + 0 + 0 + + 3 + 28 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + SEGGER_RTT.c + 0 + 0 + + + 3 + 29 + 1 + 0 + 0 + 0 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + SEGGER_RTT_printf.c + 0 + 0 + + + + + system + 1 + 0 + 0 + 0 + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + tim.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + usart.c + 0 + 0 + + + + + source + 1 + 0 + 0 + 0 + + 5 + 32 + 1 + 0 + 0 + 0 + ..\SRC\main.c + main.c + 0 + 0 + + + 5 + 33 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_common.c + modbus_common.c + 0 + 0 + + + 5 + 34 + 1 + 0 + 0 + 0 + ..\..\..\drivers\modbus\modbus_slave.c + modbus_slave.c + 0 + 0 + + + + + readme + 1 + 0 + 0 + 0 + + 6 + 35 + 5 + 0 + 0 + 0 + ..\README.txt + README.txt + 0 + 0 + + + +
diff --git a/examples/modbus_slave/MDK/use_example.uvprojx b/examples/modbus_slave/MDK/use_example.uvprojx new file mode 100644 index 0000000..51e7d24 --- /dev/null +++ b/examples/modbus_slave/MDK/use_example.uvprojx @@ -0,0 +1,607 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + 0 + + + STM32F103C8 + STMicroelectronics + Keil.STM32F1xx_DFP.2.4.0 + http://www.keil.com/pack/ + IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00010000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM)) + 0 + $$Device:STM32F103C8$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103C8$SVD\STM32F103xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + use_example + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 1 + 0x8000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x10000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x5000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 3 + 3 + 1 + 1 + 0 + 0 + 0 + + + STM32F10X_MD,USE_STDPERIPH_DRIVER + + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\inc;..\..\[base_on_stm32f1]\stm32f1_lib\cmsis;..\..\[base_on_stm32f1]\stm32f1_sys;..\..\..\drivers\common;..\..\..\drivers\modules;..\..\..\drivers\segger_rtt;..\..\..\drivers\modbus + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + cmsis + + + core_cm3.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\core_cm3.c + + + stm32f10x_it.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\stm32f10x_it.c + + + system_stm32f10x.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\system_stm32f10x.c + + + startup_stm32f10x_md.s + 2 + ..\..\[base_on_stm32f1]\stm32f1_lib\cmsis\startup\startup_stm32f10x_md.s + + + + + libs + + + misc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\misc.c + + + stm32f10x_adc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_adc.c + + + stm32f10x_bkp.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_bkp.c + + + stm32f10x_can.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_can.c + + + stm32f10x_cec.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_cec.c + + + stm32f10x_crc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_crc.c + + + stm32f10x_dac.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dac.c + + + stm32f10x_dbgmcu.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dbgmcu.c + + + stm32f10x_dma.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_dma.c + + + stm32f10x_exti.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_exti.c + + + stm32f10x_flash.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_flash.c + + + stm32f10x_fsmc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_fsmc.c + + + stm32f10x_gpio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_gpio.c + + + stm32f10x_i2c.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_i2c.c + + + stm32f10x_iwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_iwdg.c + + + stm32f10x_pwr.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_pwr.c + + + stm32f10x_rcc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rcc.c + + + stm32f10x_rtc.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_rtc.c + + + stm32f10x_sdio.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_sdio.c + + + stm32f10x_spi.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_spi.c + + + stm32f10x_tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_tim.c + + + stm32f10x_usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_usart.c + + + stm32f10x_wwdg.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_lib\driver\src\stm32f10x_wwdg.c + + + + + segger + + + SEGGER_RTT.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT.c + + + SEGGER_RTT_printf.c + 1 + ..\..\..\drivers\segger_rtt\SEGGER_RTT_printf.c + + + + + system + + + tim.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\tim.c + + + usart.c + 1 + ..\..\[base_on_stm32f1]\stm32f1_sys\usart.c + + + + + source + + + main.c + 1 + ..\SRC\main.c + + + modbus_common.c + 1 + ..\..\..\drivers\modbus\modbus_common.c + + + modbus_slave.c + 1 + ..\..\..\drivers\modbus\modbus_slave.c + + + + + readme + + + README.txt + 5 + ..\README.txt + + + + + + + + + + + + + + + + + use_example + 1 + + + + +
diff --git a/examples/modbus_slave/README.txt b/examples/modbus_slave/README.txt new file mode 100644 index 0000000..34068c5 --- /dev/null +++ b/examples/modbus_slave/README.txt @@ -0,0 +1,50 @@ +================================================================================ + 用例使用说明 +================================================================================ +Date Author MDK MCU +2023-10-25 ashuai0110 5.35 STM32F1 + +================================================================================ +功能描述 +================================================================================ +本用例展示了modbus从机程序组件的使用方法。 + +================================================================================ +测试环境 +================================================================================ +测试用板: +--------------------- +任意开发板 + +辅助工具: +--------------------- +J-Link +usb转串口 + +辅助软件: +--------------------- +J-Link RTT Viewer +Modbus Poll + +源码文件: +--------------------- +modbus_common.c +modbus_common.h +modbus_slave.c +modbus_slave.h + +================================================================================ +使用步骤 +================================================================================ +1)使用J-Link连接目标板; +2)使用usb转串口连接电脑; +3)打开工程,重新编译并下载,打开J-Link RTT Viewer进行监控; +4)打开Modbus Poll软件设置串口参数并连接对应串口,选择不同的功能码逐一进行测试, + 读请求时查看Modbus Poll对应数值,写请求时查看J-Link RTT Viewer输出信息。 + +================================================================================ +注意 +================================================================================ +1)用户根据需求可前往源码头文件修改宏定义参数 + +================================================================================ diff --git a/examples/modbus_slave/SRC/main.c b/examples/modbus_slave/SRC/main.c new file mode 100644 index 0000000..e3c427e --- /dev/null +++ b/examples/modbus_slave/SRC/main.c @@ -0,0 +1,344 @@ +/** + ****************************************************************************** + * @file main.c + * @author ashuai0110 + * @version V1.0 + * @date 2023-10-25 + * @brief 使用举例-MODBUS从机程序 + * + ****************************************************************************** + * @attention + * + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ + * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module + * + ****************************************************************************** + */ + +/* 包含头文件-----------------------------------------------------------------*/ +#include "stm32f10x.h" +#include "tim.h" +#include "usart.h" + +#include "modbus_slave.h" + +/* 私有宏定义-----------------------------------------------------------------*/ +#define USART1_MB_CH (0u) /* modbus从机管理序号 */ + +/* 私有类型定义---------------------------------------------------------------*/ + +/* 私有变量-------------------------------------------------------------------*/ +const static char *modbusErrorStr[] = { + "request message length error!", + "request message check error!", + "request message frame error!", +}; + +static uint8_t modbusBuf[MB_BUF_SIZE_MAX]; /* modbus所需缓存区 */ + +/* 全局变量-------------------------------------------------------------------*/ +uint8_t coilStatus[8] = {0xC3, 0x3C, 0x55, 0xAA}; /* 线圈 共8*8=64个 地址0~63 */ +uint8_t inputStatus[8] = {0x55, 0xAA, 0xC3, 0x3C}; /* 输入线圈 共8*8=64个 地址0~63 */ +uint16_t holdingRegister[8] = {0x111, 0x222, 0x333, 0x444}; /* 保持寄存器 共8*1=8个 地址0~7 */ +uint16_t inputRegister[8] = {0x555, 0x666, 0x777, 0x888}; /* 输入寄存器 共8*1=8个 地址0~7 */ + +/* 私有函数原型---------------------------------------------------------------*/ + +/** + * @brief 定时器中断函数 + * + * @param None + * + * @retval None + */ +void TIM1_UP_IRQHandler(void) +{ + static uint8_t ret; + + if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) + { + /* modbus从机轮询处理 */ + ret = mb_slave_poll(USART1_MB_CH); + /* 处理中 */ + if(RET_ING == ret) + { + } /* 请求处理完成 */ + else if(RET_OK == ret) + { + DEBUG_LOG("request success"); + } /* 请求错误 */ + else + { + ERROR_LOG("request error: %s", modbusErrorStr[ret - RET_LEN_ERR]); + } + + TIM_ClearITPendingBit(TIM1, TIM_FLAG_Update); + } +} + +/** + * @brief 串口中断函数 + * + * @param None + * + * @retval None + */ +void USART1_IRQHandler(void) +{ + static uint8_t rxData, txData, ret; + + if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) + { + rxData = USART_ReceiveData(USART1); + /* 写入接收缓存 */ + ret = mb_slave_write_rx_buf(USART1_MB_CH, &rxData, 1); + if(0 == ret) + { + WARN_LOG("mb_slave_write_rx_buf failure"); + } + + USART_ClearITPendingBit(USART1, USART_IT_RXNE); + } + + if(USART_GetITStatus(USART1, USART_IT_TC) != RESET) + { + /* 读出发送缓存 */ + ret = mb_slave_read_tx_buf(USART1_MB_CH, &txData, 1); + if(0 != ret) + { + USART_SendData(USART1, txData); + } + + USART_ClearITPendingBit(USART1, USART_IT_TC); + } +} + +/** + * @brief 串口发送中断开关函数 + * + * @param None + * + * @retval None + */ +void uart_tx_en(uint8_t enState) +{ + if(enState) + { + /* 使能发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, ENABLE); + } + else + { + /* 关闭发送中断 */ + USART_ITConfig(USART1, USART_IT_TC, DISABLE); + } +} + +int main(int argc, char *argv[]) +{ + VERSION_LOG("example-modbus_slave", 1, 0, 0); + + /* 定时器初始化 1ms */ + tim1_init_config(100-1, 720-1); + /* 串口初始化 9600 */ + usart1_init_config(9600); + + /* modbus从机初始化 从机地址0x1 协议RTU 波特率9600bps*/ + mb_slave_init(USART1_MB_CH, 0x1, MB_RTU, modbusBuf, sizeof(modbusBuf), uart_tx_en, 9600); + + while(1) + { + + } +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_01h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + int16_t numTmp; + + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(64 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(63 < reg) { return MB_ERRNO_ADDR; } + + numTmp = num; + while(0 < numTmp) + { + /* 获取线圈状态 */ + *pData++ = mb_get_bits(&coilStatus[0], reg, numTmp > 8 ? 8 : numTmp); + numTmp -= 8; + reg += 8; + } + } + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_02h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + int16_t numTmp; + + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(64 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(63 < reg) { return MB_ERRNO_ADDR; } + + numTmp = num; + while(0 < numTmp) + { + /* 获取线圈状态 */ + *pData++ = mb_get_bits(&inputStatus[0], reg, numTmp > 8 ? 8 : numTmp); + numTmp -= 8; + reg += 8; + } + } + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_03h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(8 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(7 < reg) { return MB_ERRNO_ADDR; } + + for(uint8_t cnt = 0; cnt < num; cnt++) + { + /* 获取寄存器值 */ + *pData++ = holdingRegister[reg] >> 8; + *pData++ = holdingRegister[reg] & 0xFF; + } + } + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_04h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(8 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(7 < reg) { return MB_ERRNO_ADDR; } + + for(uint8_t cnt = 0; cnt < num; cnt++) + { + /* 获取寄存器值 */ + *pData++ = inputRegister[reg] >> 8; + *pData++ = inputRegister[reg] & 0xFF; + } + } + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_05h(uint8_t ch, uint16_t reg, uint8_t bit) +{ + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 地址检查 */ + if(63 < reg) { return MB_ERRNO_ADDR; } + /* 写入线圈状态 */ + mb_set_bits(&coilStatus[0], reg, 1, bit); + } + + DEBUG_LOG("05-coilStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", coilStatus[0], \ + coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_06h(uint8_t ch, uint16_t reg, uint16_t data) +{ + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 地址检查 */ + if(7 < reg) { return MB_ERRNO_ADDR; } + /* 写入寄存器值 */ + holdingRegister[reg] = data; + } + + DEBUG_LOG("06-holdingRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", holdingRegister[0], holdingRegister[1], \ + holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_0fh(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + int16_t numTmp; + + DEBUG_LOG("before-coilStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", coilStatus[0], \ + coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); + + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(64 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(63 < reg) { return MB_ERRNO_ADDR; } + + numTmp = num; + while(0 < numTmp) + { + /* 写入线圈状态 */ + mb_set_bits(&coilStatus[0], reg, numTmp > 8 ? 8 : numTmp, *pData++); + numTmp -= 8; + reg += 8; + } + } + + DEBUG_LOG("after-coilStatus: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", coilStatus[0], \ + coilStatus[1],coilStatus[2],coilStatus[3], coilStatus[4], coilStatus[5], coilStatus[6], coilStatus[7]); + + return MB_ERRNO_OK; +} + +/* 此为弱定义函数的重定义 函数解释可在源码中查看 */ +uint8_t mb_slave_req_10h(uint8_t ch, uint16_t reg, uint16_t num, uint8_t *pData) +{ + DEBUG_LOG("before-holdingRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", holdingRegister[0], holdingRegister[1], \ + holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); + + /* 判断序号 */ + if(USART1_MB_CH == ch) + { + /* 数量检查 */ + if(8 < num) { return MB_ERRNO_DATA; } + /* 地址检查 */ + if(7 < reg) { return MB_ERRNO_ADDR; } + + for(uint8_t i = 0; i < num; i++) + { + /* 写入寄存器值 */ + holdingRegister[reg + i] = (pData[i * 2] << 8) | pData[i * 2 + 1]; + } + } + + DEBUG_LOG("after-holdingRegister: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", holdingRegister[0], holdingRegister[1], \ + holdingRegister[2], holdingRegister[3], holdingRegister[4], holdingRegister[5], holdingRegister[6], holdingRegister[7]); + + return MB_ERRNO_OK; +} diff --git a/examples/project_template/SRC/main.c b/examples/project_template/SRC/main.c index 5b2b02a..1a7c601 100644 --- a/examples/project_template/SRC/main.c +++ b/examples/project_template/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/ring_buffer/SRC/main.c b/examples/ring_buffer/SRC/main.c index 44b05f8..9c542c8 100644 --- a/examples/ring_buffer/SRC/main.c +++ b/examples/ring_buffer/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/ring_queue/SRC/main.c b/examples/ring_queue/SRC/main.c index 1bee2cb..7d0debd 100644 --- a/examples/ring_queue/SRC/main.c +++ b/examples/ring_queue/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/sync_method/SRC/main.c b/examples/sync_method/SRC/main.c index e9db980..b538af2 100644 --- a/examples/sync_method/SRC/main.c +++ b/examples/sync_method/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/timer_software/SRC/main.c b/examples/timer_software/SRC/main.c index 590cea0..d52edff 100644 --- a/examples/timer_software/SRC/main.c +++ b/examples/timer_software/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** diff --git a/examples/uart_handler/SRC/main.c b/examples/uart_handler/SRC/main.c index 7a9c343..d2dfeef 100644 --- a/examples/uart_handler/SRC/main.c +++ b/examples/uart_handler/SRC/main.c @@ -9,7 +9,7 @@ ****************************************************************************** * @attention * - * 版权声明:内容为编者原创,遵循CC4.0BY-SA版权协议,使用请附上出处链接和本声明 + * 版权声明:内容为编者(ashuai0110)原创,使用请注明出处,当然,你也可以不这样做^_^ * 出处链接:https://gitee.com/ashuai0110/mcu_reuse_development_module * ****************************************************************************** -- Gitee From e375b2c94b8fe1544eccfa1a8d5650124101a27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E5=B8=85=E6=9D=B0?= Date: Thu, 26 Oct 2023 18:03:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=BA=90=E7=A0=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E5=A2=9E=E5=8A=A0chm=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documents/doxygen/Doxyfile | 2862 +++++++++++++++++ ...ivers1686d5785c533d0dc81d0ee5eb80b2cf.html | 181 -- ...ivers2ba4bf0df35c7cbc8d9a6f2336fa96ef.html | 253 -- ...ivers6a582457a908fd5277f433c409afbcb7.html | 103 - ...ivers78a11cfb658a54a62e808b1c2c141e2d.html | 110 - ...ivers7e0c97abf79fd8f95bf5c94ce7e03ffa.html | 249 -- ...ivers8d7905b30d9704671a65c06b3958c380.html | 138 - ...ivers98a5cfc2e7056fc8e819d4a3d6021344.html | 291 -- ...ivers9f11fe5aefc81df42df0a4ed082eda36.html | 271 -- ..._2drivers_2modules_2memory_8h-example.html | 112 - ...iversa5d231cb1b3feec39fda5b5451caa282.html | 117 - ...iversd017b0c75ae0ea43167f4a09ef7b8068.html | 200 -- ...iversf3ae7a7bcf3054905f903371253e070d.html | 266 -- ...iversf77ba960ea085e6253d7a8eabac886b7.html | 105 - documents/html/_multi_all_8h.html | 91 - documents/html/_multi_all_8h__incl.dot | 42 - documents/html/_multi_all_8h_source.html | 108 - documents/html/annotated.html | 72 - documents/html/bc_s.png | Bin 676 -> 0 bytes documents/html/bc_sd.png | Bin 635 -> 0 bytes documents/html/classes.html | 81 - documents/html/closed.png | Bin 132 -> 0 bytes documents/html/command__line_8c.html | 371 --- documents/html/command__line_8c__incl.dot | 12 - ...4ba2de00c52759a418be208acce91a_icgraph.dot | 11 - ...c618d80b44a3b1d0abeb6176e7a3d72_cgraph.dot | 11 - documents/html/command__line_8c_source.html | 304 -- documents/html/command__line_8h.html | 623 ---- .../html/command__line_8h__dep__incl.dot | 12 - documents/html/command__line_8h__incl.dot | 10 - ...4ba2de00c52759a418be208acce91a_icgraph.dot | 11 - ...c618d80b44a3b1d0abeb6176e7a3d72_cgraph.dot | 11 - documents/html/command__line_8h_source.html | 142 - documents/html/data__convert_8c.html | 297 -- documents/html/data__convert_8c__incl.dot | 12 - documents/html/data__convert_8c_source.html | 190 -- documents/html/data__convert_8h.html | 253 -- .../html/data__convert_8h__dep__incl.dot | 12 - documents/html/data__convert_8h__incl.dot | 10 - documents/html/data__convert_8h_source.html | 91 - documents/html/delay__no__block_8c.html | 354 -- documents/html/delay__no__block_8c__incl.dot | 12 - .../html/delay__no__block_8c_source.html | 225 -- documents/html/delay__no__block_8h.html | 395 --- .../html/delay__no__block_8h__dep__incl.dot | 12 - documents/html/delay__no__block_8h__incl.dot | 10 - .../html/delay__no__block_8h_source.html | 111 - .../dir_14bc92f4b96c8519b376567118ac28b3.html | 66 - .../dir_59dd3925026fef5fcb96e4631530be30.html | 142 - ...r_59dd3925026fef5fcb96e4631530be30_dep.dot | 12 - documents/html/doc.svg | 12 - documents/html/docd.svg | 12 - documents/html/doxygen.css | 1703 ---------- documents/html/doxygen.svg | 28 - documents/html/dynsections.js | 199 -- documents/html/examples.html | 65 - documents/html/files.html | 89 - documents/html/folderclosed.svg | 11 - documents/html/folderclosedd.svg | 11 - documents/html/folderopen.svg | 17 - documents/html/folderopend.svg | 12 - documents/html/functions.html | 165 - documents/html/functions_vars.html | 165 - documents/html/globals.html | 83 - documents/html/globals_c.html | 102 - documents/html/globals_d.html | 91 - documents/html/globals_defs.html | 148 - documents/html/globals_e.html | 119 - documents/html/globals_enum.html | 71 - documents/html/globals_eval.html | 123 - documents/html/globals_func.html | 189 -- documents/html/globals_i.html | 123 - documents/html/globals_m.html | 102 - documents/html/globals_o.html | 84 - documents/html/globals_r.html | 98 - documents/html/globals_s.html | 103 - documents/html/globals_t.html | 99 - documents/html/globals_type.html | 91 - documents/html/globals_u.html | 92 - documents/html/graph_legend.dot | 24 - documents/html/graph_legend.html | 111 - documents/html/group__input__edge__type.dot | 11 - documents/html/group__input__edge__type.html | 120 - documents/html/group__input__output.dot | 23 - documents/html/group__input__output.html | 74 - ...t__output__check__parameters__validity.dot | 11 - ...__output__check__parameters__validity.html | 116 - ...roup__input__output__global__functions.dot | 11 - ...oup__input__output__global__functions.html | 641 ---- ...ce07677ae18b79b5f8575c76119261_icgraph.dot | 11 - ...ed7db2b18b96c93a835fec5e3a8204_icgraph.dot | 11 - ...abf3501a551254e461d80d75a994d21_cgraph.dot | 11 - ...91402bc1da43af8da3fb16cbdcdd604_cgraph.dot | 11 - .../group__input__output__global__macros.dot | 21 - .../group__input__output__global__macros.html | 72 - .../group__input__output__global__types.dot | 11 - .../group__input__output__global__types.html | 155 - ...group__input__output__local__functions.dot | 11 - ...roup__input__output__local__functions.html | 56 - .../group__input__output__local__macros.dot | 13 - .../group__input__output__local__macros.html | 64 - ...group__input__output__local__variables.dot | 11 - ...roup__input__output__local__variables.html | 56 - documents/html/group__io__dir.dot | 11 - documents/html/group__io__dir.html | 101 - documents/html/group__io__run__flg.dot | 11 - documents/html/group__io__run__flg.html | 101 - documents/html/group__io__task__macros.dot | 11 - documents/html/group__io__task__macros.html | 114 - documents/html/group__modules.dot | 11 - documents/html/group__modules.html | 64 - documents/html/group__out__cycle__state.dot | 11 - documents/html/group__out__cycle__state.html | 101 - documents/html/index.hhc | 660 ---- documents/html/index.hhk | 2011 ------------ documents/html/index.hhp | 291 -- documents/html/index.html | 50 - documents/html/input__output_8c.html | 130 - documents/html/input__output_8c__incl.dot | 12 - documents/html/input__output_8c_source.html | 366 --- documents/html/input__output_8h.html | 173 - .../html/input__output_8h__dep__incl.dot | 12 - documents/html/input__output_8h__incl.dot | 10 - documents/html/input__output_8h_source.html | 162 - documents/html/jquery.js | 34 - documents/html/memory_8c.html | 428 --- documents/html/memory_8c__incl.dot | 12 - ...eb26194d6566a00d3a12dd0e7a9e9da_cgraph.dot | 11 - ...b26194d6566a00d3a12dd0e7a9e9da_icgraph.dot | 11 - ...fe1c4f5e666c54df3684421fa797a42_cgraph.dot | 11 - ...e1c4f5e666c54df3684421fa797a42_icgraph.dot | 11 - ...909f452e720046f8c2b2ef8facdceb_icgraph.dot | 17 - ...e06d9b0bb022a1643f16a5c4c675b60_cgraph.dot | 19 - ...977bd99aefb4eb4c2fd1055e7da50b_icgraph.dot | 11 - documents/html/memory_8c_source.html | 347 -- documents/html/memory_8h.html | 473 --- documents/html/memory_8h__dep__incl.dot | 12 - documents/html/memory_8h__incl.dot | 10 - ...eb26194d6566a00d3a12dd0e7a9e9da_cgraph.dot | 11 - ...b26194d6566a00d3a12dd0e7a9e9da_icgraph.dot | 11 - ...c118674c87f20ecea5cc3a1e01a561_icgraph.dot | 11 - ...fe1c4f5e666c54df3684421fa797a42_cgraph.dot | 11 - ...e1c4f5e666c54df3684421fa797a42_icgraph.dot | 11 - ...909f452e720046f8c2b2ef8facdceb_icgraph.dot | 17 - ...e06d9b0bb022a1643f16a5c4c675b60_cgraph.dot | 19 - documents/html/memory_8h_source.html | 122 - documents/html/menudata.js | 99 - documents/html/message__queue_8c.html | 331 -- documents/html/message__queue_8c__incl.dot | 12 - documents/html/message__queue_8c_source.html | 184 -- documents/html/message__queue_8h.html | 409 --- .../html/message__queue_8h__dep__incl.dot | 12 - documents/html/message__queue_8h__incl.dot | 10 - documents/html/message__queue_8h_source.html | 120 - documents/html/minus.svg | 8 - documents/html/minusd.svg | 8 - documents/html/nav_f.png | Bin 153 -> 0 bytes documents/html/nav_fd.png | Bin 169 -> 0 bytes documents/html/nav_g.png | Bin 95 -> 0 bytes documents/html/nav_h.png | Bin 98 -> 0 bytes documents/html/nav_hd.png | Bin 114 -> 0 bytes documents/html/open.png | Bin 123 -> 0 bytes documents/html/plus.svg | 9 - documents/html/plusd.svg | 9 - documents/html/ring__buffer_8c.html | 498 --- documents/html/ring__buffer_8c__incl.dot | 12 - ...54fd798f20c20f03b4d2bc271439e82_cgraph.dot | 12 - ...4fd798f20c20f03b4d2bc271439e82_icgraph.dot | 10 - ...5df1a999247d375c9cb3bebbfe51abf_cgraph.dot | 11 - ...df1a999247d375c9cb3bebbfe51abf_icgraph.dot | 11 - ...fe4f702c569dc5d364feaa98e03acf_icgraph.dot | 20 - ...4fbc202c7505dc02d974fa247e5a27c_cgraph.dot | 14 - ...8dc05f73e99c8fbc5955d393a88f14d_cgraph.dot | 12 - ...dc05f73e99c8fbc5955d393a88f14d_icgraph.dot | 10 - documents/html/ring__buffer_8c_source.html | 272 -- documents/html/ring__buffer_8h.html | 493 --- documents/html/ring__buffer_8h__dep__incl.dot | 12 - documents/html/ring__buffer_8h__incl.dot | 10 - ...54fd798f20c20f03b4d2bc271439e82_cgraph.dot | 12 - ...4fd798f20c20f03b4d2bc271439e82_icgraph.dot | 10 - ...5df1a999247d375c9cb3bebbfe51abf_cgraph.dot | 11 - ...df1a999247d375c9cb3bebbfe51abf_icgraph.dot | 11 - ...fe4f702c569dc5d364feaa98e03acf_icgraph.dot | 20 - ...4fbc202c7505dc02d974fa247e5a27c_cgraph.dot | 14 - ...8dc05f73e99c8fbc5955d393a88f14d_cgraph.dot | 12 - ...dc05f73e99c8fbc5955d393a88f14d_icgraph.dot | 10 - documents/html/ring__buffer_8h_source.html | 113 - documents/html/ring__queue_8c.html | 498 --- documents/html/ring__queue_8c__incl.dot | 12 - ...050847cfb7ac966f9f72337e9e446d_icgraph.dot | 11 - ...038e43ebd856240e058091a49dd178b_cgraph.dot | 14 - ...38e43ebd856240e058091a49dd178b_icgraph.dot | 14 - ...87a1b8a096b7133b474f89c1f31985_icgraph.dot | 18 - ...e853628a9d6b667cb5f41de8c2f9a4_icgraph.dot | 18 - ...d1747928b8dce8551835f03319a97ea_cgraph.dot | 14 - ...1747928b8dce8551835f03319a97ea_icgraph.dot | 14 - ...cc4ef0c3b5353aa7e245b747b15ba7_icgraph.dot | 23 - documents/html/ring__queue_8c_source.html | 276 -- documents/html/ring__queue_8h.html | 493 --- documents/html/ring__queue_8h__dep__incl.dot | 16 - documents/html/ring__queue_8h__incl.dot | 10 - ...050847cfb7ac966f9f72337e9e446d_icgraph.dot | 11 - ...038e43ebd856240e058091a49dd178b_cgraph.dot | 14 - ...38e43ebd856240e058091a49dd178b_icgraph.dot | 14 - ...87a1b8a096b7133b474f89c1f31985_icgraph.dot | 18 - ...e853628a9d6b667cb5f41de8c2f9a4_icgraph.dot | 18 - ...d1747928b8dce8551835f03319a97ea_cgraph.dot | 14 - ...1747928b8dce8551835f03319a97ea_icgraph.dot | 14 - ...cc4ef0c3b5353aa7e245b747b15ba7_icgraph.dot | 23 - documents/html/ring__queue_8h_source.html | 115 - documents/html/splitbar.png | Bin 314 -> 0 bytes documents/html/splitbard.png | Bin 282 -> 0 bytes documents/html/structcmd__line-members.html | 65 - documents/html/structcmd__line.html | 167 - .../html/structcmd__line__item-members.html | 62 - documents/html/structcmd__line__item.html | 118 - .../structcmd__line__item__coll__graph.dot | 10 - documents/html/structdelay__item-members.html | 62 - documents/html/structdelay__item.html | 113 - .../html/structinput__output-members.html | 71 - documents/html/structinput__output.html | 291 -- .../html/structinput__output__coll__graph.dot | 9 - documents/html/structmemory-members.html | 64 - documents/html/structmemory.html | 159 - documents/html/structmes__queue-members.html | 64 - documents/html/structmes__queue.html | 164 - .../html/structmes__queue__coll__graph.dot | 11 - .../html/structmes__queue__item-members.html | 63 - documents/html/structmes__queue__item.html | 144 - .../structmes__queue__item__coll__graph.dot | 9 - .../html/structring__buffer-members.html | 64 - documents/html/structring__buffer.html | 159 - documents/html/structring__queue-members.html | 65 - documents/html/structring__queue.html | 179 -- documents/html/structtimer__s-members.html | 65 - documents/html/structtimer__s.html | 184 -- .../html/structtimer__s__coll__graph.dot | 9 - .../html/structuart__handler-members.html | 65 - documents/html/structuart__handler.html | 184 -- .../html/structuart__handler__coll__graph.dot | 10 - documents/html/sync__method_8c.html | 640 ---- documents/html/sync__method_8c__incl.dot | 12 - documents/html/sync__method_8c_source.html | 301 -- documents/html/sync__method_8h.html | 877 ----- documents/html/sync__method_8h__dep__incl.dot | 12 - documents/html/sync__method_8h__incl.dot | 10 - documents/html/sync__method_8h_source.html | 210 -- documents/html/sync_off.png | Bin 853 -> 0 bytes documents/html/sync_on.png | Bin 845 -> 0 bytes documents/html/tab_a.png | Bin 142 -> 0 bytes documents/html/tab_ad.png | Bin 135 -> 0 bytes documents/html/tab_b.png | Bin 169 -> 0 bytes documents/html/tab_bd.png | Bin 173 -> 0 bytes documents/html/tab_h.png | Bin 177 -> 0 bytes documents/html/tab_hd.png | Bin 180 -> 0 bytes documents/html/tab_s.png | Bin 184 -> 0 bytes documents/html/tab_sd.png | Bin 188 -> 0 bytes documents/html/tabs.css | 68 - documents/html/timer__software_8c.html | 663 ---- documents/html/timer__software_8c__incl.dot | 12 - ...41040e67b8e86e8325df8a1a7ff2da_icgraph.dot | 11 - ...fb502d136d218f4cbff6ad473705616_cgraph.dot | 11 - ...93eddc00cd2da68e185bbdecd16eaf4_cgraph.dot | 11 - ...c6d75b7e46e4efd2f0707d7beb9bd1_icgraph.dot | 11 - documents/html/timer__software_8c_source.html | 261 -- documents/html/timer__software_8h.html | 785 ----- .../html/timer__software_8h__dep__incl.dot | 12 - documents/html/timer__software_8h__incl.dot | 10 - ...d2b129e3f79a51ce5e38f85a997313f_cgraph.dot | 11 - ...41040e67b8e86e8325df8a1a7ff2da_icgraph.dot | 11 - ...93eddc00cd2da68e185bbdecd16eaf4_cgraph.dot | 11 - ...c6d75b7e46e4efd2f0707d7beb9bd1_icgraph.dot | 11 - documents/html/timer__software_8h_source.html | 148 - documents/html/topics.html | 68 - documents/html/uart__handler_8c.html | 554 ---- documents/html/uart__handler_8c__incl.dot | 15 - ...e37852c12e19f71a155d0671745db43_cgraph.dot | 17 - ...1664f767c48e18bc5b447e5eab79ff9_cgraph.dot | 17 - ...ac60dc7e71e02668f9642cf64ea7731_cgraph.dot | 17 - ...c19eb82dd650e652e28a21a47db3685_cgraph.dot | 11 - ...ab87f9d4de89558670d3f99d7c073ad_cgraph.dot | 17 - documents/html/uart__handler_8c_source.html | 259 -- documents/html/uart__handler_8h.html | 606 ---- .../html/uart__handler_8h__dep__incl.dot | 10 - documents/html/uart__handler_8h__incl.dot | 13 - ...e37852c12e19f71a155d0671745db43_cgraph.dot | 17 - ...1664f767c48e18bc5b447e5eab79ff9_cgraph.dot | 17 - ...ac60dc7e71e02668f9642cf64ea7731_cgraph.dot | 17 - ...c19eb82dd650e652e28a21a47db3685_cgraph.dot | 11 - ...ab87f9d4de89558670d3f99d7c073ad_cgraph.dot | 17 - documents/html/uart__handler_8h_source.html | 127 - documents/mcu_reuse_development_module2.1.chm | Bin 0 -> 2581214 bytes drivers/common/common_include.h | 2 +- drivers/modbus/modbus_common.c | 2 +- drivers/modbus/modbus_host.c | 2 +- drivers/modbus/modbus_slave.c | 2 +- drivers/modules/command_line.c | 2 +- drivers/modules/data_check.c | 2 +- drivers/modules/data_convert.c | 102 +- drivers/modules/data_convert.h | 27 + drivers/modules/delay_no_block.c | 2 +- drivers/modules/input_output.c | 2 +- drivers/modules/memory.c | 2 +- drivers/modules/message_queue.c | 2 +- drivers/modules/ring_buffer.c | 2 +- drivers/modules/ring_queue.c | 6 +- drivers/modules/ring_queue.h | 4 - drivers/modules/sync_method.c | 2 +- drivers/modules/timer_software.c | 2 +- drivers/modules/uart_handler.c | 2 +- .../project_template/MDK/use_example.uvprojx | 4 +- 311 files changed, 2984 insertions(+), 31499 deletions(-) create mode 100644 documents/doxygen/Doxyfile delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers1686d5785c533d0dc81d0ee5eb80b2cf.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers2ba4bf0df35c7cbc8d9a6f2336fa96ef.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers6a582457a908fd5277f433c409afbcb7.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers78a11cfb658a54a62e808b1c2c141e2d.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers7e0c97abf79fd8f95bf5c94ce7e03ffa.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers8d7905b30d9704671a65c06b3958c380.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers98a5cfc2e7056fc8e819d4a3d6021344.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers9f11fe5aefc81df42df0a4ed082eda36.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2drivers_2modules_2memory_8h-example.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2driversa5d231cb1b3feec39fda5b5451caa282.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2driversd017b0c75ae0ea43167f4a09ef7b8068.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2driversf3ae7a7bcf3054905f903371253e070d.html delete mode 100644 documents/html/_d_1_2_a_s_project_2mcu_project_2mcu_development_template_2mcu_reuse_development_module_2driversf77ba960ea085e6253d7a8eabac886b7.html delete mode 100644 documents/html/_multi_all_8h.html delete mode 100644 documents/html/_multi_all_8h__incl.dot delete mode 100644 documents/html/_multi_all_8h_source.html delete mode 100644 documents/html/annotated.html delete mode 100644 documents/html/bc_s.png delete mode 100644 documents/html/bc_sd.png delete mode 100644 documents/html/classes.html delete mode 100644 documents/html/closed.png delete mode 100644 documents/html/command__line_8c.html delete mode 100644 documents/html/command__line_8c__incl.dot delete mode 100644 documents/html/command__line_8c_ab94ba2de00c52759a418be208acce91a_icgraph.dot delete mode 100644 documents/html/command__line_8c_abc618d80b44a3b1d0abeb6176e7a3d72_cgraph.dot delete mode 100644 documents/html/command__line_8c_source.html delete mode 100644 documents/html/command__line_8h.html delete mode 100644 documents/html/command__line_8h__dep__incl.dot delete mode 100644 documents/html/command__line_8h__incl.dot delete mode 100644 documents/html/command__line_8h_ab94ba2de00c52759a418be208acce91a_icgraph.dot delete mode 100644 documents/html/command__line_8h_abc618d80b44a3b1d0abeb6176e7a3d72_cgraph.dot delete mode 100644 documents/html/command__line_8h_source.html delete mode 100644 documents/html/data__convert_8c.html delete mode 100644 documents/html/data__convert_8c__incl.dot delete mode 100644 documents/html/data__convert_8c_source.html delete mode 100644 documents/html/data__convert_8h.html delete mode 100644 documents/html/data__convert_8h__dep__incl.dot delete mode 100644 documents/html/data__convert_8h__incl.dot delete mode 100644 documents/html/data__convert_8h_source.html delete mode 100644 documents/html/delay__no__block_8c.html delete mode 100644 documents/html/delay__no__block_8c__incl.dot delete mode 100644 documents/html/delay__no__block_8c_source.html delete mode 100644 documents/html/delay__no__block_8h.html delete mode 100644 documents/html/delay__no__block_8h__dep__incl.dot delete mode 100644 documents/html/delay__no__block_8h__incl.dot delete mode 100644 documents/html/delay__no__block_8h_source.html delete mode 100644 documents/html/dir_14bc92f4b96c8519b376567118ac28b3.html delete mode 100644 documents/html/dir_59dd3925026fef5fcb96e4631530be30.html delete mode 100644 documents/html/dir_59dd3925026fef5fcb96e4631530be30_dep.dot delete mode 100644 documents/html/doc.svg delete mode 100644 documents/html/docd.svg delete mode 100644 documents/html/doxygen.css delete mode 100644 documents/html/doxygen.svg delete mode 100644 documents/html/dynsections.js delete mode 100644 documents/html/examples.html delete mode 100644 documents/html/files.html delete mode 100644 documents/html/folderclosed.svg delete mode 100644 documents/html/folderclosedd.svg delete mode 100644 documents/html/folderopen.svg delete mode 100644 documents/html/folderopend.svg delete mode 100644 documents/html/functions.html delete mode 100644 documents/html/functions_vars.html delete mode 100644 documents/html/globals.html delete mode 100644 documents/html/globals_c.html delete mode 100644 documents/html/globals_d.html delete mode 100644 documents/html/globals_defs.html delete mode 100644 documents/html/globals_e.html delete mode 100644 documents/html/globals_enum.html delete mode 100644 documents/html/globals_eval.html delete mode 100644 documents/html/globals_func.html delete mode 100644 documents/html/globals_i.html delete mode 100644 documents/html/globals_m.html delete mode 100644 documents/html/globals_o.html delete mode 100644 documents/html/globals_r.html delete mode 100644 documents/html/globals_s.html delete mode 100644 documents/html/globals_t.html delete mode 100644 documents/html/globals_type.html delete mode 100644 documents/html/globals_u.html delete mode 100644 documents/html/graph_legend.dot delete mode 100644 documents/html/graph_legend.html delete mode 100644 documents/html/group__input__edge__type.dot delete mode 100644 documents/html/group__input__edge__type.html delete mode 100644 documents/html/group__input__output.dot delete mode 100644 documents/html/group__input__output.html delete mode 100644 documents/html/group__input__output__check__parameters__validity.dot delete mode 100644 documents/html/group__input__output__check__parameters__validity.html delete mode 100644 documents/html/group__input__output__global__functions.dot delete mode 100644 documents/html/group__input__output__global__functions.html delete mode 100644 documents/html/group__input__output__global__functions_ga11ce07677ae18b79b5f8575c76119261_icgraph.dot delete mode 100644 documents/html/group__input__output__global__functions_ga3ded7db2b18b96c93a835fec5e3a8204_icgraph.dot delete mode 100644 documents/html/group__input__output__global__functions_ga4abf3501a551254e461d80d75a994d21_cgraph.dot delete mode 100644 documents/html/group__input__output__global__functions_gaf91402bc1da43af8da3fb16cbdcdd604_cgraph.dot delete mode 100644 documents/html/group__input__output__global__macros.dot delete mode 100644 documents/html/group__input__output__global__macros.html delete mode 100644 documents/html/group__input__output__global__types.dot delete mode 100644 documents/html/group__input__output__global__types.html delete mode 100644 documents/html/group__input__output__local__functions.dot delete mode 100644 documents/html/group__input__output__local__functions.html delete mode 100644 documents/html/group__input__output__local__macros.dot delete mode 100644 documents/html/group__input__output__local__macros.html delete mode 100644 documents/html/group__input__output__local__variables.dot delete mode 100644 documents/html/group__input__output__local__variables.html delete mode 100644 documents/html/group__io__dir.dot delete mode 100644 documents/html/group__io__dir.html delete mode 100644 documents/html/group__io__run__flg.dot delete mode 100644 documents/html/group__io__run__flg.html delete mode 100644 documents/html/group__io__task__macros.dot delete mode 100644 documents/html/group__io__task__macros.html delete mode 100644 documents/html/group__modules.dot delete mode 100644 documents/html/group__modules.html delete mode 100644 documents/html/group__out__cycle__state.dot delete mode 100644 documents/html/group__out__cycle__state.html delete mode 100644 documents/html/index.hhc delete mode 100644 documents/html/index.hhk delete mode 100644 documents/html/index.hhp delete mode 100644 documents/html/index.html delete mode 100644 documents/html/input__output_8c.html delete mode 100644 documents/html/input__output_8c__incl.dot delete mode 100644 documents/html/input__output_8c_source.html delete mode 100644 documents/html/input__output_8h.html delete mode 100644 documents/html/input__output_8h__dep__incl.dot delete mode 100644 documents/html/input__output_8h__incl.dot delete mode 100644 documents/html/input__output_8h_source.html delete mode 100644 documents/html/jquery.js delete mode 100644 documents/html/memory_8c.html delete mode 100644 documents/html/memory_8c__incl.dot delete mode 100644 documents/html/memory_8c_a1eb26194d6566a00d3a12dd0e7a9e9da_cgraph.dot delete mode 100644 documents/html/memory_8c_a1eb26194d6566a00d3a12dd0e7a9e9da_icgraph.dot delete mode 100644 documents/html/memory_8c_a3fe1c4f5e666c54df3684421fa797a42_cgraph.dot delete mode 100644 documents/html/memory_8c_a3fe1c4f5e666c54df3684421fa797a42_icgraph.dot delete mode 100644 documents/html/memory_8c_a51909f452e720046f8c2b2ef8facdceb_icgraph.dot delete mode 100644 documents/html/memory_8c_a5e06d9b0bb022a1643f16a5c4c675b60_cgraph.dot delete mode 100644 documents/html/memory_8c_aab977bd99aefb4eb4c2fd1055e7da50b_icgraph.dot delete mode 100644 documents/html/memory_8c_source.html delete mode 100644 documents/html/memory_8h.html delete mode 100644 documents/html/memory_8h__dep__incl.dot delete mode 100644 documents/html/memory_8h__incl.dot delete mode 100644 documents/html/memory_8h_a1eb26194d6566a00d3a12dd0e7a9e9da_cgraph.dot delete mode 100644 documents/html/memory_8h_a1eb26194d6566a00d3a12dd0e7a9e9da_icgraph.dot delete mode 100644 documents/html/memory_8h_a1ec118674c87f20ecea5cc3a1e01a561_icgraph.dot delete mode 100644 documents/html/memory_8h_a3fe1c4f5e666c54df3684421fa797a42_cgraph.dot delete mode 100644 documents/html/memory_8h_a3fe1c4f5e666c54df3684421fa797a42_icgraph.dot delete mode 100644 documents/html/memory_8h_a51909f452e720046f8c2b2ef8facdceb_icgraph.dot delete mode 100644 documents/html/memory_8h_a5e06d9b0bb022a1643f16a5c4c675b60_cgraph.dot delete mode 100644 documents/html/memory_8h_source.html delete mode 100644 documents/html/menudata.js delete mode 100644 documents/html/message__queue_8c.html delete mode 100644 documents/html/message__queue_8c__incl.dot delete mode 100644 documents/html/message__queue_8c_source.html delete mode 100644 documents/html/message__queue_8h.html delete mode 100644 documents/html/message__queue_8h__dep__incl.dot delete mode 100644 documents/html/message__queue_8h__incl.dot delete mode 100644 documents/html/message__queue_8h_source.html delete mode 100644 documents/html/minus.svg delete mode 100644 documents/html/minusd.svg delete mode 100644 documents/html/nav_f.png delete mode 100644 documents/html/nav_fd.png delete mode 100644 documents/html/nav_g.png delete mode 100644 documents/html/nav_h.png delete mode 100644 documents/html/nav_hd.png delete mode 100644 documents/html/open.png delete mode 100644 documents/html/plus.svg delete mode 100644 documents/html/plusd.svg delete mode 100644 documents/html/ring__buffer_8c.html delete mode 100644 documents/html/ring__buffer_8c__incl.dot delete mode 100644 documents/html/ring__buffer_8c_a154fd798f20c20f03b4d2bc271439e82_cgraph.dot delete mode 100644 documents/html/ring__buffer_8c_a154fd798f20c20f03b4d2bc271439e82_icgraph.dot delete mode 100644 documents/html/ring__buffer_8c_a55df1a999247d375c9cb3bebbfe51abf_cgraph.dot delete mode 100644 documents/html/ring__buffer_8c_a55df1a999247d375c9cb3bebbfe51abf_icgraph.dot delete mode 100644 documents/html/ring__buffer_8c_a5dfe4f702c569dc5d364feaa98e03acf_icgraph.dot delete mode 100644 documents/html/ring__buffer_8c_a64fbc202c7505dc02d974fa247e5a27c_cgraph.dot delete mode 100644 documents/html/ring__buffer_8c_ac8dc05f73e99c8fbc5955d393a88f14d_cgraph.dot delete mode 100644 documents/html/ring__buffer_8c_ac8dc05f73e99c8fbc5955d393a88f14d_icgraph.dot delete mode 100644 documents/html/ring__buffer_8c_source.html delete mode 100644 documents/html/ring__buffer_8h.html delete mode 100644 documents/html/ring__buffer_8h__dep__incl.dot delete mode 100644 documents/html/ring__buffer_8h__incl.dot delete mode 100644 documents/html/ring__buffer_8h_a154fd798f20c20f03b4d2bc271439e82_cgraph.dot delete mode 100644 documents/html/ring__buffer_8h_a154fd798f20c20f03b4d2bc271439e82_icgraph.dot delete mode 100644 documents/html/ring__buffer_8h_a55df1a999247d375c9cb3bebbfe51abf_cgraph.dot delete mode 100644 documents/html/ring__buffer_8h_a55df1a999247d375c9cb3bebbfe51abf_icgraph.dot delete mode 100644 documents/html/ring__buffer_8h_a5dfe4f702c569dc5d364feaa98e03acf_icgraph.dot delete mode 100644 documents/html/ring__buffer_8h_a64fbc202c7505dc02d974fa247e5a27c_cgraph.dot delete mode 100644 documents/html/ring__buffer_8h_ac8dc05f73e99c8fbc5955d393a88f14d_cgraph.dot delete mode 100644 documents/html/ring__buffer_8h_ac8dc05f73e99c8fbc5955d393a88f14d_icgraph.dot delete mode 100644 documents/html/ring__buffer_8h_source.html delete mode 100644 documents/html/ring__queue_8c.html delete mode 100644 documents/html/ring__queue_8c__incl.dot delete mode 100644 documents/html/ring__queue_8c_a3b050847cfb7ac966f9f72337e9e446d_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_a6038e43ebd856240e058091a49dd178b_cgraph.dot delete mode 100644 documents/html/ring__queue_8c_a6038e43ebd856240e058091a49dd178b_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_a7087a1b8a096b7133b474f89c1f31985_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_a90e853628a9d6b667cb5f41de8c2f9a4_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_a9d1747928b8dce8551835f03319a97ea_cgraph.dot delete mode 100644 documents/html/ring__queue_8c_a9d1747928b8dce8551835f03319a97ea_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_ad2cc4ef0c3b5353aa7e245b747b15ba7_icgraph.dot delete mode 100644 documents/html/ring__queue_8c_source.html delete mode 100644 documents/html/ring__queue_8h.html delete mode 100644 documents/html/ring__queue_8h__dep__incl.dot delete mode 100644 documents/html/ring__queue_8h__incl.dot delete mode 100644 documents/html/ring__queue_8h_a3b050847cfb7ac966f9f72337e9e446d_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_a6038e43ebd856240e058091a49dd178b_cgraph.dot delete mode 100644 documents/html/ring__queue_8h_a6038e43ebd856240e058091a49dd178b_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_a7087a1b8a096b7133b474f89c1f31985_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_a90e853628a9d6b667cb5f41de8c2f9a4_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_a9d1747928b8dce8551835f03319a97ea_cgraph.dot delete mode 100644 documents/html/ring__queue_8h_a9d1747928b8dce8551835f03319a97ea_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_ad2cc4ef0c3b5353aa7e245b747b15ba7_icgraph.dot delete mode 100644 documents/html/ring__queue_8h_source.html delete mode 100644 documents/html/splitbar.png delete mode 100644 documents/html/splitbard.png delete mode 100644 documents/html/structcmd__line-members.html delete mode 100644 documents/html/structcmd__line.html delete mode 100644 documents/html/structcmd__line__item-members.html delete mode 100644 documents/html/structcmd__line__item.html delete mode 100644 documents/html/structcmd__line__item__coll__graph.dot delete mode 100644 documents/html/structdelay__item-members.html delete mode 100644 documents/html/structdelay__item.html delete mode 100644 documents/html/structinput__output-members.html delete mode 100644 documents/html/structinput__output.html delete mode 100644 documents/html/structinput__output__coll__graph.dot delete mode 100644 documents/html/structmemory-members.html delete mode 100644 documents/html/structmemory.html delete mode 100644 documents/html/structmes__queue-members.html delete mode 100644 documents/html/structmes__queue.html delete mode 100644 documents/html/structmes__queue__coll__graph.dot delete mode 100644 documents/html/structmes__queue__item-members.html delete mode 100644 documents/html/structmes__queue__item.html delete mode 100644 documents/html/structmes__queue__item__coll__graph.dot delete mode 100644 documents/html/structring__buffer-members.html delete mode 100644 documents/html/structring__buffer.html delete mode 100644 documents/html/structring__queue-members.html delete mode 100644 documents/html/structring__queue.html delete mode 100644 documents/html/structtimer__s-members.html delete mode 100644 documents/html/structtimer__s.html delete mode 100644 documents/html/structtimer__s__coll__graph.dot delete mode 100644 documents/html/structuart__handler-members.html delete mode 100644 documents/html/structuart__handler.html delete mode 100644 documents/html/structuart__handler__coll__graph.dot delete mode 100644 documents/html/sync__method_8c.html delete mode 100644 documents/html/sync__method_8c__incl.dot delete mode 100644 documents/html/sync__method_8c_source.html delete mode 100644 documents/html/sync__method_8h.html delete mode 100644 documents/html/sync__method_8h__dep__incl.dot delete mode 100644 documents/html/sync__method_8h__incl.dot delete mode 100644 documents/html/sync__method_8h_source.html delete mode 100644 documents/html/sync_off.png delete mode 100644 documents/html/sync_on.png delete mode 100644 documents/html/tab_a.png delete mode 100644 documents/html/tab_ad.png delete mode 100644 documents/html/tab_b.png delete mode 100644 documents/html/tab_bd.png delete mode 100644 documents/html/tab_h.png delete mode 100644 documents/html/tab_hd.png delete mode 100644 documents/html/tab_s.png delete mode 100644 documents/html/tab_sd.png delete mode 100644 documents/html/tabs.css delete mode 100644 documents/html/timer__software_8c.html delete mode 100644 documents/html/timer__software_8c__incl.dot delete mode 100644 documents/html/timer__software_8c_a6d41040e67b8e86e8325df8a1a7ff2da_icgraph.dot delete mode 100644 documents/html/timer__software_8c_a8fb502d136d218f4cbff6ad473705616_cgraph.dot delete mode 100644 documents/html/timer__software_8c_aa93eddc00cd2da68e185bbdecd16eaf4_cgraph.dot delete mode 100644 documents/html/timer__software_8c_aedc6d75b7e46e4efd2f0707d7beb9bd1_icgraph.dot delete mode 100644 documents/html/timer__software_8c_source.html delete mode 100644 documents/html/timer__software_8h.html delete mode 100644 documents/html/timer__software_8h__dep__incl.dot delete mode 100644 documents/html/timer__software_8h__incl.dot delete mode 100644 documents/html/timer__software_8h_a0d2b129e3f79a51ce5e38f85a997313f_cgraph.dot delete mode 100644 documents/html/timer__software_8h_a6d41040e67b8e86e8325df8a1a7ff2da_icgraph.dot delete mode 100644 documents/html/timer__software_8h_aa93eddc00cd2da68e185bbdecd16eaf4_cgraph.dot delete mode 100644 documents/html/timer__software_8h_aedc6d75b7e46e4efd2f0707d7beb9bd1_icgraph.dot delete mode 100644 documents/html/timer__software_8h_source.html delete mode 100644 documents/html/topics.html delete mode 100644 documents/html/uart__handler_8c.html delete mode 100644 documents/html/uart__handler_8c__incl.dot delete mode 100644 documents/html/uart__handler_8c_a0e37852c12e19f71a155d0671745db43_cgraph.dot delete mode 100644 documents/html/uart__handler_8c_a21664f767c48e18bc5b447e5eab79ff9_cgraph.dot delete mode 100644 documents/html/uart__handler_8c_a2ac60dc7e71e02668f9642cf64ea7731_cgraph.dot delete mode 100644 documents/html/uart__handler_8c_a5c19eb82dd650e652e28a21a47db3685_cgraph.dot delete mode 100644 documents/html/uart__handler_8c_aaab87f9d4de89558670d3f99d7c073ad_cgraph.dot delete mode 100644 documents/html/uart__handler_8c_source.html delete mode 100644 documents/html/uart__handler_8h.html delete mode 100644 documents/html/uart__handler_8h__dep__incl.dot delete mode 100644 documents/html/uart__handler_8h__incl.dot delete mode 100644 documents/html/uart__handler_8h_a0e37852c12e19f71a155d0671745db43_cgraph.dot delete mode 100644 documents/html/uart__handler_8h_a21664f767c48e18bc5b447e5eab79ff9_cgraph.dot delete mode 100644 documents/html/uart__handler_8h_a2ac60dc7e71e02668f9642cf64ea7731_cgraph.dot delete mode 100644 documents/html/uart__handler_8h_a5c19eb82dd650e652e28a21a47db3685_cgraph.dot delete mode 100644 documents/html/uart__handler_8h_aaab87f9d4de89558670d3f99d7c073ad_cgraph.dot delete mode 100644 documents/html/uart__handler_8h_source.html create mode 100644 documents/mcu_reuse_development_module2.1.chm diff --git a/documents/doxygen/Doxyfile b/documents/doxygen/Doxyfile new file mode 100644 index 0000000..7e2e4d8 --- /dev/null +++ b/documents/doxygen/Doxyfile @@ -0,0 +1,2862 @@ +# Doxyfile 1.9.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = mcu_reuse_development_module + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 2.1 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = C:/Users/lh/Desktop/myTest/mcu_reuse_development_module-dev/documents + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# The MARKDOWN_ID_STYLE tag can be used to specify the algorithm used to +# generate identifiers for the Markdown headings. Note: Every identifier is +# unique. +# Possible values are: DOXYGEN use a fixed 'autotoc_md' string followed by a +# sequence number starting at 0 and GITHUB use the lower case version of title +# with any whitespace replaced by '-' and punctuation characters removed. +# The default value is: DOXYGEN. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +MARKDOWN_ID_STYLE = DOXYGEN + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +# If the TIMESTAMP tag is set different from NO then each generated page will +# contain the date or date and time when the page was generated. Setting this to +# NO can help when comparing the output of multiple runs. +# Possible values are: YES, NO, DATETIME and DATE. +# The default value is: NO. + +TIMESTAMP = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. + +CASE_SENSE_NAMES = SYSTEM + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = YES + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves +# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not +# write the warning messages in between other messages but write them at the end +# of a run, in case a WARN_LOGFILE is defined the warning messages will be +# besides being in the defined file also be shown at the end of a run, unless +# the WARN_LOGFILE is defined as - i.e. standard output (stdout) in that case +# the behavior will remain as with the setting FAIL_ON_WARNINGS. +# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = C:/Users/lh/Desktop/myTest/mcu_reuse_development_module-dev/drivers + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cxxm, +# *.cpp, *.cppm, *.c++, *.c++m, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, +# *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, *.h++, *.ixx, *.l, *.cs, *.d, *.php, +# *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be +# provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cxxm \ + *.cpp \ + *.cppm \ + *.c++ \ + *.c++m \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.ixx \ + *.l \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# ANamespace::AClass, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# If the HTML_CODE_FOLDING tag is set to YES then classes and functions can be +# dynamically folded and expanded in the generated HTML source code. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_CODE_FOLDING = YES + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = YES + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = mcu_reuse_development_module2.1.chm + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = "C:/Program Files (x86)/HTML Help Workshop/hhc.exe" + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = UTF-8 + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = YES + +# The SITEMAP_URL tag is used to specify the full URL of the place where the +# generated documentation will be placed on the server by the user during the +# deployment of the documentation. The generated sitemap is called sitemap.xml +# and placed on the directory specified by HTML_OUTPUT. In case no SITEMAP_URL +# is specified no sitemap is generated. For information about the sitemap +# protocol see https://www.sitemaps.org +# This tag requires that the tag GENERATE_HTML is set to YES. + +SITEMAP_URL = + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /