qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

qp_comms_spi.h (2006B)


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