summaryrefslogtreecommitdiff
path: root/tests/uart-basic/uart-basic.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/uart-basic/uart-basic.h')
-rw-r--r--tests/uart-basic/uart-basic.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/uart-basic/uart-basic.h b/tests/uart-basic/uart-basic.h
new file mode 100644
index 0000000..8e3b8f6
--- /dev/null
+++ b/tests/uart-basic/uart-basic.h
@@ -0,0 +1,44 @@
+/*
+ * Karl Palsson <karlp@tweak.net.au> Oct 2017
+ * Considered to be available under your choice of:
+ * BSD2 clause, Apache2, MIT, X11 or ISC licenses
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <libopencm3/stm32/usart.h>
+
+struct ub_hw {
+ /** usart itself, eg USART2 */
+ uint32_t uart;
+ /** RCC_xxx flag for this usart, eg RCC_USART2 */
+ uint32_t uart_rcc;
+ /** eg NVIC_USART2_IRQ */
+ uint32_t uart_nvic;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initialise the uart itself.
+ * gpios are required to have been already configured as needed
+ * @param ub
+ */
+void ub_init(struct ub_hw *ub);
+
+/**
+ * Call this, it will "do stuff"
+ */
+void ub_task(void);
+
+/**
+ * Call this from your board irq handler, it will "do the right thing"
+ */
+void ub_irq_handler(void);
+
+#ifdef __cplusplus
+}
+#endif