Function to calculate the memory available for malloc
Dependents: AvailableMemory_HelloWorld MCBBThermostat helloaabbc SP14P1_skeleton
AvailableMemory.h@10:7474d5df69c2, 2010-11-07 (annotated)
- Committer:
- segundo
- Date:
- Sun Nov 07 21:52:34 2010 +0000
- Revision:
- 10:7474d5df69c2
- Parent:
- 9:caba868a4c1a
- Child:
- 11:0f5d5918761a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
segundo | 10:7474d5df69c2 | 1 | /** @file |
segundo | 10:7474d5df69c2 | 2 | * Return the memory available for a malloc call |
segundo | 10:7474d5df69c2 | 3 | * This is done by a binary search approach |
segundo | 10:7474d5df69c2 | 4 | * calling malloc/free starting with a maximum |
segundo | 3:9092256004a5 | 5 | */ |
segundo | 0:a98bf0c96bf1 | 6 | #ifndef SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |
segundo | 0:a98bf0c96bf1 | 7 | #define SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |
segundo | 6:e94f3a11bad7 | 8 | |
segundo | 9:caba868a4c1a | 9 | /** |
segundo | 9:caba868a4c1a | 10 | * Segundo Equipo |
segundo | 9:caba868a4c1a | 11 | */ |
segundo | 0:a98bf0c96bf1 | 12 | namespace segundo { |
segundo | 9:caba868a4c1a | 13 | /** |
segundo | 9:caba868a4c1a | 14 | * A collection of utilities |
segundo | 9:caba868a4c1a | 15 | */ |
segundo | 0:a98bf0c96bf1 | 16 | namespace Utilities { |
segundo | 0:a98bf0c96bf1 | 17 | |
segundo | 10:7474d5df69c2 | 18 | /** Return the memory available for a malloc call |
segundo | 10:7474d5df69c2 | 19 | * @return AvailableMemory(256, 0x8000, true) |
segundo | 1:d8432d8a5b6d | 20 | */ |
segundo | 0:a98bf0c96bf1 | 21 | int AvailableMemory(); |
segundo | 1:d8432d8a5b6d | 22 | |
segundo | 10:7474d5df69c2 | 23 | /** Return the memory available for a malloc call |
segundo | 10:7474d5df69c2 | 24 | * @param resolution Resolution in number of bytes |
segundo | 10:7474d5df69c2 | 25 | * 1 will return the exact value |
segundo | 10:7474d5df69c2 | 26 | * 256 will return the available memory to the nearest 256 bytes |
segundo | 10:7474d5df69c2 | 27 | * @param maximum Maximum amount of memory to check |
segundo | 10:7474d5df69c2 | 28 | * @param disableInterrupts Disable interrupts whilst checking |
segundo | 10:7474d5df69c2 | 29 | * @return Available memory in bytes |
segundo | 1:d8432d8a5b6d | 30 | */ |
segundo | 0:a98bf0c96bf1 | 31 | int AvailableMemory(int resolution, int maximum, bool disableInterrupts); |
segundo | 0:a98bf0c96bf1 | 32 | |
segundo | 0:a98bf0c96bf1 | 33 | } // namespace Utilities |
segundo | 0:a98bf0c96bf1 | 34 | } // namespace segundo |
segundo | 0:a98bf0c96bf1 | 35 | |
segundo | 0:a98bf0c96bf1 | 36 | using namespace segundo::Utilities; |
segundo | 0:a98bf0c96bf1 | 37 | |
segundo | 0:a98bf0c96bf1 | 38 | #endif // SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |