Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: uart.cpp
- Revision:
- 2:f0fbb23b4605
- Parent:
- 0:ecd925601fc6
- Child:
- 4:7aa8cf0dd56f
diff -r ecd925601fc6 -r f0fbb23b4605 uart.cpp
--- a/uart.cpp Fri Nov 23 07:27:43 2018 +0000
+++ b/uart.cpp Fri Nov 23 08:01:44 2018 +0000
@@ -11,7 +11,10 @@
Serial sp(p9, p10);//TWILITEをモジュールを接続したポート
#define BAUD_RATE 115200
#endif
-
+
+Serial sp46Axis(p28,p27);
+#define BAUD_RATE4_6AXIS 115200
+
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// UART 受信割り込みハンドラ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -24,6 +27,19 @@
//commandPush(buf);
}
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// UART 受信割り込みハンドラ for Arduino UNO(Six Axis Sensor)
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void uartRxIntHndler46AxisS(){
+ //1Byte抜き出す
+ UCHAR buf = sp46Axis.getc();
+ //エコーバック
+ sp46Axis.putc(buf);
+ sp.putc(buf);
+ //コマンドバッファに突っ込む
+ //commandPush(buf);
+}
+
//=============================================================
//初期設定
//=============================================================
@@ -45,4 +61,21 @@
sp.printf("long = %d\r\n" ,sizeof(unsigned long) );
sp.printf("***********\r\n");
+ // for 6Axis Sensor
+ //ボーレート設定
+ sp46Axis.baud(BAUD_RATE4_6AXIS);
+
+ //受信割り込みハンドラ登録
+ sp46Axis.attach
+ (uartRxIntHndler46AxisS //登録するハンドラ
+ ,Serial::RxIrq //割り込み要因
+ );
+
+ sp46Axis.printf("***********\r\n");
+ sp46Axis.printf("UART open!!\r\n");
+ sp46Axis.printf("-----------\r\n");
+ sp46Axis.printf("short = %d\r\n" ,sizeof(unsigned short) );
+ sp46Axis.printf("int = %d\r\n" ,sizeof(unsigned int) );
+ sp46Axis.printf("long = %d\r\n" ,sizeof(unsigned long) );
+ sp46Axis.printf("***********\r\n");
}