You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//
// Created by iflyt on 2025/2/27.
//
#include "led.h"
#include "bsp.h"
void LED_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0};
// 使能 GPIOF 和 GPIOE 端口时钟
__HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOI_CLK_ENABLE();
// 配置 LED_KEY 引脚
GPIO_InitStruct.Pin = LED_KEY_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LED_KEY_GPIO_Port, &GPIO_InitStruct);
// 配置 LED_GREEN 引脚
GPIO_InitStruct.Pin = LED_GREEN_Pin; HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct);
// 配置 LED_RED 引脚
GPIO_InitStruct.Pin = LED_RED_Pin; HAL_GPIO_Init(LED_RED_GPIO_Port, &GPIO_InitStruct);
// 配置 LED_BLUE 引脚
GPIO_InitStruct.Pin = LED_BLUE_Pin; HAL_GPIO_Init(LED_BLUE_GPIO_Port, &GPIO_InitStruct);
// 配置 蜂鸣器
GPIO_InitStruct.Pin = BEPPER_ALARM_Pin; HAL_GPIO_Init(BEPPER_ALARM_GPIO_Port, &GPIO_InitStruct);
// 配置 LIGHT_FLOOD 引脚
GPIO_InitStruct.Pin = LIGHT_FLOOD_Pin; HAL_GPIO_Init(LIGHT_FLOOD_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = RK3588_POWER_Pin; HAL_GPIO_Init(RK3588_POWER_GPIO_Port, &GPIO_InitStruct);
// LED_KEY_ON;
LED_KEY_OFF; // 初始化时将所有 LED 熄灭
LED_GREEN_OFF; LED_GREEN_OFF; LED_GREEN_OFF; BEPPER_ALARM_OFF; // 初始化时将照明灯关闭
LIGHT_FLOOD_OFF; }
void tri_color_light(const LightColor color) { // 先关闭所有灯
LED_GREEN_OFF; LED_BLUE_OFF; LED_RED_OFF;
// 根据传入的枚举值开启相应的灯
switch (color) { case COLOR_GREEN: LED_GREEN_ON; break; case COLOR_BLUE: LED_BLUE_ON; break; case COLOR_RED: LED_RED_ON; break; case COLOR_OFF: default: break; } }
|