Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Wed Jun 05 17:29:31 2019 +0000
Revision:
125:ce4045184366
Parent:
84:80b15993944e
Added SnRateListner proto-class, publishing this version of the code in order to enable exporting of most recent features.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uci1 84:80b15993944e 1 #ifndef SN_SnMemMonitor
uci1 84:80b15993944e 2 #define SN_SnMemMonitor
uci1 84:80b15993944e 3
uci1 84:80b15993944e 4 /*
uci1 84:80b15993944e 5 ** Code from https://developer.mbed.org/questions/6994/How-to-print-Free-RAM-available-RAM-or-u/
uci1 84:80b15993944e 6 ** Possibly authored by Robert Spilleboudt
uci1 84:80b15993944e 7 */
uci1 84:80b15993944e 8
uci1 84:80b15993944e 9 /* Using malloc() to determine free memory.*/
uci1 84:80b15993944e 10
uci1 84:80b15993944e 11 #include <stdio.h>
uci1 84:80b15993944e 12 #include <stdlib.h>
uci1 84:80b15993944e 13 #define FREEMEM_CELL 100
uci1 84:80b15993944e 14 struct elem { /* Definition of a structure that is FREEMEM_CELL bytes in size.) */
uci1 84:80b15993944e 15 struct elem *next;
uci1 84:80b15993944e 16 char dummy[FREEMEM_CELL-2];
uci1 84:80b15993944e 17 };
uci1 84:80b15993944e 18
uci1 84:80b15993944e 19 int FreeMem(void) {
uci1 84:80b15993944e 20 int counter;
uci1 84:80b15993944e 21 struct elem *head, *current, *nextone;
uci1 84:80b15993944e 22 current = head = (struct elem*) malloc(sizeof(struct elem));
uci1 84:80b15993944e 23 if (head == NULL)
uci1 84:80b15993944e 24 return 0; /*No memory available.*/
uci1 84:80b15993944e 25 counter = 0;
uci1 84:80b15993944e 26 // __disable_irq();
uci1 84:80b15993944e 27 do {
uci1 84:80b15993944e 28 counter++;
uci1 84:80b15993944e 29 current->next = (struct elem*) malloc(sizeof(struct elem));
uci1 84:80b15993944e 30 current = current->next;
uci1 84:80b15993944e 31 } while (current != NULL);
uci1 84:80b15993944e 32 /* Now counter holds the number of type elem
uci1 84:80b15993944e 33 structures we were able to allocate. We
uci1 84:80b15993944e 34 must free them all before returning. */
uci1 84:80b15993944e 35 current = head;
uci1 84:80b15993944e 36 do {
uci1 84:80b15993944e 37 nextone = current->next;
uci1 84:80b15993944e 38 free(current);
uci1 84:80b15993944e 39 current = nextone;
uci1 84:80b15993944e 40 } while (nextone != NULL);
uci1 84:80b15993944e 41 // __enable_irq();
uci1 84:80b15993944e 42
uci1 84:80b15993944e 43 return counter*FREEMEM_CELL;
uci1 84:80b15993944e 44 }
uci1 84:80b15993944e 45
uci1 84:80b15993944e 46
uci1 84:80b15993944e 47 #endif // SN_SnMemMonitor