GeBalanceBot/Hardware/Firmware/GeBalanceBot_Firmware v1.0/DRV/bsp_GPIO.c

44 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/******************** (C) COPYRIGHT 2024 GeekRebot *****************************
* File Name : bsp_GPIO.c
* Current Version : V1.0 & ST 3.5.0
* Author : zhanli 719901725@qq.com
* Date of Issued : 2024.01.17 Create
* Comments : GPIO板级支持包(Board Support Pack)最好把所有的IO在这里
配置,方便管理
********************************************************************************/
#include "bsp_GPIO.h"
/**----------------------------------------------------------------------
* Function : LED_GPIO_Config
* Description : 初始化LED1的GPIO功能
* Author : zhanli&719901725@qq.com
* Date : 2024/01/17 zhanli
*---------------------------------------------------------------------**/
void LED_GPIO_Config(void)
{
/* 定义一个GPIO_InitTypeDef类型的结构体 */
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(LED_BLUE_CLK, ENABLE); /* 开启GPIO的外设时钟 */
GPIO_InitStructure.GPIO_Pin = LED_BLUE_Pin; /* 选择要控制的GPIO引脚 */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设置引脚模式为通用推挽输出 */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* 设置引脚速率为50MHz */
GPIO_Init(LED_BLUE_PORT, &GPIO_InitStructure); /* 调用库函数初始化GPIOC13 */
}
/**----------------------------------------------------------------------
* Function : LED_Flash
* Description : LED闪烁
* Author : zhanli&719901725@qq.com
* Date : 2024/01/17 zhanli
*---------------------------------------------------------------------**/
void LED_Flash(int time)
{
static int temp;
if(++temp == time){
// LED 蓝色色状态翻转
GPIO_WriteBit(LED_BLUE_PORT, LED_BLUE_Pin,
(BitAction) (1 - GPIO_ReadInputDataBit(LED_BLUE_PORT, LED_BLUE_Pin)));
temp = 0;
}
}