f303IM
Dependencies: mbed
Revision 0:8cc9c11c6785, committed 2022-01-13
- Comitter:
- Takagisyuiti
- Date:
- Thu Jan 13 06:54:11 2022 +0000
- Commit message:
- F303IMcant
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 13 06:54:11 2022 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "Serial.h" +DigitalOut cam_sw1(D10); //カメラの電源スイッチに接続(Highで電源ON) +DigitalOut cam_sw2(D9); //カメラの撮影スイッチ(FET)に接続(HighでD-S導通) +Serial device(PA_2,PA_3); +Serial im920(PA_9,PA_10,19200); +DigitalOut led(LED1); + +char str[10]; +int i=0; +int k=0; +void cmd(){ + if(im920.readable()){ + while(1) { + if(im920.readable()) { //IM920からのデータがある場合 + char temp = im920.getc();//一文字読み込む + if(temp != '\r') { //読み込み文字が改行で無い場合 + str[i] = temp; + i++; + } else if(temp == '\r') { //読み込み文字が改行の場合 + if(str[i-1]=='S'||'s'){ + cam_sw1 = 1; //カメラの電源スイッチON + wait(3); + cam_sw1 = 0; + wait(10); //カメラの電源ON + while(i<5){ + led=1; + wait(0.5); + i++; + } + }else if(str[i-1]=='T'||'t'){ + cam_sw2 = 1; //撮影スイッチON(撮影開始指示) + wait(0.2); //撮影開始 + cam_sw2=0; + }else if(str[i-1]=='E'||'e'){ + cam_sw2=1; //撮影スイッチON(撮影終了指示) + wait(0.2); //撮影終了 + cam_sw2=0; + }else if(str[i-1]=='A'||'a'||'B'||'b'||'C'||'c'){ + device.putc(str[i-1]); + }else{ + im920.printf("command error"); + } + } + } + } + } + } + +int main(){ + device.baud(9600); + device.attach(cmd,Serial::RxIrq); + while(1){ + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 13 06:54:11 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file