summaryrefslogtreecommitdiff
path: root/platforms/chibios/drivers/serial_protocol.h
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2022-06-18 00:04:17 +0200
committerGitHub <noreply@github.com>2022-06-18 08:04:17 +1000
commitfe680a8568d275732738b07166b8f8a950d1e282 (patch)
tree7bc27994919e1271c9f6effef2e5637442b3b02b /platforms/chibios/drivers/serial_protocol.h
parent6d67e9df4be6981de05517626c1a504da31abf16 (diff)
[Core] Split ChibiOS usart split driver in protocol and hardware driver part (#16669)
Diffstat (limited to 'platforms/chibios/drivers/serial_protocol.h')
-rw-r--r--platforms/chibios/drivers/serial_protocol.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/platforms/chibios/drivers/serial_protocol.h b/platforms/chibios/drivers/serial_protocol.h
new file mode 100644
index 0000000000..4275a7f8d8
--- /dev/null
+++ b/platforms/chibios/drivers/serial_protocol.h
@@ -0,0 +1,49 @@
+// Copyright 2022 Stefan Kerkmann
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#pragma once
+
+/**
+ * @brief Clears any intermediate sending or receiving state of the driver to a known good
+ * state. This happens after errors in the middle of transactions, to start with
+ * a clean slate.
+ */
+void serial_transport_driver_clear(void);
+
+/**
+ * @brief Driver specific initialization on the slave half.
+ */
+void serial_transport_driver_slave_init(void);
+
+/**
+ * @brief Driver specific specific initialization on the master half.
+ */
+void serial_transport_driver_master_init(void);
+
+/**
+ * @brief Blocking receive of size * bytes.
+ *
+ * @return true Receive success.
+ * @return false Receive failed, e.g. by bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_receive(uint8_t* destination, const size_t size);
+
+/**
+ * @brief Blocking receive of size * bytes with an implicitly defined timeout.
+ *
+ * @return true Receive success.
+ * @return false Receive failed, e.g. by timeout or bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_receive_blocking(uint8_t* destination, const size_t size);
+
+/**
+ * @brief Blocking send of buffer with timeout.
+ *
+ * @return true Send success.
+ * @return false Send failed, e.g. by timeout or bit errors.
+ */
+bool __attribute__((nonnull, hot)) serial_transport_send(const uint8_t* source, const size_t size);