Files
FilmForge/Inc/board_config.h
T

142 lines
5.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
#ifndef CFG_DISABLE
#define CFG_DISABLE 0
#endif
#ifndef CFG_ENABLE
#define CFG_ENABLE 1
#endif
#define PROTOCOL_BOARD_TYPE 0x01 /**< 板卡类型标识 */
#include "version.h"
/* GD32_FLASH_SIZE_KB(512/1024/2048)由 CMake 按 GD32_FLASH_CAPACITY 注入,
切换容量:cmake --preset Debug -DGD32_FLASH_CAPACITY=xG */
/* >>>>>>>>>>>>>>>>>>>>[IIC TYPE DEFINE]<<<<<<<<<<<<<<<<<<<< */
#define SOFTWARE_IIC CFG_DISABLE // CFG_DISABLE: Hardware IIC; CFG_ENABLE: Software IIC
/* TODO: I2C 驱动尚未从 GD32E23x 工程移植,先保证工程可编译(见 AGENTS.md 进度清单) */
/* >>>>>>>>>>>>>>>>>>>>[DEBUG MODE]<<<<<<<<<<<<<<<<<<<< */
#define DEBUG_MODE CFG_ENABLE // CFG_DISABLE: Release Mode; CFG_ENABLE: Debug Mode(发布/量产前改回 CFG_DISABLE)
/* >>>>>>>>>>>>>>>>>>>>[COMMAND DEBUG]<<<<<<<<<<<<<<<<<<<< */
#define COM_DEBUG CFG_DISABLE // CFG_DISABLE: Command debug off; CFG_ENABLE: Command debug on
/* 命令协议框架已移植(Src/command.c,数据口 RS485),业务命令待定义 */
/* >>>>>>>>>>>>>>>>>>>>[DEBUG ASSERTIONS DEFINE]<<<<<<<<<<<<<<<<<<<< */
#define DEBUG_VERBOSE CFG_DISABLE // CFG_DISABLE: Verbose debug off; CFG_ENABLE: Verbose debug on
/* >>>>>>>>>>>>>>>>>>>>[SEGGER RTT DETECTION]<<<<<<<<<<<<<<<<<<<< */
#define SEGGER_RTT_DETECTION CFG_ENABLE // CFG_DISABLE: SEGGER RTT off; CFG_ENABLE: SEGGER RTT on
#if SEGGER_RTT_DETECTION == CFG_ENABLE
#include "SEGGER_RTT.h"
#define RTT_printf(ch, ...) SEGGER_RTT_printf(ch, __VA_ARGS__)
#define RTT_WriteString(ch, s) SEGGER_RTT_WriteString(ch, s)
#define RTT_PutChar(ch, c) SEGGER_RTT_PutChar(ch, c)
#else
#define RTT_printf(ch, ...)
#define RTT_WriteString(ch, s)
#define RTT_PutChar(ch, c)
#endif
/* >>>>>>>>>>>>>>>>>>>>[RS485 MODE]<<<<<<<<<<<<<<<<<<<< */
#define RS485_MODE CFG_ENABLE // CFG_DISABLE: RS485 off; CFG_ENABLE: RS485 on
/* GD32F4xx USART 无硬件 RS485 DE 驱动(E23x 特有),DE 引脚由 GPIO 手动控制 */
#if RS485_MODE == CFG_ENABLE
/* 数据口 RS485:USART0(PA9 TX / PA10 RX,AF7),DE 引脚 PA8(GPIO 手动切换收发) */
#define RS485_RCU RCU_USART0
#define RS485_PHY USART0
#define RS485_IRQ USART0_IRQn
#define RS485_GPIO_RCU RCU_GPIOA
#define RS485_GPIO_PORT GPIOA
#define RS485_TX_PIN GPIO_PIN_9
#define RS485_RX_PIN GPIO_PIN_10
#define RS485_BAUDRATE 115200U
#define RS485_DE_RCU RCU_GPIOA
#define RS485_DE_PORT GPIOA
#define RS485_DE_PIN GPIO_PIN_8
#endif
/* >>>>>>>>>>>>>>>>>>>>[NTC TEMPERATURE]<<<<<<<<<<<<<<<<<<<< */
#define NTC_MODE CFG_ENABLE // CFG_DISABLE: NTC off; CFG_ENABLE: NTC on
#if NTC_MODE == CFG_ENABLE
/* 10K NTC 测温:PC5(ADC0_IN15),硬件 10K 上拉,NTC 接 GND 侧 */
#define NTC_ADC_RCU RCU_ADC0
#define NTC_GPIO_RCU RCU_GPIOC
#define NTC_GPIO_PORT GPIOC
#define NTC_GPIO_PIN GPIO_PIN_5
#define NTC_ADC ADC0
#define NTC_ADC_CHANNEL ADC_CHANNEL_15
#define NTC_SAMPLETIME ADC_SAMPLETIME_480 /* 长采样时间(高阻 NTC 分压源) */
#define NTC_SAMPLE_COUNT 16U /* 单次测温的采样次数 */
#define NTC_TRIM_COUNT 2U /* 修剪均值:每端去掉的最大/最小样本数(抗毛刺) */
#define NTC_VREF 3.3f /* ADC 参考电压 V */
#define NTC_ADC_MAX 4095.0f /* 12bit ADC 满量程 */
#define NTC_R_PULL 10000.0f /* 上拉电阻(硬件) */
#define NTC_R25 10000.0f /* NTC 标称阻值 @25C */
#define NTC_T25 298.15f /* 标称温度 K */
#define NTC_B_VALUE 3950 /* B 值:3950 或 3435,按实测确认后修改 */
#endif
/******************************************************************************/
/* 调试串口:USART1(PA2 TX / PA3 RX,AF7),纯串口,非 RS485。
注意 GD32F4xx 外设编号比 STM32 整体小 1:PA2/PA3 是 USART1(=STM32 的 USART2),
PA9/PA10 才是 USART0(=STM32 的 USART1) */
#define UART_RCU RCU_USART1
#define UART_PHY USART1
#define UART_IRQ USART1_IRQn
#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
/* USART中断处理函数声明(USART0 的处理在 rs485.c,USART1 的处理在 uart.c) */
void rs485_irq_handler(void);
void usart1_irq_handler(void);
/******************************************************************************/
/* I2C0: PB6 SCL / PB7 SDA, AF4 */
#define RCU_GPIO_I2C RCU_GPIOB
#define RCU_I2C RCU_I2C0
#define I2C_SCL_PORT GPIOB
#define I2C_SCL_PIN GPIO_PIN_6
#define I2C_SDA_PORT GPIOB
#define I2C_SDA_PIN GPIO_PIN_7
#define I2C_GPIO_AF GPIO_AF_4
/******************************************************************************/
/* LED: PA15(demo 板实测引脚,低电平点亮按原理图确认) */
#define LED_RCU RCU_GPIOA
#define LED_PORT GPIOA
#define LED_PIN GPIO_PIN_15
/******************************************************************************/
/* 加热控制参数(M3 开关 / M4 目标温度设定) */
#define HEATER_TEMP_MIN 0U /* 目标温度下限(整数摄氏度) */
#define HEATER_TEMP_MAX 200U /* 目标温度上限(整数摄氏度) */
/******************************************************************************/
#define DEBUG_UART USART1
#endif //BOARD_CONFIG_H