aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/GPIOv2
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-09-11 19:36:26 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-09-11 19:36:26 +0000
commitc3c4b3af583f8da32b34932950f9eb056b41b3da (patch)
treee63338f26d2ae1b2a4024953c86646340f1cafde /os/hal/ports/STM32/LLD/GPIOv2
parent67ac09b2f3e66f2a59261d189a0128644918727c (diff)
downloadChibiOS-c3c4b3af583f8da32b34932950f9eb056b41b3da.tar.gz
ChibiOS-c3c4b3af583f8da32b34932950f9eb056b41b3da.tar.bz2
ChibiOS-c3c4b3af583f8da32b34932950f9eb056b41b3da.zip
Fixed GPIO port index calculation.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10573 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/GPIOv2')
-rw-r--r--os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c
index dc0fd71c9..2d9bca949 100644
--- a/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c
+++ b/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.c
@@ -253,7 +253,7 @@ void _pal_lld_enablepadevent(ioportid_t port,
/* Port index is obtained assuming that GPIO ports are placed at regular
0x400 intervals in memory space. So far this is true for all devices.*/
- portidx = ((uint32_t)port >> 10U) & 0xFU;
+ portidx = (((uint32_t)port - (uint32_t)GPIOA) >> 10U) & 0xFU;
/* Port selection in SYSCFG.*/
SYSCFG->EXTICR[cridx] = (SYSCFG->EXTICR[cridx] & crmask) | (portidx << croff);
@@ -301,7 +301,7 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
/* Port index is obtained assuming that GPIO ports are placed at regular
0x400 intervals in memory space. So far this is true for all devices.*/
- portidx = ((uint32_t)port >> 10U) & 0xFU;
+ portidx = (((uint32_t)port - (uint32_t)GPIOA) >> 10U) & 0xFU;
crport = (SYSCFG->EXTICR[cridx] >> croff) & 0xFU;