/*
 * File:   adc.h
 * Author: thebears
 *
 * Created on December 10, 2021, 10:13 PM
 */

#ifndef ADC_H
#define ADC_H
#include "defines.h"
#include <avr/io.h>
#include <stdbool.h>
#include <stdint.h>
#include <util/delay.h>

#ifdef __cplusplus
extern "C" {
#endif

// Mux channel 14 is the internal 1.1 V bandgap, used to infer battery voltage.
#define ADC_CHANNEL_BANDGAP 14

int8_t adc_Initialize(void);
void adc_Enable(void);
void adc_Disable(void);
void adc_StartConversion(uint8_t channel);
bool adc_IsConversionDone(void);
uint16_t adc_GetConversionResult(void);
uint16_t adc_GetConversion(uint8_t channel);

#ifdef __cplusplus
}
#endif

#endif /* ADC_H */
