mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Merge pull request #5464 from Archcady/Fix_lockup
Fix lockup issue for REALTEK_RTL8195AMpull/5458/merge
						commit
						757a4e3b75
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -22,12 +22,10 @@ LR_IRAM 0x10007000 (0x70000 - 0x7000) {
 | 
			
		|||
    *(i.mbedtls*)
 | 
			
		||||
    *libc.a (+RO)
 | 
			
		||||
    *rtx_*.o (+RO)
 | 
			
		||||
    *lib_peripheral_mbed_arm.ar (+RO)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  RW_IRAM1 +0 UNINIT FIXED {
 | 
			
		||||
    *rtl8195a_crypto.o(+RW)
 | 
			
		||||
    ;*mbedtls*.o(+RW)
 | 
			
		||||
    *libc.a (+RW)
 | 
			
		||||
    *(.sdram.data*)
 | 
			
		||||
    *lib_peripheral_mbed_arm.ar (+RW)
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +33,6 @@ LR_IRAM 0x10007000 (0x70000 - 0x7000) {
 | 
			
		|||
 | 
			
		||||
  RW_IRAM2 +0 UNINIT FIXED {
 | 
			
		||||
    *rtl8195a_crypto.o(+ZI, COMMON)
 | 
			
		||||
    ;*mbedtls*.o(+ZI, COMMON)
 | 
			
		||||
    *libc.a (+ZI, COMMON)
 | 
			
		||||
    *(.bss.thread_stack_main)
 | 
			
		||||
    *lib_peripheral_mbed_arm.ar (+ZI, COMMON)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -70,7 +70,6 @@ SECTIONS
 | 
			
		|||
        *rtl8195a_crypto.o (.text* .rodata*)
 | 
			
		||||
        *mbedtls*.o (.text* .rodata*)
 | 
			
		||||
        *libc.a: (.text* .rodata*)
 | 
			
		||||
        *lib_peripheral_mbed_gcc.a: (.text*)
 | 
			
		||||
    } > SRAM1
 | 
			
		||||
 | 
			
		||||
    .text.sram2 :
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -128,7 +128,6 @@ define block .text.mbedtls {
 | 
			
		|||
define block .text.sram {
 | 
			
		||||
    readonly object rtl8195a_crypto.o,
 | 
			
		||||
    readonly object vector_table_M.o,
 | 
			
		||||
    readonly object lib_peripheral_mbed_iar.a,
 | 
			
		||||
    section .text.sram*,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -94,6 +94,11 @@ HalTimerReadCountRtl8195a_Patch(
 | 
			
		|||
    IN  u32 TimerId
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
VOID 
 | 
			
		||||
HalTimerSync(
 | 
			
		||||
    IN u32 TimerId
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
VOID
 | 
			
		||||
HalTimerIrqEnRtl8195a(
 | 
			
		||||
    IN  u32 TimerId
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,8 +45,7 @@ enum _ADC_DBG_LVL_ {
 | 
			
		|||
typedef uint32_t ADC_DBG_LVL;
 | 
			
		||||
typedef uint32_t * PADC_DBG_LVL;
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_DEBUG_LOG
 | 
			
		||||
#ifdef CONFIG_DEBUG_LOG_ADC_HAL
 | 
			
		||||
#if defined (CONFIG_DEBUG_LOG) && defined (CONFIG_DEBUG_LOG_ADC_HAL)
 | 
			
		||||
 | 
			
		||||
    #define DBG_8195A_ADC(...)  do{ \
 | 
			
		||||
        _DbgDump("\r"ADC_PREFIX __VA_ARGS__);\
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +63,6 @@ typedef uint32_t * PADC_DBG_LVL;
 | 
			
		|||
    #define DBG_8195A_ADC(...)
 | 
			
		||||
    #define DBG_8195A_ADC_LVL(...)
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//================ ADC HAL Related Enumeration ==================
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,9 +53,10 @@ typedef struct _HAL_TIMER_OP_ {
 | 
			
		|||
}HAL_TIMER_OP, *PHAL_TIMER_OP;
 | 
			
		||||
 | 
			
		||||
typedef struct _HAL_TIMER_OP_EXT_ {
 | 
			
		||||
	PHAL_TIMER_OP phal_timer_op_rom;
 | 
			
		||||
	VOID (*HalTimerIrqEn)(u32 TimerId);
 | 
			
		||||
	VOID (*HalTimerReLoad)(u32 TimerId, u32 LoadUs);
 | 
			
		||||
    PHAL_TIMER_OP phal_timer_op_rom;
 | 
			
		||||
    VOID (*HalTimerIrqEn)(u32 TimerId);
 | 
			
		||||
    VOID (*HalTimerReLoad)(u32 TimerId, u32 LoadUs);
 | 
			
		||||
    VOID (*HalTimerSync)(u32 TimerId);
 | 
			
		||||
}HAL_TIMER_OP_EXT, *PHAL_TIMER_OP_EXT;
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_TIMER_MODULE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@
 | 
			
		|||
#include "us_ticker_api.h"
 | 
			
		||||
#include "PeripheralNames.h"
 | 
			
		||||
 | 
			
		||||
#define TICK_READ_FROM_CPU  0   // 1: read tick from CPU, 0: read tick from G-Timer
 | 
			
		||||
#define SYS_TIM_ID          1   // the G-Timer ID for System
 | 
			
		||||
#define APP_TIM_ID          2   // the G-Timer ID for Application
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +32,6 @@
 | 
			
		|||
 *
 | 
			
		||||
 * Define the following macros to convert between TICK and US.
 | 
			
		||||
 */
 | 
			
		||||
#define MS_TO_TICK(x)       (uint64_t)(((x)*327) / 10)
 | 
			
		||||
#define US_TO_TICK(x)       (uint64_t)(((x)*32) / 1000)
 | 
			
		||||
#define TICK_TO_US(x)       (uint64_t)(((x)/2) * 61 + ((x)%2) * TIMER_TICK_US)
 | 
			
		||||
 | 
			
		||||
static int us_ticker_inited = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -73,49 +70,45 @@ void us_ticker_init(void)
 | 
			
		|||
    TimerAdapter.TimerMode = USER_DEFINED;
 | 
			
		||||
 | 
			
		||||
    HalTimerOp.HalTimerInit((void *) &TimerAdapter);
 | 
			
		||||
 | 
			
		||||
    DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t us_ticker_read(void)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t tick_cnt;
 | 
			
		||||
    uint64_t tick_us;
 | 
			
		||||
 | 
			
		||||
    if (!us_ticker_inited) {
 | 
			
		||||
        us_ticker_init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tick_cnt = HalTimerOp.HalTimerReadCount(SYS_TIM_ID);
 | 
			
		||||
    tick_us = TICK_TO_US(0xFFFFFFFFUL - tick_cnt);
 | 
			
		||||
 | 
			
		||||
    return ((uint32_t)tick_us);  //return ticker value in micro-seconds (us)
 | 
			
		||||
    return (uint32_t)TICK_TO_US(0xFFFFFFFFUL - tick_cnt);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void us_ticker_set_interrupt(timestamp_t timestamp)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t time_cur;
 | 
			
		||||
    uint32_t time_cnt;
 | 
			
		||||
 | 
			
		||||
    HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
 | 
			
		||||
    time_cur = us_ticker_read();
 | 
			
		||||
    if (timestamp > time_cur + TIMER_TICK_US) {
 | 
			
		||||
        time_cnt = timestamp - time_cur;
 | 
			
		||||
        TimerAdapter.TimerLoadValueUs = timestamp - time_cur;
 | 
			
		||||
    } else {
 | 
			
		||||
        HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, 0xffffffff);
 | 
			
		||||
        HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
 | 
			
		||||
        us_ticker_fire_interrupt();
 | 
			
		||||
        return;
 | 
			
		||||
        TimerAdapter.TimerLoadValueUs = TIMER_TICK_US;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TimerAdapter.TimerLoadValueUs = MAX(MS_TO_TICK(time_cnt/1000) + US_TO_TICK(time_cnt%1000), 1);
 | 
			
		||||
    HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
 | 
			
		||||
    HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, TimerAdapter.TimerLoadValueUs);
 | 
			
		||||
    HalTimerOpExt.HalTimerSync(SYS_TIM_ID);
 | 
			
		||||
    HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void us_ticker_fire_interrupt(void)
 | 
			
		||||
{
 | 
			
		||||
    NVIC_SetPendingIRQ(TIMER2_7_IRQ);
 | 
			
		||||
    TimerAdapter.TimerLoadValueUs = TIMER_TICK_US;
 | 
			
		||||
 | 
			
		||||
    HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId);
 | 
			
		||||
    HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, TimerAdapter.TimerLoadValueUs);
 | 
			
		||||
    HalTimerOpExt.HalTimerSync(SYS_TIM_ID);
 | 
			
		||||
    HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void us_ticker_disable_interrupt(void)
 | 
			
		||||
| 
						 | 
				
			
			@ -125,5 +118,4 @@ void us_ticker_disable_interrupt(void)
 | 
			
		|||
 | 
			
		||||
void us_ticker_clear_interrupt(void)
 | 
			
		||||
{
 | 
			
		||||
    HalTimerOp.HalTimerIrqClear((u32)TimerAdapter.TimerId);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue