From d558b3552c403bd7090472bccc9556e58aadaa35 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Sun, 1 Sep 2024 16:29:10 -0700 Subject: [PATCH] updated relays by linking with the timer module. --- src/Relays/CMakeLists.txt | 4 ++++ src/Relays/Relays.c | 24 ++++++++++++------------ src/Relays/Relays.h | 3 +++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Relays/CMakeLists.txt b/src/Relays/CMakeLists.txt index 75618c0..e08bd93 100644 --- a/src/Relays/CMakeLists.txt +++ b/src/Relays/CMakeLists.txt @@ -5,3 +5,7 @@ add_library(Relays STATIC target_include_directories(Relays PUBLIC ${CMAKE_CURRENT_LIST_DIR} ) + +target_link_libraries(Relays + timer +) diff --git a/src/Relays/Relays.c b/src/Relays/Relays.c index 435dce7..cdd62d4 100644 --- a/src/Relays/Relays.c +++ b/src/Relays/Relays.c @@ -6,24 +6,24 @@ */ #include "Relays.h" +#include "timer.h" -/* -static void WaitForRelayConnect(void) { - while (!(PORTA.IN & RELAYREADINGPIN)) { - ; + +void Relay_MeasureMakeTime(Relay *relay) { + Timer_Start(); + while (Relay_ReadState(relay)) { } + Timer_Disable(); + relay->make_time = Timer_GetOverflowCount(); } -static void WaitForRelayDisconnect(void) { - while (PORTA.IN & RELAYREADINGPIN) { - ; +void Relay_MeasureBreakTime(Relay *relay) { + Timer_Start(); + while (Relay_ReadState(relay)) { } + Timer_Disable(); + relay->make_time = Timer_GetOverflowCount(); } -*/ - -void Relay_MeasureMakeTime(Relay *relay) {} - -void Relay_MeasureBreakTime(Relay *relay) {} void Relay_Enable(Relay *relay) { if (relay->disabled_fpc) { diff --git a/src/Relays/Relays.h b/src/Relays/Relays.h index 15fc404..b0712f7 100644 --- a/src/Relays/Relays.h +++ b/src/Relays/Relays.h @@ -26,6 +26,9 @@ typedef struct Relay { 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