summaryrefslogtreecommitdiff
path: root/include/clock.h
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-03-25 17:36:52 -0400
committerFreya Murphy <freya@freyacat.org>2025-03-25 17:38:22 -0400
commit6af21e6a4f2251e71353562d5df7f376fdffc270 (patch)
treede20c7afc9878422c81e34f30c6b010075e9e69a /include/clock.h
downloadcomus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.gz
comus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.bz2
comus-6af21e6a4f2251e71353562d5df7f376fdffc270.zip
initial checkout from wrc
Diffstat (limited to 'include/clock.h')
-rw-r--r--include/clock.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/include/clock.h b/include/clock.h
new file mode 100644
index 0000000..6eae41f
--- /dev/null
+++ b/include/clock.h
@@ -0,0 +1,55 @@
+/**
+** @file clock.h
+**
+** @author CSCI-452 class of 20245
+**
+** @brief Clock module declarations
+*/
+
+#ifndef CLOCK_H_
+#define CLOCK_H_
+
+#include <common.h>
+
+/*
+** General (C and/or assembly) definitions
+*/
+
+// conversion functions for seconds, ms, and ticks
+// (SEC_TO_MS is defined in defs.h)
+#define MS_TO_TICKS(n) ((n))
+#define SEC_TO_TICKS(n) (MS_TO_TICKS(SEC_TO_MS(n)))
+#define TICKS_TO_SEC(n) ((n) / CLOCK_FREQ)
+#define TICKS_TO_SEC_ROUNDED(n) (((n)+(CLOCK_FREQ-1)) / CLOCK_FREQ)
+
+#ifndef ASM_SRC
+
+/*
+** Start of C-only definitions
+*/
+
+/*
+** Types
+*/
+
+/*
+** Globals
+*/
+
+// current system time
+extern uint32_t system_time;
+
+/*
+** Prototypes
+*/
+
+/**
+** Name: clk_init
+**
+** Clock module initialization
+*/
+void clk_init( void );
+
+#endif /* !ASM_SRC */
+
+#endif