elpekenin/spi_custom.h

Some patching on QMK’s spi_master.h driver, to allow using multiple buses.

Caution

The following must be set up:
  • SPI_DRIVERS

  • SPI_SCK_PINS

  • SPI_MOSI_PINS

  • SPI_MISO_PINS

They will be automatically configured with their single-driver counterparts, if available.


enum spi_status_t
[source]
enumerator SPI_STATUS_SUCCESS = 0
[source]
enumerator SPI_STATUS_ERROR = -1
[source]
enumerator SPI_STATUS_TIMEOUT = -2
[source]
void spi_custom_init(uint8_t n)
[source]

Initialize the n’th driver.

bool spi_custom_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor, uint8_t n)
[source]

Set up the n’th driver for a transmision.

Parameters:
  • slavePin – The chip select pin for the target device.

  • lsbFirst – Whether Least Significant Bit is sent first or last.

  • mode – SPI clocks’ mode (0-3).

  • divisor – Control the clock’s speed.

  • n – Index of the driver to be used.

Returns:

Whether operation was successful.

spi_status_t spi_custom_write(uint8_t data, uint8_t n)
[source]

Send a single byte (data) over the n’th driver.

spi_status_t spi_custom_read(uint8_t n)
[source]

Read a single byte (return) over the n’th driver.

spi_status_t spi_custom_transmit(const uint8_t *data, uint16_t length, uint8_t n)
[source]

Send length bytes from data over the n’th driver.

spi_status_t spi_custom_receive(uint8_t *data, uint16_t length, uint8_t n)
[source]

Read length bytes into data over the n’th driver.

void spi_custom_stop(uint8_t n)
[source]

Undo the settings performced by spi_custom_start()