teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Tue Nov 27 05:23:44 2018 +0000
Revision:
14:76a56d517103
Parent:
8:1ca49cb18290
Child:
17:f9610f3cfa1b
Gyro???????????????

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 8:1ca49cb18290 5 //ログ吐出し様シリアルポートインスタンス
takeru0x1103 8:1ca49cb18290 6 //----------------------------------
takeru0x1103 8:1ca49cb18290 7 #define WIREED_SERIAL
takeru0x1103 0:ecd925601fc6 8 #ifdef WIREED_SERIAL
takeru0x1103 0:ecd925601fc6 9 Serial sp(USBTX, USBRX); //有線のポート
takeru0x1103 8:1ca49cb18290 10 #define BAUD_RATE 115200
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
MasashiNomura 7:bfbbf605be43 15
MasashiNomura 14:76a56d517103 16 //Serial sp46Axis(p28,p27);
MasashiNomura 7:bfbbf605be43 17
takeru0x1103 8:1ca49cb18290 18 //Asciiコード
takeru0x1103 8:1ca49cb18290 19 #define CR 0x0D
takeru0x1103 8:1ca49cb18290 20 #define LF 0x0A
takeru0x1103 0:ecd925601fc6 21 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
takeru0x1103 0:ecd925601fc6 22 // UART 受信割り込みハンドラ
takeru0x1103 0:ecd925601fc6 23 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
takeru0x1103 0:ecd925601fc6 24 void uartRxIntHndler(){
takeru0x1103 0:ecd925601fc6 25 //1Byte抜き出す
takeru0x1103 0:ecd925601fc6 26 UCHAR buf = sp.getc();
takeru0x1103 0:ecd925601fc6 27 //エコーバック
takeru0x1103 0:ecd925601fc6 28 sp.putc(buf);
takeru0x1103 0:ecd925601fc6 29 //コマンドバッファに突っ込む
takeru0x1103 1:15ab74f0d0f1 30 commandPush(buf);
takeru0x1103 0:ecd925601fc6 31 }
takeru0x1103 0:ecd925601fc6 32
takeru0x1103 0:ecd925601fc6 33 //=============================================================
takeru0x1103 0:ecd925601fc6 34 //初期設定
takeru0x1103 0:ecd925601fc6 35 //=============================================================
takeru0x1103 0:ecd925601fc6 36 void uartInit(){
takeru0x1103 0:ecd925601fc6 37 //ボーレート設定
takeru0x1103 0:ecd925601fc6 38 sp.baud(BAUD_RATE);
takeru0x1103 0:ecd925601fc6 39
takeru0x1103 8:1ca49cb18290 40 //受信割り込みハンドラ登録(登録するハンドラ,割り込み要因)
takeru0x1103 8:1ca49cb18290 41 sp.attach(uartRxIntHndler,Serial::RxIrq);
takeru0x1103 0:ecd925601fc6 42
takeru0x1103 0:ecd925601fc6 43 sp.printf("***********\r\n");
takeru0x1103 0:ecd925601fc6 44 sp.printf("UART open!!\r\n");
takeru0x1103 0:ecd925601fc6 45 sp.printf("-----------\r\n");
takeru0x1103 0:ecd925601fc6 46 sp.printf("short = %d\r\n" ,sizeof(unsigned short) );
takeru0x1103 0:ecd925601fc6 47 sp.printf("int = %d\r\n" ,sizeof(unsigned int) );
takeru0x1103 0:ecd925601fc6 48 sp.printf("long = %d\r\n" ,sizeof(unsigned long) );
takeru0x1103 0:ecd925601fc6 49 sp.printf("***********\r\n");
takeru0x1103 0:ecd925601fc6 50 }