LPC
Dependencies: mbed MotorDrivers
Diff: main.cpp
- Revision:
- 0:13467eba9ca0
- Child:
- 1:b4ca9ec7b90b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 07 08:52:37 2020 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "string" +//1272552550b00000001\n受信例 +RawSerial con(p9,p10,115200); +RawSerial pc (USBTX,USBRX,115200); +Ticker tras;//trasからtransへ変更予定trans=transmission(送信) +char con_c;//recivへ変更予定reciv=Receive + +char motoX;//モーターX軸 +char motoY;//モーターY軸 +char motoR;//モーター回転数 +char button;//ボタン信号 上半身へ送信 + +string tras_str = "";//trasからtransへ変更予定 +string USBtx_str = "";//USB送信用変数 + +void atras(){//読み取り処理 + con_c = con.getc();//シリアル受信 + tras_str += con_c; + if(con_c == '\n'){//末尾改行コード(\n)感知 + USBtx_str = tras_str; + motoX = tras_str[1]; + tras_str = ""; + } +} +void aUSBtx(){//書き込み処理 + int motoX = motoX; + con.printf(USBtx_str.c_str());//送信 + pc.printf(USBtx_str.c_str()); + //pc.printf("thing=%d",motoX); +} +int main() +{ + tras.attach(&aUSBtx,0.5);//タイマー割込み + + con.attach(&atras,RawSerial::RxIrq);//受信割込み + while(1) { + } +} \ No newline at end of file