Communication device setting

Dependencies:   mbed

Committer:
umezawa
Date:
Tue Dec 29 06:32:30 2020 +0000
Revision:
0:cddb9809247b
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
umezawa 0:cddb9809247b 1 #include "mbed.h"
umezawa 0:cddb9809247b 2 Serial pc(USBTX, USBRX);
umezawa 0:cddb9809247b 3 Serial com(D1,D0);
umezawa 0:cddb9809247b 4 DigitalOut NRST(A5);
umezawa 0:cddb9809247b 5 int i = 0;
umezawa 0:cddb9809247b 6 char msg[256];
umezawa 0:cddb9809247b 7
umezawa 0:cddb9809247b 8 int main()
umezawa 0:cddb9809247b 9 {
umezawa 0:cddb9809247b 10 com.baud(115200);
umezawa 0:cddb9809247b 11 pc.baud(115200);
umezawa 0:cddb9809247b 12 /*reset*/
umezawa 0:cddb9809247b 13 pc.printf("reset\r\n");
umezawa 0:cddb9809247b 14 NRST = 1;
umezawa 0:cddb9809247b 15 NRST = 0;
umezawa 0:cddb9809247b 16 wait(2);
umezawa 0:cddb9809247b 17 NRST = 1;
umezawa 0:cddb9809247b 18 /*Setting*/
umezawa 0:cddb9809247b 19 com.scanf("%s",msg);//受信
umezawa 0:cddb9809247b 20 pc.printf("%s\r\n",msg);
umezawa 0:cddb9809247b 21 if (strstr(msg,"Select")!=NULL) {
umezawa 0:cddb9809247b 22 com.printf("1\r\n");
umezawa 0:cddb9809247b 23 pc.printf("Terminal mode\r\n");
umezawa 0:cddb9809247b 24 com.printf("node\r\n");
umezawa 0:cddb9809247b 25 wait(0.5);
umezawa 0:cddb9809247b 26 pc.printf("node\r\n");
umezawa 0:cddb9809247b 27 com.printf("1\r\n");
umezawa 0:cddb9809247b 28 wait(0.5);
umezawa 0:cddb9809247b 29 com.printf("ownid\r\n");
umezawa 0:cddb9809247b 30 wait(0.5);
umezawa 0:cddb9809247b 31 com.printf("0\r\n");
umezawa 0:cddb9809247b 32 wait(0.5);
umezawa 0:cddb9809247b 33 pc.printf("ownid\r\n");
umezawa 0:cddb9809247b 34 com.printf("dstid\r\n");
umezawa 0:cddb9809247b 35 wait(0.5);
umezawa 0:cddb9809247b 36 com.printf("1\r\n");
umezawa 0:cddb9809247b 37 wait(0.5);
umezawa 0:cddb9809247b 38 pc.printf("dstid\r\n");
umezawa 0:cddb9809247b 39 com.printf("q\r\n");
umezawa 0:cddb9809247b 40 wait(0.5);
umezawa 0:cddb9809247b 41 com.printf("2\r\n");
umezawa 0:cddb9809247b 42 wait(0.5);
umezawa 0:cddb9809247b 43 pc.printf("Operation\r\n");
umezawa 0:cddb9809247b 44 com.printf("save\r\n");
umezawa 0:cddb9809247b 45 wait(1.0);
umezawa 0:cddb9809247b 46 com.printf("start\r\n");
umezawa 0:cddb9809247b 47 wait(0.5);
umezawa 0:cddb9809247b 48 pc.printf("Setting is finished\r\n");
umezawa 0:cddb9809247b 49 com.printf("HEPTA\r\n");
umezawa 0:cddb9809247b 50 }else
umezawa 0:cddb9809247b 51 {
umezawa 0:cddb9809247b 52 pc.printf("error\r\n");
umezawa 0:cddb9809247b 53 }
umezawa 0:cddb9809247b 54
umezawa 0:cddb9809247b 55 }