Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
0e11966c
Commit
0e11966c
authored
Jul 01, 2021
by
iabdalkader
Committed by
Damien George
Jul 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/adc: Define the ADC instance used for internal channels.
parent
ff7be31f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
ports/stm32/adc.c
ports/stm32/adc.c
+13
-12
No files found.
ports/stm32/adc.c
View file @
0e11966c
...
...
@@ -55,6 +55,17 @@
#define PIN_ADC_MASK PIN_ADC1
#define pin_adc_table pin_adc1
#if defined(STM32H7)
// On the H7 ADC3 is used for ADCAll to be able to read internal
// channels. For all other GPIO channels, ADC12 is used instead.
#define ADCALLx (ADC3)
#define pin_adcall_table pin_adc3
#else
// Use ADC1 for ADCAll instance by default for all other MCUs.
#define ADCALLx (ADC1)
#define pin_adcall_table pin_adc1
#endif
#define ADCx_CLK_ENABLE __HAL_RCC_ADC1_CLK_ENABLE
#if defined(STM32F0)
...
...
@@ -724,24 +735,14 @@ void adc_init_all(pyb_adc_all_obj_t *adc_all, uint32_t resolution, uint32_t en_m
if
(
en_mask
&
(
1
<<
channel
))
{
// Channels 0-16 correspond to real pins. Configure the GPIO pin in
// ADC mode.
#if defined(STM32H7)
const
pin_obj_t
*
pin
=
pin_adc3
[
channel
];
#else
const
pin_obj_t
*
pin
=
pin_adc_table
[
channel
];
#endif
const
pin_obj_t
*
pin
=
pin_adcall_table
[
channel
];
if
(
pin
)
{
mp_hal_pin_config
(
pin
,
MP_HAL_PIN_MODE_ADC
,
MP_HAL_PIN_PULL_NONE
,
0
);
}
}
}
#if defined(STM32H7)
// On the H7 the internal channels are connected to ADC3. To read internal channels
// with ADCAll, ADC3 must be used here, and ADC12 is used to read the GPIO channels.
adc_all
->
handle
.
Instance
=
ADC3
;
#else
adc_all
->
handle
.
Instance
=
ADCx
;
#endif
adc_all
->
handle
.
Instance
=
ADCALLx
;
adcx_init_periph
(
&
adc_all
->
handle
,
resolution
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment