Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c
- Revision:
- 50:a417edff4437
- Parent:
- 0:9b334a45a8ff
- Child:
- 144:ef7eb2e8f9f7
diff -r 57ac6e3cdfd3 -r a417edff4437 targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c Wed Jan 13 12:45:11 2016 +0000
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c Fri Jan 15 07:45:16 2016 +0000
@@ -55,7 +55,7 @@
int gpio_is_connected(const gpio_t *obj)
{
- return (obj->pin | 0xFFFFFF00 )!= (PinName)NC;
+ return ((uint32_t)obj->pin | 0xFFFFFF00 ) != (uint32_t)((PinName)NC);
}
/*
@@ -80,7 +80,10 @@
void gpio_mode(gpio_t *obj, PinMode mode)
{
- if(obj->dir == PIN_INPUT) {
+ uint32_t pin = 1 << (obj->pin & 0xF);
+ uint32_t port = (obj->pin >> 4) & 0xF;
+
+ if(obj->dir == PIN_INPUT) {
switch(mode) {
case PullDefault:
mode = Input;
@@ -94,14 +97,22 @@
default:
break;
}
-
+
//Handle DOUT setting
if((mode & 0x10) != 0) {
//Set DOUT
- GPIO->P[(obj->pin >> 4) & 0xF].DOUTSET = 1 << (obj->pin & 0xF);
+#ifdef _GPIO_P_DOUTSET_MASK
+ GPIO->P[port].DOUTSET = pin;
+#else
+ GPIO->P[port].DOUT |= pin;
+#endif
} else {
//Clear DOUT
- GPIO->P[(obj->pin >> 4) & 0xF].DOUTCLR = 1 << (obj->pin & 0xF);
+#ifdef _GPIO_P_DOUTCLR_MASK
+ GPIO->P[port].DOUTCLR = pin;
+#else
+ GPIO->P[port].DOUT &= ~pin;
+#endif
}
} else {
switch(mode) {
@@ -118,7 +129,7 @@
break;
}
}
-
+
obj->mode = mode; // Update object
pin_mode(obj->pin, mode); // Update register
}
