Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
fcd10882
Commit
fcd10882
authored
Dec 05, 2016
by
Damien George
Browse files
stmhal/adc: Use constants from new HAL version.
parent
e44b236c
Changes
1
Hide whitespace changes
Inline
Side-by-side
stmhal/adc.c
View file @
fcd10882
...
...
@@ -198,14 +198,13 @@ STATIC void adc_init_single(pyb_obj_adc_t *adc_obj) {
adcHandle
->
Init
.
DataAlign
=
ADC_DATAALIGN_RIGHT
;
adcHandle
->
Init
.
NbrOfConversion
=
1
;
adcHandle
->
Init
.
DMAContinuousRequests
=
DISABLE
;
adcHandle
->
Init
.
Resolution
=
ADC_RESOLUTION_12B
;
#if defined(MCU_SERIES_F4) || defined(MCU_SERIES_F7)
adcHandle
->
Init
.
Resolution
=
ADC_RESOLUTION12b
;
adcHandle
->
Init
.
ClockPrescaler
=
ADC_CLOCKPRESCALER_PCLK_DIV2
;
adcHandle
->
Init
.
ClockPrescaler
=
ADC_CLOCK_SYNC_PCLK_DIV2
;
adcHandle
->
Init
.
ScanConvMode
=
DISABLE
;
adcHandle
->
Init
.
ExternalTrigConv
=
ADC_EXTERNALTRIGCONV_T1_CC1
;
adcHandle
->
Init
.
EOCSelection
=
DISABLE
;
#elif defined(MCU_SERIES_L4)
adcHandle
->
Init
.
Resolution
=
ADC_RESOLUTION_12B
;
adcHandle
->
Init
.
ClockPrescaler
=
ADC_CLOCK_ASYNC_DIV1
;
adcHandle
->
Init
.
ScanConvMode
=
ADC_SCAN_DISABLE
;
adcHandle
->
Init
.
EOCSelection
=
ADC_EOC_SINGLE_CONV
;
...
...
@@ -465,10 +464,10 @@ typedef struct _pyb_adc_all_obj_t {
void
adc_init_all
(
pyb_adc_all_obj_t
*
adc_all
,
uint32_t
resolution
,
uint32_t
en_mask
)
{
switch
(
resolution
)
{
case
6
:
resolution
=
ADC_RESOLUTION
6b
;
break
;
case
8
:
resolution
=
ADC_RESOLUTION
8b
;
break
;
case
10
:
resolution
=
ADC_RESOLUTION10
b
;
break
;
case
12
:
resolution
=
ADC_RESOLUTION12
b
;
break
;
case
6
:
resolution
=
ADC_RESOLUTION
_6B
;
break
;
case
8
:
resolution
=
ADC_RESOLUTION
_8B
;
break
;
case
10
:
resolution
=
ADC_RESOLUTION
_
10
B
;
break
;
case
12
:
resolution
=
ADC_RESOLUTION
_
12
B
;
break
;
default:
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"resolution %d not supported"
,
resolution
));
...
...
@@ -505,7 +504,7 @@ void adc_init_all(pyb_adc_all_obj_t *adc_all, uint32_t resolution, uint32_t en_m
adcHandle
->
Init
.
DMAContinuousRequests
=
DISABLE
;
adcHandle
->
Init
.
EOCSelection
=
DISABLE
;
#if defined(MCU_SERIES_F4) || defined(MCU_SERIES_F7)
adcHandle
->
Init
.
ClockPrescaler
=
ADC_CLOCK
PRESCALER
_PCLK_DIV2
;
adcHandle
->
Init
.
ClockPrescaler
=
ADC_CLOCK
_SYNC
_PCLK_DIV2
;
adcHandle
->
Init
.
ScanConvMode
=
DISABLE
;
adcHandle
->
Init
.
ExternalTrigConv
=
ADC_EXTERNALTRIGCONV_T1_CC1
;
#elif defined(MCU_SERIES_L4)
...
...
@@ -531,9 +530,9 @@ int adc_get_resolution(ADC_HandleTypeDef *adcHandle) {
uint32_t
res_reg
=
__HAL_ADC_GET_RESOLUTION
(
adcHandle
);
switch
(
res_reg
)
{
case
ADC_RESOLUTION
6b
:
return
6
;
case
ADC_RESOLUTION
8b
:
return
8
;
case
ADC_RESOLUTION10
b
:
return
10
;
case
ADC_RESOLUTION
_6B
:
return
6
;
case
ADC_RESOLUTION
_8B
:
return
8
;
case
ADC_RESOLUTION
_
10
B
:
return
10
;
}
return
12
;
}
...
...
Write
Preview
Supports
Markdown
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