summaryrefslogtreecommitdiff
path: root/drivers/painter/comms/qp_comms_spi.h
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2022-05-29 15:38:33 -0700
committerDrashna Jael're <drashna@live.com>2022-05-29 15:38:33 -0700
commit30aac80d5a6d8c6f7c06efb49189d748e70edc4a (patch)
treeceb11968ae41228e4b110c07467cdca7cc9cff22 /drivers/painter/comms/qp_comms_spi.h
parent67f4e5f34489abf986dedb4984b256692086c615 (diff)
parente22a183329fd05d39f88bb9dfebe98cfa7cd8402 (diff)
Merge remote-tracking branch 'qmk 0.17.0' into firmware21
Diffstat (limited to 'drivers/painter/comms/qp_comms_spi.h')
-rw-r--r--drivers/painter/comms/qp_comms_spi.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/painter/comms/qp_comms_spi.h b/drivers/painter/comms/qp_comms_spi.h
new file mode 100644
index 0000000000..9989987327
--- /dev/null
+++ b/drivers/painter/comms/qp_comms_spi.h
@@ -0,0 +1,51 @@
+// Copyright 2021 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#ifdef QUANTUM_PAINTER_SPI_ENABLE
+
+# include <stdint.h>
+
+# include "gpio.h"
+# include "qp_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Base SPI support
+
+struct qp_comms_spi_config_t {
+ pin_t chip_select_pin;
+ uint16_t divisor;
+ bool lsb_first;
+ int8_t mode;
+};
+
+bool qp_comms_spi_init(painter_device_t device);
+bool qp_comms_spi_start(painter_device_t device);
+uint32_t qp_comms_spi_send_data(painter_device_t device, const void* data, uint32_t byte_count);
+void qp_comms_spi_stop(painter_device_t device);
+
+extern const struct painter_comms_vtable_t spi_comms_vtable;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// SPI with D/C and RST pins
+
+# ifdef QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
+
+struct qp_comms_spi_dc_reset_config_t {
+ struct qp_comms_spi_config_t spi_config;
+ pin_t dc_pin;
+ pin_t reset_pin;
+};
+
+void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
+uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
+void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
+
+extern const struct painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
+
+# endif // QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#endif // QUANTUM_PAINTER_SPI_ENABLE