logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

qp_comms_spi.h (2006B)


  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. typedef 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. } qp_comms_spi_config_t;
  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 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. typedef struct qp_comms_spi_dc_reset_config_t {
  25. qp_comms_spi_config_t spi_config;
  26. pin_t dc_pin;
  27. pin_t reset_pin;
  28. bool command_params_uses_command_pin; // keep D/C held low when sending command sequences for data bytes
  29. } qp_comms_spi_dc_reset_config_t;
  30. bool qp_comms_spi_dc_reset_init(painter_device_t device);
  31. void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd);
  32. uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void* data, uint32_t byte_count);
  33. void qp_comms_spi_dc_reset_bulk_command_sequence(painter_device_t device, const uint8_t* sequence, size_t sequence_len);
  34. extern const painter_comms_with_command_vtable_t spi_comms_with_dc_vtable;
  35. # endif // QUANTUM_PAINTER_SPI_DC_RESET_ENABLE
  36. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37. #endif // QUANTUM_PAINTER_SPI_ENABLE