Skip to content

Commit 6964679

Browse files
authored
Merge pull request #12576 from OpenNuvoton/nuvoton_m487_custom_board
M487: Support custom board
2 parents 272cb79 + 5ec8641 commit 6964679

File tree

13 files changed

+602
-164
lines changed

13 files changed

+602
-164
lines changed

targets/TARGET_NUVOTON/TARGET_M480/PeripheralNames.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define MBED_PERIPHERALNAMES_H
1919

2020
#include "cmsis.h"
21+
#include "PinNames.h"
2122

2223
#ifdef __cplusplus
2324
extern "C" {
@@ -80,7 +81,16 @@ typedef enum {
8081
UART_4 = (int) NU_MODNAME(UART4_BASE, 4, 0),
8182
UART_5 = (int) NU_MODNAME(UART5_BASE, 5, 0),
8283
// NOTE: board-specific
83-
STDIO_UART = UART_0
84+
#if defined(MBED_CONF_TARGET_USB_UART)
85+
USB_UART = MBED_CONF_TARGET_USB_UART,
86+
#else
87+
USB_UART = NC,
88+
#endif
89+
#if defined(MBED_CONF_TARGET_STDIO_UART)
90+
STDIO_UART = MBED_CONF_TARGET_STDIO_UART
91+
#else
92+
STDIO_UART = USB_UART
93+
#endif
8494
} UARTName;
8595

8696
typedef enum {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2015-2016 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.
@@ -13,8 +15,8 @@
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_NAME_COMMON_H__
19+
#define __PIN_NAME_COMMON_H__
1820

1921
#include "cmsis.h"
2022

@@ -59,93 +61,19 @@ typedef enum {
5961
PullNone = 0,
6062
PullDown,
6163
PullUp,
62-
64+
6365
/* I/O mode */
6466
InputOnly,
6567
PushPullOutput,
6668
OpenDrain,
6769
QuasiBidirectional,
68-
70+
6971
/* Default input pull mode */
7072
PullDefault = PullUp
7173
} PinMode;
7274

73-
typedef enum {
74-
// Not connected
75-
NC = (int)0xFFFFFFFF,
76-
77-
// Generic naming
78-
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,
79-
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,
80-
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, PC_14,
81-
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,
82-
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,
83-
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,
84-
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,
85-
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,
86-
87-
// Arduino UNO naming
88-
A0 = PB_6,
89-
A1 = PB_7,
90-
A2 = PB_8,
91-
A3 = PB_9,
92-
A4 = PB_0,
93-
A5 = PB_1,
94-
95-
D0 = PB_2,
96-
D1 = PB_3,
97-
D2 = PC_9,
98-
D3 = PC_10,
99-
D4 = PC_11,
100-
D5 = PC_12,
101-
D6 = PE_4,
102-
D7 = PE_5,
103-
D8 = PA_5,
104-
D9 = PA_4,
105-
D10 = PA_3,
106-
D11 = PA_0,
107-
D12 = PA_1,
108-
D13 = PA_2,
109-
D14 = PG_1,
110-
D15 = PG_0,
111-
112-
I2C_SCL = D15,
113-
I2C_SDA = D14,
114-
115-
// Note: board-specific
116-
// UART naming
117-
USBTX = PB_13,
118-
USBRX = PB_12,
119-
STDIO_UART_TX = USBTX,
120-
STDIO_UART_RX = USBRX,
121-
SERIAL_TX = USBTX,
122-
SERIAL_RX = USBRX,
123-
// LED naming
124-
LED_RED = PH_0,
125-
LED_YELLOW = PH_1,
126-
LED_GREEN = PH_2,
127-
LED1 = LED_RED,
128-
LED2 = LED_YELLOW,
129-
LED3 = LED_GREEN,
130-
LED4 = LED1, // No real LED. Just for passing ATS.
131-
// Button naming
132-
#if TARGET_NUMAKER_PFM_M487
133-
SW2 = PG_15,
134-
SW3 = PF_11,
135-
#elif TARGET_NUMAKER_IOT_M487
136-
SW2 = PF_11,
137-
SW3 = PG_5,
138-
#endif
139-
BUTTON1 = SW2,
140-
BUTTON2 = SW3,
141-
142-
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
143-
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
144-
145-
} PinName;
146-
14775
#ifdef __cplusplus
14876
}
14977
#endif
15078

151-
#endif // MBED_PINNAMES_H
79+
#endif // __PIN_NAME_COMMON_H__
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright (c) 2020, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
#ifndef MBED_PINNAMES_H
19+
#define MBED_PINNAMES_H
20+
21+
#include "cmsis.h"
22+
#include "PinNamesCommon.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
typedef enum {
29+
// Not connected
30+
NC = (int)0xFFFFFFFF,
31+
32+
// Generic naming
33+
PA_0 = NU_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,
34+
PB_0 = NU_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,
35+
PC_0 = NU_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, PC_14,
36+
PD_0 = NU_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,
37+
PE_0 = NU_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,
38+
PF_0 = NU_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,
39+
PG_0 = NU_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,
40+
PH_0 = NU_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,
41+
42+
// Arduino UNO naming
43+
A0 = PB_6,
44+
A1 = PB_7,
45+
A2 = PB_8,
46+
A3 = PB_9,
47+
A4 = PB_0,
48+
A5 = PB_1,
49+
50+
D0 = PB_2,
51+
D1 = PB_3,
52+
D2 = PC_9,
53+
D3 = PC_10,
54+
D4 = PC_11,
55+
D5 = PC_12,
56+
D6 = PE_4,
57+
D7 = PE_5,
58+
D8 = PA_5,
59+
D9 = PA_4,
60+
D10 = PA_3,
61+
D11 = PA_0,
62+
D12 = PA_1,
63+
D13 = PA_2,
64+
D14 = PG_1,
65+
D15 = PG_0,
66+
67+
// Note: board-specific
68+
// UART naming
69+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
70+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
71+
#else
72+
USBTX = NC,
73+
#endif
74+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
75+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
76+
#else
77+
USBRX = NC,
78+
#endif
79+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
80+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
81+
#else
82+
STDIO_UART_TX = USBTX,
83+
#endif
84+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
85+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
86+
#else
87+
STDIO_UART_RX = USBRX,
88+
#endif
89+
SERIAL_TX = D10,
90+
SERIAL_RX = D13,
91+
92+
// I2C naming
93+
I2C_SCL = D15,
94+
I2C_SDA = D14,
95+
96+
// LED naming
97+
LED_RED = PH_0,
98+
LED_YELLOW = PH_1,
99+
LED_GREEN = PH_2,
100+
LED1 = LED_RED,
101+
LED2 = LED_YELLOW,
102+
LED3 = LED_GREEN,
103+
LED4 = LED1, // No real LED. Just for passing ATS.
104+
105+
// Button naming
106+
SW2 = PF_11,
107+
SW3 = PG_5,
108+
BUTTON1 = SW2,
109+
BUTTON2 = SW3,
110+
111+
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
112+
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
113+
114+
} PinName;
115+
116+
#ifdef __cplusplus
117+
}
118+
#endif
119+
120+
#endif // MBED_PINNAMES_H
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright (c) 2020, Nuvoton Technology Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
#ifndef MBED_PINNAMES_H
19+
#define MBED_PINNAMES_H
20+
21+
#include "cmsis.h"
22+
#include "PinNamesCommon.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
typedef enum {
29+
// Not connected
30+
NC = (int)0xFFFFFFFF,
31+
32+
// Generic naming
33+
PA_0 = NU_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,
34+
PB_0 = NU_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,
35+
PC_0 = NU_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, PC_14,
36+
PD_0 = NU_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,
37+
PE_0 = NU_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,
38+
PF_0 = NU_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,
39+
PG_0 = NU_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,
40+
PH_0 = NU_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,
41+
42+
// Arduino UNO naming
43+
A0 = PB_6,
44+
A1 = PB_7,
45+
A2 = PB_8,
46+
A3 = PB_9,
47+
A4 = PB_0,
48+
A5 = PB_1,
49+
50+
D0 = PB_2,
51+
D1 = PB_3,
52+
D2 = PC_9,
53+
D3 = PC_10,
54+
D4 = PC_11,
55+
D5 = PC_12,
56+
D6 = PE_4,
57+
D7 = PE_5,
58+
D8 = PA_5,
59+
D9 = PA_4,
60+
D10 = PA_3,
61+
D11 = PA_0,
62+
D12 = PA_1,
63+
D13 = PA_2,
64+
D14 = PG_1,
65+
D15 = PG_0,
66+
67+
// Note: board-specific
68+
// UART naming
69+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
70+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
71+
#else
72+
USBTX = NC,
73+
#endif
74+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
75+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
76+
#else
77+
USBRX = NC,
78+
#endif
79+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
80+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
81+
#else
82+
STDIO_UART_TX = USBTX,
83+
#endif
84+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
85+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
86+
#else
87+
STDIO_UART_RX = USBRX,
88+
#endif
89+
SERIAL_TX = D10,
90+
SERIAL_RX = D13,
91+
92+
// I2C naming
93+
I2C_SCL = D15,
94+
I2C_SDA = D14,
95+
96+
// LED naming
97+
LED_RED = PH_0,
98+
LED_YELLOW = PH_1,
99+
LED_GREEN = PH_2,
100+
LED1 = LED_RED,
101+
LED2 = LED_YELLOW,
102+
LED3 = LED_GREEN,
103+
LED4 = LED1, // No real LED. Just for passing ATS.
104+
105+
// Button naming
106+
SW2 = PG_15,
107+
SW3 = PF_11,
108+
BUTTON1 = SW2,
109+
BUTTON2 = SW3,
110+
111+
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
112+
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
113+
114+
} PinName;
115+
116+
#ifdef __cplusplus
117+
}
118+
#endif
119+
120+
#endif // MBED_PINNAMES_H

0 commit comments

Comments
 (0)