mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
チック改良。
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:
parent
f125cd2fc8
commit
69f88f2df8
@ -75,7 +75,7 @@ void osInitTick(void)
|
|||||||
|
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
osStopTimer();
|
osStopTimer();
|
||||||
osStartTimerWithMSec(1, 0);
|
osStartTimer(OS_TICK_LO_MASK+1, 0);
|
||||||
#else // SDK_ARM9
|
#else // SDK_ARM9
|
||||||
//---- OS reserves OSi_TICK_TIMER timer
|
//---- OS reserves OSi_TICK_TIMER timer
|
||||||
SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER));
|
SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER));
|
||||||
@ -131,7 +131,7 @@ static void i_osCountUpTick(void)
|
|||||||
{
|
{
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
osStopTimer();
|
osStopTimer();
|
||||||
osStartTimerWithMSec(1, 0);
|
osStartTimer(OS_TICK_LO_MASK+1, 0);
|
||||||
#else // SDK_ARM9
|
#else // SDK_ARM9
|
||||||
osSetTimerControl(OSi_TICK_TIMER, 0);
|
osSetTimerControl(OSi_TICK_TIMER, 0);
|
||||||
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0);
|
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0);
|
||||||
@ -157,17 +157,18 @@ static void i_osCountUpTick(void)
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
u64 osGetTick(void)
|
u64 osGetTick(void)
|
||||||
{
|
{
|
||||||
#ifdef SDK_ARM11
|
vu32 countL;
|
||||||
return (i_osTickCounter << 32) | reg_OS_WD_COUNT;
|
|
||||||
#else // SDK_ARM9
|
|
||||||
vu16 countL;
|
|
||||||
vu64 countH;
|
vu64 countH;
|
||||||
|
|
||||||
OSIntrMode prev = osDisableInterrupts();
|
OSIntrMode prev = osDisableInterrupts();
|
||||||
SDK_ASSERT(i_osUseTick);
|
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);
|
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
|
//---- check if timer interrupt bit is on
|
||||||
if (reg_OS_IF & OSi_TICK_IE_TIMER && !(countL & 0x8000))
|
if (reg_OS_IF & OSi_TICK_IE_TIMER && !(countL & 0x8000))
|
||||||
@ -175,10 +176,12 @@ u64 osGetTick(void)
|
|||||||
countH++;
|
countH++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
countH <<= OS_TICK_HI_SHIFT;
|
||||||
|
|
||||||
|
#endif // SDK_ARM9
|
||||||
(void)osRestoreInterrupts(prev);
|
(void)osRestoreInterrupts(prev);
|
||||||
|
|
||||||
return (countH << 16) | countL;
|
return countH | countL;
|
||||||
#endif // SDK_ARM9
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDK_ARM9
|
#ifdef SDK_ARM9
|
||||||
@ -219,17 +222,17 @@ void osSetTick(u64 count)
|
|||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
osClearInterruptPending(OSi_TICK_IE_TIMER_ID);
|
osClearInterruptPending(OSi_TICK_IE_TIMER_ID);
|
||||||
|
|
||||||
i_osTickCounter = (u64)(count >> 32);
|
i_osTickCounter = (u64)(count >> OS_TICK_HI_SHIFT);
|
||||||
|
|
||||||
osStopTimer();
|
osStopTimer();
|
||||||
osStartTimerWithMSec((u32)count, 0);
|
osStartTimer((u32)(count & OS_TICK_LO_MASK), 0);
|
||||||
#else // SDK_ARM9
|
#else // SDK_ARM9
|
||||||
reg_OS_IF = OSi_TICK_IE_TIMER;
|
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);
|
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);
|
osSetTimerControl(OSi_TICK_TIMER, (u16)OSi_TICK_TIMERCONTROL);
|
||||||
#endif // SDK_ARM9
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,12 @@ extern void osSetTick( u64 );
|
|||||||
//---- conversion tick count <-> real time count
|
//---- conversion tick count <-> real time count
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
#define OS_SYSTEM_CLOCK HW_CPU_CLOCK
|
#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
|
#else // SDK_ARM9
|
||||||
#define OS_SYSTEM_CLOCK HW_SYSTEM_CLOCK
|
#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
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
//---- sec to tick
|
//---- sec to tick
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user