Skip to content

Fix Nucleo G071RB analog pin issue #737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cores/arduino/stm32/analog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion variants/NUCLEO_G071RB/PeripheralPins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions variants/NUCLEO_G071RB/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions variants/NUCLEO_G071RB/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down