Files
3d_contorl/Core/Bsp/bsp_relay.h
2026-03-21 01:49:41 +08:00

61 lines
1.8 KiB
C

/**
* @file bsp_relay.h
* @brief Relay control driver (LIGHT & FAN)
* @details Low level effective (low level = ON)
*/
#ifndef __BSP_RELAY_H
#define __BSP_RELAY_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Exported defines ----------------------------------------------------------*/
#define RELAY_ON GPIO_PIN_RESET // Low level activates relay
#define RELAY_OFF GPIO_PIN_SET // High level deactivates relay
/* Exported types ------------------------------------------------------------*/
typedef enum {
FAN_MODE_MANUAL = 0, // Manual control
FAN_MODE_AUTO = 1 // Auto control by temperature
} fan_mode_t;
typedef struct {
fan_mode_t fan_mode; // FAN mode: manual or auto
float fan_threshold; // Temperature threshold for auto mode (Celsius)
uint8_t light_state; // LIGHT state: 0=off, 1=on
uint8_t fan_state; // FAN state: 0=off, 1=on
} system_state_t;
/* Exported functions prototypes --------------------------------------------*/
void BSP_Relay_Init(void);
void BSP_LIGHT_On(void);
void BSP_LIGHT_Off(void);
void BSP_LIGHT_Toggle(void);
uint8_t BSP_LIGHT_GetState(void);
void BSP_FAN_On(void);
void BSP_FAN_Off(void);
void BSP_FAN_Toggle(void);
uint8_t BSP_FAN_GetState(void);
/* Auto control functions (for temperature-based fan control) -------------*/
void BSP_FAN_SetMode(fan_mode_t mode);
fan_mode_t BSP_FAN_GetMode(void);
void BSP_FAN_SetThreshold(float threshold);
float BSP_FAN_GetThreshold(void);
void BSP_FAN_AutoControl(float current_temp);
/* System state --------------------------------------------------------------*/
void BSP_System_GetState(system_state_t *state);
#ifdef __cplusplus
}
#endif
#endif /* __BSP_RELAY_H */