generated from hulk/gd32e23x_template_cmake_vscode
detect MCU flash size and config usart
This commit is contained in:
@@ -21,6 +21,29 @@
|
||||
// #define EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Enable
|
||||
#undef EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Disable
|
||||
|
||||
#define GD32E23XF4 0x10
|
||||
#define GD32E23XF6 0x20
|
||||
#define GD32E23XF8 0x40
|
||||
|
||||
/* MCU Type Detection */
|
||||
extern uint8_t g_mcu_type;
|
||||
|
||||
/* Dynamic USART Configuration Structure */
|
||||
typedef struct {
|
||||
uint32_t rcu_usart;
|
||||
uint32_t usart_periph;
|
||||
uint8_t gpio_af;
|
||||
IRQn_Type irq_type;
|
||||
} usart_config_t;
|
||||
|
||||
extern usart_config_t g_usart_config;
|
||||
|
||||
/* Function to detect MCU type and configure USART */
|
||||
void mcu_detect_and_config(void);
|
||||
|
||||
/* Function to get current MCU type */
|
||||
uint8_t get_mcu_type(void);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define RCU_GPIO_I2C RCU_GPIOF
|
||||
@@ -31,7 +54,7 @@
|
||||
#define I2C_SDA_PIN GPIO_PIN_0
|
||||
#define I2C_GPIO_AF GPIO_AF_1
|
||||
|
||||
#define I2C_DEBUG_UART USART0
|
||||
#define I2C_DEBUG_UART USART1
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -41,15 +64,19 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define RS485_RCU RCU_USART0
|
||||
/* Use dynamic configuration instead of static defines */
|
||||
#define RS485_GPIO_RCU RCU_GPIOA
|
||||
#define RS485_GPIO_PORT GPIOA
|
||||
#define RS485_TX_PIN GPIO_PIN_2
|
||||
#define RS485_RX_PIN GPIO_PIN_3
|
||||
#define RS485_PHY USART0
|
||||
#define RS485_BAUDRATE 115200U
|
||||
#define RS485_EN_PIN GPIO_PIN_1
|
||||
#define RS485_IRQ USART0_IRQn
|
||||
|
||||
/* Dynamic configuration - will be set by mcu_detect_and_config() */
|
||||
#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_AF (g_usart_config.gpio_af)
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
Reference in New Issue
Block a user