Initial commit: CCU621_M firmware project with BLE debug link support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#ifndef _SYS_DRV_INIT_H_
|
||||
#define _SYS_DRV_INIT_H_
|
||||
|
||||
#include "gd32h7xx.h"
|
||||
#include "gpio.h"
|
||||
#include "gd32h7xx_gpio.h"
|
||||
|
||||
|
||||
//函数执行 调用时需要加;
|
||||
#define RUN_LED_TOGGLE() gpio_bit_toggle(LED_RUN_PORT, LED_RUN_PIN) //运行灯翻转
|
||||
#define RUN_LED_ON() RELAY_OFF(LED_RUN_PORT, LED_RUN_PIN) //运行灯亮
|
||||
#define RUN_LED_OFF() RELAY_ON(LED_RUN_PORT, LED_RUN_PIN) //运行灯灭
|
||||
|
||||
//DI口 低电平是导通,高电平断开
|
||||
#define DI1 (DI_READ(YX1_PORT,YX1_PIN)?0:1)
|
||||
#define DI2 (DI_READ(YX2_PORT,YX2_PIN)?0:1)
|
||||
#define DI3 (DI_READ(YX3_PORT,YX3_PIN)?0:1)
|
||||
#define DI4 (DI_READ(YX4_PORT,YX4_PIN)?0:1)
|
||||
#define DI5 (DI_READ(YX5_PORT,YX5_PIN)?0:1)
|
||||
#define DI6 (DI_READ(YX6_PORT,YX6_PIN)?0:1)
|
||||
#define DI7 (DI_READ(YX7_PORT,YX7_PIN)?0:1)
|
||||
#define DI8 (DI_READ(YX8_PORT,YX8_PIN)?0:1)
|
||||
#define DI9 (DI_READ(YX9_PORT,YX9_PIN)?0:1)
|
||||
#define DI10 (DI_READ(YX10_PORT,YX10_PIN)?0:1)
|
||||
#define DI11 (DI_READ(YX11_PORT,YX11_PIN)?0:1)
|
||||
#define DI12 (DI_READ(YX12_PORT,YX12_PIN)?0:1)
|
||||
#define AUX_A (DI_READ(AUX_PADET_PORT,AUX_PADET_PIN)?0:1)
|
||||
#define AUX_B (DI_READ(AUX_PBDT_PORT,AUX_PBDT_PIN)?0:1)
|
||||
//DO口 低电平是导通,高电平时断开-- 输出口控制,0断开,1闭合
|
||||
/* K1~K10 与 PK1/PK2 引脚 mode 及上电后相对复位默认的输出取反:BSP/GPIO/gpio.c -> v_outpin_config() */
|
||||
#define DO1(x) (x!=0 ? RELAY_OFF(RELAY_K1_PORT, RELAY_K1_PIN) : RELAY_ON(RELAY_K1_PORT, RELAY_K1_PIN))
|
||||
#define DO2(x) (x!=0 ? RELAY_OFF(RELAY_K2_PORT, RELAY_K2_PIN) : RELAY_ON(RELAY_K2_PORT, RELAY_K2_PIN))
|
||||
#define DO3(x) (x!=0 ? RELAY_OFF(RELAY_K3_PORT, RELAY_K3_PIN) : RELAY_ON(RELAY_K3_PORT, RELAY_K3_PIN))
|
||||
#define DO4(x) (x!=0 ? RELAY_OFF(RELAY_K4_PORT, RELAY_K4_PIN) : RELAY_ON(RELAY_K4_PORT, RELAY_K4_PIN))
|
||||
#define DO5(x) (x!=0 ? RELAY_OFF(RELAY_K5_PORT, RELAY_K5_PIN) : RELAY_ON(RELAY_K5_PORT, RELAY_K5_PIN))
|
||||
#define DO6(x) (x!=0 ? RELAY_OFF(RELAY_K6_PORT, RELAY_K6_PIN) : RELAY_ON(RELAY_K6_PORT, RELAY_K6_PIN))
|
||||
#define DO7(x) (x!=0 ? RELAY_OFF(RELAY_K7_PORT, RELAY_K7_PIN) : RELAY_ON(RELAY_K7_PORT, RELAY_K7_PIN))
|
||||
#define DO8(x) (x!=0 ? RELAY_OFF(RELAY_K8_PORT, RELAY_K8_PIN) : RELAY_ON(RELAY_K8_PORT, RELAY_K8_PIN))
|
||||
#define DO9(x) (x!=0 ? RELAY_OFF(RELAY_K9_PORT, RELAY_K9_PIN) : RELAY_ON(RELAY_K9_PORT, RELAY_K9_PIN))
|
||||
#define DO10(x) (x!=0 ? RELAY_OFF(RELAY_K10_PORT,RELAY_K10_PIN): RELAY_ON(RELAY_K10_PORT, RELAY_K10_PIN))
|
||||
//电子锁控制(PK1/PK2)
|
||||
#define ELOCK_A(x) (x==0 ? RELAY_OFF(ELOCK_A_PORT, ELOCK_A_PIN) : RELAY_ON(ELOCK_A_PORT, ELOCK_A_PIN))
|
||||
#define ELOCK_B(x) (x==0 ? RELAY_OFF(ELOCK_B_PORT, ELOCK_B_PIN) : RELAY_ON(ELOCK_B_PORT, ELOCK_B_PIN))
|
||||
|
||||
/* DO/电子锁 输出引脚电平回读:1=高电平,0=低电平(与 gpio_output_bit_get 一致) */
|
||||
#define DO_PIN_LEVEL_READ(port, pin) ((gpio_output_bit_get((port), (pin)) == SET) ? 1U : 0U)
|
||||
#define DO1_READ() DO_PIN_LEVEL_READ(RELAY_K1_PORT, RELAY_K1_PIN)
|
||||
#define DO2_READ() DO_PIN_LEVEL_READ(RELAY_K2_PORT, RELAY_K2_PIN)
|
||||
#define DO3_READ() DO_PIN_LEVEL_READ(RELAY_K3_PORT, RELAY_K3_PIN)
|
||||
#define DO4_READ() DO_PIN_LEVEL_READ(RELAY_K4_PORT, RELAY_K4_PIN)
|
||||
#define DO5_READ() DO_PIN_LEVEL_READ(RELAY_K5_PORT, RELAY_K5_PIN)
|
||||
#define DO6_READ() DO_PIN_LEVEL_READ(RELAY_K6_PORT, RELAY_K6_PIN)
|
||||
#define DO7_READ() DO_PIN_LEVEL_READ(RELAY_K7_PORT, RELAY_K7_PIN)
|
||||
#define DO8_READ() DO_PIN_LEVEL_READ(RELAY_K8_PORT, RELAY_K8_PIN)
|
||||
#define DO9_READ() DO_PIN_LEVEL_READ(RELAY_K9_PORT, RELAY_K9_PIN)
|
||||
#define DO10_READ() DO_PIN_LEVEL_READ(RELAY_K10_PORT, RELAY_K10_PIN)
|
||||
#define ELOCK_A_READ() DO_PIN_LEVEL_READ(ELOCK_A_PORT, ELOCK_A_PIN)
|
||||
#define ELOCK_B_READ() DO_PIN_LEVEL_READ(ELOCK_B_PORT, ELOCK_B_PIN)
|
||||
|
||||
//绝缘检测继电器控制
|
||||
#define GUN1_INS_CTL(x) (x==0 ? RELAY_OFF(INSA_GND_PORT, INSA_GND_PIN) : RELAY_ON(INSA_GND_PORT, INSA_GND_PIN))
|
||||
#define GUN1_UBAL_CTL(x) (x==0 ? RELAY_OFF(INSA_POS_PORT, INSA_POS_PIN) : RELAY_ON(INSA_POS_PORT, INSA_POS_PIN))
|
||||
#define GUN2_INS_CTL(x) (x==0 ? RELAY_OFF(INSB_GND_PORT, INSB_GND_PIN) : RELAY_ON(INSB_GND_PORT, INSB_GND_PIN))
|
||||
#define GUN2_UBAL_CTL(x) (x==0 ? RELAY_OFF(INSB_POS_PORT, INSB_POS_PIN) : RELAY_ON(INSB_POS_PORT, INSB_POS_PIN))
|
||||
#define GUN1_INS_KM_READ DO_PIN_LEVEL_READ(INSA_POS_PORT, INSA_POS_PIN)
|
||||
#define GUN2_INS_KM_READ DO_PIN_LEVEL_READ(INSB_POS_PORT, INSB_POS_PIN)
|
||||
//连接确认控制
|
||||
#define GUN1_UBAL_READ_H (DI_READ(CHECKOUTA1_PORT, CHECKOUTA1_PIN))
|
||||
#define GUN1_UBAL_READ_L (DI_READ(CHECKOUTA2_PORT, CHECKOUTA2_PIN))
|
||||
#define GUN2_UBAL_READ_H (DI_READ(CHECKOUTB1_PORT, CHECKOUTB1_PIN))
|
||||
#define GUN2_UBAL_READ_L (DI_READ(CHECKOUTB2_PORT, CHECKOUTB2_PIN))
|
||||
|
||||
// 硬件看门狗喂狗
|
||||
#define WATCKDOG_TOGGLE() gpio_bit_toggle(WDO_PORT, WDO_PIN)
|
||||
//4G模块控制
|
||||
#define PWR_4G(x) (((x)==0) ? RELAY_OFF(PWR_4G_PORT, PWR_4G_PIN) : RELAY_ON(PWR_4G_PORT, PWR_4G_PIN))
|
||||
#define RST_4G(x) (((x)==0) ? RELAY_OFF(RST_4G_PORT, RST_4G_PIN) : RELAY_ON(RST_4G_PORT, RST_4G_PIN))
|
||||
/* FC41D 复位 PE6:x=0 正常运行(低),x=1 拉复位(高) */
|
||||
#define FC41D_RST(x) (((x)==0) ? RELAY_OFF(FC41D_RST_PORT, FC41D_RST_PIN) : RELAY_ON(FC41D_RST_PORT, FC41D_RST_PIN))
|
||||
|
||||
//温度采集及板卡供电检测
|
||||
#define TEMP_MULT_CTRA(x) (x==0 ? RELAY_OFF(TEMP_ADDR_A_PORT,TEMP_ADDR_A_PIN) : RELAY_ON(TEMP_ADDR_A_PORT, TEMP_ADDR_A_PIN))
|
||||
#define TEMP_MULT_CTRB(x) (x==0 ? RELAY_OFF(TEMP_ADDR_B_PORT,TEMP_ADDR_B_PIN) : RELAY_ON(TEMP_ADDR_B_PORT, TEMP_ADDR_B_PIN))
|
||||
#define TEMP_MULT_CTRC(x) (x==0 ? RELAY_OFF(TEMP_ADDR_C_PORT,TEMP_ADDR_C_PIN) : RELAY_ON(TEMP_ADDR_C_PORT, TEMP_ADDR_C_PIN))
|
||||
//===============================================
|
||||
void v_sys_hardware_init(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user