Skip to content

Commit ffd5586

Browse files
committed
Squashed commit of the following:
commit 2f006d6f51ab4746d10f53d24667e551fa3a7896 Merge: a1e04f7 ca6d764 Author: 0xc0170 <[email protected]> Date: Thu May 7 09:00:36 2015 +0100 Merge branch 'pinmap_stm32f1' of https://github.com/raulMrello/mbed into raulMrello-pinmap_stm32f1 commit ca6d764 Merge: 88e7489 d50b62d Author: raulMrello <[email protected]> Date: Mon May 4 09:39:59 2015 +0200 Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1 commit 88e7489 Merge: dd27e29 ffaae4b Author: raulMrello <[email protected]> Date: Mon May 4 09:27:28 2015 +0200 Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1 commit dd27e29 Merge: 3d1afb8 f54dc44 Author: raulMrello <[email protected]> Date: Mon May 4 09:24:33 2015 +0200 Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1 commit 3d1afb8 Author: raulMrello <[email protected]> Date: Mon May 4 09:16:01 2015 +0200 Updated pinmap.c in target_stm32f1
1 parent a1e04f7 commit ffd5586

File tree

1 file changed

+9
-0
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F1

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,21 @@ 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
180181
}
181182
} else {
182183
if ((gpio->CRH & (0x03 << ((pin_index % 8) * 4))) == 0) { // MODE bits = Input mode
183184
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
184186
}
185187
}
188+
// Now it's time to setup properly if pullup or pulldown. This is done in ODR register:
189+
// set pull-up => bit=1, set pull-down => bit = 0
190+
if (mode == PullUp) {
191+
gpio->ODR |= (0x01 << (pin_index)); // Set pull-up
192+
} else{
193+
gpio->ODR &= ~(0x01 << (pin_index)); // Set pull-down
194+
}
186195
break;
187196
case OpenDrain:
188197
// Set open-drain for Output mode (General Purpose or Alternate Function)

0 commit comments

Comments
 (0)