From 2f08757512dc9a57c66226ccbc56852598917c14 Mon Sep 17 00:00:00 2001 From: Egor Ananyin Date: Wed, 24 Jun 2020 20:31:49 +0300 Subject: Shared things --- include/nitro/OS_timer_shared.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/nitro/OS_timer_shared.h (limited to 'include/nitro/OS_timer_shared.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 -- cgit v1.2.3