]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/spi_slave/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / spi_slave / main.cpp
1 #include "mbed.h"
2
3 #if defined(TARGET_KL25Z)
4 SPISlave device(PTD2, PTD3, PTD1, PTD0);    // mosi, miso, sclk, ssel
5 #elif defined(TARGET_nRF51822)
6 SPISlave device(p12, p13, p15, p14);  // mosi, miso, sclk, ssel
7 #elif defined(TARGET_LPC812)
8 SPISlave device(P0_14, P0_15, P0_12, P0_13);    // mosi, miso, sclk, ssel
9 #elif defined(TARGET_FF_ARDUINO)
10 SPISlave device(D11, D12, D13, D10);       // mosi, miso, sclk, ssel
11 #elif defined(TARGET_LPC1114)
12 SPISlave device(dp2, dp1, dp6, dp25);            // mosi, miso, sclk, ssel
13 #else
14 SPISlave device(p5, p6, p7, p8);            // mosi, miso, sclk, ssel
15 #endif
16
17
18 int main() {
19     uint8_t resp = 0;
20
21     device.reply(resp);                    // Prime SPI with first reply
22
23     while(1) {
24         if(device.receive()) {
25             resp = device.read();           // Read byte from master and add 1
26             device.reply(resp);             // Make this the next reply
27         }
28     }
29 }