/** * @file zero_cross_detection.h * @author Jake G * @date 16 June 2024 * @brief File contains the zero cross detection functions * * This file holds all the code/functions needed to read the value of the AC * waveform. It uses the trigger value from the `config.h` file to evaluate the * state. * * This module depends on the ADC.h module to get readings from the ADC * hardware. */ #ifndef ZERO_CROSS_DETECTION #define ZERO_CROSS_DETECTION #include #include /** * @brief Zero Cross Detection Setup * * Sets up the hardware to read the values coming from the AC input waveform. * */ void ZCD_Setup(void); //int ZCD_Setup(volatile uint8_t *ddrx, uint8_t *port, uint8_t pin); /** * @brief Checks if ZCD should trigger on value * * The function checks for a positive edge first using the ZCD_IsPositiveEdge * function. If a positive edge was found, then it takes an addition set of * samples and averages them; only triggering(returning true) in the case * that the average is higher than the previous sample. */ bool ZCD_IsTriggered(void); /** * @brief Function blocks execution until ZCD is triggered. * */ void ZCD_Poll(void); #endif //ZERO_CROSS_DETECTION