Pulse Oximeter (NONIN) communicates with mbed via Bluetooth dongle and sends Heart Rate and Oxygen Saturation via GPRS module
Dependencies: C12832 GPS GSM mbed
Fork of myBlueUSB_localfix by
AvailableMemory/AvailableMemory.cpp@3:55a622e3dbb5, 2015-04-14 (annotated)
- Committer:
- samialshorman
- Date:
- Tue Apr 14 21:48:07 2015 +0000
- Revision:
- 3:55a622e3dbb5
- Parent:
- 0:003889bc474f
Nonin (Pulse Oximeter) connected to mbed lpc 1768 by Bluetooth dongle and sends SMS including Heart Rate and Oxygen saturation by GPRS module
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 |