> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/linkit-7697/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/linkit-7697/linkit-7697-development-guide-for-arduino-ide/developer-guide/spi.md).

# SPI

LinkIt 7697 supports SPI Master with some limitations.

### A Note on SPI Devices <a href="#spi-anoteonspidevices" id="spi-anoteonspidevices"></a>

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](http://labs.mediatek.com/api/mt7687/group___s_p_i___m_a_s_t_e_r.html). For most users, the software implementation should be sufficient.

### Connecting to SPI Devices <a href="#spi-connectingtospidevices" id="spi-connectingtospidevices"></a>

As an example, we show how to use the SPI interface to connect to a [BMP183 Barometric Pressure & Altitude Sensor](https://www.adafruit.com/product/1900).

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2FJFAVxDBqvntzMkVcEbfl%2Fbmp183.png?alt=media\&token=e02cd7d4-1825-45d7-ab67-209bea85acdc)

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](https://github.com/adafruit/Adafruit_Sensor) and [Adafruit BMP183 Library](https://github.com/adafruit/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:

![](https://3972650740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY4gduUSLWOCI23CXUWej%2Fuploads%2FYDZxPubpm7EgbRTPqwhu%2Fbmp183_output.png?alt=media\&token=97e4cd86-d9e4-4cbd-a857-5b6472ef1592)
