Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
84:80b15993944e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SnMemMonitor.h	Fri Oct 30 04:49:40 2015 +0000
@@ -0,0 +1,47 @@
+#ifndef SN_SnMemMonitor
+#define SN_SnMemMonitor
+
+/*
+** Code from https://developer.mbed.org/questions/6994/How-to-print-Free-RAM-available-RAM-or-u/
+** Possibly authored by Robert Spilleboudt
+*/
+
+/* Using malloc() to determine free memory.*/
+ 
+#include <stdio.h>
+#include <stdlib.h>
+#define FREEMEM_CELL 100
+struct elem { /* Definition of a structure that is FREEMEM_CELL bytes  in size.) */
+    struct elem *next;
+    char dummy[FREEMEM_CELL-2];
+};
+
+int FreeMem(void) {
+    int counter;
+    struct elem *head, *current, *nextone;
+    current = head = (struct elem*) malloc(sizeof(struct elem));
+    if (head == NULL)
+        return 0;      /*No memory available.*/
+    counter = 0;
+   // __disable_irq();
+    do {
+        counter++;
+        current->next = (struct elem*) malloc(sizeof(struct elem));
+        current = current->next;
+    } while (current != NULL);
+    /* Now counter holds the number of type elem
+       structures we were able to allocate. We
+       must free them all before returning. */
+    current = head;
+    do {
+        nextone = current->next;
+        free(current);
+        current = nextone;
+    } while (nextone != NULL);
+   // __enable_irq();
+ 
+    return counter*FREEMEM_CELL;
+}
+
+
+#endif // SN_SnMemMonitor