stm32之5.长按按键(使用时钟源)调整跑马灯速度


源码

#include <stm32f4xx.h>

#include "led.h"

#include "delay.h"

#include "my_str.h"

#include "beep.h"

#include "key.h"

int main(void)

{

key_init();

Led_init();

while(1)

{

/* 长按按键才能够识别 */

if(Bit_RESET==GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0))

{

RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));

RCC->CFGR |= RCC_CFGR_SW_PLL;

}

if(Bit_RESET==GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2))

{

RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));

RCC->CFGR |= RCC_CFGR_SW_HSI;

}

if(Bit_RESET==GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3))

{

RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));

RCC->CFGR |= RCC_CFGR_SW_HSE;

}

GPIO_WriteBit(GPIOF,GPIO_Pin_9,Bit_RESET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOF,GPIO_Pin_9,Bit_SET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOF,GPIO_Pin_10,Bit_RESET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOF,GPIO_Pin_10,Bit_SET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOE,GPIO_Pin_13,Bit_RESET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOE,GPIO_Pin_13,Bit_SET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOE,GPIO_Pin_14,Bit_RESET);

MY_DelayMs(500);

GPIO_WriteBit(GPIOE,GPIO_Pin_14,Bit_SET);

MY_DelayMs(500);

}

}

相关推荐
xyx-3v10 分钟前
VS CodeC51 单片机开发环境搭建
单片机·嵌入式硬件
iCxhust1 小时前
c# U盘映像生成工具
开发语言·单片机·c#
小宋同学在不断学习3 小时前
stm32--SPI原理应用W25Q64(二)
stm32·单片机·spi
lingzhilab3 小时前
零知开源——STM32F4结合BMP581气压传感器实现ST7789中文显示教程
stm32·单片机·嵌入式硬件
夜月yeyue3 小时前
设计模式分析
linux·c++·stm32·单片机·嵌入式硬件
猫猫的小茶馆4 小时前
【STM32】外部中断
stm32·单片机·嵌入式硬件·mcu·51单片机
is08155 小时前
STM32两种不同的链接配置方式
stm32
森焱森6 小时前
垂起固定翼无人机介绍
c语言·单片机·算法·架构·无人机
brave and determined7 小时前
国产MCU学习Day11——CW32F030C8T6 低电压检测器(LVD)详解与应用
单片机·嵌入式硬件·嵌入式·国产mcu·cw32f030c8t6·cw32f030c8t6lvd·低电压检测器
哄娃睡觉7 小时前
stm32 dac无法输出满量程电压3.3V
stm32