a

Dependencies:   mbed mbed

Fork of uarttest2 by 航空研究会

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Serial.h"
00003 
00004 /*送信*/
00005 
00006 
00007 Serial usbSerial(PA_9, PA_10,115200);
00008 Serial g_Serial1(USBTX,USBRX,115200);
00009  
00010 //void ISR_Serial_Rx()
00011 //{
00012     // シリアルの受信処理
00013 //    char data = usbSerial.getc();
00014 //}
00015  
00016 //void ISR_Serial_Tx()
00017 //{
00018     // シリアルのs送信処理
00019 //    usbSerial.attach(NULL, Serial::TxIrq);
00020 //}
00021  
00022 int main()
00023 {
00024     // シリアル通信の速度設定
00025     usbSerial.baud(115200);
00026  
00027     // シリアル通信受信の割り込みイベント登録
00028 //    usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
00029  
00030     // シリアル通信のデータ送信
00031 //    usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq);
00032 
00033     
00034  
00035     while (1) {
00036         // メイン処理
00037         wait(10.0);
00038         g_Serial1.printf("a\r\n");
00039         usbSerial.putc('C');
00040         wait(20.0);
00041         
00042       
00043     }
00044 }
00045 
00046 
00047 
00048 /*受信*/
00049 /*
00050 Serial usbSerial(PA_2,PA_3);
00051 Serial usbSerial2(PB_6,PB_7);
00052 //Serial MySerial1(PA_2,PA_3);
00053 
00054 
00055  
00056 
00057  
00058 void ISR_Serial_Rx()
00059 {
00060     
00061     
00062     // シリアルの受信処理
00063     
00064     char data = usbSerial.getc();
00065     
00066     
00067     usbSerial.printf("%c\r\n",data);
00068     //printf("Hello world!\r\n");
00069     
00070     
00071  
00072     // シリアル通信受信の割り込みイベント登録
00073     //usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
00074  
00075     // シリアル通信のデータ送信
00076     //usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq);
00077     
00078 
00079     
00080         // メイン処理
00081        usbSerial.putc('3');
00082        
00083     
00084     
00085     
00086 }
00087  
00088 int main()
00089 {
00090     // シリアル通信の速度設定
00091     usbSerial.baud(115200);
00092     usbSerial2.baud(115200);
00093  
00094     // シリアル通信受信の割り込みイベント登録
00095     usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
00096  
00097     while (1) { 
00098         // メイン処理
00099         NVIC_DisableIRQ(USART2_IRQn);
00100         usbSerial.printf("TUAT\r\n");
00101         NVIC_EnableIRQ(USART2_IRQn);
00102         wait(1.0);
00103  
00104         }
00105     
00106 }
00107 */