/ ̄\                |     |                  \_/                  |               /  ̄  ̄ \             /  \ /  \            /   ⌒   ⌒   \            |    (__人__)     |            \    ` ⌒´    /            / ̄ ̄ ̄ ̄ ̄ ̄ ̄ \

Dependencies:   mbed BMP280_SPI ADXL345 MPU9250_SPI GPS FATFileSystem

Files at this revision

API Documentation at this revision

Comitter:
IKobayashi
Date:
Mon Feb 24 10:06:48 2020 +0000
Child:
1:339e7c67f42f
Commit message:
noitamina

Changed in this revision

ADXL345.lib Show annotated file Show diff for this revision Revisions of this file
BMP280_SPI.lib Show annotated file Show diff for this revision Revisions of this file
GPS.lib Show annotated file Show diff for this revision Revisions of this file
GettingStarted.html Show annotated file Show diff for this revision Revisions of this file
MPU9250.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.txt 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
mbed_config.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL345.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/ADXL345/#21a3f84ad1c9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP280_SPI.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/MACRUM/code/BMP280_SPI/#0463be4e35c0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPS.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/IKobayashi/code/GPS/#f291337e7ce9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GettingStarted.html	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+    <head>
+        <meta charset="UTF-8">
+        <meta http-equiv="refresh"
+              content="1;url="https://os.mbed.com/docs/latest/tools/exporting.html>
+        <script type="text/javascript">
+            window.location.href = "https://os.mbed.com/docs/latest/tools/exporting.html"
+        </script>
+        <title>Page Redirection</title>
+    </head>
+    <body>
+        If you are not redirected automatically, please follow the
+        <a href='https://os.mbed.com/docs/v5.6/tools/exporting.html/'>link to the online exporter documentation</a>
+    </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU9250.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/kylongmu/code/MPU9250_SPI/#084e8ba240c1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,2 @@
+# cansat_kata_vol2
+volume2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/USBDevice/#53949e6131f6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,103 @@
+#include "mbed.h"
+#include "USBSerial.h"
+#include "MPU9250.h"
+#include "BMP280_SPI.h"
+#include "ADXL345.h"
+#include "GPS.h"
+#include "SDFileSystem.h"
+
+DigitalOut led(PC_13);
+GPS gps(PB_6, PB_7); // tx, rx
+I2C i2c(PB_9, PB_8);
+ADXL345 accelerometer(i2c);
+Serial xbee(PA_2,PA_3,38400);
+SDFileSystem sd(PB_5, PB_4, PB_3, PA_15, "sd");
+SPI spi(PA_7, PA_6, PA_5);
+mpu9250_spi imu(spi,PA_4);   //define the mpu9250 object
+BMP280_SPI sensor(PA_7, PA_6, PA_5, PA_0);
+//Serial pc(USBTX, USBRX);    // tx, rx
+USBSerial pc;
+
+int main()
+{
+    int i=0;
+
+    pc.printf("*** GPS GT-720F ***\r\n");
+    float readings[3];
+
+    mkdir("/sd/mydir", 0777);
+
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+
+    if(imu.init(1,BITS_DLPF_CFG_188HZ)) { //INIT the mpu9250
+        pc.printf("\nCouldn't initialize MPU9250 via SPI!");
+    }
+    pc.printf("\nWHOAMI=0x%2x\n\r",imu.whoami()); //output the I2C address to know if SPI is working, it should be 104
+    wait(1);
+    pc.printf("Gyro_scale=%u\n\r",imu.set_gyro_scale(BITS_FS_2000DPS));    //Set full scale range for gyros
+    wait(1);
+    pc.printf("Acc_scale=%u\n\r",imu.set_acc_scale(BITS_FS_16G));          //Set full scale range for accs
+    wait(1);
+    pc.printf("AK8963 WHIAM=0x%2x\n\r",imu.AK8963_whoami());
+    wait(0.1);
+    imu.AK8963_calib_Magnetometer();
+
+    fprintf(fp,"MPU9250_data, , , , , , , , , ,");
+    fprintf(fp,"BMP280_data, ,");
+    fprintf(fp,"ADXL345_data, , ,");
+    fprintf(fp,"世界標準時: ,北緯: ,東経: ,状態: ,使用衛星数: ,\r\n");
+
+    while (i<25) {
+        wait(0.1);
+        /*
+        imu.read_temp();
+        imu.read_acc();
+        imu.read_rot();
+        imu.AK8963_read_Magnetometer();
+        */
+        imu.read_all();
+        pc.printf("%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f\n\r",
+                  imu.Temperature,
+                  imu.gyroscope_data[0],
+                  imu.gyroscope_data[1],
+                  imu.gyroscope_data[2],
+                  imu.accelerometer_data[0],
+                  imu.accelerometer_data[1],
+                  imu.accelerometer_data[2],
+                  imu.Magnetometer[0],
+                  imu.Magnetometer[1],
+                  imu.Magnetometer[2]
+                 );
+        fprintf(fp,"%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f,%10.3f",
+                imu.Temperature,
+                imu.gyroscope_data[0],
+                imu.gyroscope_data[1],
+                imu.gyroscope_data[2],
+                imu.accelerometer_data[0],
+                imu.accelerometer_data[1],
+                imu.accelerometer_data[2],
+                imu.Magnetometer[0],
+                imu.Magnetometer[1],
+                imu.Magnetometer[2]
+               );
+
+        pc.printf("%2.2f degC, %04.2f hPa\n\r", sensor.getTemperature(), sensor.getPressure());
+        fprintf(fp,"%2.2f , %04.2f ,", sensor.getTemperature(), sensor.getPressure());
+
+        accelerometer.read_mg_data(readings);
+        pc.printf("x=%f, y=%f, z=%f\r\n",readings[0],readings[1],readings[2]);
+        fprintf(fp,"%f, %f, %f,",readings[0],readings[1],readings[2]);
+
+        pc.printf("世界標準時:%02dh%02dm%02ds 北緯:%.8f 東経:%.8f 状態:%d 使用衛星数:%d\r\n",
+                  gps.g_hour, gps.g_min, gps.g_sec, gps.g_hokui, gps.g_tokei, gps.rlock, gps.stlgt);
+        fprintf(fp,"%02dh%02dm%02ds ,%.8f ,%.8f ,%d ,%d\r\n",
+                gps.g_hour, gps.g_min, gps.g_sec, gps.g_hokui, gps.g_tokei, gps.rlock, gps.stlgt);
+
+        led=!led;
+        i++;
+    }
+    fclose(fp);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.txt	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,187 @@
+/*
+説明
+Nucleo-F303K8とGPSモジュールを使ったサンプルプログラム.
+ 
+使用GPS
+http://akizukidenshi.com/catalog/g/gK-09991/
+ 
+参考
+http://www.hiramine.com/physicalcomputing/general/gps_nmeaformat.html
+
+なにするだー
+ 
+ 
+以下ピン配置
+Nucleo  GPSモジュール
+GND-----GND-----------0V
+5V------VIN
+D0------TX
+D1------RX
+*/
+
+#include "mbed.h"
+#include "USBSerial.h"
+ 
+DigitalOut myled(PC_13);
+Serial gps(PB_6,PB_7);       // tx, rx
+//Serial pc(USBTX, USBRX);    // tx, rx
+USBSerial pc; 
+
+int i,rlock,mode;
+char gps_data[256];
+char ns,ew;
+float w_time,hokui,tokei;
+float g_hokui,g_tokei;
+float d_hokui,m_hokui,d_tokei,m_tokei;
+unsigned char c;
+int stlgt;
+char status;
+float velocity, direction;
+int date;
+ 
+void getGPS() {
+  c = gps.getc();
+  if( c=='$' || i == 256){
+    mode = 0;
+    i = 0;
+    for(int j=0; j<256; j++){
+        gps_data[j]=NULL;
+    }
+  }
+  if(mode==0){
+    if((gps_data[i]=c) != '\r'){
+      i++;
+    }else{
+      gps_data[i]='\0';
+      
+      pc.printf(gps_data);
+      pc.printf("\r\n");
+      
+      if(sscanf(gps_data, "$GPGGA,%f,%f,%c,%f,%c,%d,%d",&w_time,&hokui,&ns,&tokei,&ew,&rlock,&stlgt) >= 1){
+        if(rlock==1){
+          //logitude
+          d_tokei= int(tokei/100);
+          m_tokei= (tokei-d_tokei*100)/60;
+          g_tokei= d_tokei+m_tokei;
+          //Latitude
+          d_hokui=int(hokui/100);
+          m_hokui=(hokui-d_hokui*100)/60;
+          g_hokui=d_hokui+m_hokui;
+          
+          float timenow = w_time;
+          int hour = timenow / 10000;
+          timenow = fmod(timenow, 10000);
+          int min = timenow / 100;
+          timenow = fmod(timenow, 100);
+          int sec = timenow / 1;
+          timenow = fmod(timenow, 1);
+          
+          // /*
+          // 10進法(google)
+          pc.printf("世界標準時:%02dh%02dm%02ds 北緯:%.8f 東経:%.8f 状態:%d 使用衛星数:%d\r\n",
+            hour, min, sec, g_hokui, g_tokei, rlock, stlgt);
+          //  */
+          /*
+          // 60進法(x時y分z秒w)
+          pc.printf("s世界標準時:%02dh%02dm%02ds 北緯:%.8f 東経:%.8f 状態:%d 使用衛星数:%d\r\n",
+            hour, min, sec, hokui/100, tokei/100, rlock, stlgt);
+           */
+        }
+        else{
+          float timenow = w_time;
+          int hour = timenow / 10000;
+          timenow = fmod(timenow, 10000);
+          int min = timenow / 100;
+          timenow = fmod(timenow, 100);
+          int sec = timenow / 1;
+          timenow = fmod(timenow, 1);
+          
+          pc.printf("# 世界標準時e:%02dh%02dm%02d 状態:%d 使用衛星数:%d\r\n",
+            hour, min, sec, rlock, stlgt);
+        }
+        sprintf(gps_data, "");
+      }//if
+      
+      /* ------------------------------ */
+      if(sscanf(gps_data, "$GPRMC,%f,%f,%f,%d",&w_time,&velocity,&direction,&date) >= 1){
+        if(rlock==1){
+          
+          float timenow = w_time;
+          int hour = timenow / 10000;
+          timenow = fmod(timenow, 10000);
+          int min = timenow / 100;
+          timenow = fmod(timenow, 100);
+          int sec = timenow / 1;
+          timenow = fmod(timenow, 1);
+          
+          float v_mps = velocity * 1852 / 3600;
+          
+          // /*
+          // 10進法(google)
+          pc.printf("世界標準時:%02dh%02dm%02ds 速度:%f[mps] 方位:%f, 日付:20%02d年%02d月%02d日\r\n",
+            hour,min,sec,v_mps,direction,date%100,(date/100)%100, date/10000);
+          //  */
+          /*
+          // 60進法(x時y分z秒w)
+          pc.printf("世界標準時:%02dh%02dm%02ds 速度:%f[mps] 方位:%f, 日付:20%02d年%02d月%02d日\r\n",
+            hour,min,sec,velocity,direction,date%100,(date/100)%100, date/10000);
+           */
+        }
+        else{
+          float timenow = w_time;
+          int hour = timenow / 10000;
+          timenow = fmod(timenow, 10000);
+          int min = timenow / 100;
+          timenow = fmod(timenow, 100);
+          int sec = timenow / 1;
+          timenow = fmod(timenow, 1);
+          
+          pc.printf("# 世界標準時:%02dh%02dm%02ds 速度:%f[knot] 方位:%f, 日付:20%02d年%02d月%02d日\r\n",
+            hour,min,sec,velocity,direction,date%100,(date/100)%100, date/10000);
+        }
+        sprintf(gps_data, "");
+      }//if
+      
+      pc.printf("\r\n");
+    }
+  }
+}
+ 
+int main(){
+  pc.printf("*** GPS GT-720F ***\r\n");
+  gps.baud(9600);
+//  pc.baud(115200);
+ gps.attach(getGPS,Serial::RxIrq);
+  while(1) {/*gps.attach(getGPS,Serial::RxIrq)*/}
+}
+
+
+/* --- 生データ取得用 --- */
+/*
+#include "mbed.h"
+
+Serial gps(p9, p10);       // TX, RX
+Serial pc(USBTX, USBRX);    // TX, RX
+DigitalOut led1(LED1);
+
+int main() {
+    pc.baud(115200);
+    pc.printf("PA6C DEMO\n");
+    char gpsout[1024];
+    while (1) {
+        gpsout[0] = '\0';
+        while (1) {
+            char c = gps.getc();
+            char s[2];
+            s[0] = c;
+            s[1] = '\0';
+            strcat(gpsout, s);
+            if (c == '\n') {
+                break;
+            }
+        }
+        pc.printf(gpsout);
+        led1 = !led1;
+    }
+}
+ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_config.h	Mon Feb 24 10:06:48 2020 +0000
@@ -0,0 +1,54 @@
+/*
+ * mbed SDK
+ * Copyright (c) 2017 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Automatically generated configuration file.
+// DO NOT EDIT, content will be overwritten.
+
+#ifndef __MBED_CONFIG_DATA__
+#define __MBED_CONFIG_DATA__
+
+// Configuration parameters
+#define MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED           0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX                8                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE        9600                                                                           // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO          0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_DECODE_HTTP_URL_STR       "\nFor more info, visit: https://armmbed.github.io/mbedos-error/?error=0x%08X" // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED  0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_HIST_ENABLED              0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE                 4                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_ERROR_REBOOT_MAX                1                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED 0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR        0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN          16                                                                             // set by library:platform
+#define MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER         0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE                 9600                                                                           // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL           0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES          0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_CONVERT_TTY_NEWLINES      0                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT             1                                                                              // set by library:platform
+#define MBED_CONF_PLATFORM_USE_MPU                         1                                                                              // set by library:platform
+#define MBED_CONF_TARGET_BOOT_STACK_SIZE                   0x1000                                                                         // set by target:Target
+#define MBED_CONF_TARGET_CONSOLE_UART                      1                                                                              // set by target:Target
+#define MBED_CONF_TARGET_DEEP_SLEEP_LATENCY                0                                                                              // set by target:Target
+#define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT            0                                                                              // set by target:Target
+#define MBED_CONF_TARGET_MPU_ROM_END                       0x0fffffff                                                                     // set by target:Target
+#define MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE    ETHERNET                                                                       // set by target:LPC1768
+#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER           0                                                                              // set by target:Target
+#define MBED_CONF_TARGET_US_TICKER_TIMER                   3                                                                              // set by target:LPC1768
+#define MBED_CONF_TARGET_XIP_ENABLE                        0                                                                              // set by target:Target
+
+#endif