Files
gd32f4xx_template_cmake_vscode/Inc/board_config.h
T

105 lines
3.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
/* TODO: 串口命令协议模块(command.c)尚未移植(见 AGENTS.md 进度清单) */
/* >>>>>>>>>>>>>>>>>>>>[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_DISABLE // CFG_DISABLE: RS485 off; CFG_ENABLE: RS485 on
/* GD32F4xx USART 无硬件 RS485 DE 驱动(E23x 特有),DE 引脚由 GPIO 手动控制 */
#if RS485_MODE == CFG_ENABLE
#define RS485_DE_RCU RCU_GPIOA
#define RS485_DE_PORT GPIOA
#define RS485_DE_PIN GPIO_PIN_1 // 根据实际硬件修改 DE 引脚
#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中断处理函数声明 */
void usart0_irq_handler(void);
void usart1_irq_handler(void);
void usart2_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
/******************************************************************************/
#define DEBUG_UART USART1
#endif //BOARD_CONFIG_H