<commit_before>#ifndef ADC_H_
#define ADC_H_

#include <stdint.h>

#include <macro.h>

#include "mock_avrio.h"

#define TRUE            0x01
#define FALSE           0x00

/* ADC reference voltage */
#define VCC_REF         0x00
#define AVCC_REF        0x01
#define INTERNAL_REF    0x02   /* internal 1.1 volt ref */

/* ADC channel */
#define ADC_CH0         0x00
#define ADC_CH1         0x01
#define ADC_CH2         0x02
#define ADC_CH3         0x03
#define ADC_CH4         0x04
#define ADC_CH5         0x05
#define ADC_CH6         0x06
#define ADC_CH7         0x07
#define ADC_CH8         0x08
#define VBG_READ        0x0E  /* 1.1V (VBG) */
#define GND_READ        0x0F  /* 0V (GND) */

/* conversion speed for prescaler selection */
#define ADC_FAST_CONVERSION             0x01
#define ADC_SLOW_CONVERSION             0x00
#define ADC_MAX_FREQUENCY               200000 
#define ADC_MIN_PERIOD                  1.0 / ADC_MAX_FREQUENCY
#define ADC_MIN_FREQUENCY               50000 
#define ADC_MAX_PERIOD                  1.0 / ADC_MIN_FREQUENCY
#define ADC_CYCLES_PER_CONVERSION       13

/* prescaler defines */
#define ADC_MAX_PRESCALER         0x07
#define ADC_MIN_PRESCALER         0x01 

/* function like macros */
#define adc_enable                  (sbit(ADCSRA, ADEN))
#define adc_disable                 (cbit(ADCSRA, ADEN))
#define adc_start_conversion        (sbit(ADCSRA, ADSC))
#define adc_auto_trigger_enable     (sbit(ADCSRA, ADATE))
#define adc_clear_interrupt_flag    (sbit(ADCSRA, ADIF))   /* write logical 1 to clear */
#define adc_interrupt_enable        (sbit(ADCSRA, ADIE))

typedef struct ADC_ADC_Config
{
  uint8_t ref;
  uint8_t fast_prescaler;
  uint8_t slow_prescaler;
  uint8_t fast_convert_us;
  uint8_t slow_convert_us;<commit_msg>added macro for choosing adc fast convert speed<commit_after>#ifndef ADC_H_
#define ADC_H_

#include <stdint.h>

#include <macro.h>

#include "mock_avrio.h"

#define TRUE            0x01
#define FALSE           0x00

/* ADC reference voltage */
#define VCC_REF         0x00
#define AVCC_REF        0x01
#define INTERNAL_REF    0x02   /* internal 1.1 volt ref */

/* ADC channel */
#define ADC_CH0         0x00
#define ADC_CH1         0x01
#define ADC_CH2         0x02
#define ADC_CH3         0x03
#define ADC_CH4         0x04
#define ADC_CH5         0x05
#define ADC_CH6         0x06
#define ADC_CH7         0x07
#define ADC_CH8         0x08
#define VBG_READ        0x0E  /* 1.1V (VBG) */
#define GND_READ        0x0F  /* 0V (GND) */

/* conversion speed for prescaler selection */
#define ADC_FAST_CONVERSION             0x01
#define ADC_SLOW_CONVERSION             0x00
#define ADC_MAX_FREQUENCY               200000 
#define ADC_MIN_PERIOD                  1.0 / ADC_MAX_FREQUENCY
#define ADC_MIN_FREQUENCY               50000 
#define ADC_MAX_PERIOD                  1.0 / ADC_MIN_FREQUENCY
#define ADC_CYCLES_PER_CONVERSION       13

/* prescaler defines */
#define ADC_MAX_PRESCALER         0x07
#define ADC_MIN_PRESCALER         0x01 

/* function like macros */
#define adc_enable                        (sbit(ADCSRA, ADEN))
#define adc_disable                       (cbit(ADCSRA, ADEN))
#define adc_start_conversion              (sbit(ADCSRA, ADSC))
#define adc_auto_trigger_enable           (sbit(ADCSRA, ADATE))
#define adc_clear_interrupt_flag          (sbit(ADCSRA, ADIF))   /* write logical 1 to clear */
#define adc_interrupt_enable              (sbit(ADCSRA, ADIE))
/* TODO test adc_set_fast_convert */
#define adc_set_fast_convert(adc_config)  (adc_config = ADC_FAST_CONVERSION)   

typedef struct ADC_ADC_Config
{
  uint8_t ref;
  uint8_t fast_prescaler;
  uint8_t slow_prescaler;
  uint8_t fast_convert_us;
  uint8_t slow_convert_us;
{'fraction_non_alphanumeric': 0.07263922518159806, 'fraction_numerical': 0.051116491794457895, 'mean_word_length': 2.4110091743119266, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3163586', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1343, 'n_words': 317}