- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/hal/mbed_pinmap_common.c
r352 r374 17 17 #include "platform/mbed_error.h" 18 18 19 void pinmap_pinout(PinName pin, const PinMap *map) { 20 if (pin == NC) 19 void pinmap_pinout(PinName pin, const PinMap *map) 20 { 21 if (pin == NC) { 21 22 return; 23 } 22 24 23 25 while (map->pin != NC) { … … 30 32 map++; 31 33 } 32 error("could not pinout");34 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin); 33 35 } 34 36 35 uint32_t pinmap_merge(uint32_t a, uint32_t b) { 37 uint32_t pinmap_merge(uint32_t a, uint32_t b) 38 { 36 39 // both are the same (inc both NC) 37 if (a == b) 40 if (a == b) { 38 41 return a; 42 } 39 43 40 44 // one (or both) is not connected 41 if (a == (uint32_t)NC) 45 if (a == (uint32_t)NC) { 42 46 return b; 43 if (b == (uint32_t)NC) 47 } 48 if (b == (uint32_t)NC) { 44 49 return a; 50 } 45 51 46 52 // mis-match error case 47 error("pinmap mis-match");53 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a); 48 54 return (uint32_t)NC; 49 55 } 50 56 51 uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { 57 uint32_t pinmap_find_peripheral(PinName pin, const PinMap *map) 58 { 52 59 while (map->pin != NC) { 53 if (map->pin == pin) 60 if (map->pin == pin) { 54 61 return map->peripheral; 62 } 55 63 map++; 56 64 } … … 58 66 } 59 67 60 uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { 68 uint32_t pinmap_peripheral(PinName pin, const PinMap *map) 69 { 61 70 uint32_t peripheral = (uint32_t)NC; 62 71 63 if (pin == (PinName)NC) 72 if (pin == (PinName)NC) { 64 73 return (uint32_t)NC; 74 } 65 75 peripheral = pinmap_find_peripheral(pin, map); 66 if ((uint32_t)NC == peripheral) // no mapping available 67 error("pinmap not found for peripheral"); 76 if ((uint32_t)NC == peripheral) { // no mapping available 77 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral); 78 } 68 79 return peripheral; 69 80 } 70 81 71 uint32_t pinmap_find_function(PinName pin, const PinMap* map) { 82 uint32_t pinmap_find_function(PinName pin, const PinMap *map) 83 { 72 84 while (map->pin != NC) { 73 if (map->pin == pin) 85 if (map->pin == pin) { 74 86 return map->function; 87 } 75 88 map++; 76 89 } … … 78 91 } 79 92 80 uint32_t pinmap_function(PinName pin, const PinMap* map) { 93 uint32_t pinmap_function(PinName pin, const PinMap *map) 94 { 81 95 uint32_t function = (uint32_t)NC; 82 96 83 if (pin == (PinName)NC) 97 if (pin == (PinName)NC) { 84 98 return (uint32_t)NC; 99 } 85 100 function = pinmap_find_function(pin, map); 86 if ((uint32_t)NC == function) // no mapping available 87 error("pinmap not found for function"); 101 if ((uint32_t)NC == function) { // no mapping available 102 MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function); 103 } 88 104 return function; 89 105 }
Note:
See TracChangeset
for help on using the changeset viewer.