Skip to content

Commit 2c5660a

Browse files
authored
Merge pull request #12642 from OpenNuvoton/nuvoton_m263_custom_board
M263: Support custom board
2 parents e805b58 + f5cb899 commit 2c5660a

File tree

10 files changed

+447
-114
lines changed

10 files changed

+447
-114
lines changed

targets/TARGET_NUVOTON/TARGET_M261/PeripheralNames.h

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

2121
#include "cmsis.h"
22+
#include "PinNames.h"
2223

2324
#ifdef __cplusplus
2425
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

8595
} UARTName;
8696

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright (c) 2019-2020 Nuvoton Technology Corporation
1+
/*
2+
* Copyright (c) 2020, Nuvoton Technology Corporation
3+
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,8 +15,8 @@
1415
* See the License for the specific language governing permissions and
1516
* limitations under the License.
1617
*/
17-
#ifndef MBED_PINNAMES_H
18-
#define MBED_PINNAMES_H
18+
#ifndef __PIN_NAMES_COMMON_H__
19+
#define __PIN_NAMES_COMMON_H__
1920

2021
#include "cmsis.h"
2122

@@ -60,88 +61,19 @@ typedef enum {
6061
PullNone = 0,
6162
PullDown,
6263
PullUp,
63-
64+
6465
/* I/O mode */
6566
InputOnly,
6667
PushPullOutput,
6768
OpenDrain,
6869
QuasiBidirectional,
69-
70+
7071
/* Default input pull mode */
7172
PullDefault = PullUp
7273
} PinMode;
7374

74-
typedef enum {
75-
// Not connected
76-
NC = (int)0xFFFFFFFF,
77-
78-
// Generic naming
79-
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,
80-
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,
81-
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,
82-
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,
83-
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,
84-
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,
85-
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,
86-
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,
87-
88-
// Arduino UNO naming
89-
A0 = PB_7,
90-
A1 = PB_6,
91-
A2 = PB_5,
92-
A3 = PB_4,
93-
A4 = PB_0,
94-
A5 = PB_1,
95-
96-
D0 = PB_2,
97-
D1 = PB_3,
98-
D2 = PC_4,
99-
D3 = PC_5,
100-
D4 = PC_3,
101-
D5 = PC_2,
102-
D6 = PA_7,
103-
D7 = PA_6,
104-
D8 = PA_5,
105-
D9 = PA_4,
106-
D10 = PA_3,
107-
D11 = PA_0,
108-
D12 = PA_1,
109-
D13 = PA_2,
110-
D14 = PC_0,
111-
D15 = PC_1,
112-
113-
// Other board-specific naming
114-
115-
// UART naming
116-
USBTX = PB_13,
117-
USBRX = PB_12,
118-
STDIO_UART_TX = USBTX,
119-
STDIO_UART_RX = USBRX,
120-
121-
// I2C naming
122-
I2C_SCL = D15,
123-
I2C_SDA = D14,
124-
125-
// LED naming
126-
LED1 = PB_10,
127-
LED2 = PB_10,
128-
LED3 = PB_10, // No real LED. Just for passing ATS.
129-
LED4 = PB_10, // No real LED. Just for passing ATS.
130-
LED_RED = LED1,
131-
132-
// Button naming
133-
SW2 = PB_11,
134-
SW3 = PB_11,
135-
BUTTON1 = SW2,
136-
BUTTON2 = SW3,
137-
138-
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
139-
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
140-
141-
} PinName;
142-
14375
#ifdef __cplusplus
14476
}
14577
#endif
14678

