Carlo Collodi / kangaroo

Dependencies:   QEI mbed

Master.cpp

Committer:
Sparker
Date:
2013-11-18
Revision:
33:2a96d2e00b46
Parent:
10:e52a6e1bbb48

File content as of revision 33:2a96d2e00b46:

// 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
         }
     }
 }