2013-05-08 15:05:57 +00:00
|
|
|
#include "mbed.h"
|
|
|
|
|
|
|
|
#if defined(TARGET_KL25Z)
|
|
|
|
SPISlave device(PTD2, PTD3, PTD1, PTD0); // mosi, miso, sclk, ssel
|
2014-02-03 09:33:34 +00:00
|
|
|
#elif defined(TARGET_nRF51822)
|
|
|
|
SPISlave device(p12, p13, p15, p14); // mosi, miso, sclk, ssel
|
2013-12-29 10:18:50 +00:00
|
|
|
#elif defined(TARGET_LPC812)
|
|
|
|
SPISlave device(P0_14, P0_15, P0_12, P0_13); // mosi, miso, sclk, ssel
|
2013-05-08 15:05:57 +00:00
|
|
|
#else
|
|
|
|
SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
uint8_t resp = 0;
|
|
|
|
|
|
|
|
device.reply(resp); // Prime SPI with first reply
|
2014-05-29 13:49:47 +00:00
|
|
|
|
2013-05-08 15:05:57 +00:00
|
|
|
while(1) {
|
|
|
|
if(device.receive()) {
|
|
|
|
resp = device.read(); // Read byte from master and add 1
|
|
|
|
device.reply(resp); // Make this the next reply
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|