format code according to conventions [skip ci]
This commit is contained in:
parent
5ac6fe1888
commit
2b66acf04a
2 changed files with 28 additions and 44 deletions
|
@ -17,7 +17,6 @@
|
||||||
#include "analog.h"
|
#include "analog.h"
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
|
|
||||||
/* User configurable ADC options */
|
/* User configurable ADC options */
|
||||||
#ifndef ADC_CIRCULAR_BUFFER
|
#ifndef ADC_CIRCULAR_BUFFER
|
||||||
# define ADC_CIRCULAR_BUFFER FALSE
|
# define ADC_CIRCULAR_BUFFER FALSE
|
||||||
|
@ -43,8 +42,6 @@
|
||||||
# define ADC_RESOLUTION ADC_CFGR1_RES_12BIT
|
# define ADC_RESOLUTION ADC_CFGR1_RES_12BIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static ADCConfig adcCfg = {};
|
static ADCConfig adcCfg = {};
|
||||||
static adcsample_t sampleBuffer[ADC_NUM_CHANNELS * ADC_BUFFER_DEPTH];
|
static adcsample_t sampleBuffer[ADC_NUM_CHANNELS * ADC_BUFFER_DEPTH];
|
||||||
|
|
||||||
|
@ -57,8 +54,6 @@ static bool adcInitialized[4] = {};
|
||||||
# error "adcInitialized has not been implemented for this ARM microcontroller."
|
# error "adcInitialized has not been implemented for this ARM microcontroller."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static ADCConversionGroup adcConversionGroup = {
|
static ADCConversionGroup adcConversionGroup = {
|
||||||
ADC_CIRCULAR_BUFFER,
|
ADC_CIRCULAR_BUFFER,
|
||||||
(uint16_t)(ADC_NUM_CHANNELS),
|
(uint16_t)(ADC_NUM_CHANNELS),
|
||||||
|
@ -66,8 +61,7 @@ static ADCConversionGroup adcConversionGroup = {
|
||||||
NULL, // No error callback
|
NULL, // No error callback
|
||||||
#if defined(STM32F0XX)
|
#if defined(STM32F0XX)
|
||||||
ADC_CFGR1_CONT | ADC_RESOLUTION,
|
ADC_CFGR1_CONT | ADC_RESOLUTION,
|
||||||
ADC_TR(0, 0).
|
ADC_TR(0, 0).ADC_SAMPLING_RATE,
|
||||||
ADC_SAMPLING_RATE,
|
|
||||||
NULL, // Doesn't specify a default channel
|
NULL, // Doesn't specify a default channel
|
||||||
#elif defined(STM32F3XX)
|
#elif defined(STM32F3XX)
|
||||||
ADC_CFGR_CONT | ADC_RESOLUTION,
|
ADC_CFGR_CONT | ADC_RESOLUTION,
|
||||||
|
@ -85,10 +79,7 @@ static ADCConversionGroup adcConversionGroup = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
||||||
|
|
||||||
ADCDriver* target;
|
ADCDriver* target;
|
||||||
|
|
||||||
switch (adcInt) {
|
switch (adcInt) {
|
||||||
|
@ -119,9 +110,7 @@ static inline void manageAdcInitializationDriver(uint8_t adc, ADCDriver* adcDriv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void manageAdcInitialization(uint8_t adc) {
|
static inline void manageAdcInitialization(uint8_t adc) { manageAdcInitializationDriver(adc, intToADCDriver(adc)); }
|
||||||
manageAdcInitializationDriver(adc, intToADCDriver(adc));
|
|
||||||
}
|
|
||||||
|
|
||||||
pin_and_adc pinToMux(pin_t pin) {
|
pin_and_adc pinToMux(pin_t pin) {
|
||||||
switch (pin) {
|
switch (pin) {
|
||||||
|
@ -191,9 +180,7 @@ pin_and_adc pinToMux(pin_t pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adcsample_t analogReadPin(pin_t pin) {
|
adcsample_t analogReadPin(pin_t pin) { return adc_read(pinToMux(pin)); }
|
||||||
return adc_read(pinToMux(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc) {
|
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc) {
|
||||||
pin_and_adc target = pinToMux(pin);
|
pin_and_adc target = pinToMux(pin);
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
|
|
||||||
#if !defined(STM32F0XX) && !defined(STM32F3XX)
|
#if !defined(STM32F0XX) && !defined(STM32F3XX)
|
||||||
# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time."
|
# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time."
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,14 +40,12 @@
|
||||||
# error "STM32 ADCV3 Oversampling is not supported at this time."
|
# error "STM32 ADCV3 Oversampling is not supported at this time."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pin_t pin;
|
pin_t pin;
|
||||||
uint8_t adc;
|
uint8_t adc;
|
||||||
} pin_and_adc;
|
} pin_and_adc;
|
||||||
#define PIN_AND_ADC(p,a) (pin_and_adc){p,a}
|
#define PIN_AND_ADC(p, a) \
|
||||||
|
(pin_and_adc) { p, a }
|
||||||
|
|
||||||
// analogReference has been left un-defined for ARM devices.
|
// analogReference has been left un-defined for ARM devices.
|
||||||
// void analogReference(uint8_t mode);
|
// void analogReference(uint8_t mode);
|
||||||
|
|
Loading…
Reference in a new issue