USBclock 48Mhz, enable serial4 and serial5.
Fork of mbed-src by
Embed:
(wiki syntax)
Show/hide line numbers
pinmap_common.c
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "pinmap.h" 00017 #include "mbed_error.h" 00018 00019 void pinmap_pinout(PinName pin, const PinMap *map) { 00020 if (pin == NC) 00021 return; 00022 00023 while (map->pin != NC) { 00024 if (map->pin == pin) { 00025 pin_function(pin, map->function); 00026 00027 pin_mode(pin, PullNone); 00028 return; 00029 } 00030 map++; 00031 } 00032 error("could not pinout"); 00033 } 00034 00035 uint32_t pinmap_merge(uint32_t a, uint32_t b) { 00036 // both are the same (inc both NC) 00037 if (a == b) 00038 return a; 00039 00040 // one (or both) is not connected 00041 if (a == (uint32_t)NC) 00042 return b; 00043 if (b == (uint32_t)NC) 00044 return a; 00045 00046 // mis-match error case 00047 error("pinmap mis-match"); 00048 return (uint32_t)NC; 00049 } 00050 00051 uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { 00052 while (map->pin != NC) { 00053 if (map->pin == pin) 00054 return map->peripheral; 00055 map++; 00056 } 00057 return (uint32_t)NC; 00058 } 00059 00060 uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { 00061 uint32_t peripheral = (uint32_t)NC; 00062 00063 if (pin == (PinName)NC) 00064 return (uint32_t)NC; 00065 peripheral = pinmap_find_peripheral(pin, map); 00066 if ((uint32_t)NC == peripheral) // no mapping available 00067 error("pinmap not found for peripheral"); 00068 return peripheral; 00069 } 00070 00071 uint32_t pinmap_find_function(PinName pin, const PinMap* map) { 00072 while (map->pin != NC) { 00073 if (map->pin == pin) 00074 return map->function; 00075 map++; 00076 } 00077 return (uint32_t)NC; 00078 } 00079 00080 uint32_t pinmap_function(PinName pin, const PinMap* map) { 00081 uint32_t function = (uint32_t)NC; 00082 00083 if (pin == (PinName)NC) 00084 return (uint32_t)NC; 00085 function = pinmap_find_function(pin, map); 00086 if ((uint32_t)NC == function) // no mapping available 00087 error("pinmap not found for function"); 00088 return function; 00089 }
Generated on Tue Jul 12 2022 16:19:42 by 1.7.2