Skip to content

Commit 757a4e3

Browse files
Merge pull request #5464 from Archcady/Fix_lockup
Fix lockup issue for REALTEK_RTL8195AM
2 parents ee76bd8 + 6af9a5a commit 757a4e3

File tree

13 files changed

+21
-30
lines changed

13 files changed

+21
-30
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,17 @@ LR_IRAM 0x10007000 (0x70000 - 0x7000) {
2222
*(i.mbedtls*)
2323
*libc.a (+RO)
2424
*rtx_*.o (+RO)
25-
*lib_peripheral_mbed_arm.ar (+RO)
2625
}
2726

2827
RW_IRAM1 +0 UNINIT FIXED {
2928
*rtl8195a_crypto.o(+RW)
30-
;*mbedtls*.o(+RW)
3129
*libc.a (+RW)
3230
*(.sdram.data*)
3331
*lib_peripheral_mbed_arm.ar (+RW)
3432
}
3533

3634
RW_IRAM2 +0 UNINIT FIXED {
3735
*rtl8195a_crypto.o(+ZI, COMMON)
38-
;*mbedtls*.o(+ZI, COMMON)
3936
*libc.a (+ZI, COMMON)
4037
*(.bss.thread_stack_main)
4138
*lib_peripheral_mbed_arm.ar (+ZI, COMMON)

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/TOOLCHAIN_GCC_ARM/rtl8195a.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ SECTIONS
7070
*rtl8195a_crypto.o (.text* .rodata*)
7171
*mbedtls*.o (.text* .rodata*)
7272
*libc.a: (.text* .rodata*)
73-
*lib_peripheral_mbed_gcc.a: (.text*)
7473
} > SRAM1
7574

