SPI

LinkIt 7697 supports SPI Master with some limitations.

A Note on SPI Devices

The built-in SPI library is implemented in software based on GPIO APIs. A hardware library is not provided because the design of hardware SPI function of MT7697 is not fully compatible with the SPI API usage defined by Arduino IDE. If you want to access the hardware SPI feature of LinkIt 7697, please refer to the LinkIt SDK API. For most users, the software implementation should be sufficient.

Connecting to SPI Devices

As an example, we show how to use the SPI interface to connect to a BMP183 Barometric Pressure & Altitude Sensor.

  1. Connect the board with the BMP183 sensor as shown in the above figure.

  2. Download the zip file for the Adafruit Unified Sensor Driver and Adafruit BMP183 Library.

  3. In the Arduino IDE, select the Sketch / Include Library / Add .Zip Library and choose the two zip files (Adafruit_Sensor-master.zip and Adafruit_BMP183_Library-master.zip) downloaded in the previous step to add them in.

  4. Open the Adafruit_BMP183.cpp file in the user-installed library folder.

  5. Add a line to define the _delay_ms() function in line 25, as shown below:

    #include <SPI.h>
    #define _delay_ms(t) delay(t)
     
    Adafruit_BMP183::Adafruit_BMP183(int8_t SPICS ) {
  6. Comment out line 46 and replace it with the SPISettings() class as line 47 in the following code block:

    boolean Adafruit_BMP183::begin(bmp183_mode_t mode) { 
        if (_clk == -1) { 
            SPI.begin(); 
            //SPI.setDataMode(SPI_MODE0);
            SPI.beginTransaction(SPISettings(7000000, MSBFIRST, SPI_MODE0)); 
        #ifdef __AVR__ 
            SPI.setClockDivider(SPI_CLOCK_DIV16);
  7. Save the edited file.

  8. Click the Upload icon to compile and upload the sketch to the board.

  9. You should be able to see the output from the BMP183 in the Serial Monitor (with baud rate 9,600), for example:

Last updated