diff options
Diffstat (limited to 'arm9/lib/include')
-rw-r--r-- | arm9/lib/include/OS_interrupt.h | 4 | ||||
-rw-r--r-- | arm9/lib/include/OS_tick.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/OS_timer.h | 32 | ||||
-rw-r--r-- | arm9/lib/include/registers.h | 6 |
4 files changed, 50 insertions, 1 deletions
diff --git a/arm9/lib/include/OS_interrupt.h b/arm9/lib/include/OS_interrupt.h index ec58a636..481e6c6c 100644 --- a/arm9/lib/include/OS_interrupt.h +++ b/arm9/lib/include/OS_interrupt.h @@ -1,9 +1,11 @@ #ifndef POKEDIAMOND_ARM9_OS_INTERRUPT_H #define POKEDIAMOND_ARM9_OS_INTERRUPT_H -#include "nitro/types.h" +#include "consts.h" #include "nitro/OS_interrupt_shared.h" +#define OS_IE_TIMER0 (1UL << REG_OS_IE_T0_SHIFT) + typedef void (*OSIrqFunction) (void); typedef struct diff --git a/arm9/lib/include/OS_tick.h b/arm9/lib/include/OS_tick.h index f1c7145d..3dba9818 100644 --- a/arm9/lib/include/OS_tick.h +++ b/arm9/lib/include/OS_tick.h @@ -2,6 +2,7 @@ #define POKEDIAMOND_OS_TICK_H #include "consts.h" +#include "OS_timer.h" typedef u64 OSTick; @@ -9,4 +10,12 @@ typedef u64 OSTick; #define OS_MilliSecondsToTicks(msec) ((OSTick)(((OS_SYSTEM_CLOCK/1000) * (u64)(msec)) / 64)) +#define OSi_TICK_TIMERCONTROL (REG_OS_TM0CNT_H_E_MASK | REG_OS_TM0CNT_H_I_MASK | OS_TIMER_PRESCALER_64) + +void OS_InitTick(void); +BOOL OS_IsTickAvailable(void); +static void OSi_CountUpTick(void); +OSTick OS_GetTick(void); +u16 OS_GetTickLo(void); + #endif //POKEDIAMOND_OS_TICK_H diff --git a/arm9/lib/include/OS_timer.h b/arm9/lib/include/OS_timer.h new file mode 100644 index 00000000..8b2a97a9 --- /dev/null +++ b/arm9/lib/include/OS_timer.h @@ -0,0 +1,32 @@ +#ifndef POKEDIAMOND_OS_TIMER_H +#define POKEDIAMOND_OS_TIMER_H + +#include "consts.h" + +typedef enum +{ + OS_TIMER_PRESCALER_1 = (0UL << REG_OS_TM0CNT_H_PS_SHIFT), + OS_TIMER_PRESCALER_64 = (1UL << REG_OS_TM0CNT_H_PS_SHIFT), + OS_TIMER_PRESCALER_256 = (2UL << REG_OS_TM0CNT_H_PS_SHIFT), + OS_TIMER_PRESCALER_1024 = (3UL << REG_OS_TM0CNT_H_PS_SHIFT) +} OSTimerPrescaler; + +typedef enum +{ + OS_TIMER_0 = 0, + OS_TIMER_1 = 1, + OS_TIMER_2 = 2, + OS_TIMER_3 = 3 +} OSTimer; + +static inline void OS_SetTimerCount(OSTimer id, u16 count) +{ + *((REGType16 *)((u32)®_OS_TM0CNT_L + id * 4)) = count; +} + +static inline void OS_SetTimerControl(OSTimer id, u16 control) +{ + *((REGType16 *)((u32)®_OS_TM0CNT_H + id * 4)) = control; +} + +#endif //POKEDIAMOND_OS_TIMER_H diff --git a/arm9/lib/include/registers.h b/arm9/lib/include/registers.h index 4781ba1b..06f96d5a 100644 --- a/arm9/lib/include/registers.h +++ b/arm9/lib/include/registers.h @@ -356,6 +356,12 @@ #define reg_MI_MCD1 (*(REGType32v *)0x4100010) #define reg_CARD_DATA (*(REGType32v *)0x4100010) //? +#define REG_OS_TM0CNT_H_PS_SHIFT 0 +#define REG_OS_IE_T0_SHIFT 3 + +#define REG_OS_TM0CNT_H_I_MASK 0x0040 +#define REG_OS_TM0CNT_H_E_MASK 0x0080 + #define REG_PAD_KEYINPUT_L_SHIFT 9 #define REG_PAD_KEYINPUT_L_SIZE 1 #define REG_PAD_KEYINPUT_L_MASK 0x0200 |