Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Tue May 17 16:49:23 2011 +0000
Revision:
3:799d8c61fb03
Parent:
1:b26ab2467b1a

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benecsj 1:b26ab2467b1a 1 /** @file
benecsj 1:b26ab2467b1a 2 * Return the memory available for a malloc call.
benecsj 1:b26ab2467b1a 3 */
benecsj 1:b26ab2467b1a 4 #ifndef SEGUNDO_UTILITIES_AVAILABLEMEMORY_H
benecsj 1:b26ab2467b1a 5 #define SEGUNDO_UTILITIES_AVAILABLEMEMORY_H
benecsj 1:b26ab2467b1a 6
benecsj 1:b26ab2467b1a 7 /**
benecsj 1:b26ab2467b1a 8 * Segundo Equipo
benecsj 1:b26ab2467b1a 9 */
benecsj 1:b26ab2467b1a 10 namespace segundo {
benecsj 1:b26ab2467b1a 11 /**
benecsj 1:b26ab2467b1a 12 * A collection of utilities
benecsj 1:b26ab2467b1a 13 */
benecsj 1:b26ab2467b1a 14 namespace Utilities {
benecsj 1:b26ab2467b1a 15
benecsj 1:b26ab2467b1a 16 /** Return the memory available for a malloc call.
benecsj 1:b26ab2467b1a 17 * This is done by a binary search approach
benecsj 1:b26ab2467b1a 18 * calling malloc/free starting with a maximum.
benecsj 1:b26ab2467b1a 19 *
benecsj 1:b26ab2467b1a 20 * Example:
benecsj 1:b26ab2467b1a 21 * @code
benecsj 1:b26ab2467b1a 22 * #include <stdio.h>
benecsj 1:b26ab2467b1a 23 * #include "AvailableMemory.h"
benecsj 1:b26ab2467b1a 24 *
benecsj 1:b26ab2467b1a 25 * int main() {
benecsj 1:b26ab2467b1a 26 *
benecsj 1:b26ab2467b1a 27 * printf("Available memory (bytes to nearest 256) : %d\n", AvailableMemory());
benecsj 1:b26ab2467b1a 28 * printf("Available memory (exact bytes) : %d\n", AvailableMemory(1));
benecsj 1:b26ab2467b1a 29 *
benecsj 1:b26ab2467b1a 30 * }
benecsj 1:b26ab2467b1a 31 * @endcode
benecsj 1:b26ab2467b1a 32 * @param resolution Resolution in number of bytes,
benecsj 1:b26ab2467b1a 33 * 1 will return the exact value,
benecsj 1:b26ab2467b1a 34 * default will return the available memory to the nearest 256 bytes
benecsj 1:b26ab2467b1a 35 * @param maximum Maximum amount of memory to check, default is 32K (0x8000)
benecsj 1:b26ab2467b1a 36 * @param disableInterrupts Disable interrupts whilst checking, default is true
benecsj 1:b26ab2467b1a 37 * @return Available memory in bytes accurate to within resolution
benecsj 1:b26ab2467b1a 38 */
benecsj 1:b26ab2467b1a 39 int AvailableMemory(int resolution = 256, int maximum = 0x8000, bool disableInterrupts = true);
benecsj 1:b26ab2467b1a 40
benecsj 1:b26ab2467b1a 41 } // namespace Utilities
benecsj 1:b26ab2467b1a 42 } // namespace segundo
benecsj 1:b26ab2467b1a 43
benecsj 1:b26ab2467b1a 44 using namespace segundo::Utilities;
benecsj 1:b26ab2467b1a 45
benecsj 1:b26ab2467b1a 46 #endif // SEGUNDO_UTILITIES_AVAILABLEMEMORY_H