summaryrefslogtreecommitdiff
path: root/teensy/hal_gpio.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-08 22:41:06 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-08 22:41:06 +0100
commit416227118150a6d3cac6ae94e4e9e8d7e482890f (patch)
tree586fae07925581402aa6f5dc22a6d290cc10d90b /teensy/hal_gpio.c
parenta1d3ee376c25c0842096535c38e651431028d1b8 (diff)
parentb92e7533d3b40fd5129982370f177f47b2790df8 (diff)
Merge branch 'dhylands-pin-af'
Diffstat (limited to 'teensy/hal_gpio.c')
-rw-r--r--teensy/hal_gpio.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/teensy/hal_gpio.c b/teensy/hal_gpio.c
index 0811f76fd..218560e29 100644
--- a/teensy/hal_gpio.c
+++ b/teensy/hal_gpio.c
@@ -25,12 +25,18 @@ void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
if ((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD)) {
/* Check the Alternate function parameter */
assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
- /* Configure Alternate function mapped with the current IO */
-
- *port_pcr &= ~PORT_PCR_MUX_MASK;
- *port_pcr |= PORT_PCR_MUX(GPIO_Init->Alternate);
+ }
+ else if (GPIO_Init->Mode == GPIO_MODE_ANALOG) {
+ GPIO_Init->Alternate = 0;
+ }
+ else {
+ GPIO_Init->Alternate = 1;
}
+ /* Configure Alternate function mapped with the current IO */
+ *port_pcr &= ~PORT_PCR_MUX_MASK;
+ *port_pcr |= PORT_PCR_MUX(GPIO_Init->Alternate);
+
/* Configure IO Direction mode (Input, Output, Alternate or Analog) */
if (GPIO_Init->Mode == GPIO_MODE_INPUT || GPIO_Init->Mode == GPIO_MODE_ANALOG) {
GPIOx->PDDR &= ~bitmask;
@@ -112,4 +118,3 @@ void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
#endif
}
}
-