summaryrefslogtreecommitdiff
path: root/arm9/source/devices/clock.h
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2024-11-18 14:57:19 +1300
committerBen Bridle <ben@derelict.engineering>2024-11-18 14:57:19 +1300
commit722d5509178fa5bdaa488fbbd9196f21377f8775 (patch)
tree112b39cd80cb8e074d9e71d1def4d8de33c9eefa /arm9/source/devices/clock.h
downloadbedrock-nds-722d5509178fa5bdaa488fbbd9196f21377f8775.zip
Initial commit
Diffstat (limited to 'arm9/source/devices/clock.h')
-rw-r--r--arm9/source/devices/clock.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/arm9/source/devices/clock.h b/arm9/source/devices/clock.h
new file mode 100644
index 0000000..892479f
--- /dev/null
+++ b/arm9/source/devices/clock.h
@@ -0,0 +1,46 @@
+#ifndef CLOCK_H_
+ #define CLOCK_H_
+
+ #include <time.h>
+
+ typedef struct {
+ u32 end; // real end time
+ u16 read, write; // read write caches
+ } ClockTimer;
+
+ typedef struct {
+ ClockTimer t1, t2, t3, t4; // timers
+ u32 start; // uptime offset
+ } ClockDevice;
+
+ #define YEAR(tm) (tm->tm_year - 100)
+ #define MONTH(tm) (tm->tm_mon)
+ #define DAY(tm) (tm->tm_mday - 1)
+ #define HOUR(tm) (tm->tm_hour)
+ #define MINUTE(tm) (tm->tm_min)
+ #define SECOND(tm) (tm->tm_sec)
+
+ u32 get_uptime(void);
+ void uptime_handler(void);
+ void init_clock(void);
+ struct tm* get_datetime(void);
+
+ bool check_timers(ClockDevice *clk);
+
+ u8 get_timer1_high(ClockDevice *clock);
+ u8 get_timer1_low( ClockDevice *clock);
+ u8 get_timer2_high(ClockDevice *clock);
+ u8 get_timer2_low( ClockDevice *clock);
+ u8 get_timer3_high(ClockDevice *clock);
+ u8 get_timer3_low( ClockDevice *clock);
+ u8 get_timer4_high(ClockDevice *clock);
+ u8 get_timer4_low( ClockDevice *clock);
+ void set_timer1_high(ClockDevice *clock, u8 high);
+ void set_timer1_low( ClockDevice *clock, u8 low);
+ void set_timer2_high(ClockDevice *clock, u8 high);
+ void set_timer2_low( ClockDevice *clock, u8 low);
+ void set_timer3_high(ClockDevice *clock, u8 high);
+ void set_timer3_low( ClockDevice *clock, u8 low);
+ void set_timer4_high(ClockDevice *clock, u8 high);
+ void set_timer4_low( ClockDevice *clock, u8 low);
+#endif