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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:286baeef532e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 19 05:26:48 2018 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + +SPISlave device(PB_5,PB_4,PB_3,PA_4); // mosi, miso, sclk, ssel +Serial pc(SERIAL_TX, SERIAL_RX); + + +int main() +{ + device.format(8,0); + device.frequency(1000000); + uint8_t hbyte = 7; + uint8_t lbyte = 208; + + int counter = 0; + + while(1) { + if(device.receive()) { + + int val = device.read(); + pc.printf("received1: %d, ",val); + device.reply(0xFF); + + int val2 = device.read(); + pc.printf("received2: %d, ",val2); + device.reply(hbyte); // Make this the next reply + + int val3 = device.read(); + pc.printf("receive3: %d, ",val3); + pc.printf("count: %d\r\n",counter); + device.reply(lbyte); // Make this the next reply + + counter = counter+1; + } + wait(0.01); + } +}