]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/pinmap.c
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_RENESAS / TARGET_RZ_A1H / pinmap.c
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 #include "pinmap.h"
17 #include "mbed_error.h"
18 #include "gpio_addrdefine.h"
19
20 PinName gpio_multi_guard = (PinName)NC; /* If set pin name here, setting of the "pin" is just one time */
21
22 void pin_function(PinName pin, int function) {
23 if (pin == (PinName)NC) return;
24
25 int n = pin >> 4;
26 int bitmask = 1<<(pin & 0xf);
27
28 if (gpio_multi_guard != pin) {
29 if (function == 0) {
30 // means GPIO mode
31 *PMC(n) &= ~bitmask;
32 } else {
33 // alt-function mode
34 --function;
35
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;}
39 *PIPC(n) |= bitmask;
40
41 if (P1_0 <= pin && pin <= P1_7 && function == 0) {
42 *PBDC(n) |= bitmask;
43 }
44 *PMC(n) |= bitmask;
45 }
46 } else {
47 gpio_multi_guard = (PinName)NC;
48 }
49 }
50
51 void pin_mode(PinName pin, PinMode mode) {
52 // if (pin == (PinName)NC) { return; }
53 }
Imprint / Impressum