1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "mbed_error.h"
18 #include "gpio_addrdefine.h"
20 PinName gpio_multi_guard = (PinName)NC; /* If set pin name here, setting of the "pin" is just one time */
22 void pin_function(PinName pin, int function) {
23 if (pin == (PinName)NC) return;
26 int bitmask = 1<<(pin & 0xf);
28 if (gpio_multi_guard != pin) {
36 if (function & (1 << 2)) { *PFCAE(n) |= bitmask;}else { *PFCAE(n) &= ~bitmask;}
37 if (function & (1 << 1)) { *PFCE(n) |= bitmask;}else { *PFCE(n) &= ~bitmask;}
38 if (function & (1 << 0)) { *PFC(n) |= bitmask;}else { *PFC(n) &= ~bitmask;}
41 if (P1_0 <= pin && pin <= P1_7 && function == 0) {
47 gpio_multi_guard = (PinName)NC;
51 void pin_mode(PinName pin, PinMode mode) {
52 // if (pin == (PinName)NC) { return; }