#include "bsp_relay.h" void RELAY_GPIO_Config(void){ // GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RELAY1_GPIO_CLK, ENABLE ); //配置时钟 GPIO_InitStructure.GPIO_Pin = RELAY1_GPIO_PIN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(RELAY1_GPIO_PORT,&GPIO_InitStructure); RELAY1_OFF(); } /** * @brief 获取继电器当前状态 * @param 无 * @retval 1-继电器打开, 0-继电器关闭 */ uint8_t RELAY1_GetState(void) { return GPIO_ReadOutputDataBit(RELAY1_GPIO_PORT, RELAY1_GPIO_PIN); }