summaryrefslogtreecommitdiff
path: root/drivers/arm/analog.h
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2020-03-17 00:29:52 +0000
committerGitHub <noreply@github.com>2020-03-17 00:29:52 +0000
commit567bfc97ac4f5066e8a2302c46e3b375efe59792 (patch)
tree45eb64a6c294c91bea9934d32ae8f6b98b0ff7f6 /drivers/arm/analog.h
parent7aff643031eec0b940b85d9f2a0d7a27fd6d4fa7 (diff)
ARM - ADC cleanup (#8385)
* Update switch to array to allow custom values * Add adc keymap * update docs to reflect alignment of default 10 bit * start conversion to USE_ADCVn * samplerate is hella wrong...stub out for now * basic f1 and f4 functionality * Tidy up current changes * Restore old pinToMux function * Add back sample rate for supported platforms * F0 compile fixes * wordsmithery Co-Authored-By: Ryan <fauxpark@gmail.com> * Remove reference to avr only function Co-authored-by: Ryan <fauxpark@gmail.com>
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 ab592ada33..2818e9dcb1 100644
--- a/drivers/arm/analog.h
+++ b/drivers/arm/analog.h
@@ -16,42 +16,26 @@
#pragma once
+#include <stdint.h>
#include "quantum.h"
-#include "ch.h"
-#include <hal.h>
-#if !defined(STM32F0XX) && !defined(STM32F3XX)
-# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time."
-#endif
-
-#if !HAL_USE_ADC
-# error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC."
-#endif
-
-#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4
-# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
-#endif
-
-#if STM32_ADC_DUAL_MODE
-# error "STM32 ADC Dual Mode is not supported at this time."
-#endif
-
-#if STM32_ADCV3_OVERSAMPLING
-# error "STM32 ADCV3 Oversampling is not supported at this time."
+#ifdef __cplusplus
+extern "C" {
#endif
typedef struct {
- pin_t pin;
+ uint16_t input;
uint8_t adc;
-} pin_and_adc;
-#define PIN_AND_ADC(p, a) \
- (pin_and_adc) { p, a }
+} adc_mux;
+#define TO_MUX(i, a) \
+ (adc_mux) { i, a }
-// analogReference has been left un-defined for ARM devices.
-// void analogReference(uint8_t mode);
+int16_t analogReadPin(pin_t pin);
+int16_t analogReadPinAdc(pin_t pin, uint8_t adc);
+adc_mux pinToMux(pin_t pin);
-adcsample_t analogReadPin(pin_t pin);
-adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc);
-pin_and_adc pinToMux(pin_t pin);
+int16_t adc_read(adc_mux mux);
-adcsample_t adc_read(pin_and_adc mux);
+#ifdef __cplusplus
+}
+#endif