/**
 * @brief Interface to the AVR ADC hardware.
 * @details This file is...
 * @author Jake Goodwin
 * @date 2025
 * @copyright None
 * @file ADC.h
 */

#ifndef ADC_H
#define ADC_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/**
 * @brief Initializes the AVR hardware in order to accept
 * Input for ADC usage.
 * @param pin_num The number of the pin 0-7 you are initializing.
 *
 * This function only makes use of PORTA by default. It sets the direction
 * register to input, disables the pull-up resistor and also diables interrupts
 * alongside the input buffer(digital).
 *
 * This in turn helps reduce noise when using the ADC.
 *
 */
void ADC_Init(uint8_t pin_num);

/**
 * @brief Enables the ADC
 */
void ADC_PowerOn(void);

void ADC_PowerOff(void);

/**
 * @brief Enables the ADC
 */
void ADC_Enable(void);

/**
 * @brief Disables the ADC
 */
void ADC_Disable(void);

/**
 * @brief Reads ADC value into variable
 *
 * @param pin_num The bin number of the ADC pin being read.
 *
 * This function depends on the ADC already being initialized and enabled
 * before being called.
 */
extern uint16_t (*ADC_ReadValue)(uint8_t pin_num);

/**
 * @brief Sets up the ADC
 *
 * This function sets up the ADC to take and accumulate 32 samples. It also
 * sets the inital delay to 32 ADC clock cycles, and sets the VREF to VDD or
 * VCC.
 *
 * This function should only need to be called once.
 */
void ADC_Setup(void);

/**
 * @brief Sets the pin used in the MUX for ADC0.
 *
 * @param pin_num The number of the pin in Port A.
 */
void ADC_SetPin(uint8_t pin_num);

#endif // ADC_H
