From f43a1cb6621aafe5f77ab41c98028dea5b9b304b Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Sun, 1 Sep 2024 12:49:24 -0700 Subject: [PATCH] Updated with function signitures --- src/Relays/Relays.c | 12 ++------- src/Relays/Relays.h | 66 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/src/Relays/Relays.c b/src/Relays/Relays.c index f432f9b..e10ee88 100644 --- a/src/Relays/Relays.c +++ b/src/Relays/Relays.c @@ -1,16 +1,8 @@ /* - * Author: username - * Date: 2024 + * Author: Jake G + * Date: 2024-09-01 * filename: Relays.c * description: module_purpose */ #include "Relays.h" - -// dumb test function -int add_two(int a) -{ - int b = a; - b += 2; - return b; -} diff --git a/src/Relays/Relays.h b/src/Relays/Relays.h index 3208bad..d25b347 100644 --- a/src/Relays/Relays.h +++ b/src/Relays/Relays.h @@ -1,8 +1,8 @@ /** - * @brief PUT_TEXT_HERE - * @details This file is... - * @author username - * @date todays_date + * @brief Relay control module. + * @details This file is for controlling electromechanical relays. + * @author Jake G + * @date 2024-09-01 * @copyright None * @file RELAYS.h */ @@ -10,11 +10,61 @@ #ifndef RELAYS #define RELAYS +#include /** - * A function that adds two to a number - * @param a The first argument + * Represents an individual relay. */ -int add_two(int a); +typedef struct Relay { + uint8_t output_port; + uint8_t output_pin; + uint8_t input_port; + uint8_t input_pin; + uint16_t make_time; + uint16_t break_time; +} Relay; -#endif //RELAYS +/** + * 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); + +/** + * Changes the current state to the opposite one. + * @param relay A pointer to an Relay stucture instance. + */ +void Relay_ToggleState(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); + +#endif // RELAYS