File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ void analogin_init(analogin_t *obj, PinName pin)
43
43
// ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...)
44
44
// are described in PinNames.h and PeripheralPins.c
45
45
// Pin value must be between 0xF0 and 0xFF
46
- if ((pin < 0xF0 ) || (pin >= 0x100 )) {
46
+ if ((pin < 0xF0 ) || (pin >= ALT0 )) {
47
47
// Normal channels
48
48
// Get the peripheral name from the pin and assign it to the object
49
49
obj -> handle .Instance = (ADC_TypeDef * )pinmap_peripheral (pin , PinMap_ADC );
@@ -60,6 +60,21 @@ void analogin_init(analogin_t *obj, PinName pin)
60
60
MBED_ASSERT (obj -> handle .Instance != (ADC_TypeDef * )NC );
61
61
MBED_ASSERT (function != (uint32_t )NC );
62
62
63
+ #if defined(ALTC )
64
+ if (pin == PA_0C ) {
65
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PA0 , SYSCFG_SWITCH_PA0_OPEN );
66
+ }
67
+ if (pin == PA_1C ) {
68
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PA1 , SYSCFG_SWITCH_PA1_OPEN );
69
+ }
70
+ if (pin == PC_2C ) {
71
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PC2 , SYSCFG_SWITCH_PC2_OPEN );
72
+ }
73
+ if (pin == PC_3C ) {
74
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PC3 , SYSCFG_SWITCH_PC3_OPEN );
75
+ }
76
+ #endif /* ALTC */
77
+
63
78
obj -> channel = STM_PIN_CHANNEL (function );
64
79
obj -> differential = STM_PIN_INVERTED (function );
65
80
Original file line number Diff line number Diff line change @@ -135,9 +135,24 @@ void gpio_init(gpio_t *obj, PinName pin)
135
135
// Enable GPIO clock
136
136
GPIO_TypeDef * gpio = Set_GPIO_Clock (port_index );
137
137
138
+ #if defined(ALTC )
139
+ if (pin == PA_0C ) {
140
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PA0 , SYSCFG_SWITCH_PA0_CLOSE );
141
+ }
142
+ if (pin == PA_1C ) {
143
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PA1 , SYSCFG_SWITCH_PA1_CLOSE );
144
+ }
145
+ if (pin == PC_2C ) {
146
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PC2 , SYSCFG_SWITCH_PC2_CLOSE );
147
+ }
148
+ if (pin == PC_3C ) {
149
+ HAL_SYSCFG_AnalogSwitchConfig (SYSCFG_SWITCH_PC3 , SYSCFG_SWITCH_PC3_CLOSE );
150
+ }
151
+ #endif /* ALTC */
152
+
138
153
// Fill GPIO object structure for future use
139
154
obj -> mask = gpio_set (pin );
140
- obj -> gpio = gpio ;
155
+ obj -> gpio = gpio ;
141
156
obj -> ll_pin = ll_pin_defines [STM_PIN (obj -> pin )];
142
157
obj -> reg_in = & gpio -> IDR ;
143
158
obj -> reg_set = & gpio -> BSRR ;
You can’t perform that action at this time.
0 commit comments