2023-10-06 18:47:05 +08:00
|
|
|
|
#include "gpio_cfg.h"
|
|
|
|
|
#include "base/delay.h"
|
|
|
|
|
void CtrlGpio_DefInit(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
|
|
|
|
|
//GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST,ENABLE);
|
|
|
|
|
|
|
|
|
|
PAout(LAVC_M_Pin_Nu) = 0;
|
|
|
|
|
|
|
|
|
|
//GPIO 配置
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin=LAVC_M_Pin;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
|
|
|
|
GPIO_ResetBits(GPIOA,GPIO_InitStructure.GPIO_Pin);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = SEG0_Pin;
|
2024-01-04 18:09:09 +08:00
|
|
|
|
// GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
2023-12-04 11:02:41 +08:00
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;
|
2023-10-06 18:47:05 +08:00
|
|
|
|
GPIO_Init(GPIOA,&GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PBout(R10_ON_Pin_Nu) = 1;
|
|
|
|
|
PBout(R510_ON_Pin_Nu) = 0;
|
|
|
|
|
PBout(LED1_Pin_Nu) = 0;
|
|
|
|
|
PBout(IO_APD12_Pin_Nu) = 0;
|
|
|
|
|
PBout(LED2_Pin_Nu) = 0;
|
|
|
|
|
PBout(OUTAL_Pin_Nu) = 0;
|
|
|
|
|
PBout(OUTBL_Pin_Nu) = 0;
|
|
|
|
|
PBout(OUTAH_Pin_Nu) = 0;
|
|
|
|
|
PBout(IO_CAP_AD_Pin_Nu) = 0;
|
|
|
|
|
|
|
|
|
|
//GPIO 配置
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin=\
|
|
|
|
|
R10_ON_Pin|R510_ON_Pin|LED1_Pin|IO_APD12_Pin|LED2_Pin|OUTAL_Pin|OUTBL_Pin|OUTAH_Pin|IO_CAP_AD_Pin;
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_ResetBits(GPIOB,GPIO_InitStructure.GPIO_Pin);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = FIRE_TEST_Pin;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
|
|
|
|
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
PCout(R100_ON_Pin_Nu) = 0;
|
|
|
|
|
PCout(OUTBH_Pin_Nu) = 0;
|
|
|
|
|
PCout(POWER_ON_Pin_Nu) = 0;
|
|
|
|
|
PCout(IO_APD22_Pin_Nu) = 0;
|
|
|
|
|
PCout(IO_APD21_Pin_Nu) = 0;
|
|
|
|
|
PCout(IO_APD11_Pin_Nu) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin=\
|
|
|
|
|
R100_ON_Pin|OUTBH_Pin|POWER_ON_Pin|IO_APD22_Pin|IO_APD21_Pin|IO_APD11_Pin;
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
//GPIO 配置
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin=SEG4_Pin|SEG3_Pin|SEG1_Pin|SEG2_Pin;
|
2023-12-02 11:36:38 +08:00
|
|
|
|
// GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;
|
2023-10-06 18:47:05 +08:00
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
@brief 获取设备地址
|
|
|
|
|
@param 无
|
|
|
|
|
@rtv 设备地址
|
|
|
|
|
*/
|
|
|
|
|
uint8_t Gpio_GetDeivceAddr(void)
|
|
|
|
|
{
|
|
|
|
|
uint16_t ul_addr ;
|
|
|
|
|
ul_addr = (PCin(SEG4_Pin_Nu) & 0x01) <<4;
|
|
|
|
|
ul_addr |= ((PCin(SEG3_Pin_Nu) & 0x01) <<3);
|
|
|
|
|
ul_addr |= ((PCin(SEG2_Pin_Nu) & 0x01) <<2);
|
|
|
|
|
ul_addr |= ((PCin(SEG1_Pin_Nu) & 0x01) <<1);
|
|
|
|
|
ul_addr |= (PAin(SEG0_Pin_Nu) & 0x01);
|
|
|
|
|
return ul_addr;
|
2024-01-04 18:09:09 +08:00
|
|
|
|
// return 7;
|
2023-10-06 18:47:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@brief 4限制电阻测量通道切换
|
|
|
|
|
@param 0 全关
|
|
|
|
|
1 通道1-4通,过桥丝
|
|
|
|
|
2 通道2-3通,过桥丝
|
|
|
|
|
3 通道1-3通,测阻抗
|
|
|
|
|
4 通道2-4通,测阻抗
|
|
|
|
|
*/
|
|
|
|
|
void Gpio_ResistorSwitch(uint8_t uc_r)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
1 2
|
|
|
|
|
3 4
|
|
|
|
|
*/
|
|
|
|
|
switch(uc_r)
|
|
|
|
|
{
|
|
|
|
|
//1-4通,过桥丝电阻
|
|
|
|
|
case 1: PCout(IO_APD11_Pin_Nu) = 1;PBout(IO_APD12_Pin_Nu) = 0;PCout(IO_APD22_Pin_Nu) = 1;PCout(IO_APD21_Pin_Nu) = 0; break;
|
|
|
|
|
//2-3通,过桥丝测电阻
|
|
|
|
|
case 2: PCout(IO_APD11_Pin_Nu) = 0;PBout(IO_APD12_Pin_Nu) = 1;PCout(IO_APD22_Pin_Nu) = 0;PCout(IO_APD21_Pin_Nu) = 1; break;
|
|
|
|
|
//1-3通, 测阻抗
|
|
|
|
|
case 3: PCout(IO_APD11_Pin_Nu) = 1;PBout(IO_APD12_Pin_Nu) = 1; PCout(IO_APD22_Pin_Nu) = 0; PCout(IO_APD21_Pin_Nu) = 0; break;
|
|
|
|
|
//2-4通,测阻抗
|
|
|
|
|
case 4: PCout(IO_APD11_Pin_Nu) = 0; PBout(IO_APD12_Pin_Nu) = 0; PCout(IO_APD22_Pin_Nu) = 1; PCout(IO_APD21_Pin_Nu) = 1; break;
|
|
|
|
|
//全关
|
|
|
|
|
default: PCout(IO_APD11_Pin_Nu) = 0; PBout(IO_APD12_Pin_Nu) = 0;PCout(IO_APD22_Pin_Nu) = 0; PCout(IO_APD21_Pin_Nu) = 0; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
@brief 测量电容电压压降GPIO配置
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void Gpio_CAPSwitch(uint8_t uc_sw)
|
|
|
|
|
{
|
|
|
|
|
Gpio_ResistorSwitch(0);
|
|
|
|
|
if(uc_sw > 0)
|
|
|
|
|
{
|
|
|
|
|
PBout(IO_CAP_AD_Pin_Nu) = 1;
|
|
|
|
|
}else{
|
|
|
|
|
PBout(IO_CAP_AD_Pin_Nu) = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|