Skip to content

Commit 2a20f47

Browse files
committed
Override ADC SAMPLINGTIME in Variant.h
Internal channels need slower ADC sample rate
1 parent a0c9bee commit 2a20f47

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

cores/arduino/stm32/analog.c

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#include "analog.h"
5151
#include "timer.h"
5252
#include "PinAF_STM32F1.h"
53+
// Specific defines in the variant
54+
#include "variant.h"
5355

5456
#ifdef __cplusplus
5557
extern "C" {
@@ -69,6 +71,7 @@
6971
/** @addtogroup STM32F4xx_System_Private_Defines
7072
* @{
7173
*/
74+
#ifndef SAMPLINGTIME
7275
#if defined(ADC_SAMPLETIME_15CYCLES)
7376
#define SAMPLINGTIME ADC_SAMPLETIME_15CYCLES;
7477
#elif defined(ADC_SAMPLETIME_13CYCLES_5)
@@ -82,6 +85,7 @@
8285
#else
8386
#error "ADC SAMPLINGTIME could not be defined"
8487
#endif
88+
#endif
8589

8690
#ifndef STM32F1xx
8791
#ifdef ADC_CLOCK_SYNC_PCLK_DIV2

variants/OPENTRACKER_V3/variant.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ PC_0,
132132
PC_1,
133133
PC_2,
134134
PC_3,
135+
ADC_VREF,
136+
ADC_VTEMP,
137+
ADC_VBAT,
135138
};
136139

137140
#ifdef __cplusplus

variants/OPENTRACKER_V3/variant.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,17 @@ PC0_2,
148148
PC1_2,
149149
PC2_2,
150150
PC3_2,
151+
VREF,
152+
VTEMP,
153+
VBAT,
151154

152155
PEND
153156
};
154157

155158
// This must be a literal with the same value as PEND
156159
// It is used with preprocessor tests (e.g. #if NUM_DIGITAL_PINS > 3)
157160
// so an enum will not work.
158-
#define NUM_DIGITAL_PINS 92
161+
#define NUM_DIGITAL_PINS 95
159162

160163
// Allow to define Arduino style alias for analog input pin number --> Ax
161164
// All pins are digital, analog inputs are a subset of digital pins
@@ -173,6 +176,9 @@ PC3_2,
173176
// First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS
174177
#define NUM_ANALOG_FIRST 83
175178

179+
//ADC sampling time
180+
#define SAMPLINGTIME ADC_SAMPLETIME_640CYCLES_5
181+
176182
//ADC resolution is 12bits
177183
#define ADC_RESOLUTION 12
178184
#define DACC_RESOLUTION 12

0 commit comments

Comments
 (0)