Files
MobKBK 460e0e9e73 init
2026-06-20 21:22:34 +08:00

82 lines
2.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "led.h"
int Led_Count=500; //LED flicker time control //LED闪烁时间控制
/**************************************************************************
Function: LED interface initialization
Input : none
Output : none
函数功能LED接口初始化
入口参数:无
返回 值:无
**************************************************************************/
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//使能GPIOB时钟
GPIO_InitStructure.GPIO_Pin = LED_PIN;//LED对应IO口
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIO
GPIO_SetBits(GPIOA,GPIO_Pin_12);
}
/**************************************************************************
Function: Buzzer interface initialized
Input : none
Output : none
函数功能:蜂鸣器接口初始化
入口参数:无
返回 值:无
**************************************************************************/
void Buzzer_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);//使能GPIOB时钟
GPIO_InitStructure.GPIO_Pin = Buzzer_PIN;//LED对应IO口
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIO
}
/**************************************************************************
Function: LED light flashing task
Input : none
Output : none
函数功能LED灯闪烁任务
入口参数:无
返回 值:无
**************************************************************************/
void led_task(void *pvParameters)
{
while(1)
{
//The status of the LED is reversed. 0 is on and 1 is off
//LED状态取反0是点亮1是熄灭
LED=~LED;
//The LED flicker task is very simple, requires low frequency accuracy, and uses the relative delay function
//LED闪烁任务非常简单对频率精度要求低使用相对延时函数
vTaskDelay(Led_Count);
}
}
/**************************************************************************
Function: The LED flashing
Input : none
Output : blink time
函数功能LED闪烁
入口参数:闪烁时间
返 回 值:无
**************************************************************************/
void Led_Flash(u16 time)
{
static int temp;
if(0==time) LED=0;
else if(++temp==time) LED=~LED,temp=0;
}