Carlo Collodi / kangaroo

Dependencies:   QEI mbed

Revision:
33:2a96d2e00b46
Parent:
10:e52a6e1bbb48
--- a/Master.cpp	Tue Nov 12 20:10:03 2013 +0000
+++ b/Master.cpp	Mon Nov 18 06:23:55 2013 +0000
@@ -0,0 +1,16 @@
+// Reply to a SPI master as slave
+ 
+ #include "mbed.h"
+ 
+ SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel
+ 
+ int main() {
+     device.reply(0x00);              // Prime SPI with first reply
+     while(1) {
+         if(device.receive()) {
+             int v = device.read();   // Read byte from master
+             v = (v + 1) % 0x100;     // Add one to it, modulo 256
+             device.reply(v);         // Make this the next reply
+         }
+     }
+ }
\ No newline at end of file