7675
.text.sram2 :

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/device/TOOLCHAIN_IAR/rtl8195a.icf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ define block .text.mbedtls {
128128
define block .text.sram {
129129
readonly object rtl8195a_crypto.o,
130130
readonly object vector_table_M.o,
131-
readonly object lib_peripheral_mbed_iar.a,
132131
section .text.sram*,
133132
};
134133

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ HalTimerReadCountRtl8195a_Patch(
9494
IN u32 TimerId
9595
);
9696

97+
VOID
98+
HalTimerSync(
99+
IN u32 TimerId
100+
);
101+
97102
VOID
98103
HalTimerIrqEnRtl8195a(
99104
IN u32 TimerId

targets/TARGET_Realtek/TARGET_AMEBA/sdk/soc/realtek/8195a/fwlib/hal_adc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ enum _ADC_DBG_LVL_ {
4545
typedef uint32_t ADC_DBG_LVL;
4646
typedef uint32_t * PADC_DBG_LVL;
4747

48-
#ifdef CONFIG_DEBUG_LOG
49-
#ifdef CONFIG_DEBUG_LOG_ADC_HAL
48+
#if defined (CONFIG_DEBUG_LOG) && defined (CONFIG_DEBUG_LOG_ADC_HAL)
5049

5150
#define DBG_8195A_ADC(...) do{ \
5251
_DbgDump("\r"ADC_PREFIX __VA_ARGS__);\
@@ -64,7 +63,6 @@ typedef uint32_t * PADC_DBG_LVL;
6463
#define DBG_8195A_ADC(...)
6564
#define DBG_8195A_ADC_LVL(...)
6665
#endif
67-
#endif
6866

6967

7068
//================ ADC HAL Related Enumeration ==================

targets/TARGET_Realtek/TARGET_AMEBA/sdk/soc/realtek/8195a/fwlib/hal_timer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ typedef struct _HAL_TIMER_OP_ {
5353
}HAL_TIMER_OP, *PHAL_TIMER_OP;
5454

5555
typedef struct _HAL_TIMER_OP_EXT_ {
56-
PHAL_TIMER_OP phal_timer_op_rom;
57-
VOID (*HalTimerIrqEn)(u32 TimerId);
58-
VOID (*HalTimerReLoad)(u32 TimerId, u32 LoadUs);
56+
PHAL_TIMER_OP phal_timer_op_rom;
57+
VOID (*HalTimerIrqEn)(u32 TimerId);
58+
VOID (*HalTimerReLoad)(u32 TimerId, u32 LoadUs);
59+
VOID (*HalTimerSync)(u32 TimerId);
5960
}HAL_TIMER_OP_EXT, *PHAL_TIMER_OP_EXT;
6061

6162
#ifdef CONFIG_TIMER_MODULE

targets/TARGET_Realtek/TARGET_AMEBA/us_ticker.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "us_ticker_api.h"
2020
#include "PeripheralNames.h"
2121

22-
#define TICK_READ_FROM_CPU 0 // 1: read tick from CPU, 0: read tick from G-Timer
2322
#define SYS_TIM_ID 1 // the G-Timer ID for System
2423
#define APP_TIM_ID 2 // the G-Timer ID for Application
2524

@@ -33,8 +32,6 @@
3332
*
3433
* Define the following macros to convert between TICK and US.
3534
*/
36-
#define MS_TO_TICK(x) (uint64_t)(((x)*327) / 10)
37-
#define US_TO_TICK(x) (uint64_t)(((x)*32) / 1000)
3835
#define TICK_TO_US(x) (uint64_t)(((x)/2) * 61 + ((x)%2) * TIMER_TICK_US)
3936

4037
static int us_ticker_inited = 0;
@@ -73,49 +70,45 @@ void us_ticker_init(void)
7370
TimerAdapter.TimerMode = USER_DEFINED;
7471

7572
HalTimerOp.HalTimerInit((void *) &TimerAdapter);
76-
77-
DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID);
7873
}
7974

8075
uint32_t us_ticker_read(void)
8176
{
8277
uint32_t tick_cnt;
83-
uint64_t tick_us;
8478

8579
if (!us_ticker_inited) {
8680
us_ticker_init();
8781
}
8882

8983
tick_cnt = HalTimerOp.HalTimerReadCount(SYS_TIM_ID);
90-
tick_us = TICK_TO_US(0xFFFFFFFFUL - tick_cnt);
91-
92-
return ((uint32_t)tick_us); //return ticker value in micro-seconds (us)
84+
return (uint32_t)TICK_TO_US(0xFFFFFFFFUL - tick_cnt);
9385
}
9486

9587
void us_ticker_set_interrupt(timestamp_t timestamp)
9688
{
9789
uint32_t time_cur;
98-
uint32_t time_cnt;
9990

100-
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
10191
time_cur = us_ticker_read();
10292
if (timestamp > time_cur + TIMER_TICK_US) {
103-
time_cnt = timestamp - time_cur;
93+
TimerAdapter.TimerLoadValueUs = timestamp - time_cur;
10494
} else {
105-
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, 0xffffffff);
106-
HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
107-
us_ticker_fire_interrupt();
108-
return;
95+
TimerAdapter.TimerLoadValueUs = TIMER_TICK_US;
10996
}
11097

111-
TimerAdapter.TimerLoadValueUs = MAX(MS_TO_TICK(time_cnt/1000) + US_TO_TICK(time_cnt%1000), 1);
98+
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
11299
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, TimerAdapter.TimerLoadValueUs);
100+
HalTimerOpExt.HalTimerSync(SYS_TIM_ID);
113101
HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
114102
}
115103

116104
void us_ticker_fire_interrupt(void)
117105
{
118-
NVIC_SetPendingIRQ(TIMER2_7_IRQ);
106+
TimerAdapter.TimerLoadValueUs = TIMER_TICK_US;
107+
108+
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
109+
HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, TimerAdapter.TimerLoadValueUs);
110+
HalTimerOpExt.HalTimerSync(SYS_TIM_ID);
111+
HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
119112
}
120113

121114
void us_ticker_disable_interrupt(void)
@@ -125,5 +118,4 @@ void us_ticker_disable_interrupt(void)
125118

126119
void us_ticker_clear_interrupt(void)
127120
{
128-
HalTimerOp.HalTimerIrqClear((u32)TimerAdapter.TimerId);
129121
}

0 commit comments

Comments
 (0)