Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MAXREFDES100FW300/e4a10ed6eb92/HSP/Test/Test_MAX30101.cpp@5:bc128a16232f, 2021-05-02 (annotated)
- Committer:
- darienf
- Date:
- Sun May 02 23:09:04 2021 +0000
- Revision:
- 5:bc128a16232f
- Parent:
- 3:36de8b9e4b1a
This is the program that was last used, that has the working temperature and some comments
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| darienf | 3:36de8b9e4b1a | 1 | /******************************************************************************* |
| darienf | 3:36de8b9e4b1a | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
| darienf | 3:36de8b9e4b1a | 3 | * |
| darienf | 3:36de8b9e4b1a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| darienf | 3:36de8b9e4b1a | 5 | * copy of this software and associated documentation files (the "Software"), |
| darienf | 3:36de8b9e4b1a | 6 | * to deal in the Software without restriction, including without limitation |
| darienf | 3:36de8b9e4b1a | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| darienf | 3:36de8b9e4b1a | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| darienf | 3:36de8b9e4b1a | 9 | * Software is furnished to do so, subject to the following conditions: |
| darienf | 3:36de8b9e4b1a | 10 | * |
| darienf | 3:36de8b9e4b1a | 11 | * The above copyright notice and this permission notice shall be included |
| darienf | 3:36de8b9e4b1a | 12 | * in all copies or substantial portions of the Software. |
| darienf | 3:36de8b9e4b1a | 13 | * |
| darienf | 3:36de8b9e4b1a | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| darienf | 3:36de8b9e4b1a | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| darienf | 3:36de8b9e4b1a | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| darienf | 3:36de8b9e4b1a | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| darienf | 3:36de8b9e4b1a | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| darienf | 3:36de8b9e4b1a | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| darienf | 3:36de8b9e4b1a | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| darienf | 3:36de8b9e4b1a | 21 | * |
| darienf | 3:36de8b9e4b1a | 22 | * Except as contained in this notice, the name of Maxim Integrated |
| darienf | 3:36de8b9e4b1a | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| darienf | 3:36de8b9e4b1a | 24 | * Products, Inc. Branding Policy. |
| darienf | 3:36de8b9e4b1a | 25 | * |
| darienf | 3:36de8b9e4b1a | 26 | * The mere transfer of this software does not imply any licenses |
| darienf | 3:36de8b9e4b1a | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
| darienf | 3:36de8b9e4b1a | 28 | * trademarks, maskwork rights, or any other form of intellectual |
| darienf | 3:36de8b9e4b1a | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| darienf | 3:36de8b9e4b1a | 30 | * ownership rights. |
| darienf | 3:36de8b9e4b1a | 31 | ******************************************************************************* |
| darienf | 3:36de8b9e4b1a | 32 | */ |
| darienf | 3:36de8b9e4b1a | 33 | #include "Test_MAX30101.h" |
| darienf | 3:36de8b9e4b1a | 34 | #include "Test_Utilities.h" |
| darienf | 3:36de8b9e4b1a | 35 | |
| darienf | 3:36de8b9e4b1a | 36 | uint32_t testing_max30101 = 0; |
| darienf | 3:36de8b9e4b1a | 37 | uint32_t testing_max30101_flags[4]; |
| darienf | 3:36de8b9e4b1a | 38 | |
| darienf | 3:36de8b9e4b1a | 39 | //****************************************************************************** |
| darienf | 3:36de8b9e4b1a | 40 | void test_MAX30101(void (*outputString)(const char *)) { |
| darienf | 3:36de8b9e4b1a | 41 | Timer timer; |
| darienf | 3:36de8b9e4b1a | 42 | int totalPass = 1; |
| darienf | 3:36de8b9e4b1a | 43 | int pass; |
| darienf | 3:36de8b9e4b1a | 44 | uint32_t foundHR = 0; |
| darienf | 3:36de8b9e4b1a | 45 | uint32_t foundSPO2 = 0; |
| darienf | 3:36de8b9e4b1a | 46 | uint32_t foundMULTI = 0; |
| darienf | 3:36de8b9e4b1a | 47 | MAX30101 *max30101; |
| darienf | 3:36de8b9e4b1a | 48 | |
| darienf | 3:36de8b9e4b1a | 49 | max30101 = Peripherals::max30101(); |
| darienf | 3:36de8b9e4b1a | 50 | |
| darienf | 3:36de8b9e4b1a | 51 | // display header |
| darienf | 3:36de8b9e4b1a | 52 | outputString("Testing MAX30101|"); |
| darienf | 3:36de8b9e4b1a | 53 | |
| darienf | 3:36de8b9e4b1a | 54 | // clear testing flags |
| darienf | 3:36de8b9e4b1a | 55 | testing_max30101_flags[TESTING_HR_FLAG] = 0; |
| darienf | 3:36de8b9e4b1a | 56 | testing_max30101_flags[TESTING_SPO2_FLAG] = 0; |
| darienf | 3:36de8b9e4b1a | 57 | testing_max30101_flags[TESTING_MULTI_FLAG] = 0; |
| darienf | 3:36de8b9e4b1a | 58 | testing_max30101 = 1; |
| darienf | 3:36de8b9e4b1a | 59 | |
| darienf | 3:36de8b9e4b1a | 60 | // |
| darienf | 3:36de8b9e4b1a | 61 | // start stream (HR) |
| darienf | 3:36de8b9e4b1a | 62 | // |
| darienf | 3:36de8b9e4b1a | 63 | outputString("Start HR Streaming...|"); |
| darienf | 3:36de8b9e4b1a | 64 | max30101->HRmode_init(0x0, 0x00, 0x01, 0x03, |
| darienf | 3:36de8b9e4b1a | 65 | 0x33); // This is the HR mode only (IR LED only) |
| darienf | 3:36de8b9e4b1a | 66 | // look for (HR) streaming |
| darienf | 3:36de8b9e4b1a | 67 | timer.start(); |
| darienf | 3:36de8b9e4b1a | 68 | while (1) { |
| darienf | 3:36de8b9e4b1a | 69 | if ((foundHR == 0) && (testing_max30101_flags[TESTING_HR_FLAG] == 1)) { |
| darienf | 3:36de8b9e4b1a | 70 | foundHR = 1; |
| darienf | 3:36de8b9e4b1a | 71 | outputString("HR Stream: PASS|"); |
| darienf | 3:36de8b9e4b1a | 72 | break; |
| darienf | 3:36de8b9e4b1a | 73 | } |
| darienf | 3:36de8b9e4b1a | 74 | if (timer.read() >= TESTING_MAX30101_TIMEOUT_SECONDS) { |
| darienf | 3:36de8b9e4b1a | 75 | break; |
| darienf | 3:36de8b9e4b1a | 76 | } |
| darienf | 3:36de8b9e4b1a | 77 | } |
| darienf | 3:36de8b9e4b1a | 78 | if (foundHR == 0) { |
| darienf | 3:36de8b9e4b1a | 79 | outputString("HR Stream: FAIL|"); |
| darienf | 3:36de8b9e4b1a | 80 | totalPass &= pass; |
| darienf | 3:36de8b9e4b1a | 81 | } |
| darienf | 3:36de8b9e4b1a | 82 | // stop stream |
| darienf | 3:36de8b9e4b1a | 83 | max30101->HRmode_stop(); |
| darienf | 3:36de8b9e4b1a | 84 | |
| darienf | 3:36de8b9e4b1a | 85 | // |
| darienf | 3:36de8b9e4b1a | 86 | // start stream (SPO2) |
| darienf | 3:36de8b9e4b1a | 87 | // |
| darienf | 3:36de8b9e4b1a | 88 | outputString("Start SPO2 Streaming...|"); |
| darienf | 3:36de8b9e4b1a | 89 | max30101->SpO2mode_init( |
| darienf | 3:36de8b9e4b1a | 90 | 0xF, 0x00, 0x01, 0x03, 0x33, |
| darienf | 3:36de8b9e4b1a | 91 | 0x33); // This is the SpO2 mode only (Red and IR LED only) |
| darienf | 3:36de8b9e4b1a | 92 | // look for (SPO2) stream |
| darienf | 3:36de8b9e4b1a | 93 | timer.reset(); |
| darienf | 3:36de8b9e4b1a | 94 | while (1) { |
| darienf | 3:36de8b9e4b1a | 95 | if ((foundSPO2 == 0) && (testing_max30101_flags[TESTING_SPO2_FLAG] == 1)) { |
| darienf | 3:36de8b9e4b1a | 96 | foundSPO2 = 1; |
| darienf | 3:36de8b9e4b1a | 97 | outputString("SPO2 Stream: PASS|"); |
| darienf | 3:36de8b9e4b1a | 98 | break; |
| darienf | 3:36de8b9e4b1a | 99 | } |
| darienf | 3:36de8b9e4b1a | 100 | if (timer.read() >= TESTING_MAX30101_TIMEOUT_SECONDS) { |
| darienf | 3:36de8b9e4b1a | 101 | break; |
| darienf | 3:36de8b9e4b1a | 102 | } |
| darienf | 3:36de8b9e4b1a | 103 | } |
| darienf | 3:36de8b9e4b1a | 104 | if (foundSPO2 == 0) { |
| darienf | 3:36de8b9e4b1a | 105 | outputString("SPO2 Stream: FAIL|"); |
| darienf | 3:36de8b9e4b1a | 106 | totalPass &= pass; |
| darienf | 3:36de8b9e4b1a | 107 | } |
| darienf | 3:36de8b9e4b1a | 108 | // stop stream |
| darienf | 3:36de8b9e4b1a | 109 | max30101->SpO2mode_stop(); |
| darienf | 3:36de8b9e4b1a | 110 | |
| darienf | 3:36de8b9e4b1a | 111 | // |
| darienf | 3:36de8b9e4b1a | 112 | // start stream (MULTI) |
| darienf | 3:36de8b9e4b1a | 113 | // |
| darienf | 3:36de8b9e4b1a | 114 | outputString("Start Multi Streaming...|"); |
| darienf | 3:36de8b9e4b1a | 115 | max30101->Multimode_init(0x00, 0x00, 0x01, 0x03, 0x33, 0x33, 0x33, 0x01, 0x02, |
| darienf | 3:36de8b9e4b1a | 116 | 0x03, 0x00); // Up to 4 LED can be turned on over |
| darienf | 3:36de8b9e4b1a | 117 | // look for (SPO2) stream |
| darienf | 3:36de8b9e4b1a | 118 | timer.reset(); |
| darienf | 3:36de8b9e4b1a | 119 | while (1) { |
| darienf | 3:36de8b9e4b1a | 120 | if ((foundMULTI == 0) && |
| darienf | 3:36de8b9e4b1a | 121 | (testing_max30101_flags[TESTING_MULTI_FLAG] == 1)) { |
| darienf | 3:36de8b9e4b1a | 122 | foundMULTI = 1; |
| darienf | 3:36de8b9e4b1a | 123 | outputString("Multi Stream: PASS|"); |
| darienf | 3:36de8b9e4b1a | 124 | break; |
| darienf | 3:36de8b9e4b1a | 125 | } |
| darienf | 3:36de8b9e4b1a | 126 | if (timer.read() >= TESTING_MAX30101_TIMEOUT_SECONDS) { |
| darienf | 3:36de8b9e4b1a | 127 | break; |
| darienf | 3:36de8b9e4b1a | 128 | } |
| darienf | 3:36de8b9e4b1a | 129 | } |
| darienf | 3:36de8b9e4b1a | 130 | if (foundMULTI == 0) { |
| darienf | 3:36de8b9e4b1a | 131 | outputString("Multi Stream: FAIL|"); |
| darienf | 3:36de8b9e4b1a | 132 | totalPass &= pass; |
| darienf | 3:36de8b9e4b1a | 133 | } |
| darienf | 3:36de8b9e4b1a | 134 | // stop stream |
| darienf | 3:36de8b9e4b1a | 135 | max30101->Multimode_stop(); |
| darienf | 3:36de8b9e4b1a | 136 | |
| darienf | 3:36de8b9e4b1a | 137 | testing_max30101 = 0; |
| darienf | 3:36de8b9e4b1a | 138 | |
| darienf | 3:36de8b9e4b1a | 139 | timer.stop(); |
| darienf | 3:36de8b9e4b1a | 140 | // final results |
| darienf | 3:36de8b9e4b1a | 141 | outputString("Result: "); |
| darienf | 3:36de8b9e4b1a | 142 | _printPassFail(totalPass, 0, outputString); |
| darienf | 3:36de8b9e4b1a | 143 | } |