mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
targets/TARGET_RENESAS/TARGET_RZ_A1H/pinmap.c@149:156823d33999, 2016-10-28 (annotated)
- Committer:
- <>
- Date:
- Fri Oct 28 11:17:30 2016 +0100
- Revision:
- 149:156823d33999
- Parent:
- targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/pinmap.c@144:ef7eb2e8f9f7
This updates the lib to the mbed lib v128
NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /* mbed Microcontroller Library |
<> | 144:ef7eb2e8f9f7 | 2 | * Copyright (c) 2006-2013 ARM Limited |
<> | 144:ef7eb2e8f9f7 | 3 | * |
<> | 144:ef7eb2e8f9f7 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 144:ef7eb2e8f9f7 | 5 | * you may not use this file except in compliance with the License. |
<> | 144:ef7eb2e8f9f7 | 6 | * You may obtain a copy of the License at |
<> | 144:ef7eb2e8f9f7 | 7 | * |
<> | 144:ef7eb2e8f9f7 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 144:ef7eb2e8f9f7 | 9 | * |
<> | 144:ef7eb2e8f9f7 | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 144:ef7eb2e8f9f7 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 144:ef7eb2e8f9f7 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 144:ef7eb2e8f9f7 | 13 | * See the License for the specific language governing permissions and |
<> | 144:ef7eb2e8f9f7 | 14 | * limitations under the License. |
<> | 144:ef7eb2e8f9f7 | 15 | */ |
<> | 144:ef7eb2e8f9f7 | 16 | #include "pinmap.h" |
<> | 144:ef7eb2e8f9f7 | 17 | #include "mbed_error.h" |
<> | 144:ef7eb2e8f9f7 | 18 | #include "gpio_addrdefine.h" |
<> | 144:ef7eb2e8f9f7 | 19 | |
<> | 144:ef7eb2e8f9f7 | 20 | PinName gpio_multi_guard = (PinName)NC; /* If set pin name here, setting of the "pin" is just one time */ |
<> | 144:ef7eb2e8f9f7 | 21 | |
<> | 144:ef7eb2e8f9f7 | 22 | typedef struct { |
<> | 144:ef7eb2e8f9f7 | 23 | PinName pin; |
<> | 144:ef7eb2e8f9f7 | 24 | int function; |
<> | 144:ef7eb2e8f9f7 | 25 | int pm; |
<> | 144:ef7eb2e8f9f7 | 26 | } PinFunc; |
<> | 144:ef7eb2e8f9f7 | 27 | |
<> | 144:ef7eb2e8f9f7 | 28 | static const PinFunc PIPC_0_tbl[] = { |
<> | 144:ef7eb2e8f9f7 | 29 | // pin func pm |
<> | 144:ef7eb2e8f9f7 | 30 | {P4_0 , 2 , -1}, /* TIOC0A */ |
<> | 144:ef7eb2e8f9f7 | 31 | {P5_0 , 6 , -1}, /* TIOC0A */ |
<> | 144:ef7eb2e8f9f7 | 32 | {P7_0 , 7 , -1}, /* TIOC0A */ |
<> | 144:ef7eb2e8f9f7 | 33 | {P10_4 , 2 , -1}, /* TIOC0A */ |
<> | 144:ef7eb2e8f9f7 | 34 | {P4_1 , 2 , -1}, /* TIOC0B */ |
<> | 144:ef7eb2e8f9f7 | 35 | {P5_1 , 6 , -1}, /* TIOC0B */ |
<> | 144:ef7eb2e8f9f7 | 36 | {P7_1 , 7 , -1}, /* TIOC0B */ |
<> | 144:ef7eb2e8f9f7 | 37 | {P10_5 , 2 , -1}, /* TIOC0B */ |
<> | 144:ef7eb2e8f9f7 | 38 | {P4_2 , 2 , -1}, /* TIOC0C */ |
<> | 144:ef7eb2e8f9f7 | 39 | {P5_5 , 6 , -1}, /* TIOC0C */ |
<> | 144:ef7eb2e8f9f7 | 40 | {P7_2 , 7 , -1}, /* TIOC0C */ |
<> | 144:ef7eb2e8f9f7 | 41 | {P10_6 , 2 , -1}, /* TIOC0C */ |
<> | 144:ef7eb2e8f9f7 | 42 | {P4_3 , 2 , -1}, /* TIOC0D */ |
<> | 144:ef7eb2e8f9f7 | 43 | {P5_7 , 6 , -1}, /* TIOC0D */ |
<> | 144:ef7eb2e8f9f7 | 44 | {P7_3 , 7 , -1}, /* TIOC0D */ |
<> | 144:ef7eb2e8f9f7 | 45 | {P10_7 , 2 , -1}, /* TIOC0D */ |
<> | 144:ef7eb2e8f9f7 | 46 | {P2_11 , 5 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 47 | {P6_0 , 5 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 48 | {P7_4 , 7 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 49 | {P8_8 , 5 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 50 | {P9_7 , 4 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 51 | {P10_8 , 2 , -1}, /* TIOC1A */ |
<> | 144:ef7eb2e8f9f7 | 52 | {P2_12 , 8 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 53 | {P5_2 , 6 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 54 | {P6_1 , 5 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 55 | {P7_5 , 7 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 56 | {P8_9 , 5 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 57 | {P10_9 , 2 , -1}, /* TIOC1B */ |
<> | 144:ef7eb2e8f9f7 | 58 | {P2_1 , 6 , -1}, /* TIOC2A */ |
<> | 144:ef7eb2e8f9f7 | 59 | {P6_2 , 6 , -1}, /* TIOC2A */ |
<> | 144:ef7eb2e8f9f7 | 60 | {P7_6 , 7 , -1}, /* TIOC2A */ |
<> | 144:ef7eb2e8f9f7 | 61 | {P8_14 , 4 , -1}, /* TIOC2A */ |
<> | 144:ef7eb2e8f9f7 | 62 | {P10_10 , 2 , -1}, /* TIOC2A */ |
<> | 144:ef7eb2e8f9f7 | 63 | {P2_2 , 6 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 64 | {P6_3 , 6 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 65 | {P7_7 , 7 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 66 | {P8_15 , 4 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 67 | {P10_11 , 2 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 68 | {P10_11 , 2 , -1}, /* TIOC2B */ |
<> | 144:ef7eb2e8f9f7 | 69 | {P3_4 , 6 , -1}, /* TIOC3A */ |
<> | 144:ef7eb2e8f9f7 | 70 | {P7_8 , 7 , -1}, /* TIOC3A */ |
<> | 144:ef7eb2e8f9f7 | 71 | {P8_10 , 4 , -1}, /* TIOC3A */ |
<> | 144:ef7eb2e8f9f7 | 72 | {P3_5 , 6 , -1}, /* TIOC3B */ |
<> | 144:ef7eb2e8f9f7 | 73 | {P7_9 , 7 , -1}, /* TIOC3B */ |
<> | 144:ef7eb2e8f9f7 | 74 | {P8_11 , 4 , -1}, /* TIOC3B */ |
<> | 144:ef7eb2e8f9f7 | 75 | {P3_6 , 6 , -1}, /* TIOC3C */ |
<> | 144:ef7eb2e8f9f7 | 76 | {P5_3 , 6 , -1}, /* TIOC3C */ |
<> | 144:ef7eb2e8f9f7 | 77 | {P7_10 , 7 , -1}, /* TIOC3C */ |
<> | 144:ef7eb2e8f9f7 | 78 | {P8_12 , 4 , -1}, /* TIOC3C */ |
<> | 144:ef7eb2e8f9f7 | 79 | {P3_7 , 6 , -1}, /* TIOC3D */ |
<> | 144:ef7eb2e8f9f7 | 80 | {P5_4 , 6 , -1}, /* TIOC3D */ |
<> | 144:ef7eb2e8f9f7 | 81 | {P7_11 , 7 , -1}, /* TIOC3D */ |
<> | 144:ef7eb2e8f9f7 | 82 | {P8_13 , 4 , -1}, /* TIOC3D */ |
<> | 144:ef7eb2e8f9f7 | 83 | {P3_8 , 6 , -1}, /* TIOC4A */ |
<> | 144:ef7eb2e8f9f7 | 84 | {P4_4 , 3 , -1}, /* TIOC4A */ |
<> | 144:ef7eb2e8f9f7 | 85 | {P7_12 , 7 , -1}, /* TIOC4A */ |
<> | 144:ef7eb2e8f9f7 | 86 | {P11_0 , 2 , -1}, /* TIOC4A */ |
<> | 144:ef7eb2e8f9f7 | 87 | {P3_9 , 6 , -1}, /* TIOC4B */ |
<> | 144:ef7eb2e8f9f7 | 88 | {P4_5 , 3 , -1}, /* TIOC4B */ |
<> | 144:ef7eb2e8f9f7 | 89 | {P7_13 , 7 , -1}, /* TIOC4B */ |
<> | 144:ef7eb2e8f9f7 | 90 | {P11_1 , 2 , -1}, /* TIOC4B */ |
<> | 144:ef7eb2e8f9f7 | 91 | {P3_10 , 6 , -1}, /* TIOC4C */ |
<> | 144:ef7eb2e8f9f7 | 92 | {P4_6 , 3 , -1}, /* TIOC4C */ |
<> | 144:ef7eb2e8f9f7 | 93 | {P7_14 , 7 , -1}, /* TIOC4C */ |
<> | 144:ef7eb2e8f9f7 | 94 | {P11_2 , 2 , -1}, /* TIOC4C */ |
<> | 144:ef7eb2e8f9f7 | 95 | {P3_11 , 6 , -1}, /* TIOC4D */ |
<> | 144:ef7eb2e8f9f7 | 96 | {P4_7 , 3 , -1}, /* TIOC4D */ |
<> | 144:ef7eb2e8f9f7 | 97 | {P7_15 , 7 , -1}, /* TIOC4D */ |
<> | 144:ef7eb2e8f9f7 | 98 | {P11_3 , 2 , -1}, /* TIOC4D */ |
<> | 144:ef7eb2e8f9f7 | 99 | {P5_7 , 1 , 1 }, /* TXOUT0M */ |
<> | 144:ef7eb2e8f9f7 | 100 | {P5_6 , 1 , 1 }, /* TXOUT0P */ |
<> | 144:ef7eb2e8f9f7 | 101 | {P5_5 , 1 , 1 }, /* TXOUT1M */ |
<> | 144:ef7eb2e8f9f7 | 102 | {P5_4 , 1 , 1 }, /* TXOUT1P */ |
<> | 144:ef7eb2e8f9f7 | 103 | {P5_3 , 1 , 1 }, /* TXOUT2M */ |
<> | 144:ef7eb2e8f9f7 | 104 | {P5_2 , 1 , 1 }, /* TXOUT2P */ |
<> | 144:ef7eb2e8f9f7 | 105 | {P5_1 , 1 , 1 }, /* TXCLKOUTM */ |
<> | 144:ef7eb2e8f9f7 | 106 | {P5_0 , 1 , 1 }, /* TXCLKOUTP */ |
<> | 144:ef7eb2e8f9f7 | 107 | {P2_11 , 4 , 0 }, /* SSITxD0 */ |
<> | 144:ef7eb2e8f9f7 | 108 | {P4_7 , 5 , 0 }, /* SSITxD0 */ |
<> | 144:ef7eb2e8f9f7 | 109 | {P7_4 , 6 , 0 }, /* SSITxD1 */ |
<> | 144:ef7eb2e8f9f7 | 110 | {P10_15 , 2 , 0 }, /* SSITxD1 */ |
<> | 144:ef7eb2e8f9f7 | 111 | {P4_15 , 6 , 0 }, /* SSITxD3 */ |
<> | 144:ef7eb2e8f9f7 | 112 | {P7_11 , 2 , 0 }, /* SSITxD3 */ |
<> | 144:ef7eb2e8f9f7 | 113 | {P2_7 , 4 , 0 }, /* SSITxD5 */ |
<> | 144:ef7eb2e8f9f7 | 114 | {P4_11 , 5 , 0 }, /* SSITxD5 */ |
<> | 144:ef7eb2e8f9f7 | 115 | {P8_10 , 8 , 0 }, /* SSITxD5 */ |
<> | 144:ef7eb2e8f9f7 | 116 | {P3_7 , 8 , 0 }, /* WDTOVF */ |
<> | 144:ef7eb2e8f9f7 | 117 | {NC , 0 , -1} |
<> | 144:ef7eb2e8f9f7 | 118 | }; |
<> | 144:ef7eb2e8f9f7 | 119 | |
<> | 144:ef7eb2e8f9f7 | 120 | void pin_function(PinName pin, int function) { |
<> | 144:ef7eb2e8f9f7 | 121 | if (pin == (PinName)NC) return; |
<> | 144:ef7eb2e8f9f7 | 122 | |
<> | 144:ef7eb2e8f9f7 | 123 | int n = pin >> 4; |
<> | 144:ef7eb2e8f9f7 | 124 | int bitmask = 1<<(pin & 0xf); |
<> | 144:ef7eb2e8f9f7 | 125 | const PinFunc * Pipc_0_func = PIPC_0_tbl; |
<> | 144:ef7eb2e8f9f7 | 126 | int pipc_data = 1; |
<> | 144:ef7eb2e8f9f7 | 127 | |
<> | 144:ef7eb2e8f9f7 | 128 | if (gpio_multi_guard != pin) { |
<> | 144:ef7eb2e8f9f7 | 129 | if (function == 0) { |
<> | 144:ef7eb2e8f9f7 | 130 | // means GPIO mode |
<> | 144:ef7eb2e8f9f7 | 131 | *PMC(n) &= ~bitmask; |
<> | 144:ef7eb2e8f9f7 | 132 | } else { |
<> | 144:ef7eb2e8f9f7 | 133 | // alt-function mode |
<> | 144:ef7eb2e8f9f7 | 134 | --function; |
<> | 144:ef7eb2e8f9f7 | 135 | |
<> | 144:ef7eb2e8f9f7 | 136 | if (function & (1 << 2)) { *PFCAE(n) |= bitmask;}else { *PFCAE(n) &= ~bitmask;} |
<> | 144:ef7eb2e8f9f7 | 137 | if (function & (1 << 1)) { *PFCE(n) |= bitmask;}else { *PFCE(n) &= ~bitmask;} |
<> | 144:ef7eb2e8f9f7 | 138 | if (function & (1 << 0)) { *PFC(n) |= bitmask;}else { *PFC(n) &= ~bitmask;} |
<> | 144:ef7eb2e8f9f7 | 139 | |
<> | 144:ef7eb2e8f9f7 | 140 | while (Pipc_0_func->pin != NC) { |
<> | 144:ef7eb2e8f9f7 | 141 | if ((Pipc_0_func->pin == pin) && ((Pipc_0_func->function - 1) == function)) { |
<> | 144:ef7eb2e8f9f7 | 142 | pipc_data = 0; |
<> | 144:ef7eb2e8f9f7 | 143 | if (Pipc_0_func->pm == 0) { |
<> | 144:ef7eb2e8f9f7 | 144 | *PMSR(n) = (bitmask << 16) | 0; |
<> | 144:ef7eb2e8f9f7 | 145 | } else if (Pipc_0_func->pm == 1) { |
<> | 144:ef7eb2e8f9f7 | 146 | *PMSR(n) = (bitmask << 16) | bitmask; |
<> | 144:ef7eb2e8f9f7 | 147 | } else { |
<> | 144:ef7eb2e8f9f7 | 148 | // Do Nothing |
<> | 144:ef7eb2e8f9f7 | 149 | } |
<> | 144:ef7eb2e8f9f7 | 150 | break; |
<> | 144:ef7eb2e8f9f7 | 151 | } |
<> | 144:ef7eb2e8f9f7 | 152 | Pipc_0_func++; |
<> | 144:ef7eb2e8f9f7 | 153 | } |
<> | 144:ef7eb2e8f9f7 | 154 | if (pipc_data == 1) { |
<> | 144:ef7eb2e8f9f7 | 155 | *PIPC(n) |= bitmask; |
<> | 144:ef7eb2e8f9f7 | 156 | } else { |
<> | 144:ef7eb2e8f9f7 | 157 | *PIPC(n) &= ~bitmask; |
<> | 144:ef7eb2e8f9f7 | 158 | } |
<> | 144:ef7eb2e8f9f7 | 159 | |
<> | 144:ef7eb2e8f9f7 | 160 | if (P1_0 <= pin && pin <= P1_7 && function == 0) { |
<> | 144:ef7eb2e8f9f7 | 161 | *PBDC(n) |= bitmask; |
<> | 144:ef7eb2e8f9f7 | 162 | } |
<> | 144:ef7eb2e8f9f7 | 163 | *PMC(n) |= bitmask; |
<> | 144:ef7eb2e8f9f7 | 164 | } |
<> | 144:ef7eb2e8f9f7 | 165 | } else { |
<> | 144:ef7eb2e8f9f7 | 166 | gpio_multi_guard = (PinName)NC; |
<> | 144:ef7eb2e8f9f7 | 167 | } |
<> | 144:ef7eb2e8f9f7 | 168 | } |
<> | 144:ef7eb2e8f9f7 | 169 | |
<> | 144:ef7eb2e8f9f7 | 170 | void pin_mode(PinName pin, PinMode mode) { |
<> | 144:ef7eb2e8f9f7 | 171 | // if (pin == (PinName)NC) { return; } |
<> | 144:ef7eb2e8f9f7 | 172 | } |