Leon Wehmeier / Mbed OS fiasco_max32630

Dependencies:   SoftSerial MAX14690 Buffer

Fork of rtos_threading_with_callback by mbed_example

Revision:
3:d7ec6dc025b0
Parent:
2:bf699e054b34
diff -r bf699e054b34 -r d7ec6dc025b0 main.cpp
--- a/main.cpp	Sun Feb 25 16:40:28 2018 +0000
+++ b/main.cpp	Fri Mar 30 10:32:10 2018 +0000
@@ -8,6 +8,15 @@
 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
 
 
+#include "platform/mbed_assert.h"
+#include "platform/mbed_debug.h"
+#include "platform/mbed_error.h"
+#include "platform/mbed_stats.h"
+#define MAX_THREAD_INFO 10
+mbed_stats_heap_t heap_info;
+mbed_stats_stack_t stack_info[ MAX_THREAD_INFO ];
+
+
 SPI spi(P5_1, P5_2, P5_0);
 I2C i2c(P5_7, P6_0); //sda, scl
 I2C i2c2(P3_4, P3_5); //sda, scl
@@ -52,11 +61,12 @@
             {
                 txBuf[i]|=(linkEnc.getNext()<<j);
             }
-        printf("0x%02x%02x%02x%02x%02x%02x%02x%02x\r\n", txBuf[0], txBuf[1], txBuf[2], txBuf[3], txBuf[4], txBuf[5], txBuf[6], txBuf[7]);
+        //printf("0x%02x%02x%02x%02x%02x%02x%02x%02x\r\n", txBuf[0], txBuf[1], txBuf[2], txBuf[3], txBuf[4], txBuf[5], txBuf[6], txBuf[7]);
         spi.write((char*)txBuf, 8, (char*)0, 0);
     }
 }
 int main() {
+    set_time(0);
     setupTx();
     thread_txRF.start(txData);
     
@@ -68,6 +78,38 @@
     printf("MAIN: started %u registered application threads\r\n", numRegisteredThreads);
     
     while(1)
-        wait(1024);
+    {/*
+        printf("\r\nRuntimeStats:");
+        printf("\r\n\tSystem uptime in s: %d", time(NULL));
+        printf("\r\nMemoryStats:");
+        mbed_stats_heap_get( &heap_info );
+        printf("\r\n\tBytes allocated currently: %d", heap_info.current_size);
+        printf("\r\n\tMax bytes allocated at a given time: %d", heap_info.max_size);
+        printf("\r\n\tCumulative sum of bytes ever allocated: %d", heap_info.total_size);
+        printf("\r\n\tCurrent number of bytes allocated for the heap: %d", heap_info.reserved_size);
+        printf("\r\n\tCurrent number of allocations: %d", heap_info.alloc_cnt);
+        printf("\r\n\tNumber of failed allocations: %d", heap_info.alloc_fail_cnt);
+        
+        mbed_stats_stack_get( &stack_info[0] );
+        printf("\r\nCumulative Stack Info:");
+        printf("\r\n\tMaximum number of bytes used on the stack: %d", stack_info[0].max_size);
+        printf("\r\n\tCurrent number of bytes allocated for the stack: %d", stack_info[0].reserved_size);
+        printf("\r\n\tNumber of stacks stats accumulated in the structure: %d", stack_info[0].stack_cnt);
+        
+        mbed_stats_stack_get_each( stack_info, MAX_THREAD_INFO );
+        printf("\r\nThread Stack Info:");
+        for(int i=0;i < MAX_THREAD_INFO; i++)
+        {
+            if(stack_info[i].thread_id != 0)
+            {
+                printf("\r\n\tThread: %d", i);
+                printf("\r\n\t\tMaximum number of bytes used on the stack: %d", stack_info[i].max_size);
+                printf("\r\n\t\tCurrent number of bytes allocated for the stack: %d", stack_info[i].reserved_size);
+                printf("\r\n\t\tNumber of stacks stats accumulated in the structure: %d", stack_info[i].stack_cnt); 
+            }
+        }
+        */
+        rtos::Thread::wait(60000);
+    }
 }
  
\ No newline at end of file