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
Revision 0:e770d057315d, committed 2021-01-02
- Comitter:
- taiga_prelude
- Date:
- Sat Jan 02 09:03:56 2021 +0000
- Commit message:
- 1st upload;
Changed in this revision
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
spi_slave.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r e770d057315d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jan 02 09:03:56 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
diff -r 000000000000 -r e770d057315d spi_slave.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spi_slave.cpp Sat Jan 02 09:03:56 2021 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + + +SPISlave to_cdh(p5,p6,p7,p8); // mosi, miso, sclk, ssel +Serial pc(USBTX, USBRX); + +int main() +{ + pc.printf("--Hi,this is eps(slave).\r\n"); + + to_cdh.format(8,3); + to_cdh.frequency(1000000); + + int sdummy = 0x09; + + while(1) { + + if(to_cdh.receive()) { + int rcmd = to_cdh.read(); //receive 1st byte + int rdummy = to_cdh.read(); //receive 2nd byte + + to_cdh.reply(sdummy); // prepare to send 1st byte (dummy) + + if(rcmd%2 == 0){ + to_cdh.reply(rcmd); + } + else{ + to_cdh.reply(0xFF); + } + + pc.printf("rcmd: %02x, dummy: %02x\r\n",rcmd, rdummy); + + + } + } +} \ No newline at end of file