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: spi_master.cpp
- Revision:
- 1:5a1355e57aed
- Parent:
- 0:382b3838a100
- Child:
- 2:6d9572f5523e
--- a/spi_master.cpp Sat Jan 02 09:02:40 2021 +0000
+++ b/spi_master.cpp Thu Jan 07 10:13:16 2021 +0000
@@ -12,7 +12,7 @@
pc.printf("--Hi,this is cdh(master).\r\n");
cs = 1;
- to_eps.format(8,3);
+ to_eps.format(8,0);
to_eps.frequency(1000000);
int cmd = 0;
@@ -22,11 +22,27 @@
cs=0;
int dummy = to_eps.write(cmd); // send command
- int rdata = to_eps.write(0x00);
cs=1;
- pc.printf("dummy: %d, ",dummy);
- pc.printf("rdata: %d\r\n",rdata);
+ pc.printf("dummy: %x, ",dummy);
+
+ if(cmd == 1){
+ wait(1);
+ cs=0;
+ int rdata = to_eps.write(0x00);
+ cs=1;
+ pc.printf("rdata: %x\r\n",rdata);
+ }
+
+ if(cmd == 2){
+ wait(3);
+ cs=0;
+ int rdata1 = to_eps.write(0x00);
+ int rdata2 = to_eps.write(0x00);
+ cs=1;
+ pc.printf("rdata1: %x\r\n",rdata1);
+ pc.printf("rdata2: %x\r\n",rdata2);
+ }
cmd++;
}