1- /* mbed Microcontroller Library
2- * Copyright (c) 2017-2018 Nuvoton
1+ /*
2+ * Copyright (c) 2020, Nuvoton Technology Corporation
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
35 *
46 * Licensed under the Apache License, Version 2.0 (the "License");
57 * you may not use this file except in compliance with the License.
1315 * See the License for the specific language governing permissions and
1416 * limitations under the License.
1517 */
16- #ifndef MBED_PINNAMES_H
17- #define MBED_PINNAMES_H
18+ #ifndef __PIN_NAMES_COMMON_H__
19+ #define __PIN_NAMES_COMMON_H__
1820
1921#include "cmsis.h"
2022#include "partition_M2351.h"
@@ -44,7 +46,7 @@ extern "C" {
4446__STATIC_INLINE GPIO_T * NU_PORT_BASE (uint32_t PORT )
4547{
4648 uint32_t port_base = ((uint32_t ) GPIOA_BASE ) + 0x40 * PORT ;
47-
49+
4850#if defined(SCU_INIT_IONSSET_VAL )
4951 if (SCU_INIT_IONSSET_VAL & (1 << (PORT + 0 ))) {
5052 port_base += NS_OFFSET ;
@@ -65,7 +67,7 @@ __STATIC_INLINE uint32_t NU_GET_GPIO_PIN_DATA(uint32_t PORT, uint32_t PIN)
6567 return GPIO_PIN_DATA_NS (PORT , PIN );
6668 }
6769#endif
68-
70+
6971 return GPIO_PIN_DATA_S (PORT , PIN );
7072}
7173
@@ -78,7 +80,7 @@ __STATIC_INLINE void NU_SET_GPIO_PIN_DATA(uint32_t PORT, uint32_t PIN, uint32_t
7880 return ;
7981 }
8082#endif
81-
83+
8284 GPIO_PIN_DATA_S (PORT , PIN ) = VALUE ;
8385}
8486
@@ -98,88 +100,19 @@ typedef enum {
98100 PullNone = 0 ,
99101 PullDown ,
100102 PullUp ,
101-
103+
102104 /* I/O mode */
103105 InputOnly ,
104106 PushPullOutput ,
105107 OpenDrain ,
106108 QuasiBidirectional ,
107-
109+
108110 /* Default input pull mode */
109111 PullDefault = PullUp
110112} PinMode ;
111113
112- typedef enum {
113- // Not connected
114- NC = (int )0xFFFFFFFF ,
115-
116- // Generic naming
117- PA_0 = NU_PORT_N_PIN_TO_PINNAME (0 , 0 ), PA_1 , PA_2 , PA_3 , PA_4 , PA_5 , PA_6 , PA_7 , PA_8 , PA_9 , PA_10 , PA_11 , PA_12 , PA_13 , PA_14 , PA_15 ,
118- PB_0 = NU_PORT_N_PIN_TO_PINNAME (1 , 0 ), PB_1 , PB_2 , PB_3 , PB_4 , PB_5 , PB_6 , PB_7 , PB_8 , PB_9 , PB_10 , PB_11 , PB_12 , PB_13 , PB_14 , PB_15 ,
119- PC_0 = NU_PORT_N_PIN_TO_PINNAME (2 , 0 ), PC_1 , PC_2 , PC_3 , PC_4 , PC_5 , PC_6 , PC_7 , PC_8 , PC_9 , PC_10 , PC_11 , PC_12 , PC_13 ,
120- PD_0 = NU_PORT_N_PIN_TO_PINNAME (3 , 0 ), PD_1 , PD_2 , PD_3 , PD_4 , PD_5 , PD_6 , PD_7 , PD_8 , PD_9 , PD_10 , PD_11 , PD_12 , PD_13 , PD_14 ,
121- PE_0 = NU_PORT_N_PIN_TO_PINNAME (4 , 0 ), PE_1 , PE_2 , PE_3 , PE_4 , PE_5 , PE_6 , PE_7 , PE_8 , PE_9 , PE_10 , PE_11 , PE_12 , PE_13 , PE_14 , PE_15 ,
122- PF_0 = NU_PORT_N_PIN_TO_PINNAME (5 , 0 ), PF_1 , PF_2 , PF_3 , PF_4 , PF_5 , PF_6 , PF_7 , PF_8 , PF_9 , PF_10 , PF_11 ,
123- PG_0 = NU_PORT_N_PIN_TO_PINNAME (6 , 0 ), PG_1 , PG_2 , PG_3 , PG_4 , PG_5 , PG_6 , PG_7 , PG_8 , PG_9 , PG_10 , PG_11 , PG_12 , PG_13 , PG_14 , PG_15 ,
124- PH_0 = NU_PORT_N_PIN_TO_PINNAME (7 , 0 ), PH_1 , PH_2 , PH_3 , PH_4 , PH_5 , PH_6 , PH_7 , PH_8 , PH_9 , PH_10 , PH_11 ,
125-
126- // Arduino UNO naming
127- A0 = PB_11 ,
128- A1 = PB_10 ,
129- A2 = PB_9 ,
130- A3 = PB_8 ,
131- A4 = PB_4 ,
132- A5 = PB_5 ,
133-
134- D0 = PA_8 ,
135- D1 = PA_9 ,
136- D2 = PB_7 ,
137- D3 = PB_6 ,
138- D4 = PB_3 ,
139- D5 = PB_2 ,
140- D6 = PC_12 ,
141- D7 = PC_11 ,
142- D8 = PC_9 ,
143- D9 = PC_10 ,
144- D10 = PF_9 ,
145- D11 = PF_6 ,
146- D12 = PF_7 ,
147- D13 = PF_8 ,
148- D14 = PG_3 ,
149- D15 = PG_2 ,
150-
151- // Other board-specific naming
152-
153- // UART naming
154- USBTX = PB_13 ,
155- USBRX = PB_12 ,
156- STDIO_UART_TX = USBTX ,
157- STDIO_UART_RX = USBRX ,
158-
159- // I2C naming
160- I2C_SCL = D15 ,
161- I2C_SDA = D14 ,
162-
163- // LED naming
164- LED1 = PA_10 ,
165- LED2 = PA_11 ,
166- LED3 = PA_10 , // No real LED. Just for passing ATS.
167- LED4 = PA_11 , // No real LED. Just for passing ATS.
168- LED_GREEN = LED1 ,
169-
170- // Button naming
171- SW2 = PB_0 ,
172- SW3 = PB_1 ,
173- BUTTON1 = SW2 ,
174- BUTTON2 = SW3 ,
175-
176- // Force PinName to 32-bit required by NU_PINNAME_BIND(...)
177- FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF ,
178-
179- } PinName ;
180-
181114#ifdef __cplusplus
182115}
183116#endif
184117
185- #endif // MBED_PINNAMES_H
118+ #endif // __PIN_NAMES_COMMON_H__
0 commit comments