File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,8 @@ void pin_mode(PinName pin, PinMode mode) {
108
108
109
109
if (pin == NC ) return ;
110
110
111
- uint32_t pin_number = (uint32_t )pin ;
111
+ uint32_t pin_number = (uint32_t )pin ;
112
+ uint32_t pin_index = (pin_number & 0xF );
112
113
uint32_t port_index = (pin_number >> 4 );
113
114
114
115
// Get GPIO structure base address and enable clock
@@ -141,7 +142,7 @@ void pin_mode(PinName pin, PinMode mode) {
141
142
// Configure pull-up/pull-down resistors
142
143
uint32_t pupd = (uint32_t )mode ;
143
144
if (pupd > 2 ) pupd = 0 ; // Open-drain = No pull-up/No pull-down
144
- gpio -> PUPDR &= (uint32_t )(~(GPIO_PUPDR_PUPDR0 << (pin_number * 2 )));
145
- gpio -> PUPDR |= (uint32_t )(pupd << (pin_number * 2 ));
145
+ gpio -> PUPDR &= (uint32_t )(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2 )));
146
+ gpio -> PUPDR |= (uint32_t )(pupd << (pin_index * 2 ));
146
147
147
148
}
You can’t perform that action at this time.
0 commit comments