diff options
Diffstat (limited to 'docs/spi_driver.md')
-rw-r--r-- | docs/spi_driver.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/spi_driver.md b/docs/spi_driver.md index c1c6831e73..569a19f1db 100644 --- a/docs/spi_driver.md +++ b/docs/spi_driver.md @@ -2,6 +2,18 @@ The SPI Master drivers used in QMK have a set of common functions to allow portability between MCUs. +## Usage :id=usage + +In most cases, the SPI Master driver code is automatically included if you are using a feature or driver which requires it, such as [OLED](feature_oled_driver.md). + +However, if you need to use the driver standalone, add the following to your `rules.mk`: + +```make +SPI_DRIVER_REQUIRED = yes +``` + +You can then call the SPI API by including `spi_master.h` in your code. + ## AVR Configuration :id=avr-configuration No special setup is required - just connect the `SS`, `SCK`, `MOSI` and `MISO` pins of your SPI devices to the matching pins on the MCU: @@ -49,6 +61,11 @@ Configuration-wise, you'll need to set up the peripheral as per your MCU's datas As per the AVR configuration, you may choose any other standard GPIO as a slave select pin, which should be supplied to `spi_start()`. +If a complete SPI interface is not required, then the following can be done to disable certain SPI pins, so they don't occupy a GPIO unnecessarily: + - in `config.h`: `#define SPI_MISO_PIN NO_PIN` + - in `config.h`: `#define SPI_MOSI_PIN NO_PIN` + - in `mcuconf.h`: `#define SPI_SELECT_MODE SPI_SELECT_MODE_NONE`, in this case the `slavePin` argument passed to `spi_start()` may be `NO_PIN` if the slave select pin is not used. + ## API :id=api ### `void spi_init(void)` :id=api-spi-init |