初始化具体的FAN。void FAN_Init(FAN_TypeDef_Struct *FANInit,FAN_InitTypeDef_Struct *FANInitStruct)
{
GPIO_InitTypeDef GPIO_InitStructure;
FANInit->FAN_Hardware.FAN_RCC = FANInitStruct->FAN_Hardware.FAN_RCC;
FANInit->FAN_Hardware.FAN_GPIOx = FANInitStruct->FAN_Hardware.FAN_GPIOx;
FANInit->FAN_Hardware.FAN_GPIO_Pin = FANInitStruct->FAN_Hardware.FAN_GPIO_Pin;
FANInit->FAN_Parameter.fan_state = FANInitStruct->FAN_Parameter.fan_state;
RCC_APB2PeriphClockCmd(FANInit->FAN_Hardware.FAN_RCC,ENABLE);
GPIO_InitStructure.GPIO_Pin = FANInit->FAN_Hardware.FAN_GPIO_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(FANInit->FAN_Hardware.FAN_GPIOx,&GPIO_InitStructure);
switch(FANInit->FAN_Parameter.fan_state)
{
case FAN_ON:
GPIO_SetBits(FANInit->FAN_Hardware.FAN_GPIOx,FANInit->FAN_Hardware.FAN_GPIO_Pin);
break;
case FAN_OFF:
GPIO_ResetBits(FANInit->FAN_Hardware.FAN_GPIOx,FANInit->FAN_Hardware.FAN_GPIO_Pin);
break;
default:
GPIO_ResetBits(FANInit->FAN_Hardware.FAN_GPIOx,FANInit->FAN_Hardware.FAN_GPIO_Pin);
break;
}
}
|
———————————————— 版权声明:本文为CSDN博主「CaewarfeneggerCao」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_56286356/article/details/123352038