菜鸟新学的32,望大神指点,共进步:
#include "bitband.h"
/**********
LED1-->PG9
LED2-->PE4
LED3-->PE3
低电平亮 AHB1
***********/
void led_init(void){
GPIO_InitTypeDef GpioInitValue;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOG,ENABLE);
//GPIO配置
GpioInitValue.GPIO_Mode = GPIO_Mode_OUT;//输出
GpioInitValue.GPIO_OType = GPIO_OType_PP;//推挽
GpioInitValue.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4;//引脚
GpioInitValue.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GpioInitValue.GPIO_Speed = GPIO_Speed_50MHz;//速率
GPIO_Init(GPIOE,&GpioInitValue);
GpioInitValue.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOG,&GpioInitValue);}
void led_switch(int num,int state){
if(state!=0)
state = 1;
switch(num){
case 0:
PGOut(9) = state;
break;
case 1:
PGOut(4) = state;
break;
case 2:
PGOut(3) = state;
break;
default :break;
}
}
|