チック改良。

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@113 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
nakasima 2008-12-17 04:24:50 +00:00
parent f125cd2fc8
commit 69f88f2df8
2 changed files with 20 additions and 13 deletions

View File

@ -75,7 +75,7 @@ void osInitTick(void)
#ifdef SDK_ARM11
osStopTimer();
osStartTimerWithMSec(1, 0);
osStartTimer(OS_TICK_LO_MASK+1, 0);
#else // SDK_ARM9
//---- OS reserves OSi_TICK_TIMER timer
SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER));
@ -131,7 +131,7 @@ static void i_osCountUpTick(void)
{
#ifdef SDK_ARM11
osStopTimer();
osStartTimerWithMSec(1, 0);
osStartTimer(OS_TICK_LO_MASK+1, 0);
#else // SDK_ARM9
osSetTimerControl(OSi_TICK_TIMER, 0);
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0);
@ -157,17 +157,18 @@ static void i_osCountUpTick(void)
*---------------------------------------------------------------------------*/
u64 osGetTick(void)
{
#ifdef SDK_ARM11
return (i_osTickCounter << 32) | reg_OS_WD_COUNT;
#else // SDK_ARM9
vu16 countL;
vu32 countL;
vu64 countH;
OSIntrMode prev = osDisableInterrupts();
SDK_ASSERT(i_osUseTick);
#ifdef SDK_ARM11
countL = reg_OS_TM_COUNT;
countH = i_osTickCounter << OS_TICK_HI_SHIFT;
#else // SDK_ARM9
countL = *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4);
countH = i_osTickCounter & 0xffffffffffffULL;
countH = i_osTickCounter;
//---- check if timer interrupt bit is on
if (reg_OS_IF & OSi_TICK_IE_TIMER && !(countL & 0x8000))
@ -175,10 +176,12 @@ u64 osGetTick(void)
countH++;
}
countH <<= OS_TICK_HI_SHIFT;
#endif // SDK_ARM9
(void)osRestoreInterrupts(prev);
return (countH << 16) | countL;
#endif // SDK_ARM9
return countH | countL;
}
#ifdef SDK_ARM9
@ -219,17 +222,17 @@ void osSetTick(u64 count)
#ifdef SDK_ARM11
osClearInterruptPending(OSi_TICK_IE_TIMER_ID);
i_osTickCounter = (u64)(count >> 32);
i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT);
osStopTimer();
osStartTimerWithMSec((u32)count, 0);
osStartTimer((u32)(count & OS_TICK_LO_MASK), 0);
#else // SDK_ARM9
reg_OS_IF = OSi_TICK_IE_TIMER;
i_osTickCounter = (u64)(count >> 16);
i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT);
osSetTimerControl(OSi_TICK_TIMER, 0);
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)(count & 0xffff));
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)(count & OS_TICK_LO_MASK));
osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL);
#endif // SDK_ARM9

View File

@ -45,8 +45,12 @@ extern void osSetTick( u64 );
//---- conversion tick count <-> real time count
#ifdef SDK_ARM11
#define OS_SYSTEM_CLOCK HW_CPU_CLOCK
#define OS_TICK_HI_SHIFT 31 // 2の累乗単位でチック管理するのであれば32は指定できないロード値0では割り込み発生せず
#define OS_TICK_LO_MASK ((u32)((1ULL<<OS_TICK_HI_SHIFT)-1))
#else // SDK_ARM9
#define OS_SYSTEM_CLOCK HW_SYSTEM_CLOCK
#define OS_TICK_HI_SHIFT 16 // ロード値0でも割り込み発生
#define OS_TICK_LO_MASK ((u16)((1ULL<<OS_TICK_HI_SHIFT)-1))
#endif // SDK_ARM9
//---- sec to tick