I-O DATA DEV2 / Mbed 2 deprecated ud-gs4-R_400G_SD_Log_No1

Dependencies:   mbed SDFileSystem_

Revision:
41:43828af3765f
Parent:
40:16c2d6b97a92
Child:
42:f42b74882970
--- a/main.cpp	Fri Sep 10 08:41:05 2021 +0000
+++ b/main.cpp	Mon Sep 13 08:54:03 2021 +0000
@@ -1,9 +1,7 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
 #include <errno.h>
-#include <stdio.h>
-#include <FileHandle.h>
-#include <mbed_poll.h>
+#include "watchdog.h"
 
 /*
    This basic example just shows how to read the ADC internal channels raw values.
@@ -50,8 +48,6 @@
 //#define OFFSET_Z   0
 
 #define DATA_SIZE 512
-//#define MBED_BUFF 512
-
 
 HAL_StatusTypeDef writeEEPROMByte(uint32_t address, uint8_t data);
 uint8_t readEEPROMByte(uint32_t address);
@@ -95,10 +91,7 @@
 int ret = 0,init=1;
 short end_flag = 0;
 
-/*
-void timer(){
-}
-*/
+Watchdog wdt;
 
 void sub(){
     static short tx=0,ty=0,tz=0;
@@ -296,6 +289,11 @@
     short retry = 0;
     sprintf(filename1,"/sd/new_%d",lognum1);
     sprintf(filename2,"/sd/old_%d",lognum2);
+    
+    if (wdt.WatchdogCausedReset())
+        pc.printf("WatchDog Reset.\r\n");
+    
+    wdt.Configure(30);
 
     while(!fp1 && retry < 5){
         fp1 = fopen(filename1,"ab");
@@ -333,18 +331,18 @@
     while(init) {
         init = initLIS331();
         initLIS3DH();
-        pc.printf(" init acc sensor %d\r\n",ret);
+        pc.printf(" init acc sensor %d\r\n",init);
         wait_ms(100);
     }
     //interrupt.attach_us(&timer,20000);//20ms
     while(!end_flag)
     {
+        wdt.Service();
         timecount++;
         oldcount++;
         newcount++;
         sub();
         //wait_ms(20);
-        //wait_ms(1);
     }
     pc.printf("Program End.\r\n");
     return 0;