aboutsummaryrefslogtreecommitdiff
path: root/drivers/arm/analog.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/arm/analog.h')
-rw-r--r--drivers/arm/analog.h44
1 files changed, 14 insertions, 30 deletions
diff --git a/drivers/arm/analog.h b/drivers/arm/analog.h
index ab592ada3..2818e9dcb 100644
--- a/drivers/arm/analog.h
+++ b/drivers/arm/analog.h
@@ -16,42 +16,26 @@
16 16
17#pragma once 17#pragma once
18 18
19#include <stdint.h>
19#include "quantum.h" 20#include "quantum.h"
20#include "ch.h"
21#include <hal.h>
22 21
23#if !defined(STM32F0XX) && !defined(STM32F3XX) 22#ifdef __cplusplus
24# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time." 23extern "C" {
25#endif
26
27#if !HAL_USE_ADC
28# error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC."
29#endif
30
31#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4
32# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
33#endif
34
35#if STM32_ADC_DUAL_MODE
36# error "STM32 ADC Dual Mode is not supported at this time."
37#endif
38
39#if STM32_ADCV3_OVERSAMPLING
40# error "STM32 ADCV3 Oversampling is not supported at this time."
41#endif 24#endif
42 25
43typedef struct { 26typedef struct {
44 pin_t pin; 27 uint16_t input;
45 uint8_t adc; 28 uint8_t adc;
46} pin_and_adc; 29} adc_mux;
47#define PIN_AND_ADC(p, a) \ 30#define TO_MUX(i, a) \
48 (pin_and_adc) { p, a } 31 (adc_mux) { i, a }
49 32
50// analogReference has been left un-defined for ARM devices. 33int16_t analogReadPin(pin_t pin);
51// void analogReference(uint8_t mode); 34int16_t analogReadPinAdc(pin_t pin, uint8_t adc);
35adc_mux pinToMux(pin_t pin);
52 36
53adcsample_t analogReadPin(pin_t pin); 37int16_t adc_read(adc_mux mux);
54adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc);
55pin_and_adc pinToMux(pin_t pin);
56 38
57adcsample_t adc_read(pin_and_adc mux); 39#ifdef __cplusplus
40}
41#endif