Skip to content

Commit ffb7f13

Browse files
committed
[NUCLEO_F152RE] Correction in pinmap
1 parent ba5866b commit ffb7f13

File tree

1 file changed

+4
-3
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE

1 file changed

+4
-3
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/pinmap.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ void pin_mode(PinName pin, PinMode mode) {
108108

109109
if (pin == NC) return;
110110

111-
uint32_t pin_number = (uint32_t)pin;
111+
uint32_t pin_number = (uint32_t)pin;
112+
uint32_t pin_index = (pin_number & 0xF);
112113
uint32_t port_index = (pin_number >> 4);
113114

114115
// Get GPIO structure base address and enable clock
@@ -141,7 +142,7 @@ void pin_mode(PinName pin, PinMode mode) {
141142
// Configure pull-up/pull-down resistors
142143
uint32_t pupd = (uint32_t)mode;
143144
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));
146147

147148
}

0 commit comments

Comments
 (0)