init: DLD154V4B 单路车检器项目

This commit is contained in:
wangfq
2026-06-22 18:20:37 +08:00
commit 7b95eb1183
62 changed files with 38533 additions and 0 deletions

116
inc/bsp_pins.h Normal file
View File

@@ -0,0 +1,116 @@
/**
* @file bsp_pins.h
* @brief DLD154V4B 引脚定义
* @author wangfq
* @date 2026-06-22
*/
#ifndef BSP_PINS_H
#define BSP_PINS_H
#include "at32f421.h"
/*===========================================================================
* 拨码开关 — 输入 (PA0~PA4)
*===========================================================================*/
/* 灵敏度设置 */
#define PIN_SA_1 GPIO_PINS_0 /* PA0, 灵敏度 bit0 */
#define PIN_SA_2 GPIO_PINS_1 /* PA1, 灵敏度 bit1 */
#define PORT_SA GPIOA
/* 存在/脉冲选择 */
#define PIN_SW_3 GPIO_PINS_2 /* PA2, 0=存在, 1=脉冲 */
#define PORT_SW GPIOA
/* 延时使能 */
#define PIN_SW_4 GPIO_PINS_3 /* PA3, 0=无延时, 1=延时 */
/* 安全复位 */
#define PIN_SW_5 GPIO_PINS_4 /* PA4, 1=安全复位 */
/*===========================================================================
* 继电器输出 — PA5, PA6
*===========================================================================*/
#define PIN_RLY2 GPIO_PINS_5 /* PA5, 继电器2 */
#define PIN_RLY1 GPIO_PINS_6 /* PA6, 继电器1 */
#define PORT_RLY GPIOA
/*===========================================================================
* 线圈输入捕获 — PA7 (TIM3_CH2)
*===========================================================================*/
#define PIN_LP GPIO_PINS_7 /* PA7, 线圈频率捕获 */
#define PORT_LP GPIOA
#define LP_TIM TMR3
#define LP_TIM_CH TMR_SELECT_CHANNEL_2
#define LP_TMR_IRQn TMR3_GLOBAL_IRQn
#define LP_TIM_MUX_CFG GPIO_MUX_1 /* PA7 AF1 → TIM3_CH2 */
/*===========================================================================
* 指示灯
*===========================================================================*/
/* LEDA — 红色呼吸灯, PB1 */
#define PIN_LEDA GPIO_PINS_1 /* PB1 */
#define PORT_LEDA GPIOB
/* 呼吸灯使用 TIM2_CH4 (PB1 AF2) 或软件 PWM */
#define LEDA_TIM TMR2
#define LEDA_TIM_CH TMR_SELECT_CHANNEL_4
#define LEDA_TMR_IRQn TMR2_GLOBAL_IRQn
#define LEDA_TIM_MUX_CFG GPIO_MUX_2
/* LEDB — 绿色, 有车亮, PA9 */
#define PIN_LEDB GPIO_PINS_9 /* PA9 */
#define PORT_LEDB GPIOA
/* LEDC — 黄色, 故障指示, PA10 */
#define PIN_LEDC GPIO_PINS_10 /* PA10 */
#define PORT_LEDC GPIOA
/*===========================================================================
* 拨码读取宏
*===========================================================================*/
/* 4 级灵敏度编码 */
#define SA_READ() ((((PORT_SA)->idt & PIN_SA_2) ? 2 : 0) | \
(((PORT_SA)->idt & PIN_SA_1) ? 1 : 0))
/* 0=低, 1=中, 2=高, 3=最高 */
#define SW3_EXIST() (!((PORT_SW)->idt & PIN_SW_3)) /* 存在模式 */
#define SW3_PULSE() (!!((PORT_SW)->idt & PIN_SW_3)) /* 脉冲模式 */
#define SW4_DELAY_EN() (!!((PORT_SW)->idt & PIN_SW_4)) /* 延时使能 */
#define SW5_SAFE_RST() (!!((PORT_SW)->idt & PIN_SW_5)) /* 安全复位 */
/*===========================================================================
* 继电器控制宏
*===========================================================================*/
#define RLY1_ON() ((PORT_RLY)->clr = PIN_RLY1)
#define RLY1_OFF() ((PORT_RLY)->scr = PIN_RLY1)
#define RLY2_ON() ((PORT_RLY)->clr = PIN_RLY2)
#define RLY2_OFF() ((PORT_RLY)->scr = PIN_RLY2)
/*===========================================================================
* 指示灯控制宏
*===========================================================================*/
#define LEDB_ON() ((PORT_LEDB)->clr = PIN_LEDB)
#define LEDB_OFF() ((PORT_LEDB)->scr = PIN_LEDB)
#define LEDC_ON() ((PORT_LEDC)->clr = PIN_LEDC)
#define LEDC_OFF() ((PORT_LEDC)->scr = PIN_LEDC)
/*===========================================================================
* 初始化声明
*===========================================================================*/
void bsp_pins_init(void);
void bsp_timer_init(void);
void bsp_leda_breath_tick(void); /* 呼吸灯定时调用 */
#endif /* BSP_PINS_H */