Function to calculate the memory available for malloc

Dependents:   AvailableMemory_HelloWorld MCBBThermostat helloaabbc SP14P1_skeleton

AvailableMemory.h

Committer:
segundo
Date:
2010-11-08
Revision:
11:0f5d5918761a
Parent:
10:7474d5df69c2
Child:
12:3004855925ff

File content as of revision 11:0f5d5918761a:

/** @file
 * @brief Return the memory available for a malloc call
 * This is done by a binary search approach
 * calling malloc/free starting with a maximum
 */
#ifndef SEGUNDO_UTILITIES_AVAILABLEMEMORY_H
#define SEGUNDO_UTILITIES_AVAILABLEMEMORY_H

/**
 * Segundo Equipo
 */
namespace segundo {
/**
 * A collection of utilities
 */
namespace Utilities {

/** Return the memory available for a malloc call
 * @param resolution Resolution in number of bytes,
 * 1 will return the exact value,
 * default is 256 which will return the available memory to the nearest 256 bytes
 * @param maximum Maximum amount of memory to check, default is 32K
 * @param disableInterrupts Disable interrupts whilst checking, default is true
 * @return Available memory in bytes accurate to within resolution
 */
int AvailableMemory(int resolution = 256, int maximum = 0x8000, bool disableInterrupts = true);

} // namespace Utilities
} // namespace segundo

using namespace segundo::Utilities;

#endif // SEGUNDO_UTILITIES_AVAILABLEMEMORY_H