From 25de14554c627f1e7727edcec59c2e47b8520187 Mon Sep 17 00:00:00 2001 From: nakasima Date: Thu, 18 Dec 2008 04:58:37 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=9E=E3=83=BC=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA=E3=82=92=E3=83=9E=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@122 b871894f-2f95-9b40-918c-086798483c85 --- .../bootrom/build/libraries/os/ARM11/Makefile | 3 +- .../build/libraries/os/ARM11/os_timer.c | 332 ------------------ .../build/libraries/os/common/os_tick.c | 19 +- .../libraries/os/{ARM9 => common}/os_timer.c | 121 +++---- trunk/bootrom/include/brom/os.h | 3 +- trunk/bootrom/include/brom/os/ARM11/timer.h | 191 ---------- trunk/bootrom/include/brom/os/common/tick.h | 6 +- .../include/brom/os/{ARM9 => common}/timer.h | 93 +++-- 8 files changed, 133 insertions(+), 635 deletions(-) delete mode 100644 trunk/bootrom/build/libraries/os/ARM11/os_timer.c rename trunk/bootrom/build/libraries/os/{ARM9 => common}/os_timer.c (92%) delete mode 100644 trunk/bootrom/include/brom/os/ARM11/timer.h rename trunk/bootrom/include/brom/os/{ARM9 => common}/timer.h (81%) diff --git a/trunk/bootrom/build/libraries/os/ARM11/Makefile b/trunk/bootrom/build/libraries/os/ARM11/Makefile index 128c4e6..a578aa8 100644 --- a/trunk/bootrom/build/libraries/os/ARM11/Makefile +++ b/trunk/bootrom/build/libraries/os/ARM11/Makefile @@ -28,7 +28,6 @@ BROM_CODEGEN_ALL ?= TRUE SRCDIR = . ../common SRCS = \ - os_alarm.c \ os_init.c \ os_system.c \ os_timer.c \ @@ -39,6 +38,8 @@ SRCS = \ os_thread.c \ os_context.c \ +# os_alarm.c \ + TARGET_LIB = libos$(BROM_LIBSUFFIX).a include $(CTRBROM_ROOT)/build/buildtools/commondefs diff --git a/trunk/bootrom/build/libraries/os/ARM11/os_timer.c b/trunk/bootrom/build/libraries/os/ARM11/os_timer.c deleted file mode 100644 index b60145a..0000000 --- a/trunk/bootrom/build/libraries/os/ARM11/os_timer.c +++ /dev/null @@ -1,332 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: CtrBrom - libraries - OS - File: os_timer.c - - Copyright 2008 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Date:: $ - $Rev$ - $Author$ - *---------------------------------------------------------------------------*/ -#include - - -static void i_osStartTimer( u32 count, u8 preScale, OSTimerReload reload, OSTimerIntrReq ireq ); -static void i_osStartWatchdog( u32 count, u8 preScale, OSTimerReload reload, OSTimerIntrReq ireq, - OSWatchdogMode watchdogMode ); - -static u32 osTimerClock = OS_TIMER_CLOCK_DEFAULT; - - -/*---------------------------------------------------------------------------* - Name: osInitTimer - - Description: Initialize Timers - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ - -void osInitTimer( void ) -{ - static BOOL isInit; - - if ( isInit == FALSE ) - { - OSIntrMode intr = osDisableInterrupts(); - - isInit = TRUE; - - osTimerClock = OS_TIMER_CLOCK_DEFAULT; - - osStopTimer(); - osStopWatchdog(); - osResetWatchdog(); - osDisableWatchdog(); - - osRestoreInterrupts( intr ); - } -} - - -/*---------------------------------------------------------------------------* - Name: osStartTimerWithUSec - - Description: Start Timer - - Arguments: micro second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimerWithUSec( u32 usec, u8 preScale ) -{ - u32 count = ((usec) * (osTimerClock / 1000)) / (preScale+1) / 1000; - - i_osStartTimer( count, preScale, OS_TM_AUTO_RELOAD, OS_TM_INTR_REQ_ENABLE ); -} - -/*---------------------------------------------------------------------------* - Name: osStartTimerWithMSec - - Description: Start Timer - - Arguments: milli second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimerWithMSec( u32 msec, u8 preScale ) -{ - u32 count = (((msec) * osTimerClock / 1000)) / (preScale+1); - - i_osStartTimer( count, preScale, OS_TM_AUTO_RELOAD, OS_TM_INTR_REQ_ENABLE ); -} - -/*---------------------------------------------------------------------------* - Name: osStartTimer - - Description: Start Timer - - Arguments: interval - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimer( u32 count, u8 preScale ) -{ - i_osStartTimer( count, preScale, OS_TM_AUTO_RELOAD, OS_TM_INTR_REQ_ENABLE ); -} - -/*---------------------------------------------------------------------------* - Name: osStartWatchdogWithUSec - - Description: Start Watchdog - - Arguments: micro second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchdogWithUSec( u32 usec, u8 preScale, OSWatchdogMode watchdogMode ) -{ - u32 count = ((usec) * (osTimerClock / 1000)) / (preScale+1) / 1000; - - i_osStartWatchdog( count, preScale, OS_TM_SINGLE_SHOT, OS_TM_INTR_REQ_ENABLE, watchdogMode ); -} - -/*---------------------------------------------------------------------------* - Name: osStartWatchdogWithMSec - - Description: Start Watchdog - - Arguments: milli second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchdogWithMSec( u32 msec, u8 preScale, OSWatchdogMode watchdogMode ) -{ - u32 count = (((msec) * osTimerClock / 1000)) / (preScale+1); - - i_osStartWatchdog( count, preScale, OS_TM_SINGLE_SHOT, OS_TM_INTR_REQ_ENABLE, watchdogMode ); -} - -/*---------------------------------------------------------------------------* - Name: osStartWatchdog - - Description: Start Watchdog - - Arguments: interval - watchdogMode - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchdog( u32 count, u8 preScale, OSWatchdogMode watchdogMode ) -{ - i_osStartWatchdog( count, preScale, OS_TM_SINGLE_SHOT, OS_TM_INTR_REQ_DISABLE, watchdogMode ); -} - -/*---------------------------------------------------------------------------* - Name: i_osStartTimer - - Description: Start Timer - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ - -static void i_osStartTimer( u32 count, u8 preScale, OSTimerReload reload, OSTimerIntrReq ireq ) -{ - OSIntrMode intr = osDisableInterrupts(); - - reg_OS_TM_CNT = 0; - reg_OS_TM_LD = count; - reg_OS_TM_CNT = REG_OS_TM_CNT_E_MASK | reload | ireq - | ((preScale < - -/*---------------------------------------------------------------------------* - Name: osEnableTimerAndWatchdog - - Description: Enable Timer & Watchdog - - Arguments: None - - Returns: previous status - *---------------------------------------------------------------------------*/ - -ASM BOOL osEnableTimerAndWatchdog( void ) -{ - stmfd sp!, {r4, lr} // stack requires 8byte alignment - - bl __cpp(osDisableInterrupts) - - mrc p15, 0, r4, c15, c12, 0 - orr r1, r4, #HW_C15_COUNT_ENABLE - mcr p15, 0, r1, c15, c12, 0 - - // 引数 r0 は osDisableInterrupts の返り値 - bl __cpp(osRestoreInterrupts) - - mov r0, r4 -// and r0, r4, #HW_CPUTM_ENABLE // retuen value - ldmfd sp!, {r4, pc} // stack requires 8byte alignment -} - - -/*---------------------------------------------------------------------------* - Name: osDisableTimerAndWatchdog - - Description: Enable Timer & Watchdog - - Arguments: None - - Returns: previous status - *---------------------------------------------------------------------------*/ - -ASM BOOL osDisableTimerAndWatchdog( void ) -{ - stmfd sp!, {r4, lr} // stack requires 8byte alignment - - bl __cpp(osDisableInterrupts) - - mrc p15, 0, r4, c15, c12, 0 - bic r1, r4, #HW_C15_COUNT_ENABLE - mcr p15, 0, r1, c15, c12, 0 - - // 引数 r0 は osDisableInterrupts の返り値 - bl __cpp(osRestoreInterrupts) - - mov r0, r4 -// and r0, r4, #HW_CPUTM_ENABLE // retuen value - ldmfd sp!, {r4, pc} // stack requires 8byte alignment -} - -#include - -/*====== End of main.c ======*/ diff --git a/trunk/bootrom/build/libraries/os/common/os_tick.c b/trunk/bootrom/build/libraries/os/common/os_tick.c index 472f965..756c1e6 100644 --- a/trunk/bootrom/build/libraries/os/common/os_tick.c +++ b/trunk/bootrom/build/libraries/os/common/os_tick.c @@ -18,6 +18,9 @@ //---------------------------------------------------------------------- +//---- timer number tick uses +#define OSi_TICK_TIMER OS_TIMER_0 + #ifdef SDK_ARM11 //---- timer interrupt ID #define OSi_TICK_IE_TIMER_ID OS_INTR_ID_TIMER @@ -29,9 +32,6 @@ //---- timer interrupt mask (must be same number with OSi_TICK_TIMER) #define OSi_TICK_IE_TIMER REG_OS_IF_T0_MASK -//---- timer number tick uses -#define OSi_TICK_TIMER OS_TIMER_0 - //---- timer control setting for tick #define OSi_TICK_TIMERCONTROL ( REG_OS_TM0CNT_H_E_MASK | REG_OS_TM0CNT_H_I_MASK | OS_TIMER_PRESCALER_64 ) #endif // SDK_ARM9 @@ -74,8 +74,9 @@ void osInitTick(void) i_osTickCounter = 0; #ifdef SDK_ARM11 - osStopTimer(); - osStartTimer(OS_TICK_LO_LIMIT, 0); + osStopTimer(OSi_TICK_TIMER); + osEnableTimerReload(OSi_TICK_TIMER); + osStartTimer(OSi_TICK_TIMER, OS_TICK_LO_LIMIT, 0); #else // SDK_ARM9 //---- OS reserves OSi_TICK_TIMER timer SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER)); @@ -130,8 +131,8 @@ static void i_osCountUpTick(void) if (i_osNeedResetTimer) { #ifdef SDK_ARM11 - osStopTimer(); - osStartTimer(OS_TICK_LO_LIMIT, 0); + osStopTimer(OSi_TICK_TIMER); + osStartTimer(OSi_TICK_TIMER, OS_TICK_LO_LIMIT, 0); #else // SDK_ARM9 osSetTimerControl(OSi_TICK_TIMER, 0); osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0); @@ -232,10 +233,10 @@ void i_osSetTick(u64 count) i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT); #ifdef SDK_ARM11 - osStopTimer(); + osStopTimer(OSi_TICK_TIMER); osClearInterruptPendingID(OSi_TICK_IE_TIMER_ID); - osStartTimer((u32)(count & OS_TICK_LO_MASK), 0); + osStartTimer(OSi_TICK_TIMER, (u32)(count & OS_TICK_LO_MASK), 0); #else // SDK_ARM9 osSetTimerControl(OSi_TICK_TIMER, 0); diff --git a/trunk/bootrom/build/libraries/os/ARM9/os_timer.c b/trunk/bootrom/build/libraries/os/common/os_timer.c similarity index 92% rename from trunk/bootrom/build/libraries/os/ARM9/os_timer.c rename to trunk/bootrom/build/libraries/os/common/os_timer.c index 3d54e2e..0e2daf7 100644 --- a/trunk/bootrom/build/libraries/os/ARM9/os_timer.c +++ b/trunk/bootrom/build/libraries/os/common/os_timer.c @@ -57,10 +57,8 @@ void osInitTimer( void ) #ifdef SDK_ARM11 - osTimerClock = OS_TIMER_CLOCK_DEFAULT; - - osStopTimer(); - osStopWatchdog(); + osStopTimer(OS_TIMER_0); + osStopTimer(OS_TIMER_1); osResetWatchdog(); osDisableWatchdog(); @@ -146,7 +144,7 @@ void osStartTimer( OSTimer id, OSTimerCount count, OSTimerPrescaler preScale ) osSetTimerCount(id, count); osSetTimerControl(id, REG_OS_TM_CNT_E_MASK | REG_OS_TM_CNT_IT_MASK | i_osTimerControl[id] | - (preScale << REG_OS_TM_CNT_PS_SHIFT); + (preScale << REG_OS_TM_CNT_PS_SHIFT)); } #else // SDK_ARM9 @@ -250,6 +248,9 @@ void osStopTimer( OSTimer id ) SDK_ASSERT(!i_osIsTimerReserved(id)); osSetTimerControl(id, 0); +#ifdef SDK_ARM11 + osClearTimerEventFlag(id); +#endif // SDK_ARM11 } #ifdef SDK_ARM9 @@ -304,6 +305,61 @@ void osStopTimer64( void ) #endif // SDK_ARM9 #ifdef SDK_ARM11 +/*---------------------------------------------------------------------------* + Name: osIsEnableTimerReload + + Description: check if specified timer is enabling reload + + Arguments: timerNum : timerNo (0-1) + + Returns: non-0 if repeated + *---------------------------------------------------------------------------*/ +u8 osIsEnableTimerReload( OSTimer timer_id ) +{ + SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); + return i_osTimerControl[timer_id] & REG_OS_WD_CNT_RLD_MASK ? TRUE : FALSE; +} + +/*---------------------------------------------------------------------------* + Name: osEnableTimerReload + + Description: enable specified timer to reload + + Arguments: timerNum : timerNo (0-1) + + Returns: None. + *---------------------------------------------------------------------------*/ +void osEnableTimerReload( OSTimer timer_id ) +{ + SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); + + OSIntrMode intr = osDisableInterrupts(); + + i_osTimerControl[timer_id] |= REG_OS_WD_CNT_RLD_MASK; + + osRestoreInterrupts( intr ); +} + +/*---------------------------------------------------------------------------* + Name: osDisableTimerReload + + Description: disable specified timer to reload + + Arguments: timerNum : timerNo (0-1) + + Returns: None. + *---------------------------------------------------------------------------*/ +void osDisableTimerReload( OSTimer timer_id ) +{ + SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); + + OSIntrMode intr = osDisableInterrupts(); + + i_osTimerControl[timer_id] &= ~REG_OS_WD_CNT_RLD_MASK; + + osRestoreInterrupts( intr ); +} + /*---------------------------------------------------------------------------* Name: osResetWatchdog @@ -338,60 +394,5 @@ void osDisableWatchdog( void ) osRestoreInterrupts( intr ); } -/*---------------------------------------------------------------------------* - Name: osIsTimerReload - - Description: check if specified timer is enabling reload - - Arguments: timerNum : timerNo (0-1) - - Returns: non-0 if repeated - *---------------------------------------------------------------------------*/ -u8 osIsTimerReload( int timer_id ) -{ - SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); - return i_osTimerControl[timer_id] & REG_OS_WD_CNT_RLD_MASK ? TRUE : FALSE; -} - -/*---------------------------------------------------------------------------* - Name: osSetTimerReload - - Description: set specified timer to reload - - Arguments: timerNum : timerNo (0-1) - - Returns: None. - *---------------------------------------------------------------------------*/ -void osSetTimerReload( int timer_id ) -{ - SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); - - OSIntrMode intr = osDisableInterrupts(); - - i_osTimerControl[timer_id] |= REG_OS_WD_CNT_RLD_MASK; - - osRestoreInterrupts( intr ); -} - -/*---------------------------------------------------------------------------* - Name: osUnsetTimerReload - - Description: unset specified timer to reload - - Arguments: timerNum : timerNo (0-1) - - Returns: None. - *---------------------------------------------------------------------------*/ -void osUnsetTimerReload( int timer_id ) -{ - SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); - - OSIntrMode intr = osDisableInterrupts(); - - i_osTimerControl[timer_id] &= ~REG_OS_WD_CNT_RLD_MASK; - - osRestoreInterrupts( intr ); -} - #endif // SDK_ARM11 diff --git a/trunk/bootrom/include/brom/os.h b/trunk/bootrom/include/brom/os.h index 9cfbe2f..e6d432e 100644 --- a/trunk/bootrom/include/brom/os.h +++ b/trunk/bootrom/include/brom/os.h @@ -35,12 +35,11 @@ extern "C" { #include #include #include +#include #ifdef SDK_ARM11 #include -#include #else // SDK_ARM9 #include -#include #endif // SDK_ARM9 #if 0 #include diff --git a/trunk/bootrom/include/brom/os/ARM11/timer.h b/trunk/bootrom/include/brom/os/ARM11/timer.h deleted file mode 100644 index 4c219a7..0000000 --- a/trunk/bootrom/include/brom/os/ARM11/timer.h +++ /dev/null @@ -1,191 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: CtrBrom - OS - include - File: timer.h - - Copyright 2008 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Date:: $ - $Rev$ - $Author$ - *---------------------------------------------------------------------------*/ -#ifndef BROM_OS_TIMER_H_ -#define BROM_OS_TIMER_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define OS_TIMER_CLOCK_DEFAULT HW_CPU_CLOCK - -#define OSi_WATCHDOG_DISABLE_CODE_0 0x12345678 -#define OSi_WATCHDOG_DISABLE_CODE_1 0x87654321 - - -//---------------------------------------------------------------------- -//---- control -typedef u32 OSTimerControl; - -//---- count -typedef u32 OSTimerCount; - -//---- pre-scaler -typedef u8 OSTimerPrescaler; - -//---- timer number -typedef enum -{ - OS_TIMER_0 = 0, - OS_TIMER_1 = 1, - OS_TIMER_NUM -} -OSTimer; - -//---- timer ID -typedef enum -{ - OS_CPU_TIMER = 0, - OS_CPU_WATCHDOG = 1 -} -OSTimerID; - -typedef enum -{ - OS_WD_WATCHDOG_MODE = REG_OS_WD_CNT_M_MASK, - OS_WD_TIMER_MODE = 0 -} -OSWatchdogMode; - -typedef enum -{ - OS_TM_AUTO_RELOAD = REG_OS_TM_CNT_RLD_MASK, - OS_TM_SINGLE_SHOT = 0 -} -OSTimerReload; - -typedef enum -{ - OS_TM_INTR_REQ_ENABLE = REG_OS_TM_CNT_IT_MASK, - OS_TM_INTR_REQ_DISABLE = 0 -} -OSTimerIntrReq; - - -void osInitTimer( void ); - -/*---------------------------------------------------------------------------* - Name: osStartTimerWithUSec - - Description: Start Timer - - Arguments: micro second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimerWithUSec( u32 usec, u8 preScale ); - -/*---------------------------------------------------------------------------* - Name: osStartTimerWithMSec - - Description: Start Timer - - Arguments: milli second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimerWithMSec( u32 msec, u8 preScale ); - -/*---------------------------------------------------------------------------* - Name: osStartTimer - - Description: Start Timer - - Arguments: interval - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartTimer( u32 count, u8 preScale ); - -/*---------------------------------------------------------------------------* - Name: osStopTimer - - Description: Stop Timer - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStopTimer( void ); - -/*---------------------------------------------------------------------------* - Name: osStartWatchdogWithUSec - - Description: Start Watchdog - - Arguments: micro second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchdogWithUSec( u32 usec, u8 preScale, OSWatchdogMode watchdogMode ); - -/*---------------------------------------------------------------------------* - Name: osStartWatchdogWithMSec - - Description: Start Watchdog - - Arguments: milli second - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchdogWithMSec( u32 msec, u8 preScale, OSWatchdogMode watchdogMode ); - -/*---------------------------------------------------------------------------* - Name: osStartWatchdog - - Description: Start Watchdog - - Arguments: interval - watchdogMode - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStartWatchDog( u32 count, u8 preScale, OSWatchdogMode watchdogMode ); - -/*---------------------------------------------------------------------------* - Name: osStopWatchdog - - Description: Stop Watchdog - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ - -void osStopWatchdog( void ); - -BOOL osEnableTimerAndWatchdog( void ); -BOOL osDisableTimerAndWatchdog( void ); -void osResetWatchdog( void ); -void osDisableWatchdog( void ); - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // BROM_OS_TIMER_H_ diff --git a/trunk/bootrom/include/brom/os/common/tick.h b/trunk/bootrom/include/brom/os/common/tick.h index 2f671c1..78aaea8 100644 --- a/trunk/bootrom/include/brom/os/common/tick.h +++ b/trunk/bootrom/include/brom/os/common/tick.h @@ -24,11 +24,7 @@ extern "C" { #include #include #include -#ifdef SDK_ARM11 -#include -#else // SDK_ARM9 -#include -#endif // SDK_ARM9 +#include //---- unit of tick diff --git a/trunk/bootrom/include/brom/os/ARM9/timer.h b/trunk/bootrom/include/brom/os/common/timer.h similarity index 81% rename from trunk/bootrom/include/brom/os/ARM9/timer.h rename to trunk/bootrom/include/brom/os/common/timer.h index 541ce3a..c8aa30d 100644 --- a/trunk/bootrom/include/brom/os/ARM9/timer.h +++ b/trunk/bootrom/include/brom/os/common/timer.h @@ -30,6 +30,12 @@ extern "C" { //---------------------------------------------------------------------- #ifdef SDK_ARM11 + +#define OS_TIMER_CLOCK_DEFAULT HW_CPU_CLOCK + +#define OSi_WATCHDOG_DISABLE_CODE_0 0x12345678 +#define OSi_WATCHDOG_DISABLE_CODE_1 0x87654321 + //---- control typedef u32 OSTimerControl; @@ -124,7 +130,7 @@ static inline void osSetTimerCount( OSTimer id, OSTimerCount count ) { SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); #ifdef SDK_ARM11 - *((REGType32 *)((u32)REG_TM_COUNT_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR))) = count; + *((REGType32 *)((u32)REG_TM_LD_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR))) = count; #else // SDK_ARM9 *((REGType16 *)((u32)REG_TM0CNT_L_ADDR + id * 4)) = count; #endif // SDK_ARM9 @@ -144,12 +150,29 @@ static inline void osSetTimerControl( OSTimer id, OSTimerControl control ) { SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); #ifdef SDK_ARM11 - *((REGType32 *)((u32)REG_TM_CNT_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR))) = count; + *((REGType32 *)((u32)REG_TM_CNT_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR))) = control; #else // SDK_ARM9 *((REGType16 *)((u32)REG_TM0CNT_H_ADDR + id * 4)) = control; #endif // SDK_ARM9 } +/*---------------------------------------------------------------------------* + Name: osClearTimerEventFlag + + Description: clear timer event flag + + Arguments: id timerNo + + Returns: None + *---------------------------------------------------------------------------*/ +static inline void osClearTimerEventFlag( OSTimer id ) +{ +#ifdef SDK_ARM11 + SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM); + *((REGType32 *)((u32)REG_TM_IF_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR))) = REG_OS_TM_IF_IF_MASK; +#endif // SDK_ARM11 +} + /*---------------------------------------------------------------------------* Name: osStartTimer @@ -217,6 +240,39 @@ void osStopTimer64( void ); #endif // SDK_ARM9 #ifdef SDK_ARM11 +/*---------------------------------------------------------------------------* + Name: osIsEnableTimerReload + + Description: check if specified timer is enabling reload + + Arguments: timerNum : timerNo (0-1) + + Returns: non-0 if repeated + *---------------------------------------------------------------------------*/ +u8 osIsEnableTimerReload( OSTimer timer_id ); + +/*---------------------------------------------------------------------------* + Name: osEnableTimerReload + + Description: enable specified timer to reload + + Arguments: timerNum : timerNo (0-1) + + Returns: None. + *---------------------------------------------------------------------------*/ +void osEnableTimerReload( OSTimer timer_id ); + +/*---------------------------------------------------------------------------* + Name: osDisableTimerReload + + Description: disable specified timer to reload + + Arguments: timerNum : timerNo (0-1) + + Returns: None. + *---------------------------------------------------------------------------*/ +void osDisableTimerReload( OSTimer timer_id ); + /*---------------------------------------------------------------------------* Name: osResetWatchdog @@ -239,39 +295,6 @@ void osResetWatchdog( void ); *---------------------------------------------------------------------------*/ void osDisableWatchdog( void ); -/*---------------------------------------------------------------------------* - Name: osIsTimerRepeat - - Description: check if specified timer is enabling repeat - - Arguments: timerNum : timerNo (0-1) - - Returns: non-0 if repeated - *---------------------------------------------------------------------------*/ -u8 osIsTimerRepeat( int timer_id ); - -/*---------------------------------------------------------------------------* - Name: osSetTimerRepeat - - Description: set specified timer to repeat - - Arguments: timerNum : timerNo (0-1) - - Returns: None. - *---------------------------------------------------------------------------*/ -void osSetTimerRepeat( int timer_id ); - -/*---------------------------------------------------------------------------* - Name: osUnsetTimerRepeat - - Description: unset specified timer to repeat - - Arguments: timerNum : timerNo (0-1) - - Returns: None. - *---------------------------------------------------------------------------*/ -void osUnsetTimerRepeat( int timer_id ); - #endif // SDK_ARM11