6.2 SPI Driver Example Source Code Reference
This file contains the API that implements the SPI master driver example functionalities.
This file contains sample source codes to demonstrate the SPI Foundation Services APIs.
For this example application to work the following needs to be done:
- Configure the SPI module as follows:
- Enable SPI: ticked
- Modes: Master
- Interrupt driven: unticked
- Configure other settings as desired.
- Select TX and RX pins in Pin Manager: Grid View.
- Make loop back connection to MISO and MOSI or connect SPI pins to a slave
- If connected to a slave, assign CS pin and add the necessary calls in drive_slave_select_low() and drive_slave_select_high()
- Program the slave device to exchange the string "data"
- Call SPI_Master_test from main()
This example works like this:
- Upon reset, the application will transmit a string "data" and read the same number of bytes back.
- The program will then compare the received string with "data". Returns 1 to indicate a match or 0 if not.