class library to access fischertechnik interfaces via USB
Dependencies: FatFileSystem mbed myBlueUSB neigbourhood rfcomm sdp
AvailableMemory.h@0:7da612835693, 2011-06-15 (annotated)
- Committer:
- networker
- Date:
- Wed Jun 15 19:12:25 2011 +0000
- Revision:
- 0:7da612835693
initial version
; Bluetooth support incomplete
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
networker |
0:7da612835693 | 1 | /** @file |
networker |
0:7da612835693 | 2 | * Return the memory available for a malloc call. |
networker |
0:7da612835693 | 3 | */ |
networker |
0:7da612835693 | 4 | #ifndef SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |
networker |
0:7da612835693 | 5 | #define SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |
networker |
0:7da612835693 | 6 | |
networker |
0:7da612835693 | 7 | /** |
networker |
0:7da612835693 | 8 | * Segundo Equipo |
networker |
0:7da612835693 | 9 | */ |
networker |
0:7da612835693 | 10 | namespace segundo { |
networker |
0:7da612835693 | 11 | /** |
networker |
0:7da612835693 | 12 | * A collection of utilities |
networker |
0:7da612835693 | 13 | */ |
networker |
0:7da612835693 | 14 | namespace Utilities { |
networker |
0:7da612835693 | 15 | |
networker |
0:7da612835693 | 16 | /** Return the memory available for a malloc call. |
networker |
0:7da612835693 | 17 | * This is done by a binary search approach |
networker |
0:7da612835693 | 18 | * calling malloc/free starting with a maximum. |
networker |
0:7da612835693 | 19 | * |
networker |
0:7da612835693 | 20 | * Example: |
networker |
0:7da612835693 | 21 | * @code |
networker |
0:7da612835693 | 22 | * #include <stdio.h> |
networker |
0:7da612835693 | 23 | * #include "AvailableMemory.h" |
networker |
0:7da612835693 | 24 | * |
networker |
0:7da612835693 | 25 | * int main() { |
networker |
0:7da612835693 | 26 | * |
networker |
0:7da612835693 | 27 | * printf("Available memory (bytes to nearest 256) : %d\n", AvailableMemory()); |
networker |
0:7da612835693 | 28 | * printf("Available memory (exact bytes) : %d\n", AvailableMemory(1)); |
networker |
0:7da612835693 | 29 | * |
networker |
0:7da612835693 | 30 | * } |
networker |
0:7da612835693 | 31 | * @endcode |
networker |
0:7da612835693 | 32 | * @param resolution Resolution in number of bytes, |
networker |
0:7da612835693 | 33 | * 1 will return the exact value, |
networker |
0:7da612835693 | 34 | * default will return the available memory to the nearest 256 bytes |
networker |
0:7da612835693 | 35 | * @param maximum Maximum amount of memory to check, default is 32K (0x8000) |
networker |
0:7da612835693 | 36 | * @param disableInterrupts Disable interrupts whilst checking, default is true |
networker |
0:7da612835693 | 37 | * @return Available memory in bytes accurate to within resolution |
networker |
0:7da612835693 | 38 | */ |
networker |
0:7da612835693 | 39 | int AvailableMemory(int resolution = 256, int maximum = 0x8000, bool disableInterrupts = true); |
networker |
0:7da612835693 | 40 | |
networker |
0:7da612835693 | 41 | } // namespace Utilities |
networker |
0:7da612835693 | 42 | } // namespace segundo |
networker |
0:7da612835693 | 43 | |
networker |
0:7da612835693 | 44 | using namespace segundo::Utilities; |
networker |
0:7da612835693 | 45 | |
networker |
0:7da612835693 | 46 | #endif // SEGUNDO_UTILITIES_AVAILABLEMEMORY_H |