Modified for BG96
Fork of mbed-dev by
Diff: hal/mbed_pinmap_common.c
- Revision:
- 187:0387e8f68319
- Parent:
- 186:707f6e361f3e
diff -r 707f6e361f3e -r 0387e8f68319 hal/mbed_pinmap_common.c --- a/hal/mbed_pinmap_common.c Fri Jun 22 16:45:37 2018 +0100 +++ b/hal/mbed_pinmap_common.c Thu Sep 06 13:40:20 2018 +0100 @@ -16,9 +16,11 @@ #include "hal/pinmap.h" #include "platform/mbed_error.h" -void pinmap_pinout(PinName pin, const PinMap *map) { - if (pin == NC) +void pinmap_pinout(PinName pin, const PinMap *map) +{ + if (pin == NC) { return; + } while (map->pin != NC) { if (map->pin == pin) { @@ -32,58 +34,72 @@ MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin); } -uint32_t pinmap_merge(uint32_t a, uint32_t b) { +uint32_t pinmap_merge(uint32_t a, uint32_t b) +{ // both are the same (inc both NC) - if (a == b) + if (a == b) { return a; + } // one (or both) is not connected - if (a == (uint32_t)NC) + if (a == (uint32_t)NC) { return b; - if (b == (uint32_t)NC) + } + if (b == (uint32_t)NC) { return a; + } // mis-match error case MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a); return (uint32_t)NC; } -uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { +uint32_t pinmap_find_peripheral(PinName pin, const PinMap *map) +{ while (map->pin != NC) { - if (map->pin == pin) + if (map->pin == pin) { return map->peripheral; + } map++; } return (uint32_t)NC; } -uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { +uint32_t pinmap_peripheral(PinName pin, const PinMap *map) +{ uint32_t peripheral = (uint32_t)NC; - if (pin == (PinName)NC) + if (pin == (PinName)NC) { return (uint32_t)NC; + } peripheral = pinmap_find_peripheral(pin, map); - if ((uint32_t)NC == peripheral) // no mapping available + if ((uint32_t)NC == peripheral) { // no mapping available MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral); + } return peripheral; } -uint32_t pinmap_find_function(PinName pin, const PinMap* map) { +uint32_t pinmap_find_function(PinName pin, const PinMap *map) +{ while (map->pin != NC) { - if (map->pin == pin) + if (map->pin == pin) { return map->function; + } map++; } return (uint32_t)NC; } -uint32_t pinmap_function(PinName pin, const PinMap* map) { +uint32_t pinmap_function(PinName pin, const PinMap *map) +{ uint32_t function = (uint32_t)NC; - if (pin == (PinName)NC) + if (pin == (PinName)NC) { return (uint32_t)NC; + } function = pinmap_find_function(pin, map); - if ((uint32_t)NC == function) // no mapping available + if ((uint32_t)NC == function) { // no mapping available MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function); + } return function; }