You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

  1. // Copyright 2021 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #ifdef QUANTUM_PAINTER_SPI_ENABLE
  5. # include <stdint.h>
  6. # include "gpio.h"
  7. # include "qp_internal.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. // Base SPI support
  10. struct qp_comms_spi_config_t {
  11. pin_t chip_select_pin;
  12. uint16_t divisor;
  13. bool lsb_first;
  14. int8_t mode;
  15. };
  16. bool qp_comms_spi_init(painter_device_t device);
  17. bool qp_comms_spi_start(painter_device_t device);
  18. uint32_t qp_comms_spi_send_data(painter_device_t device, const void* data, uint32_t byte_count);
  19. void qp_comms_spi_stop(painter_device_t device);
  20. extern const struct painter_comms_vtable_t spi_comms_vtable;
  21. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  22. // SPI with D/C and RST pins
  23. # ifdef QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
  24. struct qp_comms_spi_dc_reset_config_t {
  25. struct qp_comms_spi_config_t spi_config;
  26. pin_t dc_pin;
  27. pin_t reset_pin;
  28. };
  29. void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
  30. uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
  31. void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
  32. extern const struct painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
  33. # endif // QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35. #endif // QUANTUM_PAINTER_SPI_ENABLE