]> Pileus Git - ~andy/csm213a-hw/blobdiff - hw2/main_comm.h
Refactor main into separate files
[~andy/csm213a-hw] / hw2 / main_comm.h
diff --git a/hw2/main_comm.h b/hw2/main_comm.h
new file mode 100644 (file)
index 0000000..299b223
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef MAIN_COMM_H
+#define MAIN_COMM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#include "timer_dma.h"
+#include "serial_irq.h"
+
+/**
+ * Initialization
+ */
+void comm_init(sirq_t *dbg, sirq_t *bbb, sirq_t *mbed,
+               tdma_t *rcv, tdma_t *xmt);
+
+/**
+ * Output initialization message init message
+ */
+void comm_send_init(uint16_t device, uint64_t local);
+void comm_send_sync(sirq_t *port, uint64_t now);
+void comm_send_event(sirq_t *port, uint16_t event, uint64_t local);
+
+/**
+ * Handle init message
+ */
+void comm_handle_init(int msgid, init_msg_t *msg);
+void comm_handle_sync(int msgid, sync_msg_t *msg);
+void comm_handle_event(int msgid, event_msg_t *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif