summaryrefslogtreecommitdiff
path: root/libhw/rp2040_include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-29 20:20:07 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-29 20:20:07 -0600
commit6c114930eef133293856189a93f7ca7ca3751268 (patch)
treedfb880db4838503ce8d0ac79b8fa56a0f2624fa1 /libhw/rp2040_include
parentbcaf0bc655df337bc02c5dd78bfc3f4487103959 (diff)
wip host_alarmclock
Diffstat (limited to 'libhw/rp2040_include')
-rw-r--r--libhw/rp2040_include/libhw/rp2040_hwalarm.h55
-rw-r--r--libhw/rp2040_include/libhw/rp2040_hwspi.h3
-rw-r--r--libhw/rp2040_include/libhw/rp2040_hwtimer.h26
3 files changed, 27 insertions, 57 deletions
diff --git a/libhw/rp2040_include/libhw/rp2040_hwalarm.h b/libhw/rp2040_include/libhw/rp2040_hwalarm.h
deleted file mode 100644
index 3a7ae10..0000000
--- a/libhw/rp2040_include/libhw/rp2040_hwalarm.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* libhw/rp2040_hwalarm.h - Alarms for the RP2040
- *
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#ifndef _LIBHW_RP2040_HWALARM_H_
-#define _LIBHW_RP2040_HWALARM_H_
-
-#include <stdbool.h> /* for bool */
-#include <stdint.h> /* for uint{n}_t */
-
-#include <libmisc/private.h> /* for BEGIN_PRIVATE, END_PRIVATE */
-
-/**
- * The RP2040 has one system "timer" (which we also use for
- * ./rp2040_bootclock.c) with 4 alarm interrupts.
- */
-enum rp2040_hwalarm_instance {
- RP2040_HWALARM_0 = 0,
- RP2040_HWALARM_1 = 1,
- RP2040_HWALARM_2 = 2,
- RP2040_HWALARM_3 = 3,
- _RP2040_HWALARM_NUM,
-};
-
-struct rp2040_hwalarm_trigger;
-struct rp2040_hwalarm_trigger {
- BEGIN_PRIVATE(LIBHW_RP2040_HWALARM_H)
- void *alarm;
- struct rp2040_hwalarm_trigger *prev, *next;
-
- uint64_t fire_at_us;
- void (*cb)(void *);
- void *cb_arg;
- END_PRIVATE(LIBHW_RP2040_HWALARM_H)
-};
-
-/**
- * Returns true on error.
- *
- * fire_at_ns must be at most UINT32_MAX µs (72 minutes) in the future
- * (or an error will be returned).
- *
- * If fire_at_ns is in the past, then it will fire immediately.
- */
-bool rp2040_hwalarm_trigger_init(struct rp2040_hwalarm_trigger *self,
- enum rp2040_hwalarm_instance alarm_num,
- uint64_t fire_at_ns,
- void (*cb)(void *),
- void *cb_arg);
-
-void rp2040_hwalarm_trigger_cancel(struct rp2040_hwalarm_trigger *self);
-
-#endif /* _LIBHW_RP2040_HWALARM_H_ */
diff --git a/libhw/rp2040_include/libhw/rp2040_hwspi.h b/libhw/rp2040_include/libhw/rp2040_hwspi.h
index 8d90dbb..19fb4ba 100644
--- a/libhw/rp2040_include/libhw/rp2040_hwspi.h
+++ b/libhw/rp2040_include/libhw/rp2040_hwspi.h
@@ -1,5 +1,4 @@
-/* libhw/rp2040_hwspi.h - `implements_spi` implementation for the RP2040's
- * ARM Primecell SSP (PL022) (header file)
+/* libhw/rp2040_hwspi.h - <libhw/generic/spi.h> implementation for the RP2040's ARM Primecell SSP (PL022)
*
* Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/libhw/rp2040_include/libhw/rp2040_hwtimer.h b/libhw/rp2040_include/libhw/rp2040_hwtimer.h
new file mode 100644
index 0000000..0885edf
--- /dev/null
+++ b/libhw/rp2040_include/libhw/rp2040_hwtimer.h
@@ -0,0 +1,26 @@
+/* libhw/rp2040_hwtimer.h - <libhw/generic/alarmclock.h> implementation for the RP2040's hardware timer
+ *
+ * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#ifndef _LIBHW_RP2040_HWALARM_H_
+#define _LIBHW_RP2040_HWALARM_H_
+
+#include <libhw/generic/alarmclock.h>
+
+/**
+ * The RP2040 has one system "timer" (which we also use for
+ * ./rp2040_bootclock.c) with 4 alarm interrupts.
+ */
+enum rp2040_hwalarm_instance {
+ RP2040_HWALARM_0 = 0,
+ RP2040_HWALARM_1 = 1,
+ RP2040_HWALARM_2 = 2,
+ RP2040_HWALARM_3 = 3,
+ _RP2040_HWALARM_NUM,
+};
+
+implements_alarmclock *rp2040_hwtimer(enum rp2040_hwalarm_instance alarm_num);
+
+#endif /* _LIBHW_RP2040_HWALARM_H_ */