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