Skip to content

Commit e9f22fe

Browse files
author
Daniel Lee
committed
Add a Realtek RTL8710AF as target device
1 parent daefce6 commit e9f22fe

File tree

22 files changed

+2330
-2
lines changed

22 files changed

+2330
-2
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ nsapi_error_t RTWInterface::disconnect()
255255
return NSAPI_ERROR_DEVICE_ERROR;
256256
}
257257
while(1) {
258+
wait(0.1);
258259
if (wext_get_ssid(WLAN0_NAME, (unsigned char *) essid) < 0) {
259260
break;
260261
}

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_MCU_RTL8195A/analogin_ext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
extern "C" {
2121
#endif
2222

23+
#if CONFIG_ADC_EN
2324
extern void analogin_deinit(analogin_t *obj);
25+
#endif
2426

2527
#ifdef __cplusplus
2628
}

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_MCU_RTL8195A/device/platform_autoconf.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@
3232
#undef CONFIG_FT
3333
#define RTL8195A 1
3434
#define CONFIG_CPU_CLK 1
35+
#if defined(TARGET_RTL8195A)
3536
#define CONFIG_CPU_166_6MHZ 1
3637
#undef CONFIG_CPU_83_3MHZ
38+
#define PLATFORM_CLOCK (166666666)
39+
#else
40+
#undef CONFIG_CPU_166_6MHZ
41+
#define CONFIG_CPU_83_3MHZ 1
42+
#define PLATFORM_CLOCK (166666666/2)
43+
#endif
3744
#undef CONFIG_CPU_41_6MHZ
3845
#undef CONFIG_CPU_20_8MHZ
3946
#undef CONFIG_CPU_10_4MHZ
4047
#undef CONFIG_CPU_4MHZ
4148
#undef CONFIG_FPGA_CLK
42-
#define PLATFORM_CLOCK (166666666)
4349
#define CPU_CLOCK_SEL_VALUE (0)
4450
#define CONFIG_SDR_CLK 1
4551
#define CONFIG_SDR_100MHZ 1
@@ -178,8 +184,13 @@
178184
#define CONFIG_SPIC_NORMAL 1
179185
#undef CONFIG_SPIC_TEST
180186
#define CONFIG_SPIC_MODULE 1
187+
#if defined(TARGET_RTL8710A)
188+
#undef CONFIG_ADC_EN
189+
#undef CONFIG_DAC_EN
190+
#else
181191
#define CONFIG_ADC_EN 1
182192
#define CONFIG_DAC_EN 1
193+
#endif
183194
#define CONFIG_NOR_FLASH 1
184195
#undef CONFIG_SPI_FLASH
185196
#undef CONFIG_NAND_FLASH

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_MCU_RTL8195A/flash_ext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ extern "C" {
2424
#endif
2525

2626
#define FLASH_PAGE_SIZE 256
27+
#if defined(TARGET_RTL8710A)
28+
#define FLASH_SIZE 0x100000
29+
#else
2730
#define FLASH_SIZE 0x200000
31+
#endif
2832
#define FLASH_OFS_START 0x0
2933
#define FLASH_OFS_END (FLASH_OFS_START + FLASH_SIZE)
3034

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 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_PERIPHERALNAMES_H
17+
#define MBED_PERIPHERALNAMES_H
18+
19+
#include "cmsis.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
#define UART_3 3
26+
#define STDIO_UART_TX PB_0
27+
#define STDIO_UART_RX PB_1
28+
#define STDIO_UART UART_3
29+
30+
31+
typedef enum {
32+
DAC_0 = 0,
33+
DAC_1
34+
} DACName;
35+
36+
37+
#ifdef __cplusplus
38+
}
39+
#endif
40+
41+
#endif
42+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 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+
17+
#include "PeripheralPins.h"
18+
19+
// for spi_api.c
20+
const PinMap PinMap_SSI_MOSI[] = {
21+
{PC_2, RTL_PIN_PERI(SPI0, 0, S1), RTL_PIN_FUNC(SPI0, S1)},
22+
{NC, NC, 0}
23+
};
24+
25+
const PinMap PinMap_SSI_MISO[] = {
26+
{PC_3, RTL_PIN_PERI(SPI0, 0, S1), RTL_PIN_FUNC(SPI0, S1)},
27+
{NC, NC, 0}
28+
};
29+
30+
// for serial_api.c
31+
const PinMap PinMap_UART_TX[] = {
32+
{PA_4, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)},
33+
{PB_0, RTL_PIN_PERI(LOG_UART, 3, S0), RTL_PIN_FUNC(LOG_UART, S0)},
34+
{NC, NC, 0}
35+
};
36+
37+
const PinMap PinMap_UART_RX[] = {
38+
{PA_0, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)},
39+
{PB_1, RTL_PIN_PERI(LOG_UART, 3, S0), RTL_PIN_FUNC(LOG_UART, S0)},
40+
{NC, NC, 0}
41+
};
42+
43+
// for i2c_api.c
44+
const PinMap PinMap_I2C_SDA[] = {
45+
{PB_3, RTL_PIN_PERI(I2C3, 3, S0), RTL_PIN_FUNC(I2C3, S0)},
46+
{NC, NC, 0}
47+
};
48+
49+
const PinMap PinMap_I2C_SCL[] = {
50+
{PB_2, RTL_PIN_PERI(I2C3, 3, S0), RTL_PIN_FUNC(I2C3, S0)},
51+
{NC, NC, 0}
52+
};
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 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 _PINNAMES_H_
17+
#define _PINNAMES_H_
18+
19+
#include "cmsis.h"
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
typedef enum {
26+
PORT_A = 0,
27+
PORT_B = 1,
28+
PORT_C = 2,
29+
PORT_D = 3,
30+
PORT_E = 4,
31+
PORT_F = 5,
32+
PORT_G = 6,
33+
PORT_H = 7,
34+
PORT_I = 8,
35+
PORT_J = 9,
36+
PORT_K = 10,
37+
38+
PORT_V = 11,
39+
PORT_U = 12,
40+
PORT_MAX
41+
} GPIO_PORT;
42+
43+
#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL)))
44+
#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL)))
45+
#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F))
46+
#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F))
47+
48+
typedef enum {
49+
PIN_INPUT=0,
50+
PIN_OUTPUT
51+
} PinDirection;
52+
53+
54+
typedef enum {
55+
PA_0 = (PORT_A<<4|0),
56+
PA_1 = (PORT_A<<4|1),
57+
PA_2 = (PORT_A<<4|2),
58+
PA_3 = (PORT_A<<4|3),
59+
PA_4 = (PORT_A<<4|4),
60+
PA_5 = (PORT_A<<4|5),
61+
PA_6 = (PORT_A<<4|6),
62+
PA_7 = (PORT_A<<4|7),
63+
64+
PB_0 = (PORT_B<<4|0),
65+
PB_1 = (PORT_B<<4|1),
66+
PB_2 = (PORT_B<<4|2),
67+
PB_3 = (PORT_B<<4|3),
68+
PB_4 = (PORT_B<<4|4),
69+
PB_5 = (PORT_B<<4|5),
70+
PB_6 = (PORT_B<<4|6),
71+
PB_7 = (PORT_B<<4|7),
72+
73+
PC_0 = (PORT_C<<4|0),
74+
PC_1 = (PORT_C<<4|1),
75+
PC_2 = (PORT_C<<4|2),
76+
PC_3 = (PORT_C<<4|3),
77+
PC_4 = (PORT_C<<4|4),
78+
PC_5 = (PORT_C<<4|5),
79+
PC_6 = (PORT_C<<4|6),
80+
PC_7 = (PORT_C<<4|7),
81+
PC_8 = (PORT_C<<4|8),
82+
PC_9 = (PORT_C<<4|9),
83+
84+
PD_0 = (PORT_D<<4|0),
85+
PD_1 = (PORT_D<<4|1),
86+
PD_2 = (PORT_D<<4|2),
87+
PD_3 = (PORT_D<<4|3),
88+
PD_4 = (PORT_D<<4|4),
89+
PD_5 = (PORT_D<<4|5),
90+
PD_6 = (PORT_D<<4|6),
91+
PD_7 = (PORT_D<<4|7),
92+
PD_8 = (PORT_D<<4|8),
93+
PD_9 = (PORT_D<<4|9),
94+
95+
PE_0 = (PORT_E<<4|0),
96+
PE_1 = (PORT_E<<4|1),
97+
PE_2 = (PORT_E<<4|2),
98+
PE_3 = (PORT_E<<4|3),
99+
PE_4 = (PORT_E<<4|4),
100+
PE_5 = (PORT_E<<4|5),
101+
PE_6 = (PORT_E<<4|6),
102+
PE_7 = (PORT_E<<4|7),
103+
PE_8 = (PORT_E<<4|8),
104+
PE_9 = (PORT_E<<4|9),
105+
PE_A = (PORT_E<<4|10),
106+
107+
PF_0 = (PORT_F<<4|0),
108+
PF_1 = (PORT_F<<4|1),
109+
PF_2 = (PORT_F<<4|2),
110+
PF_3 = (PORT_F<<4|3),
111+
PF_4 = (PORT_F<<4|4),
112+
PF_5 = (PORT_F<<4|5),
113+
/* unavailable pins */
114+
// PF_6 = (PORT_F<<4|6),
115+
// PF_7 = (PORT_F<<4|7),
116+
117+
PG_0 = (PORT_G<<4|0),
118+
PG_1 = (PORT_G<<4|1),
119+
PG_2 = (PORT_G<<4|2),
120+
PG_3 = (PORT_G<<4|3),
121+
PG_4 = (PORT_G<<4|4),
122+
PG_5 = (PORT_G<<4|5),
123+
PG_6 = (PORT_G<<4|6),
124+
PG_7 = (PORT_G<<4|7),
125+
126+
PH_0 = (PORT_H<<4|0),
127+
PH_1 = (PORT_H<<4|1),
128+
PH_2 = (PORT_H<<4|2),
129+
PH_3 = (PORT_H<<4|3),
130+
PH_4 = (PORT_H<<4|4),
131+
PH_5 = (PORT_H<<4|5),
132+
PH_6 = (PORT_H<<4|6),
133+
PH_7 = (PORT_H<<4|7),
134+
135+
PI_0 = (PORT_I<<4|0),
136+
PI_1 = (PORT_I<<4|1),
137+
PI_2 = (PORT_I<<4|2),
138+
PI_3 = (PORT_I<<4|3),
139+
PI_4 = (PORT_I<<4|4),
140+
PI_5 = (PORT_I<<4|5),
141+
PI_6 = (PORT_I<<4|6),
142+
PI_7 = (PORT_I<<4|7),
143+
144+
PJ_0 = (PORT_J<<4|0),
145+
PJ_1 = (PORT_J<<4|1),
146+
PJ_2 = (PORT_J<<4|2),
147+
PJ_3 = (PORT_J<<4|3),
148+
PJ_4 = (PORT_J<<4|4),
149+
PJ_5 = (PORT_J<<4|5),
150+
PJ_6 = (PORT_J<<4|6),
151+
/* unavailable pins */
152+
// PJ_7 = (PORT_J<<4|7),
153+
154+
PK_0 = (PORT_K<<4|0),
155+
PK_1 = (PORT_K<<4|1),
156+
PK_2 = (PORT_K<<4|2),
157+
PK_3 = (PORT_K<<4|3),
158+
PK_4 = (PORT_K<<4|4),
159+
PK_5 = (PORT_K<<4|5),
160+
PK_6 = (PORT_K<<4|6),
161+
/* unavailable pins */
162+
// PK_7 = (PORT_K<<4|7),
163+
164+
AD_1 = (PORT_V<<4|1),
165+
AD_2 = (PORT_V<<4|2),
166+
AD_3 = (PORT_V<<4|3),
167+
168+
DA_0 = (PORT_U<<4|0),
169+
DA_1 = (PORT_U<<4|1),
170+
171+
// Not connected
172+
NC = (int)0xFFFFFFFF,
173+
174+
// Generic signals namings
175+
/* LED1~4 are defined as alias of GPIO pins, they are not the LEDs on board*/
176+
// Pinmap is followed PADI IoT Stamp Pinout Diagram:
177+
// http://files.pine64.org/doc/PADI/documentation/padi-pinout-diagram.pdf
178+
LED1 = PA_5,
179+
LED2 = PA_5,
180+
LED3 = PA_5,
181+
LED4 = PA_5,
182+
SERIAL_TX = PA_4,
183+
SERIAL_RX = PA_0,
184+
USBTX = PB_0,
185+
USBRX = PB_1,
186+
I2C_SCL = PB_2,
187+
I2C_SDA = PB_3,
188+
SPI_MOSI = PC_2,
189+
SPI_MISO = PC_3,
190+
SPI_SCK = PC_1,
191+
SPI_CS = PC_0,
192+
193+
} PinName;
194+
195+
typedef enum {
196+
PullNone = 0,
197+
PullUp = 1,
198+
PullDown = 2,
199+
OpenDrain = 3,
200+
PullDefault = PullNone
201+
} PinMode;
202+
203+
#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF)
204+
#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF)
205+
206+
#ifdef __cplusplus
207+
}
208+
#endif
209+
210+
#endif

0 commit comments

Comments
 (0)