diff --git a/cores/arduino/stm32/analog.cpp b/cores/arduino/stm32/analog.cpp index 566ad68d58..1cd924a152 100644 --- a/cores/arduino/stm32/analog.cpp +++ b/cores/arduino/stm32/analog.cpp @@ -797,7 +797,11 @@ uint16_t adc_read_value(PinName pin) #ifdef ADC_DATAALIGN_RIGHT AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; /* Right-alignment for converted data */ #endif +#ifdef ADC_SCAN_SEQ_FIXED + AdcHandle.Init.ScanConvMode = ADC_SCAN_SEQ_FIXED; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */ +#else AdcHandle.Init.ScanConvMode = DISABLE; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */ +#endif #ifdef ADC_EOC_SINGLE_CONV AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; /* EOC flag picked-up to indicate conversion end */ #endif @@ -845,7 +849,6 @@ uint16_t adc_read_value(PinName pin) #if defined(STM32G0xx) AdcHandle.Init.SamplingTimeCommon1 = samplingTime; /* Set sampling time common to a group of channels. */ AdcHandle.Init.SamplingTimeCommon2 = samplingTime; /* Set sampling time common to a group of channels, second common setting possible.*/ - AdcHandle.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH; #endif #if defined(STM32L0xx) AdcHandle.Init.LowPowerFrequencyMode = DISABLE; /* To be enabled only if ADC clock < 2.8 MHz */ @@ -887,7 +890,11 @@ uint16_t adc_read_value(PinName pin) #endif /* STM32L4xx || STM32WBxx */ return 0; } +#ifdef ADC_SCAN_SEQ_FIXED + AdcChannelConf.Rank = ADC_RANK_CHANNEL_NUMBER; /* Enable the rank of the selected channels when not fully configurable */ +#else AdcChannelConf.Rank = ADC_REGULAR_RANK_1; /* Specifies the rank in the regular group sequencer */ +#endif #if !defined(STM32L0xx) #if !defined(STM32G0xx) AdcChannelConf.SamplingTime = samplingTime; /* Sampling time value to be set for the selected channel */ diff --git a/variants/NUCLEO_G071RB/PeripheralPins.c b/variants/NUCLEO_G071RB/PeripheralPins.c index a25c613fc2..7e89758274 100644 --- a/variants/NUCLEO_G071RB/PeripheralPins.c +++ b/variants/NUCLEO_G071RB/PeripheralPins.c @@ -32,7 +32,7 @@ WEAK const PinMap PinMap_ADC[] = { //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 {PB_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 {PB_10, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 diff --git a/variants/NUCLEO_G071RB/variant.cpp b/variants/NUCLEO_G071RB/variant.cpp index 20006148ce..1f95ff2ea3 100644 --- a/variants/NUCLEO_G071RB/variant.cpp +++ b/variants/NUCLEO_G071RB/variant.cpp @@ -34,9 +34,9 @@ const PinName digitalPin[] = { PA_8, //D7 PA_9, //D8 PC_7, //D9 - PB_0, //D10/A8 - PA_7, //D11/A7 - PA_6, //D12/A6 + PB_0, //D10 + PA_7, //D11/A6 + PA_6, //D12/A7 PA_5, //D13/LED PB_9, //D14 PB_8, //D15 @@ -74,10 +74,10 @@ const PinName digitalPin[] = { PA_12, //D42 PC_1, //D43 PC_0, //D44 - PB_2, //D45/A9 + PB_2, //D45/A8 PB_6, //D46 PB_15, //D47 - PB_10, //D48/A10 + PB_10, //D48/A9 PB_13, //D49 PA_2, //D50 PD_8, //D51 @@ -89,11 +89,10 @@ const PinName digitalPin[] = { PB_11, //D57/A4 PB_12, //D58/A5 // Duplicated pins in order to be aligned with PinMap_ADC - PB_0, //D59/A6 = D10 - PA_7, //D60/A7 = D11 - PA_6, //D61/A8 = D12 - PB_2, //D62/A9 = D45 - PB_10 //D63/A10 = D48 + PA_7, //D59/A6 = D11 + PA_6, //D60/A7 = D12 + PB_2, //D61/A8 = D45 + PB_10 //D62/A9 = D48 }; #ifdef __cplusplus diff --git a/variants/NUCLEO_G071RB/variant.h b/variants/NUCLEO_G071RB/variant.h index 978357e034..037539c55c 100644 --- a/variants/NUCLEO_G071RB/variant.h +++ b/variants/NUCLEO_G071RB/variant.h @@ -37,9 +37,9 @@ extern "C" { #define PA8 7 #define PA9 8 #define PC7 9 -#define PB0 10 // A6 -#define PA7 11 // A7 -#define PA6 12 // A8 +#define PB0 10 +#define PA7 11 // A6 +#define PA6 12 // A7 #define PA5 13 // LED #define PB9 14 #define PB8 15 @@ -77,10 +77,10 @@ extern "C" { #define PA12 42 #define PC1 43 #define PC0 44 -#define PB2 45 // A9 +#define PB2 45 // A8 #define PB6 46 #define PB15 47 -#define PB10 48 // A10 +#define PB10 48 // A9 #define PB13 49 #define PA2 50 #define PD8 51 @@ -93,9 +93,9 @@ extern "C" { #define PB12 58 // A5 // This must be a literal -#define NUM_DIGITAL_PINS 64 +#define NUM_DIGITAL_PINS 63 // This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 11 +#define NUM_ANALOG_INPUTS 10 #define NUM_ANALOG_FIRST 53 // On-board LED pin number