POC1.5 prototype 2 x color sensor 2 x LM75B 3 x AnalogIn 1 x accel

Dependencies:   mbed vt100

Files at this revision

API Documentation at this revision

Comitter:
Rhyme
Date:
Tue Dec 12 06:53:12 2017 +0000
Parent:
12:4c0bd7fce2fd
Commit message:
MCU Reset Reason Attribute added

Changed in this revision

af_utils/af_attriburtes.cpp Show annotated file Show diff for this revision Revisions of this file
af_utils/af_attributes.h Show annotated file Show diff for this revision Revisions of this file
edge_utils/edge_mgr.cpp Show annotated file Show diff for this revision Revisions of this file
edge_utils/edge_reset_mgr.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4c0bd7fce2fd -r 88ee926c56ae af_utils/af_attriburtes.cpp
--- a/af_utils/af_attriburtes.cpp	Tue Dec 12 02:28:51 2017 +0000
+++ b/af_utils/af_attriburtes.cpp	Tue Dec 12 06:53:12 2017 +0000
@@ -82,6 +82,7 @@
     {  ATTR_GAS_THR_LOW,      "Gas Press Low Thresh",      ATTRIBUTE_TYPE_SINT16,  2 },
 /* Software Reset Request */    
     {  ATTR_SOFTWARE_RESET,   "Software Reset",            ATTRIBUTE_TYPE_BOOLEAN, 1 },
+    {  ATTR_MCU_RESET_REASON, "MCU Reset Reason",          ATTRIBUTE_TYPE_UTF8S,  64 },
                    
     { ATTR_LED,               "LED",                       ATTRIBUTE_TYPE_SINT16,  2 },
     { ATTR_IO0,               "I/O 0",                     ATTRIBUTE_TYPE_SINT64,  8 },
diff -r 4c0bd7fce2fd -r 88ee926c56ae af_utils/af_attributes.h
--- a/af_utils/af_attributes.h	Tue Dec 12 02:28:51 2017 +0000
+++ b/af_utils/af_attributes.h	Tue Dec 12 06:53:12 2017 +0000
@@ -108,6 +108,7 @@
 #define ATTR_CURRENT_VALUE           503
 
 #define ATTR_SOFTWARE_RESET          666
+#define ATTR_MCU_RESET_REASON        999
 
 #define ATTR_LED                 1024
 #define ATTR_IO0                 1025
@@ -173,6 +174,7 @@
     const uint8_t   *value
 ) ;
 
+extern char *reset_reason_str ;
 extern afLib *afero ; 
 // extern iafLib *afero ;
 #endif /* _AF_ATTRIBUTES_H */
\ No newline at end of file
diff -r 4c0bd7fce2fd -r 88ee926c56ae edge_utils/edge_mgr.cpp
--- a/edge_utils/edge_mgr.cpp	Tue Dec 12 02:28:51 2017 +0000
+++ b/edge_utils/edge_mgr.cpp	Tue Dec 12 06:53:12 2017 +0000
@@ -70,6 +70,10 @@
     }
     switch(sensor_index) {
     case 0: /* accel */
+        if (reset_reason_str) {
+            afero->setAttribute(ATTR_MCU_RESET_REASON, reset_reason_str) ;
+            reset_reason_str = 0 ;
+        }
         if (sensor[sensor_index]) {
            afero->setAttributeBool(ATTR_ACCEL_PRESENT, true) ;
            afero->setAttributeBool(ATTR_ACCEL_ENABLE, true) ;
diff -r 4c0bd7fce2fd -r 88ee926c56ae edge_utils/edge_reset_mgr.cpp
--- a/edge_utils/edge_reset_mgr.cpp	Tue Dec 12 02:28:51 2017 +0000
+++ b/edge_utils/edge_reset_mgr.cpp	Tue Dec 12 06:53:12 2017 +0000
@@ -39,40 +39,76 @@
 #define SW_RESET_BIT     0x04
 #define LOCKUP_RESET_BIT 0x02
 
+#define IDX_POR_RESET    0
+#define IDX_PIN_RESET    1
+#define IDX_WDG_RESET    2
+#define IDX_LOL_RESET    3
+#define IDX_LOC_RESET    4
+#define IDX_LVD_RESET    5
+#define IDX_WUP_RESET    6
+#define IDX_SACK_RESET   7
+#define IDX_MDM_RESET    8
+#define IDX_SW_RESET     9
+#define IDX_LOCKUP_RESET 10 
+
+const char *reset_reason[] = {
+    "Power On Reset",
+    "Reset Pin Asserted",
+    "Watch Dog Reset",
+    "Loss of Lock Reset",
+    "Loss of Clock Reset",
+    "Low Voltage Detect Reset",
+    "Low Leakage Wakeup Reset",
+    "Stop Mode Acknowledge Error Reset",
+    "MDM-AP System Reset Request",
+    "Software Reset",
+    "Core Lockup Reset",
+    0
+} ;
+
+char *reset_reason_str = 0 ;
+
 void print_reset_reason(void) 
 {
+    extern char *reset_reason_str ;
+    int idx = 0 ;
     uint8_t *data = REG_RCM_SRS0 ;
     if (*data & POR_RESET_BIT) {
-        printf("Power On Reset\n") ;
+        idx = IDX_POR_RESET ;
     }
     if (*data & PIN_RESET_BIT) {
-        printf("Reset Pin asserted\n") ;
+        idx = IDX_PIN_RESET ; 
     }
     if (*data & WDG_RESET_BIT) {
-        printf("Watch Dog Reset\n") ;
+        idx = IDX_WDG_RESET ; 
     }
     if (*data & LOL_RESET_BIT) {
-        printf("Loss of Lock Reset\n") ;
+        idx = IDX_LOL_RESET ;
     }
     if (*data & LVD_RESET_BIT) {
-        printf("Low Voltage Detect Reset\n") ;
+        idx = IDX_LVD_RESET ;
     }  
+    if (*data & LOC_RESET_BIT) {
+        idx = IDX_LOC_RESET ;
+    }
     if (*data & WUP_RESET_BIT) {
-        printf("Low Leakage Wakeup Reset\n") ;
+        idx = IDX_WUP_RESET ;
     }
     data = REG_RCM_SRS1 ;
     if (*data & SACK_RESET_BIT) {
-        printf("Stop Mode Acknowledge Error Reset\n") ;
+        idx = IDX_SACK_RESET ;
     }
     if (*data & MDM_RESET_BIT) {
-        printf("MDM-AP System Reset Request\n") ;
+        idx = IDX_MDM_RESET ;
     }
     if (*data & SW_RESET_BIT) {
-        printf("Software Reset\n") ;
+        idx = IDX_SW_RESET ;
     }
     if (*data & LOCKUP_RESET_BIT) {
-        printf("Core Lockup Reset\n") ;
+        idx = IDX_LOCKUP_RESET ;
     }
+    printf("%s\n", reset_reason[idx]) ;
+    reset_reason_str = (char *)reset_reason[idx] ;
 }
 
 /**