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: main.cpp
- Revision:
- 0:0b5a11c7df57
- Child:
- 1:226fc487b92e
diff -r 000000000000 -r 0b5a11c7df57 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Dec 17 12:55:12 2020 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+/*ドップラーシフト対策 calsatが計算した周波数のデータを受け取る*/
+Serial pc(SERIAL_TX, SERIAL_RX,921600);
+Serial device(PA_9,PA_10,9600);
+#define kHz 1000
+#define MHz 1000000
+
+void doppler(char *a) //データを取得し、出力する関数
+{
+ int data[10] = {0};
+ int doppler_data = 0;
+ int flag = 0;
+ for(int i = 5; i < 10; i++) {
+ char c = a[i];
+ data[flag] = (c >> 4) & 0xf;
+ data[flag+1] = c & 0xf;
+ flag += 2;
+ }
+
+ for(int i = 0; i < 10 ; i++)
+ printf("%d ", data[i]);
+ printf("\r\n");
+
+ doppler_data = 10 * data[0] + data[1] + kHz * data[2] + 100 * data[3] + 100*kHz * data[4] + 10*kHz * data[5] + 10*MHz * data[6] + MHz * data[7] + data[8] + 100*MHz * data[9];
+ printf("\n%d\n",doppler_data);
+
+
+
+}
+
+int main()
+{
+
+ while(1) {
+ char command[128] = {'0'};
+ char c = device.getc();
+ int i = 1;
+ if(c == 0xfe) { //FEコマンドがきたらdataが始まる
+ command[0] = c;
+
+ while(c != 0xfd) {
+ c = device.getc();
+ command[i] = c;
+ i++;
+ }
+ //ここまでで一旦プリアンブルからポストアンブルまでをcommandに格納する
+ //表示確認
+
+ for(int j = 0; j < i; j++)
+ printf("%02hhx",command[j]);
+ printf("\r\n");
+
+ if(command[4] == 0x00)
+ doppler(command);
+ }
+ }
+}
+
+
+