提交全部资料
This commit is contained in:
117
1.主程序源代码/User/src/bsp_led.c
Normal file
117
1.主程序源代码/User/src/bsp_led.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* @Date: 2025-06-26 09:38:27
|
||||
* @LastEditors: 路怀帅
|
||||
* @LastEditTime: 2025-06-26 15:04:35
|
||||
* @FilePath: \Andon_Remote_Control\MDK_PROJECT\Drive\Led.c
|
||||
*/
|
||||
#include "main.h"
|
||||
|
||||
static void LED_Init(void);
|
||||
static void LED_Set(uint8_t led_x);
|
||||
static void Green_Toggle_Fun(void);
|
||||
static void Red_Toggle_Fun(void);
|
||||
static void Blue_Toggle_Fun(void);
|
||||
static void Yellow_Toggle_Fun(void);
|
||||
|
||||
typedef LED_Color_Enum Led_Color;
|
||||
|
||||
LEDClassStruct LEDClass = {
|
||||
.Init = LED_Init,
|
||||
.Set = LED_Set,
|
||||
.GREEN_Toggle = Green_Toggle_Fun,
|
||||
.RED_Toggle = Red_Toggle_Fun,
|
||||
.BLUE_Toggle = Blue_Toggle_Fun,
|
||||
.YELLOW_Toggle = Yellow_Toggle_Fun};
|
||||
|
||||
static void LED_Set(uint8_t led_x)
|
||||
{
|
||||
switch (led_x)
|
||||
{
|
||||
case BLACK:
|
||||
LED_ALL_OFF;
|
||||
break;
|
||||
case BLUE:
|
||||
BLUE_ON;
|
||||
break;
|
||||
case GREEN:
|
||||
GREEN_ON;
|
||||
break;
|
||||
case RED:
|
||||
RED_ON;
|
||||
break;
|
||||
case YELLOW:
|
||||
RED_ON;
|
||||
GREEN_ON;
|
||||
break;
|
||||
case WHITE:
|
||||
RED_ON;
|
||||
GREEN_ON;
|
||||
BLUE_ON;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Green_Toggle_Fun()
|
||||
{
|
||||
GREEN_TOG;
|
||||
}
|
||||
static void Blue_Toggle_Fun()
|
||||
{
|
||||
BLUE_TOG;
|
||||
}
|
||||
static void Red_Toggle_Fun()
|
||||
{
|
||||
RED_TOG;
|
||||
}
|
||||
static void Yellow_Toggle_Fun()
|
||||
{
|
||||
RED_TOG;
|
||||
GREEN_TOG;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LED初始化
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void LED_Init()
|
||||
{
|
||||
/*初始化LED引脚*/
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
GPIO_SetBits(GPIOA, GPIO_Pin_6 | GPIO_Pin_7);
|
||||
GPIO_SetBits(GPIOB, GPIO_Pin_0);
|
||||
}
|
||||
|
||||
void ASR_Power_Init()
|
||||
{
|
||||
/*初始化LED引脚*/
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
void BOARD_Power_Init()
|
||||
{
|
||||
/*初始化LED引脚*/
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
BOARD_Power_ON;
|
||||
}
|
||||
Reference in New Issue
Block a user