a

Dependencies:   mbed mbed

Fork of uarttest2 by 航空研究会

main.cpp

Committer:
TUATBM
Date:
2018-09-10
Revision:
1:e257c3c3f659
Parent:
0:1f2bac0f6ab8

File content as of revision 1:e257c3c3f659:

#include "mbed.h"
#include "Serial.h"

/*送信*/


Serial usbSerial(PA_9, PA_10,115200);
Serial g_Serial1(USBTX,USBRX,115200);
 
//void ISR_Serial_Rx()
//{
    // シリアルの受信処理
//    char data = usbSerial.getc();
//}
 
//void ISR_Serial_Tx()
//{
    // シリアルのs送信処理
//    usbSerial.attach(NULL, Serial::TxIrq);
//}
 
int main()
{
    // シリアル通信の速度設定
    usbSerial.baud(115200);
 
    // シリアル通信受信の割り込みイベント登録
//    usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
 
    // シリアル通信のデータ送信
//    usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq);

    
 
    while (1) {
        // メイン処理
        wait(10.0);
        g_Serial1.printf("a\r\n");
        usbSerial.putc('C');
        wait(20.0);
        
      
    }
}



/*受信*/
/*
Serial usbSerial(PA_2,PA_3);
Serial usbSerial2(PB_6,PB_7);
//Serial MySerial1(PA_2,PA_3);


 

 
void ISR_Serial_Rx()
{
    
    
    // シリアルの受信処理
    
    char data = usbSerial.getc();
    
    
    usbSerial.printf("%c\r\n",data);
    //printf("Hello world!\r\n");
    
    
 
    // シリアル通信受信の割り込みイベント登録
    //usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
 
    // シリアル通信のデータ送信
    //usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq);
    

    
        // メイン処理
       usbSerial.putc('3');
       
    
    
    
}
 
int main()
{
    // シリアル通信の速度設定
    usbSerial.baud(115200);
    usbSerial2.baud(115200);
 
    // シリアル通信受信の割り込みイベント登録
    usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
 
    while (1) { 
        // メイン処理
        NVIC_DisableIRQ(USART2_IRQn);
        usbSerial.printf("TUAT\r\n");
        NVIC_EnableIRQ(USART2_IRQn);
        wait(1.0);
 
        }
    
}
*/