mbed library sources
Fork of mbed-src by
Diff: common/pinmap_common.c
- Revision:
- 511:532f83b66a7f
- Parent:
- 285:31249416b6f9
- Child:
- 523:d25d72bcc348
--- a/common/pinmap_common.c Thu Apr 09 08:00:08 2015 +0100 +++ b/common/pinmap_common.c Thu Apr 09 12:15:08 2015 +0100 @@ -67,3 +67,23 @@ error("pinmap not found for peripheral"); return peripheral; } + +uint32_t pinmap_find_function(PinName pin, const PinMap* map) { + while (map->pin != NC) { + if (map->pin == pin) + return map->function; + map++; + } + return (uint32_t)NC; +} + +uint32_t pinmap_function(PinName pin, const PinMap* map) { + uint32_t function = (uint32_t)NC; + + if (pin == (PinName)NC) + return (uint32_t)NC; + function = pinmap_find_function(pin, map); + if ((uint32_t)NC == function) // no mapping available + error("pinmap not found for function"); + return function; +} \ No newline at end of file