mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
アラームのタイマーAPI変更対応
チックのタイマーチャンネル変更対応。 git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@123 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
25de14554c
commit
bdb55f2e6a
@ -28,6 +28,7 @@ BROM_CODEGEN_ALL ?= TRUE
|
||||
SRCDIR = . ../common
|
||||
|
||||
SRCS = \
|
||||
os_alarm.c \
|
||||
os_init.c \
|
||||
os_system.c \
|
||||
os_timer.c \
|
||||
@ -38,8 +39,6 @@ SRCS = \
|
||||
os_thread.c \
|
||||
os_context.c \
|
||||
|
||||
# os_alarm.c \
|
||||
|
||||
TARGET_LIB = libos$(BROM_LIBSUFFIX).a
|
||||
|
||||
include $(CTRBROM_ROOT)/build/buildtools/commondefs
|
||||
|
||||
@ -19,6 +19,9 @@
|
||||
#define osPanic(...) ((void)0)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//---- timer number alarm uses
|
||||
#define OSi_ALARM_TIMER OS_TIMER_1
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
//---- timer interrupt ID
|
||||
#define OSi_ALARM_IE_TIMER_ID OS_INTR_ID_WATCHDOG
|
||||
@ -30,9 +33,6 @@
|
||||
//---- timer interrupt mask (must be same number with OSi_ALARM_TIMER)
|
||||
#define OSi_ALARM_IE_TIMER OS_IE_TIMER1
|
||||
|
||||
//---- timer number alarm uses
|
||||
#define OSi_ALARM_TIMER OS_TIMER_1
|
||||
|
||||
//---- timer control setting for alarm
|
||||
#define OSi_ALARM_TIMERCONTROL ( REG_OS_TM0CNT_H_E_MASK | REG_OS_TM0CNT_H_I_MASK | OS_TIMER_PRESCALER_64 )
|
||||
|
||||
@ -67,44 +67,52 @@ void i_osArrangeTimer(void);
|
||||
*---------------------------------------------------------------------------*/
|
||||
static void i_osSetTimer(OSAlarm *alarm)
|
||||
{
|
||||
OSTick tick = osGetTick();
|
||||
OSTimerCount timerCount;
|
||||
s64 delta;
|
||||
|
||||
//---- let timer be disable
|
||||
#ifdef SDK_ARM11
|
||||
osStopWatchdog();
|
||||
#else // SDK_ARM9
|
||||
s64 delta;
|
||||
u16 timerCount;
|
||||
OSTick tick = osGetTick();
|
||||
|
||||
delta = (s64)(alarm->fire - tick);
|
||||
|
||||
//---- let timer be disable
|
||||
osSetTimerControl(OSi_ALARM_TIMER, 0);
|
||||
#endif // SDK_ARM9
|
||||
|
||||
//---- set interrupt callback
|
||||
osSetInterruptHandler( OSi_ALARM_IE_TIMER_ID, i_osArrangeTimer );
|
||||
// osEnterTimerCallback(OSi_ALARM_TIMER, i_osAlarmHandler, NULL);
|
||||
|
||||
//---- set count and let timer be enable
|
||||
#ifdef SDK_ARM11
|
||||
osStartWatchdogWithMSec(1, 0, OS_WD_TIMER_MODE);
|
||||
#else // SDK_ARM9
|
||||
if (delta < 0)
|
||||
{
|
||||
#ifdef SDK_ARM11
|
||||
timerCount = 1;
|
||||
#else // SDK_ARM9
|
||||
// ARM9‚Í0xFFFF<46>Ý’è‹ÖŽ~
|
||||
timerCount = (u16)~1;
|
||||
#endif // SDK_ARM9
|
||||
}
|
||||
else if (delta < OS_TICK_HI_LSB)
|
||||
else if (delta < OS_TICK_LO_LIMIT)
|
||||
{
|
||||
#ifdef SDK_ARM11
|
||||
timerCount = delta;
|
||||
#else // SDK_ARM9
|
||||
timerCount = (u16)(~delta);
|
||||
#endif // SDK_ARM9
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SDK_ARM11
|
||||
timerCount = OS_TICK_LO_LIMIT;
|
||||
#else // SDK_ARM9
|
||||
timerCount = 0;
|
||||
#endif // SDK_ARM9
|
||||
}
|
||||
|
||||
//osPrintf( "**i_osSetTimer alarm=%x, fire=%llx time=%llx delta=%lld timeCount=%x \n", alarm, alarm->fire, time, delta, (int)timerCount );
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
osStartTimer(OSi_ALARM_TIMER, timerCount, 0);
|
||||
#else // SDK_ARM9
|
||||
osSetTimerCount((OSTimer)OSi_ALARM_TIMER, timerCount);
|
||||
osSetTimerControl(OSi_ALARM_TIMER, (u16)OSi_ALARM_TIMERCONTROL);
|
||||
#endif // SDK_ARM9
|
||||
@ -131,11 +139,12 @@ void osInitAlarm(void)
|
||||
//---- check if tick system is available
|
||||
SDK_ASSERTMSG(osIsTickAvailable(), "osInitAlarm: alarm system needs of tick system.");
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
//---- OS reserves OSi_ALARM_TIMER
|
||||
SDK_ASSERT(!i_osIsTimerReserved(OSi_ALARM_TIMER));
|
||||
i_osSetTimerReserved(OSi_ALARM_TIMER);
|
||||
#endif // SDK_ARM9
|
||||
#ifdef SDK_ARM11
|
||||
osDisableTimerReload(OSi_ALARM_TIMER);
|
||||
#endif // SDK_ARM11
|
||||
|
||||
//---- clear alarm list
|
||||
i_osAlarmQueue.head = NULL;
|
||||
@ -478,12 +487,9 @@ void i_osArrangeTimer(void)
|
||||
(void)osDisableInterruptID(OSi_ALARM_IE_TIMER_ID);
|
||||
|
||||
//---- let timer be disable
|
||||
#ifdef SDK_ARM11
|
||||
osStopWatchdog();
|
||||
|
||||
#else // SDK_ARM9
|
||||
osSetTimerControl(OSi_ALARM_TIMER, 0);
|
||||
|
||||
#ifdef SDK_ARM9
|
||||
//---- set check flag timer interrupt
|
||||
// osSetIrqCheckFlag(OSi_ALARM_IE_TIMER);
|
||||
|
||||
|
||||
@ -73,15 +73,15 @@ void osInitTick(void)
|
||||
|
||||
i_osTickCounter = 0;
|
||||
|
||||
//---- OS reserves OSi_TICK_TIMER timer
|
||||
SDK_ASSERT(!i_osIsTimerReserved(OSi_TICK_TIMER));
|
||||
i_osSetTimerReserved(OSi_TICK_TIMER);
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
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));
|
||||
i_osSetTimerReserved(OSi_TICK_TIMER);
|
||||
|
||||
//---- setting timer
|
||||
osSetTimerControl(OSi_TICK_TIMER, 0);
|
||||
osSetTimerCount((OSTimer)OSi_TICK_TIMER, (u16)0);
|
||||
@ -164,11 +164,10 @@ u64 osGetTick(void)
|
||||
OSIntrMode prev = osDisableInterrupts();
|
||||
SDK_ASSERT(i_osUseTick);
|
||||
|
||||
countL = osGetTimerCount(OSi_TICK_TIMER);
|
||||
#ifdef SDK_ARM11
|
||||
countL = OS_TICK_LO_LIMIT - reg_OS_TM_COUNT;
|
||||
#else // SDK_ARM9
|
||||
countL = *(REGType16 *)((u32)REG_TM0CNT_L_ADDR + OSi_TICK_TIMER * 4);
|
||||
#endif // SDK_ARM9
|
||||
countL = OS_TICK_LO_LIMIT - countL;
|
||||
#endif // SDK_ARM11
|
||||
countH = i_osTickCounter;
|
||||
|
||||
//---- check if timer interrupt bit is on
|
||||
@ -202,14 +201,10 @@ u64 osGetTick(void)
|
||||
|
||||
Returns: tick value (only u16 part)
|
||||
*---------------------------------------------------------------------------*/
|
||||
u16 osGetTickLo(void)
|
||||
OSTimerCount osGetTickLo(void)
|
||||
{
|
||||
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);
|
||||
#endif // SDK_ARM9
|
||||
return osGetTimerCount(OSi_TICK_TIMER);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
|
||||
@ -136,6 +136,25 @@ static inline void osSetTimerCount( OSTimer id, OSTimerCount count )
|
||||
#endif // SDK_ARM9
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osGetTimerCount
|
||||
|
||||
Description: get timer count
|
||||
|
||||
Arguments: id timerNo
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
static inline OSTimerCount osGetTimerCount( OSTimer id)
|
||||
{
|
||||
SDK_ASSERT(OS_TIMER_0 <= id && id < OS_TIMER_NUM);
|
||||
#ifdef SDK_ARM11
|
||||
return *((REGType32 *)((u32)REG_TM_COUNT_ADDR + id * (REG_WD_CNT_ADDR-REG_TM_CNT_ADDR)));
|
||||
#else // SDK_ARM9
|
||||
return *((REGType16 *)((u32)REG_TM0CNT_L_ADDR + id * 4));
|
||||
#endif // SDK_ARM9
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osSetTimerControl
|
||||
|
||||
@ -184,14 +203,13 @@ static inline void osClearTimerEventFlag( OSTimer id )
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifdef SDK_ARM11
|
||||
void osStartTimer( OSTimer id, OSTimerCount count, OSTimerPrescaler preScale );
|
||||
|
||||
#else // SDK_ARM9
|
||||
#ifdef SDK_ARM9
|
||||
//
|
||||
// use 1 timer, 16bit counter, timer<id> interrupt occurs by overflow
|
||||
//
|
||||
void osStartTimer( OSTimer id, OSTimerCount count, OSTimerPrescaler preScale );
|
||||
//void osStartTimer( OSTimer id, OSTimerCount count, OSTimerPrescaler preScale );
|
||||
//
|
||||
// use 2 timers, 32bit counter, timer<id+1> interrupt occurs by overflow
|
||||
//
|
||||
|
||||
Loading…
Reference in New Issue
Block a user