[mw_shl_code=c,false][mw_shl_code=c,true][/mw_shl_code]#include "led.h"
void led_init()
{
//端口时钟PF,PC
RCC->AHB1ENR |=1<<5;
RCC->AHB1ENR |=1<<2;
GPIO_Set(GPIOC,0);
GPIO_Set(GPIOF,6);
GPIO_Set(GPIOF,9);
GPIO_Set(GPIOF,10);
}
/*端口引脚初始化配置函数*/
void GPIO_Set(GPIO_TypeDef * GPIOx,u8 MODE)
{
GPIOx->MODER &=~(3<<MODE*2);//清除原来的配置
GPIOx->MODER |=1<<MODE*2;
GPIOx->OTYPER&=~(1<<MODE); //清除原来的设置
GPIOx->OSPEEDR &=~(3<<MODE*2);//输出速度2M
GPIOx->OSPEEDR |=2<<MODE*2;
GPIOx->PUPDR &=~(3<<MODE*2);
GPIOx->PUPDR |=1<<MODE*2;
}
void delay(u32 t)
{
while(t--);
}[/mw_shl_code] |