Skip to content

Fix pin mode for STM32F1 target. #1915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hal/targets/hal/TARGET_STM/TARGET_STM32F1/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ 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
gpio->CRL &= ~(0x04 << (pin_index * 4)); // 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
gpio->CRH &= ~(0x04 << ((pin_index % 8) * 4)); // ENSURES GPIOx_CRH.CNFx.bit0 = 0
}
}
// Now it's time to setup properly if pullup or pulldown. This is done in ODR register:
Expand Down