a
Revision 0:8a10e55fdbab, committed 24 months ago
- Comitter:
- goro56
- Date:
- Tue Nov 01 05:08:54 2022 +0000
- Commit message:
- a
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Nov 01 05:08:54 2022 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+DigitalOut myleds[]={LED1,LED2};
+SPISlave slave(p11,p12,p13,p14);
+DigitalOut pin21(p21);
+DigitalOut pin22(p22);
+int counter = 0;
+int main() {
+ slave.format(8,0);
+ slave.frequency(1000000);
+ while(1){
+ if(slave.receive()){
+ int val = slave.read();//受信データをvalに格納する
+ pc.printf("received from master : %d\r\n",val);
+ if(val==0xAA){
+ //myleds[0]=1;
+ //wait(1.0);
+ //myleds[0]=0;
+ pin21=1;
+ wait(1.0);
+ pin21=0;
+ }
+
+ else if(val==0xAB){
+ pc.printf("Hello World!\r\n");
+ //myleds[1]=1;
+ //wait(1.0);
+ //myleds[1]=0;
+ pin22=1;
+ wait(1.0);
+ pin22=0;
+ }
+ counter = counter+1;
+ slave.reply(counter);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 01 05:08:54 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file