revert Merge pull request 'dev' (#1) from dev into main

Reviewed-on: #1
This commit is contained in:
2025-08-25 17:34:39 +08:00
parent 3ad18bf1f1
commit 3e42b474d1
12 changed files with 174 additions and 241 deletions

View File

@@ -1,10 +1,6 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
#define GD32E23XF4 0x10
#define GD32E23XF6 0x20
#define GD32E23XF8 0x40
/* >>>>>>>>>>>>>>>>>>>>[RS485 PHY DEFINE]<<<<<<<<<<<<<<<<<<<< */
// #define RS485_MAX13487 // RS485 PHY : MAX13487 (AutoDir)
@@ -22,23 +18,6 @@
/******************************************************************************/
/* Dynamic USART Configuration Structure */
typedef struct {
uint32_t rcu_usart;
uint32_t usart_periph;
IRQn_Type irq_type;
void (*irq_handler)(void); // 函数指针:指向中断处理函数
} usart_config_t;
extern usart_config_t g_usart_config;
extern uint8_t g_mcu_flash_size;
/* USART中断处理函数声明 */
void usart0_irq_handler(void);
void usart1_irq_handler(void);
/******************************************************************************/
#define RCU_GPIO_I2C RCU_GPIOF
#define RCU_I2C RCU_I2C0
#define I2C_SCL_PORT GPIOF
@@ -57,15 +36,15 @@ 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_RCU RCU_USART0
#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_PHY USART0
#define RS485_BAUDRATE 115200U
#define RS485_EN_PIN GPIO_PIN_1
#define RS485_IRQ USART0_IRQn
/******************************************************************************/
@@ -79,6 +58,11 @@ void usart1_irq_handler(void);
/******************************************************************************/
#define US_TX_DELAY_RCU RCU_TIMER15
#define US_TX_DELAY_TIMER TIMER15
/******************************************************************************/
#define US_RX_GPIO_RCU RCU_GPIOB
#define US_RX_EXTI_RCU RCU_CFGCMP
#define US_RX_GPIO_PORT GPIOA
@@ -92,11 +76,12 @@ void usart1_irq_handler(void);
#define US_ECHO_RCU RCU_TIMER16
#define US_ECHO_TIMER TIMER16
#define US_ECHO_CH TIMER_CH_0
#define US_ECHO_TIMER_IRQ TIMER16_IRQn
/******************************************************************************/
void mcu_detect_and_config(void);
uint8_t get_flash_size(void);
#define TIME_CORRECTION_US 230U
#define CAPTURE_VALUE_MAX 550U
/******************************************************************************/
#endif //BOARD_CONFIG_H

View File

@@ -81,8 +81,6 @@ void command_process(void);
*/
void handle_command(const uint8_t *cmd, uint8_t len);
void ultrasonic_distance_raw_value_report(void);
/** @} */ // end of Command group
#endif // COMMAND_H

View File

@@ -9,13 +9,23 @@ extern volatile bool g_ultrasonic_measure_done;
/**************************************************************************************************/
#define ULTRASONIC_TX_CYCLES 5U /* 发送5个PWM周期驱动换能器 */
#define ULTRASONIC_TX_RINGDOWN_RELOAD 240U // 240us
#define ULTRASONIC_MAX_TOF_RELOAD 1000U // 1000us
#define ULTRASONIC_TX_TIME 498U // ms
#define ULTRASONIC_MAX_TOF_RELOAD 1000U //us
/**************************************************************************************************/
void ultrasonic_tx_init(void);
void ultrasonic_pwm_out_cycles(void);
// void ultrasonic_transmit_delay(const uint16_t micro_second);
// void ultrasonic_rece_exti_config(void);
void ultrasonic_echo_timer_config(void);
void ultrasonic_config(void);
#endif // ULTRASONIC_ANALOG_H
// uint16_t ultrasonic_calc_distance(void);
#endif // UART_H