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