147-
#endif // MBED_PINNAMES_H
79+
#endif // __PIN_NAMES_COMMON_H__
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright (c) 2019-2020 Nuvoton Technology Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef MBED_PINNAMES_H
18+
#define MBED_PINNAMES_H
19+
20+
#include "cmsis.h"
21+
#include "PinNamesCommon.h"
22+
23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
27+
typedef enum {
28+
// Not connected
29+
NC = (int)0xFFFFFFFF,
30+
31+
// Generic naming
32+
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,
33+
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,
34+
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,
35+
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,
36+
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,
37+
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,
38+
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,
39+
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,
40+
41+
// Arduino UNO naming
42+
A0 = PB_7,
43+
A1 = PB_6,
44+
A2 = PB_5,
45+
A3 = PB_4,
46+
A4 = PB_0,
47+
A5 = PB_1,
48+
49+
D0 = PB_2,
50+
D1 = PB_3,
51+
D2 = PC_4,
52+
D3 = PC_5,
53+
D4 = PC_3,
54+
D5 = PC_2,
55+
D6 = PA_7,
56+
D7 = PA_6,
57+
D8 = PA_5,
58+
D9 = PA_4,
59+
D10 = PA_3,
60+
D11 = PA_0,
61+
D12 = PA_1,
62+
D13 = PA_2,
63+
D14 = PC_0,
64+
D15 = PC_1,
65+
66+
// Other board-specific naming
67+
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 = D1,
90+
SERIAL_RX = D0,
91+
92+
// I2C naming
93+
I2C_SCL = D15,
94+
I2C_SDA = D14,
95+
96+
// LED naming
97+
LED1 = PB_10,
98+
LED2 = PB_10,
99+
LED3 = PB_10, // No real LED. Just for passing ATS.
100+
LED4 = PB_10, // No real LED. Just for passing ATS.
101+
LED_RED = LED1,
102+
103+
// Button naming
104+
SW2 = PB_11,
105+
SW3 = PB_11,
106+
BUTTON1 = SW2,
107+
BUTTON2 = SW3,
108+
109+
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
110+
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
111+
112+
} PinName;
113+
114+
#ifdef __cplusplus
115+
}
116+
#endif
117+
118+
#endif // MBED_PINNAMES_H
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
19+
#ifndef __M261_MEM_H__
20+
#define __M261_MEM_H__
21+
22+
/* About M261_mem.h/M261_mem.icf.h
23+
*
24+
* 1. M261_mem.h is created for centralizing memory configuration. It will be included by C/C++ files
25+
* and linker files (except IAR linker file).
26+
* 2. IAR linker doesn't support preprocessor, so M261_mem.icf.h, duplicate of M261_mem.h
27+
* is created for IAR linker file.
28+
* 3. To continue above, we name M261_mem.icf.h instead of M261_mem.icf because:
29+
* (1) Mbed OS build tool may mis-regard M261_mem.icf as the main linker configuration file.
30+
* (2) *.icf files may not be present in search directories for "include" directive. Per observation,
31+
* the search directories are inconsistent among normal example build and test code build. To address
32+
* it, we name M261_mem.icf.h instead because *.h files are always present in these builds
33+
* (already there or via copy).
34+
*/
35+
36+
/* Default memory specification
37+
*
38+
* Flash size: 512KiB
39+
* SRAM size: 96KiB
40+
*/
41+
42+
/* Resolve ROM start */
43+
#ifndef MBED_ROM_START
44+
#define MBED_ROM_START (0x0)
45+
#endif
46+
47+
/* Resolve ROM size */
48+
#ifndef MBED_ROM_SIZE
49+
#define MBED_ROM_SIZE (0x80000)
50+
#endif
51+
52+
/* Resolve RAM start */
53+
#ifndef MBED_RAM_START
54+
#define MBED_RAM_START (0x20000000)
55+
#endif
56+
57+
/* Resolve RAM size */
58+
#ifndef MBED_RAM_SIZE
59+
#define MBED_RAM_SIZE (0x18000)
60+
#endif
61+
62+
63+
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
64+
* MBED_APP_xxx macros to linker files even though they mean the same thing.
65+
* Because this file is to include by both C/C++ files and linker files, we add
66+
* these macros according to the others for consistency when they are missing
67+
* in compile or link stage. */
68+
69+
#ifndef APPLICATION_ADDR
70+
#ifdef MBED_APP_START
71+
#define APPLICATION_ADDR MBED_APP_START
72+
#else
73+
#define APPLICATION_ADDR MBED_ROM_START
74+
#endif
75+
#endif
76+
77+
#ifndef APPLICATION_SIZE
78+
#ifdef MBED_APP_SIZE
79+
#define APPLICATION_SIZE MBED_APP_SIZE
80+
#else
81+
#define APPLICATION_SIZE MBED_ROM_SIZE
82+
#endif
83+
#endif
84+
85+
#ifndef APPLICATION_RAM_ADDR
86+
#ifdef MBED_RAM_APP_START
87+
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
88+
#else
89+
#define APPLICATION_RAM_ADDR MBED_RAM_START
90+
#endif
91+
#endif
92+
93+
#ifndef APPLICATION_RAM_SIZE
94+
#ifdef MBED_RAM_APP_SIZE
95+
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
96+
#else
97+
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
98+
#endif
99+
#endif
100+
101+
#ifndef MBED_APP_START
102+
#define MBED_APP_START APPLICATION_ADDR
103+
#endif
104+
105+
#ifndef MBED_APP_SIZE
106+
#define MBED_APP_SIZE APPLICATION_SIZE
107+
#endif
108+
109+
#ifndef MBED_RAM_APP_START
110+
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
111+
#endif
112+
113+
#ifndef MBED_RAM_APP_SIZE
114+
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
115+
#endif
116+
117+
#if (APPLICATION_ADDR != MBED_APP_START)
118+
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
119+
#endif
120+
121+
#if (APPLICATION_SIZE != MBED_APP_SIZE)
122+
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
123+
#endif
124+
125+
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
126+
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
127+
#endif
128+
129+
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
130+
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
131+
#endif
132+
133+
#endif /* __M261_MEM_H__ */

0 commit comments

Comments
 (0)