Skip to content

Commit e16c2d2

Browse files
committed
Add RTW8195AM support for mbed client with ARMCC
Move ticker related code to SRAM due to time drift sensitive
1 parent 56a98e1 commit e16c2d2

File tree

7 files changed

+49
-24
lines changed

7 files changed

+49
-24
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/TOOLCHAIN_ARM_STD/rtl8195a.sct

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,50 @@ LR_IRAM 0x10007000 (0x70000 - 0x7000) {
1818
}
1919

2020
ER_IRAM +0 FIXED {
21-
*rtl8195a_crypto.o(.text*, .rodata*)
22-
*mbedtls*.o(.text*, .rodata*)
23-
libc.a: (.text*, .rodata*)
21+
*rtl8195a_crypto.o (+RO)
22+
* (i.mbedtls*)
23+
*libc.a (+RO)
24+
25+
*rtx_*.o (+RO)
26+
*Ticker.o (+RO)
27+
*Timeout.o (+RO)
28+
*rtx_timer.o (+RO)
29+
*TimerEvent.o (+RO)
30+
*mbed_ticker_api.o (+RO)
31+
*mbed_critical.o (+RO)
32+
*us_ticker.o (+RO)
33+
34+
*lib_peripheral_mbed_arm.ar (+RO)
2435
}
2536

2637
RW_IRAM1 +0 UNINIT FIXED {
27-
*rtl8195a_crypto.o(.data*)
28-
*mbedtls*.o(.data*)
29-
libc.a: (.data*)
38+
*rtl8195a_crypto.o(+RW)
39+
;*mbedtls*.o(+RW)
40+
*libc.a (+RW)
3041
*(.sdram.data*)
42+
*lib_peripheral_mbed_arm.ar (+RW)
3143
}
3244

3345
RW_IRAM2 +0 UNINIT FIXED {
34-
*rtl8195a_crypto.o(.bss*, COMMON)
35-
*mbedtls*.o(.bss*, COMMON)
36-
libc.a: (.bss*, COMMON)
46+
*rtl8195a_crypto.o(+ZI, COMMON)
47+
;*mbedtls*.o(+ZI, COMMON)
48+
*libc.a (+ZI, COMMON)
3749
*(.bss.thread_stack_main)
50+
*lib_peripheral_mbed_arm.ar (+ZI, COMMON)
3851
}
3952

4053
ARM_LIB_STACK (0x10070000 - 0x1000) EMPTY 0x1000 {
4154
}
4255
}
4356

57+
;LR_TCM 0x1FFF0000 0x10000 {
58+
; TCM_OVERLAY 0x1FFF0000 0x10000 {
59+
; lwip_mem.o(.bss*)
60+
; lwip_memp.o(.bss*)
61+
; *.o(.tcm.heap*)
62+
; }
63+
;}
64+
4465
LR_DRAM 0x30000000 0x200000 {
4566

4667
ER_DRAM +0 FIXED {

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/rtl8195a_init.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ void __TRAP_HardFaultHandler_Patch(uint32_t addr)
125125
* Otherwise it will keep hitting MemMange Fault on the same assembly code.
126126
*
127127
* To step to next command, we need parse the assembly code to check if
128-
* it is 16-bit or 32-bit command.
128+
* it is 16-bit or 32-bit command.
129129
* Ref: ARM Architecture Reference Manual (ARMv7-A and ARMv7-R edition),
130-
* Chapter A6 - Thumb Instruction Set Encoding
130+
* Chapter A6 - Thumb Instruction Set Encoding
131131
*
132132
* However, the fault assembly code (Ex. LDR or ADR) is not actually executed,
133133
* So the register value is un-predictable.
@@ -202,6 +202,9 @@ void PLAT_Start(void)
202202
#else
203203
TRAP_OverrideTable(0x1FFFFFFC);
204204
#endif
205+
extern HAL_TIMER_OP_EXT HalTimerOpExt;
206+
__rtl_memset_v1_00((void *)&HalTimerOpExt, 0, sizeof(HalTimerOpExt));
207+
__rtl_memset_v1_00((void *)&HalTimerOp, 0, sizeof(HalTimerOp));
205208

206209
HalTimerOpInit_Patch(&HalTimerOp);
207210
SystemCoreClockUpdate();

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/rtl8195a_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define _RTL8195A_TIMER_H_
1616

1717

18-
#define TIMER_TICK_US 31
18+
#define TIMER_TICK_US 32
1919

2020
#define TIMER_LOAD_COUNT_OFF 0x00
2121
#define TIMER_CURRENT_VAL_OFF 0x04

targets/TARGET_Realtek/TARGET_AMEBA/sdk/common/drivers/wlan/realtek/include/autoconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
#if defined(CONFIG_PLATFORM_AMEBA_X)
109109
#if !defined(CONFIG_PLATFORM_8711B)
110-
#define CONFIG_USE_TCM_HEAP 1 /* USE TCM HEAP */
110+
#define CONFIG_USE_TCM_HEAP 0 /* USE TCM HEAP */
111111
#endif
112112
#define CONFIG_RECV_TASKLET_THREAD
113113
#define CONFIG_XMIT_TASKLET_THREAD

targets/TARGET_Realtek/TARGET_AMEBA/sdk/os/os_dep/include/osdep_service.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232

3333
#if defined(CONFIG_PLATFORM_8195A)
3434
#ifndef CONFIG_USE_TCM_HEAP
35-
#define CONFIG_USE_TCM_HEAP 1 /* USE TCM HEAP */
35+
#define CONFIG_USE_TCM_HEAP 0 /* USE TCM HEAP */
3636
#endif
3737
#define USE_MUTEX_FOR_SPINLOCK 1
3838
#endif

targets/TARGET_Realtek/TARGET_AMEBA/us_ticker.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,22 @@ uint32_t us_ticker_read()
7777
void us_ticker_set_interrupt(timestamp_t timestamp)
7878
{
7979
uint32_t cur_time_us;
80-
uint32_t time_def;
81-
80+
uint32_t time_dif;
8281

82+
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
8383
cur_time_us = us_ticker_read();
84-
if ((uint32_t)timestamp >= cur_time_us) {
85-
time_def = (uint32_t)timestamp - cur_time_us;
84+
if ((uint32_t)timestamp > cur_time_us) {
85+
time_dif = (uint32_t)timestamp - cur_time_us;
8686
} else {
87-
time_def = 0xffffffff - cur_time_us + (uint32_t)timestamp;
87+
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, 0xffffffff);
88+
HalTimerOpExt.HalTimerIrqEn((u32)TimerAdapter.TimerId);
89+
HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
90+
NVIC_SetPendingIRQ(TIMER2_7_IRQ);
91+
return;
8892
}
8993

90-
if (time_def < TIMER_TICK_US) {
91-
time_def = TIMER_TICK_US; // at least 1 tick
92-
}
93-
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
94-
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, time_def);
94+
TimerAdapter.TimerLoadValueUs = time_dif;
95+
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, time_dif / TIMER_TICK_US);
9596
HalTimerOpExt.HalTimerIrqEn((u32)TimerAdapter.TimerId);
9697
HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
9798

0 commit comments

Comments
 (0)