Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Master.cpp
- 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