Relay_and_Socket_Protection/src/Relays/Relays.h
2024-09-01 16:29:10 -07:00

75 lines
1.9 KiB
C

/**
* @brief Relay control module.
* @details This file is for controlling electromechanical relays.
* @author Jake G
* @date 2024-09-01
* @copyright None
* @file RELAYS.h
*/
#ifndef RELAYS
#define RELAYS
#include <stdbool.h>
#include <stdint.h>
/**
* Represents an individual relay.
*/
typedef struct Relay {
void *output_port;
uint8_t output_pin;
void *input_port;
uint8_t input_pin;
uint16_t make_time;
uint16_t break_time;
bool disabled_fpc;
} Relay;
// extern void ptr_Timer_Start(void);
// extern void Timer_Disable(void);
/**
* Uses the AVR timer/counter to get the time it takes the relay to fully
* activate. The value is then saved into the passed structure. To get the
* time in ms divide the value by 10.
* @param relay A pointer to an Relay stucture instance.
*/
void Relay_MeasureMakeTime(Relay *relay);
/**
* Uses the AVR timer/counter to get the time it takes the relay to
* deactivate. The value is then saved into the passed structure. To get the
* time in ms divide the value by 10.
* @param relay A pointer to an Relay stucture instance.
*/
void Relay_MeasureBreakTime(Relay *relay);
/**
* Enables or activates the relay. If the relay has been disabled
* for this power cycle it will do nothing.
* @param relay A pointer to an Relay stucture instance.
*/
void Relay_Enable(Relay *relay);
/**
* Disables or activates the relay. If the relay has been disabled
* for this power cycle it will do nothing.
* @param relay A pointer to an Relay stucture instance.
*/
void Relay_Disable(Relay *relay);
/**
* Disables the relay, other Relay function calls will not enable the relay
* or change it's state. This takes affect until restart of the system.
* @param relay A pointer to an Relay stucture instance.
*/
void Relay_DisableForPowerCycle(Relay *relay);
/**
* Reads the relay's input pin on the input port.
* @return True for enabled false for disabled relays.
*/
bool Relay_ReadState(Relay *relay);
#endif // RELAYS