z

Dependencies:   TextLCD mbed

Committer:
TUATBM
Date:
Fri Sep 07 05:26:27 2018 +0000
Revision:
0:a1acaff29a23
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TUATBM 0:a1acaff29a23 1 #include "mbed.h"
TUATBM 0:a1acaff29a23 2
TUATBM 0:a1acaff29a23 3 /*送信*/
TUATBM 0:a1acaff29a23 4 /*
TUATBM 0:a1acaff29a23 5 Serial g_Serial1(USBTX,USBRX);
TUATBM 0:a1acaff29a23 6 Serial g_serial2(PB_6, PB_7);
TUATBM 0:a1acaff29a23 7
TUATBM 0:a1acaff29a23 8 int main() {
TUATBM 0:a1acaff29a23 9 g_serial2.baud(9600);
TUATBM 0:a1acaff29a23 10
TUATBM 0:a1acaff29a23 11 char k[]="Hello world!";
TUATBM 0:a1acaff29a23 12 while(1) {
TUATBM 0:a1acaff29a23 13 g_serial2.printf( "%s\r\n",k);
TUATBM 0:a1acaff29a23 14 wait(1.0);
TUATBM 0:a1acaff29a23 15 printf("a\r\n");
TUATBM 0:a1acaff29a23 16 }
TUATBM 0:a1acaff29a23 17 }
TUATBM 0:a1acaff29a23 18 */
TUATBM 0:a1acaff29a23 19
TUATBM 0:a1acaff29a23 20
TUATBM 0:a1acaff29a23 21 /*受信*/
TUATBM 0:a1acaff29a23 22
TUATBM 0:a1acaff29a23 23 #include "mbed.h"
TUATBM 0:a1acaff29a23 24
TUATBM 0:a1acaff29a23 25 Serial MySerial1(USBTX,USBRX);
TUATBM 0:a1acaff29a23 26 Serial MySerial2(PA_9,PA_10);
TUATBM 0:a1acaff29a23 27
TUATBM 0:a1acaff29a23 28 int main() {
TUATBM 0:a1acaff29a23 29 while(1) {
TUATBM 0:a1acaff29a23 30 char c;
TUATBM 0:a1acaff29a23 31
TUATBM 0:a1acaff29a23 32 if (MySerial1.readable())
TUATBM 0:a1acaff29a23 33 {
TUATBM 0:a1acaff29a23 34 c = MySerial1.getc();
TUATBM 0:a1acaff29a23 35 while(!MySerial2.writeable())
TUATBM 0:a1acaff29a23 36 {
TUATBM 0:a1acaff29a23 37 // 受信可能になるまで、ループ
TUATBM 0:a1acaff29a23 38 }
TUATBM 0:a1acaff29a23 39 MySerial2.putc(c);
TUATBM 0:a1acaff29a23 40 }
TUATBM 0:a1acaff29a23 41
TUATBM 0:a1acaff29a23 42 if (MySerial2.readable())
TUATBM 0:a1acaff29a23 43 {
TUATBM 0:a1acaff29a23 44 c = MySerial2.getc();
TUATBM 0:a1acaff29a23 45 while(!MySerial1.writeable())
TUATBM 0:a1acaff29a23 46 {
TUATBM 0:a1acaff29a23 47 // 受信可能になるまで、ループ
TUATBM 0:a1acaff29a23 48 }
TUATBM 0:a1acaff29a23 49 MySerial1.putc(c);
TUATBM 0:a1acaff29a23 50 }
TUATBM 0:a1acaff29a23 51 }
TUATBM 0:a1acaff29a23 52 }