Skip to content

Commit 408461b

Browse files
authored
Merge pull request #13382 from OpenNuvoton/nuvoton_m252_iot
M252: Support custom board
2 parents 0f3d614 + dde8f6f commit 408461b

File tree

10 files changed

+434
-133
lines changed

10 files changed

+434
-133
lines changed

targets/TARGET_NUVOTON/TARGET_M251/PeripheralNames.h

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

2222
#include "cmsis.h"
23+
#include "PinNames.h"
2324

2425
#ifdef __cplusplus
2526
extern "C" {
@@ -77,7 +78,16 @@ typedef enum {
7778
UART_2 = (int) NU_MODNAME(UART2_BASE, 2, 0),
7879

7980
/* NOTE: board-specific */
80-
STDIO_UART = UART_0
81+
#if defined(MBED_CONF_TARGET_USB_UART)
82+
USB_UART = MBED_CONF_TARGET_USB_UART,
83+
#else
84+
USB_UART = NC,
85+
#endif
86+
#if defined(MBED_CONF_TARGET_STDIO_UART)
87+
STDIO_UART = MBED_CONF_TARGET_STDIO_UART
88+
#else
89+
STDIO_UART = USB_UART
90+
#endif
8191
} UARTName;
8292

8393
typedef enum {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Nuvoton Technology Corporation
2+
* Copyright (c) 2020, Nuvoton Technology Corporation
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -15,9 +15,8 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
19-
#ifndef MBED_PINNAMES_H
20-
#define MBED_PINNAMES_H
18+
#ifndef __PIN_NAMES_COMMON_H__
19+
#define __PIN_NAMES_COMMON_H__
2120

2221
#include "cmsis.h"
2322

@@ -56,84 +55,19 @@ typedef enum {
5655
PullNone = 0,
5756
PullDown,
5857
PullUp,
59-
58+
6059
/* I/O mode */
6160
InputOnly,
6261
PushPullOutput,
6362
OpenDrain,
6463
QuasiBidirectional,
65-
64+
6665
/* Default input pull mode */
6766
PullDefault = PullUp
6867
} PinMode;
6968

70-
typedef enum {
71-
/* Not connected */
72-
NC = (int)0xFFFFFFFF,
73-
74-
/* Generic naming */
75-
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,
76-
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,
77-
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_14 = PC_12 + 2,
78-
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_15 = PD_13 + 2,
79-
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,
80-
PF_0 = NU_PINNAME(5, 0), PF_1, PF_2, PF_3, PF_4, PF_5, PF_6, PF_7, PF_14 = PF_7 + 7,
81-
82-
/* Arduino UNO naming */
83-
A0 = PB_7,
84-
A1 = PB_6,
85-
A2 = PB_5,
86-
A3 = PB_4,
87-
A4 = PB_0,
88-
A5 = PB_1,
89-
90-
D0 = PB_2,
91-
D1 = PB_3,
92-
D2 = PC_4,
93-
D3 = PC_5,
94-
D4 = PC_3,
95-
D5 = PC_2,
96-
D6 = PA_7,
97-
D7 = PA_6,
98-
D8 = PA_5,
99-
D9 = PA_4,
100-
D10 = PA_3,
101-
D11 = PA_0,
102-
D12 = PA_1,
103-
D13 = PA_2,
104-
D14 = PC_0,
105-
D15 = PC_1,
106-
107-
/* Other board-specific naming */
108-
109-
/* UART naming */
110-
USBTX = PB_13,
111-
USBRX = PB_12,
112-
STDIO_UART_TX = USBTX,
113-
STDIO_UART_RX = USBRX,
114-
SERIAL_TX = USBTX,
115-
SERIAL_RX = USBRX,
116-
117-
/* I2C naming */
118-
I2C_SCL = D15,
119-
I2C_SDA = D14,
120-
121-
/* LED naming */
122-
LED_RED = PB_14,
123-
LED1 = LED_RED,
124-
LED2 = LED1, // No real LED. Just for passing ATS.
125-
LED3 = LED1, // No real LED. Just for passing ATS.
126-
LED4 = LED1, // No real LED. Just for passing ATS.
127-
128-
/* Button naming */
129-
130-
/* Force PinName to 32-bit required by NU_PINNAME_BIND(...) */
131-
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
132-
133-
} PinName;
134-
13569
#ifdef __cplusplus
13670
}
13771
#endif
13872

139-
#endif // MBED_PINNAMES_H
73+
#endif // __PIN_NAMES_COMMON_H__
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright (c) 2019, 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 MBED_PINNAMES_H
20+
#define MBED_PINNAMES_H
21+
22+
#include "cmsis.h"
23+
#include "PinNamesCommon.h"
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
typedef enum {
30+
/* Not connected */
31+
NC = (int)0xFFFFFFFF,
32+
33+
/* Generic naming */
34+
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,
35+
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,
36+
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_14 = PC_12 + 2,
37+
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_15 = PD_13 + 2,
38+
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,
39+
PF_0 = NU_PINNAME(5, 0), PF_1, PF_2, PF_3, PF_4, PF_5, PF_6, PF_7, PF_14 = PF_7 + 7,
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 = D10,
90+
SERIAL_RX = D13,
91+
92+
/* I2C naming */
93+
I2C_SCL = D15,
94+
I2C_SDA = D14,
95+
96+
/* LED naming */
97+
LED_RED = PB_14,
98+
LED1 = LED_RED,
99+
LED2 = LED1, // No real LED. Just for passing ATS.
100+
LED3 = LED1, // No real LED. Just for passing ATS.
101+
LED4 = LED1, // No real LED. Just for passing ATS.
102+
103+
/* Button naming */
104+
105+
/* Force PinName to 32-bit required by NU_PINNAME_BIND(...) */
106+
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
107+
108+
} PinName;
109+
110+
#ifdef __cplusplus
111+
}
112+
#endif
113+
114+
#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 __M251_MEM_H__
20+
#define __M251_MEM_H__
21+
22+
/* About M251_mem.h/M251_mem.icf.h
23+
*
24+
* 1. M251_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 M251_mem.icf.h, duplicate of M251_mem.h
27+
* is created for IAR linker file.
28+
* 3. To continue above, we name M251_mem.icf.h instead of M251_mem.icf because:
29+
* (1) Mbed OS build tool may mis-regard M251_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 M251_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: 256KiB
39+
* SRAM size: 32KiB
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 (0x40000)
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 (0x8000)
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 /* __M251_MEM_H__ */

0 commit comments

Comments
 (0)