Skip to content

Commit 0a6e586

Browse files
authored
Merge pull request #12660 from OpenNuvoton/nuvoton_m2351_custom_board
M2351: Support custom board
2 parents 6cdb44e + e6823c6 commit 0a6e586

File tree

145 files changed

+567
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+567
-150
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/PeripheralNames.h

Lines changed: 15 additions & 3 deletions
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) 2015-2016, 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.
@@ -18,6 +20,7 @@
1820
#define MBED_PERIPHERALNAMES_H
1921

2022
#include "cmsis.h"
23+
#include "PinNames.h"
2124
#include "partition_M2351.h"
2225

2326
#ifdef __cplusplus
@@ -181,7 +184,16 @@ typedef enum {
181184
#endif
182185

183186
// NOTE: board-specific
184-
STDIO_UART = UART_0,
187+
#if defined(MBED_CONF_TARGET_USB_UART)
188+
USB_UART = MBED_CONF_TARGET_USB_UART,
189+
#else
190+
USB_UART = NC,
191+
#endif
192+
#if defined(MBED_CONF_TARGET_STDIO_UART)
193+
STDIO_UART = MBED_CONF_TARGET_STDIO_UART,
194+
#else
195+
STDIO_UART = USB_UART,
196+
#endif
185197

186198
} UARTName;
187199

targets/TARGET_NUVOTON/TARGET_M2351/PeripheralPins.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017-2018 Nuvoton
1+
/*
2+
* Copyright (c) 2017-2018, 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.

targets/TARGET_NUVOTON/TARGET_M2351/PeripheralPins.h

Lines changed: 4 additions & 2 deletions
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) 2015-2016, 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.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
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.
@@ -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_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__

targets/TARGET_NUVOTON/TARGET_M2351/PortNames.h

Lines changed: 4 additions & 2 deletions
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) 2015-2016, 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.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright (c) 2017-2018, 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+
#include "partition_M2351.h"
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
typedef enum {
31+
// Not connected
32+
NC = (int)0xFFFFFFFF,
33+
34+
// Generic naming
35+
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,
36+
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,
37+
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,
38+
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,
39+
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,
40+
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,
41+
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,
42+
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,
43+
44+
// Arduino UNO naming
45+
A0 = PB_11,
46+
A1 = PB_10,
47+
A2 = PB_9,
48+
A3 = PB_8,
49+
A4 = PB_4,
50+
A5 = PB_5,
51+
52+
D0 = PA_8,
53+
D1 = PA_9,
54+
D2 = PB_7,
55+
D3 = PB_6,
56+
D4 = PB_3,
57+
D5 = PB_2,
58+
D6 = PC_12,
59+
D7 = PC_11,
60+
D8 = PC_9,
61+
D9 = PC_10,
62+
D10 = PF_9,
63+
D11 = PF_6,
64+
D12 = PF_7,
65+
D13 = PF_8,
66+
D14 = PG_3,
67+
D15 = PG_2,
68+
69+
// Other board-specific naming
70+
71+
// UART naming
72+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
73+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
74+
#else
75+
USBTX = NC,
76+
#endif
77+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
78+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
79+
#else
80+
USBRX = NC,
81+
#endif
82+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
83+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
84+
#else
85+
STDIO_UART_TX = USBTX,
86+
#endif
87+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
88+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
89+
#else
90+
STDIO_UART_RX = USBRX,
91+
#endif
92+
93+
// I2C naming
94+
I2C_SCL = D15,
95+
I2C_SDA = D14,
96+
97+
// LED naming
98+
LED1 = PA_10,
99+
LED2 = PA_11,
100+
LED3 = PA_10, // No real LED. Just for passing ATS.
101+
LED4 = PA_11, // No real LED. Just for passing ATS.
102+
LED_GREEN = LED1,
103+
104+
// Button naming
105+
SW2 = PB_0,
106+
SW3 = PB_1,
107+
BUTTON1 = SW2,
108+
BUTTON2 = SW3,
109+
110+
// Force PinName to 32-bit required by NU_PINNAME_BIND(...)
111+
FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF,
112+
113+
} PinName;
114+
115+
#ifdef __cplusplus
116+
}
117+
#endif
118+
119+
#endif // MBED_PINNAMES_H

targets/TARGET_NUVOTON/TARGET_M2351/analogin_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017-2018 Nuvoton
1+
/*
2+
* Copyright (c) 2017-2018, 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.

targets/TARGET_NUVOTON/TARGET_M2351/analogout_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2018, Nuvoton Technology Corporation
3+
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017-2018 Nuvoton
1+
/*
2+
* Copyright (c) 2017-2018, 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.
@@ -14,7 +16,6 @@
1416
* limitations under the License.
1517
*/
1618

17-
1819
#include "cmsis.h"
1920
#include "mbed_assert.h"
2021
#include "mbed_atomic.h"

targets/TARGET_NUVOTON/TARGET_M2351/crypto/crypto-misc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017-2018 Nuvoton
1+
/*
2+
* Copyright (c) 2017-2018, 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.

targets/TARGET_NUVOTON/TARGET_M2351/device.h

Lines changed: 4 additions & 2 deletions
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) 2015-2016, 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.

targets/TARGET_NUVOTON/TARGET_M2351/device/M2351.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* @brief Peripheral Access Layer Header File
55
*
66
* @note
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
710
* Copyright (C) 2017 Nuvoton Technology Corp. All rights reserved.
811
*
912
******************************************************************************/

targets/TARGET_NUVOTON/TARGET_M2351/device/Reg/NuMicro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* @version V1.00
44
* @brief NuMicro peripheral access layer header file.
55
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*
68
* @copyright (C) 2017 Nuvoton Technology Corp. All rights reserved.
79
*****************************************************************************/
810
#ifndef __NUMICRO_H__

0 commit comments

Comments
 (0)