g0b1vetx-board/Board/relay-board.c
2023-05-19 18:02:00 +08:00

55 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "relay-board.h"
RelayInfo_t RelayInfo =
{
{GPIOB, GPIO_PIN_8, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, NULL}, //PB5
{GPIOB, GPIO_PIN_9, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_VERY_HIGH, NULL}, //PB5
};
/********************************************
函数名称UartInfoInit
输入参数:串口句柄
输出参数NULL
功能描述:初始化一个串口
********************************************/
void RelayInfoInit (void)
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = RelayInfo.Relay1.mode;
GPIO_InitStruct.Pull = RelayInfo.Relay1.Pull;
GPIO_InitStruct.Speed = RelayInfo.Relay1.Speed;
GPIO_InitStruct.Pin = RelayInfo.Relay1.pin;
HAL_GPIO_Init (RelayInfo.Relay1.GPIOx, &GPIO_InitStruct);
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_RESET);
GPIO_InitStruct.Mode = RelayInfo.Relay2.mode;
GPIO_InitStruct.Pull = RelayInfo.Relay2.Pull;
GPIO_InitStruct.Speed = RelayInfo.Relay2.Speed;
GPIO_InitStruct.Pin = RelayInfo.Relay2.pin;
HAL_GPIO_Init (RelayInfo.Relay2.GPIOx, &GPIO_InitStruct);
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_RESET);
}
void RelayOpenDoor (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_SET);
}
void RelayCloseDoor (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay1.GPIOx, RelayInfo.Relay1.pin, GPIO_PIN_RESET);
}
void RelayOpenK2 (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_SET);
}
void RelayCloseK2 (void)
{
HAL_GPIO_WritePin (RelayInfo.Relay2.GPIOx, RelayInfo.Relay2.pin, GPIO_PIN_RESET);
}