Skip to content

Commit 45dbe35

Browse files
committed
Merge pull request #1490 from ytsuboi/add-TY51822r3
[TY51822r3] add platform
2 parents 6010f32 + 9b7d776 commit 45dbe35

File tree

6 files changed

+281
-0
lines changed

6 files changed

+281
-0
lines changed

libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/system_nrf51.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ void SystemCoreClockUpdate(void)
6161

6262
void SystemInit(void)
6363
{
64+
#if defined(TARGET_NRF_32MHZ_XTAL)
65+
/* For 32MHz HFCLK XTAL such as Taiyo Yuden
66+
Physically, tiny footprint XTAL oscillate higher freq. To make BLE modules smaller, some modules
67+
are using 32MHz XTAL.
68+
This code wriging the value 0xFFFFFF00 to the UICR (User Information Configuration Register)
69+
at address 0x10001008, to make nRF51 works with 32MHz system clock. This register will be overwritten
70+
by SoftDevice to 0xFFFFFFFF, the default value. Each hex files built with mbed classic online compiler
71+
contain SoftDevice, so that, this code run once just after the hex file will be flashed onto nRF51.
72+
After changing the value, nRF51 need to reboot. */
73+
if (*(uint32_t *)0x10001008 == 0xFFFFFFFF)
74+
{
75+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
76+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
77+
*(uint32_t *)0x10001008 = 0xFFFFFF00;
78+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
79+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
80+
NVIC_SystemReset();
81+
while (true){}
82+
}
83+
#endif
84+
6485
/* If desired, switch off the unused RAM to lower consumption by the use of RAMON register.
6586
It can also be done in the application main() function. */
6687

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2015 Nordic Semiconductor
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef MBED_PINNAMES_H
17+
#define MBED_PINNAMES_H
18+
19+
#include "cmsis.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
typedef enum {
26+
PIN_INPUT,
27+
PIN_OUTPUT
28+
} PinDirection;
29+
30+
#define PORT_SHIFT 3
31+
32+
typedef enum {
33+
p0 = 0,
34+
p1 = 1,
35+
p2 = 2,
36+
p3 = 3,
37+
p4 = 4,
38+
p5 = 5,
39+
p6 = 6,
40+
p7 = 7,
41+
p8 = 8,
42+
p9 = 9,
43+
p10 = 10,
44+
p11 = 11,
45+
p12 = 12,
46+
p13 = 13,
47+
p14 = 14,
48+
p15 = 15,
49+
p16 = 16,
50+
p17 = 17,
51+
p18 = 18,
52+
p19 = 19,
53+
p20 = 20,
54+
p21 = 21,
55+
p22 = 22,
56+
p23 = 23,
57+
p24 = 24,
58+
p25 = 25,
59+
p26 = 26,
60+
p27 = 27,
61+
p28 = 28,
62+
p29 = 29,
63+
p30 = 30,
64+
65+
P0_0 = p0,
66+
P0_1 = p1,
67+
P0_2 = p2,
68+
P0_3 = p3,
69+
P0_4 = p4,
70+
P0_5 = p5,
71+
P0_6 = p6,
72+
P0_7 = p7,
73+
74+
P0_8 = p8,
75+
P0_9 = p9,
76+
P0_10 = p10,
77+
P0_11 = p11,
78+
P0_12 = p12,
79+
P0_13 = p13,
80+
P0_14 = p14,
81+
P0_15 = p15,
82+
83+
P0_16 = p16,
84+
P0_17 = p17,
85+
P0_18 = p18,
86+
P0_19 = p19,
87+
P0_20 = p20,
88+
P0_21 = p21,
89+
P0_22 = p22,
90+
P0_23 = p23,
91+
92+
P0_24 = p24,
93+
P0_25 = p25,
94+
P0_26 = p26,
95+
P0_27 = p27,
96+
P0_28 = p28,
97+
P0_29 = p29,
98+
P0_30 = p30,
99+
100+
LED1 = p21,
101+
LED2 = p22,
102+
LED3 = p23,
103+
LED4 = p24,
104+
105+
BUTTON1 = p17,
106+
BUTTON2 = p18,
107+
BUTTON3 = p19,
108+
BUTTON4 = p20,
109+
110+
RX_PIN_NUMBER = p11,
111+
TX_PIN_NUMBER = p9,
112+
CTS_PIN_NUMBER = p10,
113+
RTS_PIN_NUMBER = p8,
114+
115+
// mBed interface Pins
116+
USBTX = TX_PIN_NUMBER,
117+
USBRX = RX_PIN_NUMBER,
118+
119+
SPI_PSELMOSI0 = p25,
120+
SPI_PSELMISO0 = p28,
121+
SPI_PSELSS0 = p24,
122+
SPI_PSELSCK0 = p29,
123+
124+
SPI_PSELMOSI1 = p13,
125+
SPI_PSELMISO1 = p14,
126+
SPI_PSELSS1 = p12,
127+
SPI_PSELSCK1 = p15,
128+
129+
SPIS_PSELMOSI = p13,
130+
SPIS_PSELMISO = p14,
131+
SPIS_PSELSS = p12,
132+
SPIS_PSELSCK = p15,
133+
134+
I2C_SDA0 = p30,
135+
I2C_SCL0 = p7,
136+
137+
D0 = p12,
138+
D1 = p13,
139+
D2 = p14,
140+
D3 = p15,
141+
D4 = p16,
142+
D5 = p17,
143+
D6 = p18,
144+
D7 = p19,
145+
146+
D8 = p20,
147+
D9 = p23,
148+
D10 = p24,
149+
D11 = p25,
150+
D12 = p28,
151+
D13 = p29,
152+
153+
D14 = p30,
154+
D15 = p7,
155+
156+
A0 = p1,
157+
A1 = p2,
158+
A2 = p3,
159+
A3 = p4,
160+
A4 = p5,
161+
A5 = p6,
162+
163+
// Not connected
164+
NC = (int)0xFFFFFFFF
165+
} PinName;
166+
167+
typedef enum {
168+
PullNone = 0,
169+
PullDown = 1,
170+
PullUp = 3,
171+
PullDefault = PullUp
172+
} PinMode;
173+
174+
#ifdef __cplusplus
175+
}
176+
#endif
177+
178+
#endif
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2015 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef MBED_DEVICE_H
17+
#define MBED_DEVICE_H
18+
19+
#define DEVICE_PORTIN 1
20+
#define DEVICE_PORTOUT 1
21+
#define DEVICE_PORTINOUT 1
22+
23+
#define DEVICE_INTERRUPTIN 1
24+
25+
#define DEVICE_ANALOGIN 1
26+
#define DEVICE_ANALOGOUT 0
27+
28+
#define DEVICE_SERIAL 1
29+
30+
#define DEVICE_I2C 1
31+
#define DEVICE_I2CSLAVE 0
32+
33+
#define DEVICE_SPI 1
34+
#define DEVICE_SPISLAVE 1
35+
36+
#define DEVICE_CAN 0
37+
38+
#define DEVICE_RTC 0
39+
40+
#define DEVICE_ETHERNET 0
41+
42+
#define DEVICE_PWMOUT 1
43+
44+
#define DEVICE_SEMIHOST 0
45+
#define DEVICE_LOCALFILESYSTEM 0
46+
47+
#define DEVICE_SLEEP 1
48+
49+
#define DEVICE_DEBUG_AWARENESS 0
50+
51+
#define DEVICE_STDIO_MESSAGES 0
52+
53+
#define DEVICE_ERROR_PATTERN 1
54+
55+
#include "objects.h"
56+
57+
#endif

