local fix version of myBlueUSB (http://mbed.org/users/networker/code/myBlueUSB/). - merge deleted files which are required to compile. - enable echo back of received data via RFCOMM.

Dependencies:   AvailableMemory FatFileSystem mbed myUSBHost

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AvailableMemory.cpp Source File

AvailableMemory.cpp

00001 #include "AvailableMemory.h"
00002 #include <stdlib.h>
00003 
00004 namespace segundo {
00005 namespace Utilities {
00006 
00007 int AvailableMemory(int resolution, int maximum, bool disableInterrupts) {
00008 
00009     if (resolution < 1) resolution = 1;
00010     if (maximum < 0) maximum = 0;
00011 
00012     int low = 0;
00013     int high = maximum + 1;
00014 
00015     if (disableInterrupts) __disable_irq();
00016 
00017     while (high - low > resolution) {
00018         int mid = (low + high) / 2;
00019         void* p = malloc(mid);
00020         if (p == NULL) {
00021             high = mid;
00022         } else {
00023             free(p);
00024             low = mid;
00025         }
00026     }
00027 
00028     if (disableInterrupts) __enable_irq();
00029 
00030     return low;
00031 }
00032 
00033 } // namespace Utilities
00034 } // namespace segundo