teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
takeru0x1103
Date:
Sat Nov 24 11:35:48 2018 +0000
Revision:
1:15ab74f0d0f1
Parent:
0:ecd925601fc6
Child:
7:bfbbf605be43
8??????;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeru0x1103 0:ecd925601fc6 1 #include "typedef.h"
takeru0x1103 0:ecd925601fc6 2 #include "uart.h"
takeru0x1103 1:15ab74f0d0f1 3 #include "command.h"
takeru0x1103 0:ecd925601fc6 4
takeru0x1103 0:ecd925601fc6 5 //#define WIREED_SERIAL
takeru0x1103 0:ecd925601fc6 6
takeru0x1103 0:ecd925601fc6 7 //シリアルポートインスタンス
takeru0x1103 0:ecd925601fc6 8 #ifdef WIREED_SERIAL
takeru0x1103 0:ecd925601fc6 9 Serial sp(USBTX, USBRX); //有線のポート
takeru0x1103 0:ecd925601fc6 10 #define BAUD_RATE 9600
takeru0x1103 0:ecd925601fc6 11 #else
takeru0x1103 0:ecd925601fc6 12 Serial sp(p9, p10);//TWILITEをモジュールを接続したポート
takeru0x1103 0:ecd925601fc6 13 #define BAUD_RATE 115200
takeru0x1103 0:ecd925601fc6 14 #endif
takeru0x1103 0:ecd925601fc6 15
takeru0x1103 0:ecd925601fc6 16 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
takeru0x1103 0:ecd925601fc6 17 // UART 受信割り込みハンドラ
takeru0x1103 0:ecd925601fc6 18 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
takeru0x1103 0:ecd925601fc6 19 void uartRxIntHndler(){
takeru0x1103 0:ecd925601fc6 20 //1Byte抜き出す
takeru0x1103 0:ecd925601fc6 21 UCHAR buf = sp.getc();
takeru0x1103 0:ecd925601fc6 22 //エコーバック
takeru0x1103 0:ecd925601fc6 23 sp.putc(buf);
takeru0x1103 0:ecd925601fc6 24 //コマンドバッファに突っ込む
takeru0x1103 1:15ab74f0d0f1 25 commandPush(buf);
takeru0x1103 0:ecd925601fc6 26 }
takeru0x1103 0:ecd925601fc6 27
takeru0x1103 0:ecd925601fc6 28 //=============================================================
takeru0x1103 0:ecd925601fc6 29 //初期設定
takeru0x1103 0:ecd925601fc6 30 //=============================================================
takeru0x1103 0:ecd925601fc6 31 void uartInit(){
takeru0x1103 0:ecd925601fc6 32 //ボーレート設定
takeru0x1103 0:ecd925601fc6 33 sp.baud(BAUD_RATE);
takeru0x1103 0:ecd925601fc6 34
takeru0x1103 0:ecd925601fc6 35 //受信割り込みハンドラ登録
takeru0x1103 0:ecd925601fc6 36 sp.attach
takeru0x1103 0:ecd925601fc6 37 (uartRxIntHndler //登録するハンドラ
takeru0x1103 0:ecd925601fc6 38 ,Serial::RxIrq //割り込み要因
takeru0x1103 0:ecd925601fc6 39 );
takeru0x1103 0:ecd925601fc6 40
takeru0x1103 0:ecd925601fc6 41 sp.printf("***********\r\n");
takeru0x1103 0:ecd925601fc6 42 sp.printf("UART open!!\r\n");
takeru0x1103 0:ecd925601fc6 43 sp.printf("-----------\r\n");
takeru0x1103 0:ecd925601fc6 44 sp.printf("short = %d\r\n" ,sizeof(unsigned short) );
takeru0x1103 0:ecd925601fc6 45 sp.printf("int = %d\r\n" ,sizeof(unsigned int) );
takeru0x1103 0:ecd925601fc6 46 sp.printf("long = %d\r\n" ,sizeof(unsigned long) );
takeru0x1103 0:ecd925601fc6 47 sp.printf("***********\r\n");
takeru0x1103 0:ecd925601fc6 48
takeru0x1103 0:ecd925601fc6 49 }