Skip to content

Commit 9836fed

Browse files
authored
Merge pull request #1915 from anpilog/master
Fix pin mode for STM32F1 target.
2 parents 42561b9 + 9c0d455 commit 9836fed

File tree

1 file changed

+2
-2
lines changed
  • hal/targets/hal/TARGET_STM/TARGET_STM32F1

1 file changed

+2
-2
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32F1/pinmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ void pin_mode(PinName pin, PinMode mode)
177177
if (pin_index < 8) {
178178
if ((gpio->CRL & (0x03 << (pin_index * 4))) == 0) { // MODE bits = Input mode
179179
gpio->CRL |= (0x08 << (pin_index * 4)); // Set pull-up / pull-down
180-
gpio->CRL &= ~(0x08 << ((pin_index * 4)-1)); // ENSURES GPIOx_CRL.CNFx.bit0 = 0
180+
gpio->CRL &= ~(0x04 << (pin_index * 4)); // ENSURES GPIOx_CRL.CNFx.bit0 = 0
181181
}
182182
} else {
183183
if ((gpio->CRH & (0x03 << ((pin_index % 8) * 4))) == 0) { // MODE bits = Input mode
184184
gpio->CRH |= (0x08 << ((pin_index % 8) * 4)); // Set pull-up / pull-down
185-
gpio->CRH &= ~(0x08 << (((pin_index % 8) * 4)-1)); // ENSURES GPIOx_CRH.CNFx.bit0 = 0
185+
gpio->CRH &= ~(0x04 << ((pin_index % 8) * 4)); // ENSURES GPIOx_CRH.CNFx.bit0 = 0
186186
}
187187
}
188188
// Now it's time to setup properly if pullup or pulldown. This is done in ODR register:

0 commit comments

Comments
 (0)