taka yamanouchi
/
Nucleo_Communication
test
Diff: main.cpp
- Revision:
- 0:171079900b6e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 25 05:00:15 2020 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "string" +#define INT_TIME 0.5 + +Ticker timer; + +DigitalOut led(LED1); + +RawSerial pc (USBTX,USBRX,115200); +RawSerial Master (D5,D4,115200); + +string Master_str = ""; +string pc_str = ""; + +void Master_recv(){ + + char Master_c = Master.getc(); + Master_str += Master_c; + + if(Master_c == '\n'){ + pc_str = Master_str; + Master_str = ""; + } +} + +void timer_warikomi(){ + Master.printf("Comm_Slave\n"); + pc.printf(pc_str.c_str()); + led = !led; +} + +int main(){ + + timer.attach(&timer_warikomi,INT_TIME); + + Master.attach(&Master_recv,RawSerial::RxIrq); + + while(true){} +}