Host software for the MAX30001 ECG, PACE, biopotential, bioimpedance, R-to-R peak sensor. Hosted on the MAX32630FTHR.
Dependencies: SDFileSystem USBDevice max32630fthr
Fork of MAX30001-MAX32630FTHR-ECG-EVKIT by
HSP/Devices/MAX30001/MAX30001_helper.cpp@13:6031b0bd9773, 2018-07-24 (annotated)
- Committer:
- Emre.Eken
- Date:
- Tue Jul 24 15:22:35 2018 +0300
- Revision:
- 13:6031b0bd9773
- Parent:
- 0:8e4630a71eb1
.hgtags is added.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 1 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 2 | /******************************************************************************* |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 3 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 4 | * |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 6 | * copy of this software and associated documentation files (the "Software"), |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 7 | * to deal in the Software without restriction, including without limitation |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 9 | * and/or sell copies of the Software, and to permit persons to whom the |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 10 | * Software is furnished to do so, subject to the following conditions: |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 11 | * |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 12 | * The above copyright notice and this permission notice shall be included |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 13 | * in all copies or substantial portions of the Software. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 14 | * |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 18 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 19 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 21 | * OTHER DEALINGS IN THE SOFTWARE. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 22 | * |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 23 | * Except as contained in this notice, the name of Maxim Integrated |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 24 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 25 | * Products, Inc. Branding Policy. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 26 | * |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 27 | * The mere transfer of this software does not imply any licenses |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 28 | * of trade secrets, proprietary technology, copyrights, patents, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 29 | * trademarks, maskwork rights, or any other form of intellectual |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 30 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 31 | * ownership rights. |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 32 | ******************************************************************************* |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 33 | */ |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 34 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 35 | #include "MAX30001_helper.h" |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 36 | #include "MAX30001.h" |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 37 | #include "StringInOut.h" |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 38 | #include "Peripherals.h" |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 39 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 40 | static uint8_t flags[4]; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 41 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 42 | int MAX30001_Helper_IsStreaming(eFlags flag) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 43 | return flags[(uint32_t)flag]; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 44 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 45 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 46 | void MAX30001_Helper_SetStreamingFlag(eFlags flag, uint8_t state) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 47 | flags[(uint32_t)flag] = state; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 48 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 49 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 50 | void MAX30001_Helper_Stop(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 51 | if (flags[(uint32_t)eStreaming_ECG] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 52 | Peripherals::max30001()->max30001_Stop_ECG(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 53 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 54 | if (flags[(uint32_t)eStreaming_PACE] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 55 | Peripherals::max30001()->max30001_Stop_PACE(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 56 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 57 | if (flags[(uint32_t)eStreaming_BIOZ] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 58 | Peripherals::max30001()->max30001_Stop_BIOZ(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 59 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 60 | if (flags[(uint32_t)eStreaming_RtoR] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 61 | Peripherals::max30001()->max30001_Stop_RtoR(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 62 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 63 | MAX30001_Helper_ClearStreamingFlags(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 64 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 65 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 66 | int MAX30001_AnyStreamingSet(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 67 | uint32_t i; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 68 | for (i = 0; i < 4; i++) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 69 | if (flags[i] == 1) return 1; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 70 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 71 | return 0; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 72 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 73 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 74 | void MAX30001_Helper_StartSync(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 75 | if (MAX30001_AnyStreamingSet() == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 76 | Peripherals::max30001()->max30001_synch(); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 77 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 78 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 79 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 80 | void MAX30001_Helper_ClearStreamingFlags(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 81 | uint32_t i; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 82 | for (i = 0; i < 4; i++) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 83 | flags[i] = 0; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 84 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 85 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 86 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 87 | void MAX30001_Helper_Debug_ShowStreamFlags(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 88 | putStr("\r\n"); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 89 | if (flags[(uint32_t)eStreaming_ECG] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 90 | putStr("eStreaming_ECG, "); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 91 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 92 | if (flags[(uint32_t)eStreaming_PACE] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 93 | putStr("eStreaming_PACE, "); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 94 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 95 | if (flags[(uint32_t)eStreaming_BIOZ] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 96 | putStr("eStreaming_BIOZ, "); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 97 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 98 | if (flags[(uint32_t)eStreaming_RtoR] == 1) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 99 | putStr("eStreaming_RtoR, "); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 100 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 101 | putStr("\r\n"); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 102 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 103 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 104 | void MAX30001_Helper_SetupInterrupts() { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 105 | // We removed this baed on the assumption that user provides a INT_assignment command |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 106 | /* |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 107 | Peripherals::max30001()->max30001_INT_assignment(MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_enint_loc, en_eovf_loc, en_fstint_loc, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 108 | MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_dcloffint_loc, en_bint_loc, en_bovf_loc, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 109 | MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_bover_loc, en_bundr_loc, en_bcgmon_loc, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 110 | MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_pint_loc, en_povf_loc, en_pedge_loc, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 111 | MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, // en_lonint_loc, en_rrint_loc, en_samp_loc, |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 112 | MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR); // intb_Type, int2b_Type) |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 113 | */ |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 114 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 115 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 116 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 117 | |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 118 | static uint8_t serialNumber[6]; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 119 | uint8_t *MAX30001_Helper_getVersion(void) { |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 120 | // read the id |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 121 | Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 122 | // read id twice because it needs to be read twice |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 123 | Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 124 | return serialNumber; |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 125 | } |
Emre.Eken@IST-LT-35101.maxim-ic.internal | 0:8e4630a71eb1 | 126 |