update
This commit is contained in:
54
leakage_system/usr/bsp/bsp_relay.c
Normal file
54
leakage_system/usr/bsp/bsp_relay.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "bsp_relay.h"
|
||||
|
||||
/*<2A><><EFBFBD>ؿ<EFBFBD><D8BF>Ƶ<EFBFBD>ƽ<EFBFBD><C6BD>ʹ<EFBFBD><CAB9>ͬһ<CDAC>ĵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>Ʒ<EFBFBD>ʽ*/
|
||||
#define RELAY_GPIO_ON GPIO_PIN_SET
|
||||
#define RELAY_GPIO_OFF GPIO_PIN_RESET
|
||||
|
||||
#define RELAY_1_ON HAL_GPIO_WritePin (RELAY_1_GPIO_Port, RELAY_1_Pin, RELAY_GPIO_ON)
|
||||
#define RELAY_1_OFF HAL_GPIO_WritePin (RELAY_1_GPIO_Port, RELAY_1_Pin, RELAY_GPIO_OFF)
|
||||
|
||||
#define RELAY_2_ON HAL_GPIO_WritePin (RELAY_2_GPIO_Port, RELAY_2_Pin, RELAY_GPIO_ON)
|
||||
#define RELAY_2_OFF HAL_GPIO_WritePin (RELAY_2_GPIO_Port, RELAY_2_Pin, RELAY_GPIO_OFF)
|
||||
|
||||
#define RELAY_3_ON HAL_GPIO_WritePin (RELAY_3_GPIO_Port, RELAY_3_Pin, RELAY_GPIO_ON)
|
||||
#define RELAY_3_OFF HAL_GPIO_WritePin (RELAY_3_GPIO_Port, RELAY_3_Pin, RELAY_GPIO_OFF)
|
||||
|
||||
#define RELAY_4_ON HAL_GPIO_WritePin (RELAY_4_GPIO_Port, RELAY_4_Pin, RELAY_GPIO_ON)
|
||||
#define RELAY_4_OFF HAL_GPIO_WritePin (RELAY_4_GPIO_Port, RELAY_4_Pin, RELAY_GPIO_OFF)
|
||||
|
||||
static void bsp_relay_init(void);
|
||||
static void bsp_relay_task(void);
|
||||
static void bsp_relay_set(u8 ch,u8 state);
|
||||
|
||||
bsp_relay_t relay =
|
||||
{
|
||||
.init = bsp_relay_init,
|
||||
.task = bsp_relay_task,
|
||||
.set = bsp_relay_set,
|
||||
};
|
||||
|
||||
bsp_relay_t *p_relay = &relay;
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
static void bsp_relay_init(void)
|
||||
{
|
||||
RELAY_1_OFF;
|
||||
RELAY_2_OFF;
|
||||
RELAY_3_OFF;
|
||||
RELAY_4_OFF;
|
||||
}
|
||||
|
||||
static void bsp_relay_task(void)
|
||||
{
|
||||
(USR_ON == p_relay->state[0]) ? RELAY_1_ON : RELAY_1_OFF;
|
||||
(USR_ON == p_relay->state[1]) ? RELAY_2_ON : RELAY_2_OFF;
|
||||
(USR_ON == p_relay->state[2]) ? RELAY_3_ON : RELAY_3_OFF;
|
||||
(USR_ON == p_relay->state[3]) ? RELAY_4_ON : RELAY_4_OFF;
|
||||
}
|
||||
/*<2A><><EFBFBD>ƶ<EFBFBD>Ӧͨ<D3A6><CDA8>״̬*/
|
||||
static void bsp_relay_set(u8 ch,u8 state)
|
||||
{
|
||||
if(ch < BSP_RELAY_CH_NUM)
|
||||
{
|
||||
p_relay->state[ch] = state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user