diff options
author | Egor Ananyin <ananinegor@gmail.com> | 2020-06-24 20:31:49 +0300 |
---|---|---|
committer | Egor Ananyin <ananinegor@gmail.com> | 2020-06-24 20:31:49 +0300 |
commit | 2f08757512dc9a57c66226ccbc56852598917c14 (patch) | |
tree | 1bc802dd9aaaa5408765b7810ae5a4ad95c93ab9 | |
parent | 60d9344c63e43abd81ccca87891b2ccdc05c6f93 (diff) |
Shared things
-rw-r--r-- | arm7/lib/include/OS_tick.h | 4 | ||||
-rw-r--r-- | arm7/lib/include/OS_timer.h | 28 | ||||
-rw-r--r-- | arm7/lib/src/OS_tick.c | 5 | ||||
-rw-r--r-- | arm9/lib/include/OS_timer.h | 28 | ||||
-rw-r--r-- | include/nitro/OS_timer_shared.h | 32 | ||||
-rw-r--r-- | include/nitro/registers_shared.h | 11 |
6 files changed, 50 insertions, 58 deletions
diff --git a/arm7/lib/include/OS_tick.h b/arm7/lib/include/OS_tick.h index 892e0499..7ee9544a 100644 --- a/arm7/lib/include/OS_tick.h +++ b/arm7/lib/include/OS_tick.h @@ -1,11 +1,11 @@ #ifndef POKEDIAMOND_OS_TICK_H #define POKEDIAMOND_OS_TICK_H -#include "OS_timer.h" +#include "nitro/OS_tick_shared.h" void OS_InitTick(void); u16 OS_IsTickAvailable(void); void OSi_CountUpTick(void); -u64 OS_GetTick(void); +OSTick OS_GetTick(void); #endif diff --git a/arm7/lib/include/OS_timer.h b/arm7/lib/include/OS_timer.h index b00967ca..fee42c6f 100644 --- a/arm7/lib/include/OS_timer.h +++ b/arm7/lib/include/OS_timer.h @@ -1,32 +1,6 @@ #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; -} +#include "nitro/OS_timer_shared.h" #endif diff --git a/arm7/lib/src/OS_tick.c b/arm7/lib/src/OS_tick.c index 063b05c9..e45b6833 100644 --- a/arm7/lib/src/OS_tick.c +++ b/arm7/lib/src/OS_tick.c @@ -1,12 +1,13 @@ #include "OS_interrupt.h" #include "OS_system.h" #include "OS_tick.h" +#include "OS_timer.h" #include "function_target.h" extern void OSi_SetTimerReserved(u32); static u16 OSi_UseTick; -static u64 OSi_TickCounter; +static OSTick OSi_TickCounter; static BOOL OSi_NeedResetTimer; ARM_FUNC void OS_InitTick(void) { @@ -38,7 +39,7 @@ ARM_FUNC void OSi_CountUpTick(void) { OSi_EnterTimerCallback(0, (void(*)(void*))OSi_CountUpTick, NULL); } -ARM_FUNC u64 OS_GetTick(void) { +ARM_FUNC OSTick OS_GetTick(void) { OSIntrMode prev = OS_DisableInterrupts(); vu16 countL = *(REGType16 *)((u32)®_OS_TM0CNT_L + OS_TIMER_0 * 4); vu64 countH = OSi_TickCounter & 0xffffffffffffULL; diff --git a/arm9/lib/include/OS_timer.h b/arm9/lib/include/OS_timer.h index 8b2a97a9..effa5fc0 100644 --- a/arm9/lib/include/OS_timer.h +++ b/arm9/lib/include/OS_timer.h @@ -1,32 +1,6 @@ #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; -} +#include "nitro/OS_timer_shared.h" #endif //POKEDIAMOND_OS_TIMER_H diff --git a/include/nitro/OS_timer_shared.h b/include/nitro/OS_timer_shared.h new file mode 100644 index 00000000..db20ee08 --- /dev/null +++ b/include/nitro/OS_timer_shared.h @@ -0,0 +1,32 @@ +#ifndef POKEDIAMOND_OS_TIMER_SHARED_H +#define POKEDIAMOND_OS_TIMER_SHARED_H + +#include "nitro/consts_shared.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 diff --git a/include/nitro/registers_shared.h b/include/nitro/registers_shared.h index 60152ab0..4962e608 100644 --- a/include/nitro/registers_shared.h +++ b/include/nitro/registers_shared.h @@ -10,8 +10,19 @@ #include "nitro/types.h" +#define reg_OS_TM0CNT_L (*(REGType16v *)0x4000100) +#define reg_OS_TM0CNT_H (*(REGType16v *)0x4000102) +#define reg_OS_TM1CNT_L (*(REGType16v *)0x4000104) +#define reg_OS_TM1CNT_H (*(REGType16v *)0x4000106) +#define reg_OS_TM2CNT_L (*(REGType16v *)0x4000108) +#define reg_OS_TM2CNT_H (*(REGType16v *)0x400010a) +#define reg_OS_TM3CNT_L (*(REGType16v *)0x400010c) +#define reg_OS_TM3CNT_H (*(REGType16v *)0x400010e) + #define reg_OS_IME (*(REGType16v *)0x4000208) #define reg_OS_IE (*(REGType32v *)0x4000210) #define reg_OS_IF (*(REGType32v *)0x4000214) +#define REG_OS_TM0CNT_H_PS_SHIFT 0 + #endif //POKEDIAMOND_REGISTERS_SHARED_H |