diff options
Diffstat (limited to 'drivers/arm/analog.h')
| -rw-r--r-- | drivers/arm/analog.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/arm/analog.h b/drivers/arm/analog.h new file mode 100644 index 000000000..081d0c1e7 --- /dev/null +++ b/drivers/arm/analog.h | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* Copyright 2019 Drew Mills | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | #include "ch.h" | ||
| 21 | #include <hal.h> | ||
| 22 | |||
| 23 | |||
| 24 | #if !defined(STM32F0XX) && !defined(STM32F3XX) | ||
| 25 | #error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time." | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if !HAL_USE_ADC | ||
| 29 | #error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC." | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4 | ||
| 33 | #error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC." | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #if STM32_ADC_DUAL_MODE | ||
| 37 | #error "STM32 ADC Dual Mode is not supported at this time." | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #if STM32_ADCV3_OVERSAMPLING | ||
| 41 | #error "STM32 ADCV3 Oversampling is not supported at this time." | ||
| 42 | #endif | ||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | typedef struct { | ||
| 47 | pin_t pin; | ||
| 48 | uint8_t adc; | ||
| 49 | } pin_and_adc; | ||
| 50 | #define PIN_AND_ADC(p,a) (pin_and_adc){p,a} | ||
| 51 | |||
| 52 | |||
| 53 | // analogReference has been left un-defined for ARM devices. | ||
| 54 | // void analogReference(uint8_t mode); | ||
| 55 | |||
| 56 | adcsample_t analogReadPin(pin_t pin); | ||
| 57 | adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc); | ||
| 58 | pin_and_adc pinToMux(pin_t pin); | ||
| 59 | |||
| 60 | adcsample_t adc_read(pin_and_adc mux); | ||
