#include "mbed.h"


#include"mbed.h"

Serial pc(SERIAL_TX,SERIAL_RX);//USART2  tx, rx
Serial device(PA_11, PA_12); // PCusbתTTL CP2102   USART6 tx, rx
DigitalOut led(LED1);

void xxIRQ()
{
pc.putc(device.getc());    
}

void xxxIRQ()
{
device.putc(pc.getc());    
}

int main()
{
  int i=1;
  pc.attach(&xxIRQ,SerialBase::RxIrq); 
  device.attach(&xxxIRQ,SerialBase::RxIrq); 
  while(1)
  {
    //pc.attach(&xxIRQ,SerialBase::RxIrq); 
    led=0;wait(0.1);led=1;wait(0.1);wait(1);
    pc.printf("This demo work runs since %d seconds.\n", i++);
    
    if(pc.readable()) 
      {
       device.putc(pc.getc()); // ⴮ڽ,PC
      }
    if(device.readable()) 
      {
       pc.putc(device.getc()); // PCڽ,⴮
      }
  }
}