Updated pinmap.c in target_stm32f1

pull/1089/head
raulMrello 2015-05-04 09:16:01 +02:00
parent 8c95d60d0a
commit 3d1afb8142
1 changed files with 10 additions and 0 deletions

View File

@ -177,12 +177,22 @@ 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)