first commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include "Bsp.h"
|
||||
|
||||
/**
|
||||
* @brief 启用GPIO口时钟
|
||||
* @note void
|
||||
* @param GpioX:GPIO引脚
|
||||
* @retval void
|
||||
*/
|
||||
void GpioClockEnable(const GPIO_MAP_T *GpioX)
|
||||
{
|
||||
GpioX->ClockCmd(GpioX->ClockTree,ENABLE);
|
||||
}
|
||||
/**
|
||||
* @brief 配置GPIO口
|
||||
* @note void
|
||||
* @param GpioX:引脚 GpioMode:GPIO模式 GpioSpeed:GPIO速度
|
||||
* @retval void
|
||||
*/
|
||||
void GpioConfig(const GPIO_MAP_T *GpioX, GPIOMode_TypeDef GpioMode, GPIOSpeed_TypeDef GpioSpeed)
|
||||
{
|
||||
GPIO_InitTypeDef GpioInitSt;
|
||||
|
||||
GpioInitSt.GPIO_Pin = GpioX->Periph.GpioPin;
|
||||
GpioInitSt.GPIO_Mode = GpioMode;
|
||||
GpioInitSt.GPIO_Speed = GpioSpeed;
|
||||
//打开外设时钟
|
||||
GpioClockEnable(GpioX);
|
||||
GPIO_Init(GpioX->Periph.GpioPort, &GpioInitSt);
|
||||
}
|
||||
/**
|
||||
* @brief 改变GPIO口状态
|
||||
* @note
|
||||
* @param GpioX:GPIO引脚 Value:设置值
|
||||
* @retval void
|
||||
*/
|
||||
void GpioSet(const GPIO_MAP_T *GpioX, uint8_t Value)
|
||||
{
|
||||
if (Value == (uint8_t)RESET)
|
||||
{
|
||||
GPIO_ResetBits(GpioX->Periph.GpioPort, GpioX->Periph.GpioPin);
|
||||
}
|
||||
else if (Value == (uint8_t)SET)
|
||||
{
|
||||
GPIO_SetBits(GpioX->Periph.GpioPort, GpioX->Periph.GpioPin);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief 读取GPIO口状态
|
||||
* @note
|
||||
* @param GpioX:GPIO引脚
|
||||
* @retval 0:低电平,1高电平
|
||||
*/
|
||||
unsigned char GpioGet(const GPIO_MAP_T *GpioX)
|
||||
{
|
||||
return (unsigned char)GPIO_ReadInputDataBit(GpioX->Periph.GpioPort, GpioX->Periph.GpioPin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user