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@120 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
9a8881e31e
commit
1dd141a11f
@ -75,7 +75,7 @@ void osInitTick(void)
|
|||||||
|
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
osStopTimer();
|
osStopTimer();
|
||||||
osStartTimer(OS_TICK_LO_MASK+1, 0);
|
osStartTimer(OS_TICK_LO_LIMIT, 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();
|
||||||
osStartTimer(OS_TICK_LO_MASK+1, 0);
|
osStartTimer(OS_TICK_LO_LIMIT, 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);
|
||||||
@ -164,27 +164,34 @@ u64 osGetTick(void)
|
|||||||
SDK_ASSERT(i_osUseTick);
|
SDK_ASSERT(i_osUseTick);
|
||||||
|
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
countL = reg_OS_TM_COUNT;
|
countL = OS_TICK_LO_LIMIT - reg_OS_TM_COUNT;
|
||||||
countH = i_osTickCounter << OS_TICK_HI_SHIFT;
|
|
||||||
#else // SDK_ARM9
|
#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);
|
||||||
|
#endif // SDK_ARM9
|
||||||
countH = i_osTickCounter;
|
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 (osIsInterruptPending(OSi_TICK_IE_TIMER_ID) &&
|
||||||
|
// countLが0xFFFFで直後に割り込み要求が来た場合の対策
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
// ダウンカウンタなので
|
||||||
|
(countL & OS_TICK_LO_MSB)
|
||||||
|
#else // SDK_ARM9
|
||||||
|
// アップカウンタなので
|
||||||
|
!(countL & OS_TICK_LO_MSB)
|
||||||
|
#endif // SDK_ARM9
|
||||||
|
)
|
||||||
{
|
{
|
||||||
countH++;
|
countH++;
|
||||||
}
|
}
|
||||||
|
|
||||||
countH <<= OS_TICK_HI_SHIFT;
|
countH <<= OS_TICK_HI_SHIFT;
|
||||||
|
|
||||||
#endif // SDK_ARM9
|
|
||||||
(void)osRestoreInterrupts(prev);
|
(void)osRestoreInterrupts(prev);
|
||||||
|
|
||||||
return countH | countL;
|
return countH | countL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDK_ARM9
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: osGetTickLo
|
Name: osGetTickLo
|
||||||
|
|
||||||
@ -197,9 +204,12 @@ u64 osGetTick(void)
|
|||||||
u16 osGetTickLo(void)
|
u16 osGetTickLo(void)
|
||||||
{
|
{
|
||||||
SDK_ASSERT(OSi_UseTick);
|
SDK_ASSERT(OSi_UseTick);
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
return reg_OS_TM_COUNT;
|
||||||
|
#else // SDK_ARM9
|
||||||
return *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4);
|
return *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4);
|
||||||
}
|
|
||||||
#endif // SDK_ARM9
|
#endif // SDK_ARM9
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: i_osSetTick
|
Name: i_osSetTick
|
||||||
|
|||||||
@ -76,6 +76,33 @@ BOOL osDisableInterruptID( OSIntrID id );
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
BOOL osRestoreInterruptID( OSIntrID id, BOOL state );
|
BOOL osRestoreInterruptID( OSIntrID id, BOOL state );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osIsInterruptIDPending
|
||||||
|
|
||||||
|
Description: set Interrupt Clear Pending Register
|
||||||
|
|
||||||
|
Arguments: Interrupt Distributor ID
|
||||||
|
|
||||||
|
Returns: TRUE if last state is pending
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
static inline BOOL osIsInterruptPending( OSIntrID id )
|
||||||
|
{
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
u32 ofs = id/32;
|
||||||
|
u32 sft = id%32;
|
||||||
|
BOOL retval;
|
||||||
|
|
||||||
|
retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft);
|
||||||
|
#else // SDK_ARM9
|
||||||
|
OSIntrMask prep = reg_OS_IF;
|
||||||
|
BOOL retval;
|
||||||
|
|
||||||
|
retval = TRUE & (BOOL)(prep >> id);
|
||||||
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: osSetInterruptPendingID
|
Name: osSetInterruptPendingID
|
||||||
|
|
||||||
|
|||||||
@ -177,18 +177,18 @@ BOOL osClearInterruptPendingID( OSIntrID id );
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
static inline BOOL osIsInterruptPending( OSIntrID id )
|
static inline BOOL osIsInterruptPending( OSIntrID id )
|
||||||
{
|
{
|
||||||
#ifdef SDK_ARM9
|
#ifdef SDK_ARM11
|
||||||
OSIntrMask prep = reg_OS_IF;
|
|
||||||
BOOL retval;
|
|
||||||
|
|
||||||
retval = TRUE & (BOOL)(prep >> id);
|
|
||||||
#else // MPCORE
|
|
||||||
u32 ofs = id/32;
|
u32 ofs = id/32;
|
||||||
u32 sft = id%32;
|
u32 sft = id%32;
|
||||||
BOOL retval;
|
BOOL retval;
|
||||||
|
|
||||||
retval = TRUE & (reg_OS_IDR_SET_PENDING_WP[ofs] >> sft);
|
retval = TRUE & (reg_OS_IDR_SET_PND[ofs] >> sft);
|
||||||
#endif // MPCORE
|
#else // SDK_ARM9
|
||||||
|
OSIntrMask prep = reg_OS_IF;
|
||||||
|
BOOL retval;
|
||||||
|
|
||||||
|
retval = TRUE & (BOOL)(prep >> id);
|
||||||
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,23 @@ extern "C" {
|
|||||||
#include <brom/os/common/interrupt_common.h>
|
#include <brom/os/common/interrupt_common.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef SDK_ARM11
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
|
||||||
|
//---- pre-scaler
|
||||||
|
typedef u8 OSTimerPrescaler;
|
||||||
|
|
||||||
|
//---- timer number
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
OS_TIMER_0 = 0,
|
||||||
|
OS_TIMER_1 = 1,
|
||||||
|
OS_TIMER_NUM
|
||||||
|
}
|
||||||
|
OSTimer;
|
||||||
|
|
||||||
|
#else // SDK_ARM9
|
||||||
|
|
||||||
//---- pre-scaler
|
//---- pre-scaler
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -48,7 +62,7 @@ typedef enum
|
|||||||
OS_TIMER_1 = 1,
|
OS_TIMER_1 = 1,
|
||||||
OS_TIMER_2 = 2,
|
OS_TIMER_2 = 2,
|
||||||
OS_TIMER_3 = 3,
|
OS_TIMER_3 = 3,
|
||||||
OS_TIMER_NUM = 4
|
OS_TIMER_NUM
|
||||||
}
|
}
|
||||||
OSTimer;
|
OSTimer;
|
||||||
|
|
||||||
@ -69,6 +83,9 @@ typedef enum
|
|||||||
}
|
}
|
||||||
OSTimer48;
|
OSTimer48;
|
||||||
|
|
||||||
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
// TIMER
|
// TIMER
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -95,8 +112,11 @@ void osInitTimer( void );
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
static inline void osSetTimerCount( OSTimer id, u16 count )
|
static inline void osSetTimerCount( OSTimer id, u16 count )
|
||||||
{
|
{
|
||||||
SDK_ASSERT(OS_TIMER_0 <= id && id <= OS_TIMER_3);
|
SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM);
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
#else // SDK_ARM9
|
||||||
*((REGType16 *)((u32)REG_TM0CNT_L_ADDR + id * 4)) = count;
|
*((REGType16 *)((u32)REG_TM0CNT_L_ADDR + id * 4)) = count;
|
||||||
|
#endif // SDK_ARM9
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
@ -111,8 +131,11 @@ static inline void osSetTimerCount( OSTimer id, u16 count )
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
static inline void osSetTimerControl( OSTimer id, u16 control )
|
static inline void osSetTimerControl( OSTimer id, u16 control )
|
||||||
{
|
{
|
||||||
SDK_ASSERT(OS_TIMER_0 <= id && id <= OS_TIMER_3);
|
SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM);
|
||||||
|
#ifdef SDK_ARM11
|
||||||
|
#else // SDK_ARM9
|
||||||
*((REGType16 *)((u32)REG_TM0CNT_H_ADDR + id * 4)) = control;
|
*((REGType16 *)((u32)REG_TM0CNT_H_ADDR + id * 4)) = control;
|
||||||
|
#endif // SDK_ARM9
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
@ -130,6 +153,9 @@ static inline void osSetTimerControl( OSTimer id, u16 control )
|
|||||||
// use 1 timer, 16bit counter, timer<id> interrupt occurs by overflow
|
// use 1 timer, 16bit counter, timer<id> interrupt occurs by overflow
|
||||||
//
|
//
|
||||||
void osStartTimer( OSTimer id, u16 count, OSTimerPrescaler preScale );
|
void osStartTimer( OSTimer id, u16 count, OSTimerPrescaler preScale );
|
||||||
|
|
||||||
|
#ifndef SDK_ARM11
|
||||||
|
|
||||||
//
|
//
|
||||||
// use 2 timers, 32bit counter, timer<id+1> interrupt occurs by overflow
|
// use 2 timers, 32bit counter, timer<id+1> interrupt occurs by overflow
|
||||||
//
|
//
|
||||||
@ -143,6 +169,8 @@ void osStartTimer48( OSTimer48 id, u64 count, OSTimerPrescaler preScale );
|
|||||||
//
|
//
|
||||||
void osStartTimer64( u64 count, OSTimerPrescaler preScale );
|
void osStartTimer64( u64 count, OSTimerPrescaler preScale );
|
||||||
|
|
||||||
|
#endif // SDK_ARM11
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Name: osStopTimer
|
Name: osStopTimer
|
||||||
@ -157,6 +185,9 @@ void osStartTimer64( u64 count, OSTimerPrescaler preScale );
|
|||||||
// stop a timer
|
// stop a timer
|
||||||
//
|
//
|
||||||
void osStopTimer( OSTimer id );
|
void osStopTimer( OSTimer id );
|
||||||
|
|
||||||
|
#ifndef SDK_ARM11
|
||||||
|
|
||||||
//
|
//
|
||||||
// stop 2 timers
|
// stop 2 timers
|
||||||
//
|
//
|
||||||
@ -170,7 +201,6 @@ void osStopTimer48( OSTimer48 id );
|
|||||||
//
|
//
|
||||||
void osStopTimer64( void );
|
void osStopTimer64( void );
|
||||||
|
|
||||||
|
|
||||||
#endif // SDK_ARM11
|
#endif // SDK_ARM11
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,12 +45,18 @@ extern void i_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_HI_SHIFT 24 // 2の累乗単位でチック管理するのであれば32は指定できない(ロード値0では割り込みが発生しないため)
|
||||||
#define OS_TICK_LO_MASK ((u32)((1ULL<<OS_TICK_HI_SHIFT)-1))
|
#define OS_TICK_HI_LSB (1ULL<<OS_TICK_HI_SHIFT)
|
||||||
|
#define OS_TICK_LO_MASK ((u32)(OS_TICK_HI_LSB-1))
|
||||||
|
#define OS_TICK_LO_MSB ((u32)(OS_TICK_HI_LSB>>1))
|
||||||
|
#define OS_TICK_LO_LIMIT OS_TICK_HI_LSB
|
||||||
#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_HI_SHIFT 16 // ロード値0でも割り込み発生
|
||||||
#define OS_TICK_LO_MASK ((u16)((1ULL<<OS_TICK_HI_SHIFT)-1))
|
#define OS_TICK_HI_LSB (1ULL<<OS_TICK_HI_SHIFT)
|
||||||
|
#define OS_TICK_LO_MASK ((u16)(OS_TICK_HI_LSB-1))
|
||||||
|
#define OS_TICK_LO_MSB ((u16)(OS_TICK_HI_LSB>>1))
|
||||||
|
#define OS_TICK_LO_LIMIT OS_TICK_HI_LSB
|
||||||
#endif // SDK_ARM9
|
#endif // SDK_ARM9
|
||||||
|
|
||||||
//---- sec to tick
|
//---- sec to tick
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user