Just a regular publish

Dependencies:   mbed imu_driver

Revision:
4:f05bef255292
Parent:
2:c7a3a8c1aeed
Child:
5:8116016abee0
--- a/main.cpp	Sat Jul 14 20:04:58 2018 +0000
+++ b/main.cpp	Tue Nov 12 14:12:58 2019 +0000
@@ -1,17 +1,14 @@
 #include "mbed.h"
-#include "SDFileSystem.h"
 #define dt  0.01f
 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
 
 DigitalOut  Cool(PA_15,0);
 DigitalOut  LED(D13, 0);                            //Internal LED output, general purpose
-CAN     can1(PA_11, PA_12, 1000000);                //(Inverter, PadalBox, DashBoard) 1Mbps, contain critical torque command message
-CAN     can2(PB_5, PB_13, 500000);                  //(BMS1, BMS2) 500kbps, contain battery status
+CAN     can1(PA_11, PA_12, 1000000);                //1Mbps, contain critical torque command message
 Serial  pc(USBTX, USBRX, 115200);
 Ticker  ticker1;                                    //General
 
 Ticker  ticker2;                                    //Logger
-SDFileSystem    sd(PC_12, PC_11, PC_10, PD_2, "sd");           // mosi, miso, sck, cs
 
 CANMessage  can_msg_1;
 CANMessage  can_msg_2;
@@ -56,11 +53,9 @@
 void CAN_RX2(void);
 void Send2CAN1(void);
 
-FILE *fp;                                           //General file pointer
 void start_log(void);
 void stop_log(void);
 void autoname(void);
-char fileName[] = "/sd/NTHU_RACING/00.CSV";
 int16_t max_val(int16_t i1, int16_t i2, int16_t i3);
 
 void timer1_interrupt(void)
@@ -75,12 +70,8 @@
     CAN_flag_2 = 0;
 
     can1.attach(&CAN_RX1, CAN::RxIrq);              //CAN1 Recieve Irq
-    can2.attach(&CAN_RX2, CAN::RxIrq);              //CAN2 Recieve Irq
     ticker1.attach(&timer1_interrupt, 1);           //1sec
 
-    //Logger header
-    mkdir("/sd/NTHU_RACING", 0777);
-
     //General task
     while(1) {
         if(timer_flag == 1) {
@@ -147,53 +138,20 @@
 
 void timer2_interrupt(void)
 {
-    fprintf(fp, "%.0f,%.0f,%d\n", DC_Voltage*0.1f, DC_Current*0.1f, Motor_Speed);
 }
 
 void start_log(void)
 {
-    fprintf(fp, "NTHU_RACING DataLogger_V1.00\n");
-    fprintf(fp, "Sample period: %.3f\n", dt);
-    fprintf(fp, "POOPOOphysic\n\n");
-    fprintf(fp, "Volt,Amp,RPM\n");
-    ticker2.attach(&timer2_interrupt, dt);
+
 }
 
 void stop_log(void)
 {
-    ticker2.detach();
-    fprintf(fp, "End of logging\n");
-    fclose(fp);
+
 }
 
 void autoname(void)
 {
-    for(uint8_t i=0; i<100; i++) {
-        fileName[16] = i/10 + '0';
-        fileName[17] = i%10 + '0';
-
-        pc.printf("Openning: ");
-        pc.printf(fileName);
-        pc.printf("\n");
-
-        fp = fopen(fileName, "r" );
-
-        if(fp == NULL) {
-            fp = fopen(fileName, "w" );
-            if(fp != NULL) {                                                    //indicates a valid file
-                printf("File opened: %s\n", fileName);
-                SD_OK = 1;
-                break;                                                          //out of for loop
-
-            } else {
-                printf("Failed to open %s for read or write access. Check card is inserted.\n", fileName);
-                SD_OK = 0;
-            }
-        } else {
-            fclose(fp);
-            SD_OK = 0;
-        }
-    }
 
 }
 
@@ -241,58 +199,58 @@
     }
 }
 
-void CAN_RX2(void)
-{
-    if(can2.read(can_msg_2)) {
-        switch(can_msg_2.id) {
-            case 0xD1:
-                //BMS1 soc
-                Module_Total_BMS1 = can_msg_2.data[1] << 8 | can_msg_2.data[0];
-                Module_Total_BMS1 += can_msg_2.data[3] << 8 | can_msg_2.data[2];
-                Module_Total_BMS1 += can_msg_2.data[5] << 8 | can_msg_2.data[4];
-                CAN_flag_2 = 1;
-                break;
-            case 0xD2:
-                //BMS1 min Volt
-                Module_Min_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-            case 0xD3:
-                //BMS1 max Volt
-                Module_Max_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-            case 0xD4:
-                //BMS1 max temperature
-                Max_temp_within_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-
-            case 0xE1:
-                //BMS2 soc
-                Module_Total_BMS2 = can_msg_2.data[1] << 8 | can_msg_2.data[0];
-                Module_Total_BMS2 += can_msg_2.data[3] << 8 | can_msg_2.data[2];
-                Module_Total_BMS2 += can_msg_2.data[5] << 8 | can_msg_2.data[4];
-                CAN_flag_2 = 1;
-                break;
-            case 0xE2:
-                //BMS2 min Volt
-                Module_Min_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-            case 0xE3:
-                //BMS2 max Volt
-                Module_Max_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-            case 0xE4:
-                //BMS2 max temperature
-                Max_temp_within_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
-                CAN_flag_2 = 1;
-                break;
-        }
-    }
-}
+//void CAN_RX2(void)
+//{
+//    if(can2.read(can_msg_2)) {
+//        switch(can_msg_2.id) {
+////            case 0xD1:
+////                //BMS1 soc
+////                Module_Total_BMS1 = can_msg_2.data[1] << 8 | can_msg_2.data[0];
+////                Module_Total_BMS1 += can_msg_2.data[3] << 8 | can_msg_2.data[2];
+////                Module_Total_BMS1 += can_msg_2.data[5] << 8 | can_msg_2.data[4];
+////                CAN_flag_2 = 1;
+////                break;
+////            case 0xD2:
+////                //BMS1 min Volt
+////                Module_Min_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+////                CAN_flag_2 = 1;
+////                break;
+////            case 0xD3:
+////                //BMS1 max Volt
+////                Module_Max_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+////                CAN_flag_2 = 1;
+////                break;
+//            case 0xD4:
+//                //BMS1 max temperature
+//                Max_temp_within_BMS1 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+//                CAN_flag_2 = 1;
+//                break;
+//
+////            case 0xE1:
+////                //BMS2 soc
+////                Module_Total_BMS2 = can_msg_2.data[1] << 8 | can_msg_2.data[0];
+////                Module_Total_BMS2 += can_msg_2.data[3] << 8 | can_msg_2.data[2];
+////                Module_Total_BMS2 += can_msg_2.data[5] << 8 | can_msg_2.data[4];
+////                CAN_flag_2 = 1;
+////                break;
+////            case 0xE2:
+////                //BMS2 min Volt
+////                Module_Min_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+////                CAN_flag_2 = 1;
+////                break;
+////            case 0xE3:
+////                //BMS2 max Volt
+////                Module_Max_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+////                CAN_flag_2 = 1;
+////                break;
+//            case 0xE4:
+//                //BMS2 max temperature
+//                Max_temp_within_BMS2 = can_msg_2.data[7] << 8 | can_msg_2.data[6];
+//                CAN_flag_2 = 1;
+//                break;
+//        }
+//    }
+//}
 
 void Send2CAN1(void)
 {