update template
This commit is contained in:
@@ -5,26 +5,30 @@
|
||||
#define GD32E23XF6 0x20
|
||||
#define GD32E23XF8 0x40
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[RS485 PHY DEFINE]<<<<<<<<<<<<<<<<<<<< */
|
||||
#define PROTOCOL_BOARD_TYPE 0x01 /**< 板卡类型标识 */
|
||||
|
||||
// #define RS485_MAX13487 // RS485 PHY : MAX13487 (AutoDir)
|
||||
#undef RS485_MAX13487 // RS485 PHY : SP3487 (no AutoDir)
|
||||
#include "version.h"
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[IIC TYPE DEFINE]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define SOFTWARE_IIC // IIC Type : Software IIC
|
||||
#undef SOFTWARE_IIC // IIC Type : Hardware IIC
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[DEBUG MODE]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define DEBUG_MODE // Operating Mode : Debug Mode
|
||||
#undef DEBUG_MODE // Operating Mode : Release Mode
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[COMMAND DEBUG]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define COM_DEBUG // Enable Command Debug Information
|
||||
#undef COM_DEBUG // Disable Command Debug Information
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[DEBUG ASSERTIONS DEFINE]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define DEBUG_VERBOSE // Debug Assertions Status : Debug Verbose Information
|
||||
#undef DEBUG_VERBOSE // Debug Assertions Status : No Debug Verbose Information
|
||||
|
||||
/* >>>>>>>>>>>>>>>>>>>>[EDDY DRIVE CURRENT DETECTION]<<<<<<<<<<<<<<<<<<<< */
|
||||
|
||||
// #define EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Enable
|
||||
#undef EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Disable
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* Dynamic USART Configuration Structure */
|
||||
@@ -52,8 +56,6 @@ void usart1_irq_handler(void);
|
||||
#define I2C_SDA_PIN GPIO_PIN_0
|
||||
#define I2C_GPIO_AF GPIO_AF_1
|
||||
|
||||
#define I2C_DEBUG_UART USART0
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define LED_RCU RCU_GPIOA
|
||||
@@ -62,18 +64,47 @@ void usart1_irq_handler(void);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define RS485_RCU (g_usart_config.rcu_usart)
|
||||
#define RS485_PHY (g_usart_config.usart_periph)
|
||||
#define RS485_IRQ (g_usart_config.irq_type)
|
||||
#define RS485_GPIO_RCU RCU_GPIOA
|
||||
#define RS485_GPIO_PORT GPIOA
|
||||
#define RS485_EN_PIN GPIO_PIN_1
|
||||
#define RS485_TX_PIN GPIO_PIN_2
|
||||
#define RS485_RX_PIN GPIO_PIN_3
|
||||
#define RS485_BAUDRATE 115200U
|
||||
#define UART_RCU (g_usart_config.rcu_usart)
|
||||
#define UART_PHY (g_usart_config.usart_periph)
|
||||
#define UART_IRQ (g_usart_config.irq_type)
|
||||
#define UART_GPIO_RCU RCU_GPIOA
|
||||
#define UART_GPIO_PORT GPIOA
|
||||
#define UART_TX_PIN GPIO_PIN_2
|
||||
#define UART_RX_PIN GPIO_PIN_3
|
||||
#define UART_BAUDRATE 115200U
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define FAN_T_GPIO_PORT_RCU RCU_GPIOA
|
||||
#define FAN_T_GPIO_PORT GPIOA
|
||||
#define FAN_T_PWR_EN GPIO_PIN_5
|
||||
#define FAN_T_PWM GPIO_PIN_6
|
||||
#define FAN_T_DETECT GPIO_PIN_4
|
||||
|
||||
#define FAN_A_GPIO_PORT_RCU RCU_GPIOA
|
||||
#define FAN_A_PWR_PORT_RCU RCU_GPIOB
|
||||
#define FAN_A_GPIO_PORT GPIOA
|
||||
#define FAN_A_PWR_PORT GPIOB
|
||||
#define FAN_A_PWR_EN GPIO_PIN_1
|
||||
#define FAN_A_PWM GPIO_PIN_9
|
||||
#define FAN_A_DETECT GPIO_PIN_10
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// UV-LED NTC Temperature Sensor Definitions AD_CHANNEL_0
|
||||
#define LAMP_TEMP_GPIO_PORT_RCU RCU_GPIOA
|
||||
#define LAMP_TEMP_GPIO_PORT GPIOA
|
||||
#define LAMP_TEMP_AD_PIN GPIO_PIN_0
|
||||
|
||||
// DMD NTC Temperature Sensor Definitions AD_CHANNEL_1
|
||||
#define DMD_TEMP_GPIO_PORT_RCU RCU_GPIOA
|
||||
#define DMD_TEMP_GPIO_PORT GPIOA
|
||||
#define DMD_TEMP_AD_PIN GPIO_PIN_1
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define DEBUG_UART USART0
|
||||
|
||||
void mcu_detect_and_config(void);
|
||||
uint8_t get_flash_size(void);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* 接收命令帧格式:
|
||||
* @code
|
||||
* [0] HEADER = 0xD5 // 包头标识
|
||||
* [1] BOARD_TYPE = 0x03 // 板卡类型标识
|
||||
* [1] BOARD_TYPE = 0x01 // 板卡类型标识
|
||||
* [2] LEN = 数据区字节数 // 有效载荷长度
|
||||
* [3..(3+LEN-1)] 数据 // 命令数据
|
||||
* [last] CRC // 校验码(从索引1累加到len-2的低8位)
|
||||
@@ -77,5 +77,24 @@ void command_process(void);
|
||||
*/
|
||||
void handle_command(const uint8_t *cmd, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief 执行命令(简化版)
|
||||
* @details 根据命令字符串直接构造命令帧并执行,无需手动构造协议帧
|
||||
* @param cmd_str 命令字符串(如"M730S0T1000"、"M731S100"等)
|
||||
* @note 简化的测试函数,自动处理协议帧构造、CRC计算和命令执行
|
||||
* @ingroup Command
|
||||
*/
|
||||
void command_execute(const char *cmd_str);
|
||||
|
||||
/**
|
||||
* @brief M737命令投光结束回调函数
|
||||
* @details 当定时器结束时调用此函数,向等待中的M737命令发送OK响应
|
||||
* @param none
|
||||
* @note 此函数由定时器中断调用,不应直接调用
|
||||
* @ingroup Command
|
||||
*/
|
||||
void command_m737_timer_finished_callback(void);
|
||||
|
||||
/** @} */ // end of Command group
|
||||
|
||||
#endif // COMMAND_H
|
||||
|
||||
27
Inc/i2c.h
27
Inc/i2c.h
@@ -18,7 +18,7 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define I2C_SPEED 100000U /* 100kHz */
|
||||
#define I2C_SPEED 20000U /* 20kHz */
|
||||
#define I2C_TIME_OUT 5000U /* 5000 loops timeout */
|
||||
#define I2C_MAX_RETRY 3U /* Maximum retry attempts */
|
||||
#define I2C_DELAY_10US 10U /* Delay in microseconds for bus reset */
|
||||
@@ -107,15 +107,29 @@ i2c_result_t i2c_write_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t data
|
||||
*/
|
||||
i2c_result_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
|
||||
/* Generic read/write functions with configurable length */
|
||||
/*!
|
||||
\brief read 16-bit data from I2C device
|
||||
\param[in] slave_addr: 7-bit slave address
|
||||
\brief write data to I2C device with configurable length
|
||||
\param[in] slave_addr: slave device address (7-bit)
|
||||
\param[in] reg_addr: register address
|
||||
\param[out] data: pointer to 2-byte data buffer
|
||||
\retval i2c_result_t
|
||||
\param[in] data: pointer to data buffer
|
||||
\param[in] length: number of bytes to write (1-255)
|
||||
\param[out] none
|
||||
\retval i2c_result_t: operation result
|
||||
*/
|
||||
i2c_result_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
i2c_result_t i2c_write(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t length);
|
||||
|
||||
/*!
|
||||
\brief read data from I2C device with configurable length
|
||||
\param[in] slave_addr: slave device address (7-bit)
|
||||
\param[in] reg_addr: register address
|
||||
\param[out] data: pointer to data buffer
|
||||
\param[in] length: number of bytes to read (1-255)
|
||||
\retval i2c_result_t: operation result
|
||||
*/
|
||||
i2c_result_t i2c_read(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t length);
|
||||
|
||||
#ifdef DEBUG_VERBOSE
|
||||
/*!
|
||||
\brief get status string for debugging
|
||||
\param[in] status: i2c_result_t value
|
||||
@@ -123,5 +137,6 @@ i2c_result_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data
|
||||
\retval const char* status string
|
||||
*/
|
||||
const char* i2c_get_status_string(i2c_result_t status);
|
||||
#endif
|
||||
|
||||
#endif //I2C_H
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
|
||||
#include "gd32e23x.h"
|
||||
|
||||
void rs485_init(void);
|
||||
/*!
|
||||
\brief initialize UART interface
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void uart_init(void);
|
||||
void debug_usart_init(void);
|
||||
|
||||
#endif // UART_H
|
||||
|
||||
Reference in New Issue
Block a user