12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #pragma once
- #include <stdint.h>
- #include "quantum.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- void analogReference(uint8_t mode);
- int16_t analogReadPin(pin_t pin);
- uint8_t pinToMux(pin_t pin);
- int16_t adc_read(uint8_t mux);
- #ifdef __cplusplus
- }
- #endif
- #define ADC_REF_EXTERNAL 0
- #define ADC_REF_POWER _BV(REFS0)
- #define ADC_REF_INTERNAL (_BV(REFS1) | _BV(REFS0))
- #if F_CPU == 16000000L || F_CPU == 12000000L
- # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS1))
- #elif F_CPU == 8000000L
- # define ADC_PRESCALER (_BV(ADPS2) | _BV(ADPS0))
- #elif F_CPU == 4000000L
- # define ADC_PRESCALER (_BV(ADPS2))
- #elif F_CPU == 2000000L
- # define ADC_PRESCALER (_BV(ADPS1) | _BV(ADPS0))
- #elif F_CPU == 1000000L
- # define ADC_PRESCALER _BV(ADPS1)
- #else
- # define ADC_PRESCALER _BV(ADPS0)
- #endif
|