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
AvailableMemory/AvailableMemory.cpp@2:9f25a7fa1a54, 2013-12-08 (annotated)
- Committer:
- nobukuma
- Date:
- Sun Dec 08 21:52:09 2013 +0000
- Revision:
- 2:9f25a7fa1a54
- Parent:
- 0:003889bc474f
???BT??????????????????; ?????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nobukuma | 0:003889bc474f | 1 | #include "AvailableMemory.h" |
nobukuma | 0:003889bc474f | 2 | #include <stdlib.h> |
nobukuma | 0:003889bc474f | 3 | |
nobukuma | 0:003889bc474f | 4 | namespace segundo { |
nobukuma | 0:003889bc474f | 5 | namespace Utilities { |
nobukuma | 0:003889bc474f | 6 | |
nobukuma | 0:003889bc474f | 7 | int AvailableMemory(int resolution, int maximum, bool disableInterrupts) { |
nobukuma | 0:003889bc474f | 8 | |
nobukuma | 0:003889bc474f | 9 | if (resolution < 1) resolution = 1; |
nobukuma | 0:003889bc474f | 10 | if (maximum < 0) maximum = 0; |
nobukuma | 0:003889bc474f | 11 | |
nobukuma | 0:003889bc474f | 12 | int low = 0; |
nobukuma | 0:003889bc474f | 13 | int high = maximum + 1; |
nobukuma | 0:003889bc474f | 14 | |
nobukuma | 0:003889bc474f | 15 | if (disableInterrupts) __disable_irq(); |
nobukuma | 0:003889bc474f | 16 | |
nobukuma | 0:003889bc474f | 17 | while (high - low > resolution) { |
nobukuma | 0:003889bc474f | 18 | int mid = (low + high) / 2; |
nobukuma | 0:003889bc474f | 19 | void* p = malloc(mid); |
nobukuma | 0:003889bc474f | 20 | if (p == NULL) { |
nobukuma | 0:003889bc474f | 21 | high = mid; |
nobukuma | 0:003889bc474f | 22 | } else { |
nobukuma | 0:003889bc474f | 23 | free(p); |
nobukuma | 0:003889bc474f | 24 | low = mid; |
nobukuma | 0:003889bc474f | 25 | } |
nobukuma | 0:003889bc474f | 26 | } |
nobukuma | 0:003889bc474f | 27 | |
nobukuma | 0:003889bc474f | 28 | if (disableInterrupts) __enable_irq(); |
nobukuma | 0:003889bc474f | 29 | |
nobukuma | 0:003889bc474f | 30 | return low; |
nobukuma | 0:003889bc474f | 31 | } |
nobukuma | 0:003889bc474f | 32 | |
nobukuma | 0:003889bc474f | 33 | } // namespace Utilities |
nobukuma | 0:003889bc474f | 34 | } // namespace segundo |