workspace_tools/build_release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
('DELTA_DFCM_NNN40', ('ARM', 'GCC_ARM')),
108108
('NRF51_MICROBIT', ('ARM',)),
109109
('NRF51_MICROBIT_B', ('ARM',)),
110+
('TY51822R3', ('ARM', 'GCC_ARM')),
110111

111112
('LPC11U68', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')),
112113
('OC_MBUINO', ('ARM', 'uARM', 'GCC_ARM', 'IAR')),

workspace_tools/targets.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,26 @@ def __init__(self):
15281528
self.extra_labels += ['NRF51_MICROBIT']
15291529
self.macros += ['TARGET_NRF51_MICROBIT', 'TARGET_NRF_LFCLK_RC']
15301530

1531+
class TY51822R3(MCU_NRF51_32K):
1532+
def __init__(self):
1533+
MCU_NRF51_32K.__init__(self)
1534+
self.macros += ['TARGET_NRF_32MHZ_XTAL']
1535+
self.supported_toolchains = ["ARM", "GCC_ARM"]
1536+
1537+
class TY51822R3_BOOT(MCU_NRF51_32K_BOOT):
1538+
def __init__(self):
1539+
MCU_NRF51_32K_BOOT.__init__(self)
1540+
self.extra_labels += ['TY51822R3']
1541+
self.macros += ['TARGET_TY51822R3', 'TARGET_NRF_32MHZ_XTAL']
1542+
self.supported_toolchains = ["ARM", "GCC_ARM"]
1543+
1544+
class TY51822R3_OTA(MCU_NRF51_32K_OTA):
1545+
def __init__(self):
1546+
MCU_NRF51_32K_OTA.__init__(self)
1547+
self.extra_labels += ['NRF51_DK']
1548+
self.macros += ['TARGET_TY51822R3', 'TARGET_NRF_32MHZ_XTAL']
1549+
self.supported_toolchains = ["ARM", "GCC_ARM"]
1550+
15311551

15321552
### ARM ###
15331553

@@ -1903,6 +1923,9 @@ def __init__(self):
19031923
NRF51_MICROBIT_B(), # nRF51_16K - default
19041924
NRF51_MICROBIT_B_BOOT(),# nRF51_16K - default
19051925
NRF51_MICROBIT_B_OTA(), # nRF51_16K - default
1926+
TY51822R3(), # nRF51_32K
1927+
TY51822R3_BOOT(), # nRF51_32K
1928+
TY51822R3_OTA(), # nRF51_32K
19061929

19071930

19081931
### ARM ###

workspace_tools/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@
463463
"NRF51_MICROBIT", "NRF51_MICROBIT_B", "NRF51_MICROBIT_BOOT",
464464
"NRF51_MICROBIT_B_BOOT", "NRF51_MICROBIT_B_OTA", "NRF51_MICROBIT_OTA",
465465
"HRM1017", "HRM1017_BOOT", "HRM1701_OTA",
466+
"TY51822R3", "TY51822R3_BOOT", "TY51822R3_OTA",
466467
"NRF15_DONGLE", "NRF15_DONGLE_BOOT", "NRF15_DONGLE_OTA",
467468
"ARCH_BLE", "ARCH_BLE_BOOT", "ARCH_BLE_OTA",
468469
"ARCH_LINK", "ARCH_LINK_BOOT", "ARCH_LINK_OTA",

0 commit comments

Comments
 (0)