initial test app that shows potential memory usage by mbed-rtos

Dependencies:   mbed-rtosMemoryTest mbed

Committer:
dmatsumoto
Date:
Tue Dec 09 18:42:05 2014 +0000
Revision:
0:9a0840718117
initial test app that shows potential memory usage by mbed-rtos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dmatsumoto 0:9a0840718117 1 #include "mbed.h"
dmatsumoto 0:9a0840718117 2 #include "heapsize.hpp"
dmatsumoto 0:9a0840718117 3
dmatsumoto 0:9a0840718117 4 DigitalOut GreenLed(LED_GREEN);
dmatsumoto 0:9a0840718117 5 DigitalOut RedLed(LED_RED);
dmatsumoto 0:9a0840718117 6 DigitalOut BlueLed(LED_BLUE);
dmatsumoto 0:9a0840718117 7
dmatsumoto 0:9a0840718117 8 void BlinkErrorCodeNoRtos( int blinks)
dmatsumoto 0:9a0840718117 9 {
dmatsumoto 0:9a0840718117 10 GreenLed = 1;
dmatsumoto 0:9a0840718117 11 BlueLed = 1;
dmatsumoto 0:9a0840718117 12 for( int i=0; i<blinks; i++) {
dmatsumoto 0:9a0840718117 13 RedLed = 0;
dmatsumoto 0:9a0840718117 14 wait( 0.15);
dmatsumoto 0:9a0840718117 15 RedLed = 1;
dmatsumoto 0:9a0840718117 16 wait( 0.15);
dmatsumoto 0:9a0840718117 17 }
dmatsumoto 0:9a0840718117 18 wait(0.5);
dmatsumoto 0:9a0840718117 19 }
dmatsumoto 0:9a0840718117 20
dmatsumoto 0:9a0840718117 21 extern "C" void HardFault_Handler()
dmatsumoto 0:9a0840718117 22 {
dmatsumoto 0:9a0840718117 23 while( 1)
dmatsumoto 0:9a0840718117 24 BlinkErrorCodeNoRtos(1);
dmatsumoto 0:9a0840718117 25 }
dmatsumoto 0:9a0840718117 26
dmatsumoto 0:9a0840718117 27 extern "C" void UsageFault_Handler()
dmatsumoto 0:9a0840718117 28 {
dmatsumoto 0:9a0840718117 29 while( 1)
dmatsumoto 0:9a0840718117 30 BlinkErrorCodeNoRtos( 2);
dmatsumoto 0:9a0840718117 31 }
dmatsumoto 0:9a0840718117 32
dmatsumoto 0:9a0840718117 33 extern "C" void BusFault_Handler()
dmatsumoto 0:9a0840718117 34 {
dmatsumoto 0:9a0840718117 35 while( 1)
dmatsumoto 0:9a0840718117 36 BlinkErrorCodeNoRtos( 3);
dmatsumoto 0:9a0840718117 37 }
dmatsumoto 0:9a0840718117 38
dmatsumoto 0:9a0840718117 39 extern "C" void MemManage_Handler()
dmatsumoto 0:9a0840718117 40 {
dmatsumoto 0:9a0840718117 41 while( 1)
dmatsumoto 0:9a0840718117 42 BlinkErrorCodeNoRtos( 4);
dmatsumoto 0:9a0840718117 43 }
dmatsumoto 0:9a0840718117 44
dmatsumoto 0:9a0840718117 45 /*
dmatsumoto 0:9a0840718117 46 extern "C" void SVC_Handler(int R0)
dmatsumoto 0:9a0840718117 47 {
dmatsumoto 0:9a0840718117 48 //wait(0.1);
dmatsumoto 0:9a0840718117 49 }
dmatsumoto 0:9a0840718117 50
dmatsumoto 0:9a0840718117 51 extern "C" void NMI_Handler()
dmatsumoto 0:9a0840718117 52 {
dmatsumoto 0:9a0840718117 53 }
dmatsumoto 0:9a0840718117 54
dmatsumoto 0:9a0840718117 55 extern "C" void DebugMon_Handler()
dmatsumoto 0:9a0840718117 56 {
dmatsumoto 0:9a0840718117 57 GreenLed = 1;
dmatsumoto 0:9a0840718117 58
dmatsumoto 0:9a0840718117 59 BlueLed = 0;
dmatsumoto 0:9a0840718117 60 RedLed = 0;
dmatsumoto 0:9a0840718117 61 wait( 0.1);
dmatsumoto 0:9a0840718117 62 BlueLed = 1;
dmatsumoto 0:9a0840718117 63 RedLed = 1;
dmatsumoto 0:9a0840718117 64 }
dmatsumoto 0:9a0840718117 65
dmatsumoto 0:9a0840718117 66 extern "C" void PendSV_Handler()
dmatsumoto 0:9a0840718117 67 {
dmatsumoto 0:9a0840718117 68 BlueLed = 1;
dmatsumoto 0:9a0840718117 69
dmatsumoto 0:9a0840718117 70 GreenLed = 0;
dmatsumoto 0:9a0840718117 71 RedLed = 0;
dmatsumoto 0:9a0840718117 72 wait( 0.1);
dmatsumoto 0:9a0840718117 73 GreenLed = 1;
dmatsumoto 0:9a0840718117 74 RedLed = 1;
dmatsumoto 0:9a0840718117 75 }
dmatsumoto 0:9a0840718117 76
dmatsumoto 0:9a0840718117 77 extern "C" void SysTick_Handler()
dmatsumoto 0:9a0840718117 78 {
dmatsumoto 0:9a0840718117 79
dmatsumoto 0:9a0840718117 80 }
dmatsumoto 0:9a0840718117 81
dmatsumoto 0:9a0840718117 82 extern "C" void IntDefaultHandler()
dmatsumoto 0:9a0840718117 83 {
dmatsumoto 0:9a0840718117 84 }
dmatsumoto 0:9a0840718117 85 */
dmatsumoto 0:9a0840718117 86
dmatsumoto 0:9a0840718117 87 int main()
dmatsumoto 0:9a0840718117 88 {
dmatsumoto 0:9a0840718117 89 #ifdef __CC_ARM
dmatsumoto 0:9a0840718117 90 printf( "CC ARM \r\n");
dmatsumoto 0:9a0840718117 91 #elif defined(__GNUC__)
dmatsumoto 0:9a0840718117 92 printf( "GNUC \r\n");
dmatsumoto 0:9a0840718117 93 #elif defined(__ICCARM__)
dmatsumoto 0:9a0840718117 94 printf( "ICC ARM \r\n");
dmatsumoto 0:9a0840718117 95 #endif
dmatsumoto 0:9a0840718117 96
dmatsumoto 0:9a0840718117 97 printf( "in main, heap free is: %ld\r\n", heapSize());
dmatsumoto 0:9a0840718117 98
dmatsumoto 0:9a0840718117 99 while (true) {
dmatsumoto 0:9a0840718117 100 GreenLed = 0;
dmatsumoto 0:9a0840718117 101 BlueLed = 0;
dmatsumoto 0:9a0840718117 102 RedLed = 0;
dmatsumoto 0:9a0840718117 103 wait( 0.15);
dmatsumoto 0:9a0840718117 104 GreenLed = 1;
dmatsumoto 0:9a0840718117 105 BlueLed = 1;
dmatsumoto 0:9a0840718117 106 RedLed = 1;
dmatsumoto 0:9a0840718117 107 wait( 0.15);
dmatsumoto 0:9a0840718117 108 }
dmatsumoto 0:9a0840718117 109 }