Squashed commit of the following:

commit 2f006d6f51ab4746d10f53d24667e551fa3a7896
Merge: a1e04f7 ca6d764
Author: 0xc0170 <c0170@rocketmail.com>
Date:   Thu May 7 09:00:36 2015 +0100

    Merge branch 'pinmap_stm32f1' of https://github.com/raulMrello/mbed into raulMrello-pinmap_stm32f1

commit ca6d7649a5
Merge: 88e7489 d50b62d
Author: raulMrello <raul.martin.rello@gmail.com>
Date:   Mon May 4 09:39:59 2015 +0200

    Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1

commit 88e7489862
Merge: dd27e29 ffaae4b
Author: raulMrello <raul.martin.rello@gmail.com>
Date:   Mon May 4 09:27:28 2015 +0200

    Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1

commit dd27e29bde
Merge: 3d1afb8 f54dc44
Author: raulMrello <raul.martin.rello@gmail.com>
Date:   Mon May 4 09:24:33 2015 +0200

    Merge remote-tracking branch 'upstream/master' into pinmap_stm32f1

commit 3d1afb8142
Author: raulMrello <raul.martin.rello@gmail.com>
Date:   Mon May 4 09:16:01 2015 +0200

    Updated pinmap.c in target_stm32f1
pull/1097/head
0xc0170 2015-05-07 09:03:48 +01:00
parent a1e04f782b
commit ffd558657c
1 changed files with 9 additions and 0 deletions

View File

@ -177,12 +177,21 @@ void pin_mode(PinName pin, PinMode mode)
if (pin_index < 8) {
if ((gpio->CRL & (0x03 << (pin_index * 4))) == 0) { // MODE bits = Input mode
gpio->CRL |= (0x08 << (pin_index * 4)); // Set pull-up / pull-down
gpio->CRL &= ~(0x08 << ((pin_index * 4)-1)); // ENSURES GPIOx_CRL.CNFx.bit0 = 0
}
} else {
if ((gpio->CRH & (0x03 << ((pin_index % 8) * 4))) == 0) { // MODE bits = Input mode
gpio->CRH |= (0x08 << ((pin_index % 8) * 4)); // Set pull-up / pull-down
gpio->CRH &= ~(0x08 << (((pin_index % 8) * 4)-1)); // ENSURES GPIOx_CRH.CNFx.bit0 = 0
}
}
// Now it's time to setup properly if pullup or pulldown. This is done in ODR register:
// set pull-up => bit=1, set pull-down => bit = 0
if (mode == PullUp) {
gpio->ODR |= (0x01 << (pin_index)); // Set pull-up
} else{
gpio->ODR &= ~(0x01 << (pin_index)); // Set pull-down
}
break;
case OpenDrain:
// Set open-drain for Output mode (General Purpose or Alternate Function)