MAX30001-MAX32630FTHR SYS EvKit
Dependencies: USBDevice max32630fthr
MAX30001_helper.cpp
00001 00002 /******************************************************************************* 00003 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a 00006 * copy of this software and associated documentation files (the "Software"), 00007 * to deal in the Software without restriction, including without limitation 00008 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00009 * and/or sell copies of the Software, and to permit persons to whom the 00010 * Software is furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included 00013 * in all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00018 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00019 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00021 * OTHER DEALINGS IN THE SOFTWARE. 00022 * 00023 * Except as contained in this notice, the name of Maxim Integrated 00024 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00025 * Products, Inc. Branding Policy. 00026 * 00027 * The mere transfer of this software does not imply any licenses 00028 * of trade secrets, proprietary technology, copyrights, patents, 00029 * trademarks, maskwork rights, or any other form of intellectual 00030 * property whatsoever. Maxim Integrated Products, Inc. retains all 00031 * ownership rights. 00032 ******************************************************************************* 00033 */ 00034 00035 #include "MAX30001_helper.h" 00036 #include "MAX30001.h" 00037 #include "StringInOut.h" 00038 #include "Peripherals.h" 00039 00040 static uint8_t flags[4]; 00041 00042 int MAX30001_Helper_IsStreaming(eFlags flag) { 00043 return flags[(uint32_t)flag]; 00044 } 00045 00046 void MAX30001_Helper_SetStreamingFlag(eFlags flag, uint8_t state) { 00047 flags[(uint32_t)flag] = state; 00048 } 00049 00050 void MAX30001_Helper_Stop(void) { 00051 if (flags[(uint32_t)eStreaming_ECG] == 1) { 00052 Peripherals::max30001()->max30001_Stop_ECG(); 00053 } 00054 if (flags[(uint32_t)eStreaming_PACE] == 1) { 00055 Peripherals::max30001()->max30001_Stop_PACE(); 00056 } 00057 if (flags[(uint32_t)eStreaming_BIOZ] == 1) { 00058 Peripherals::max30001()->max30001_Stop_BIOZ(); 00059 } 00060 if (flags[(uint32_t)eStreaming_RtoR] == 1) { 00061 Peripherals::max30001()->max30001_Stop_RtoR(); 00062 } 00063 MAX30001_Helper_ClearStreamingFlags(); 00064 } 00065 00066 int MAX30001_AnyStreamingSet(void) { 00067 uint32_t i; 00068 for (i = 0; i < 4; i++) { 00069 if (flags[i] == 1) return 1; 00070 } 00071 return 0; 00072 } 00073 00074 void MAX30001_Helper_StartSync(void) { 00075 if (MAX30001_AnyStreamingSet() == 1) { 00076 Peripherals::max30001()->max30001_synch(); 00077 } 00078 } 00079 00080 void MAX30001_Helper_ClearStreamingFlags(void) { 00081 uint32_t i; 00082 for (i = 0; i < 4; i++) { 00083 flags[i] = 0; 00084 } 00085 } 00086 00087 void MAX30001_Helper_Debug_ShowStreamFlags(void) { 00088 putStr("\r\n"); 00089 if (flags[(uint32_t)eStreaming_ECG] == 1) { 00090 putStr("eStreaming_ECG, "); 00091 } 00092 if (flags[(uint32_t)eStreaming_PACE] == 1) { 00093 putStr("eStreaming_PACE, "); 00094 } 00095 if (flags[(uint32_t)eStreaming_BIOZ] == 1) { 00096 putStr("eStreaming_BIOZ, "); 00097 } 00098 if (flags[(uint32_t)eStreaming_RtoR] == 1) { 00099 putStr("eStreaming_RtoR, "); 00100 } 00101 putStr("\r\n"); 00102 } 00103 00104 void MAX30001_Helper_SetupInterrupts() { 00105 // We removed this baed on the assumption that user provides a INT_assignment command 00106 /* 00107 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, 00108 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_dcloffint_loc, en_bint_loc, en_bovf_loc, 00109 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_bover_loc, en_bundr_loc, en_bcgmon_loc, 00110 MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_pint_loc, en_povf_loc, en_pedge_loc, 00111 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, // en_lonint_loc, en_rrint_loc, en_samp_loc, 00112 MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR); // intb_Type, int2b_Type) 00113 */ 00114 } 00115 00116 00117 00118 static uint8_t serialNumber[6]; 00119 uint8_t *MAX30001_Helper_getVersion(void) { 00120 // read the id 00121 Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); 00122 // read id twice because it needs to be read twice 00123 Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); 00124 return serialNumber; 00125 } 00126
Generated on Tue Jul 12 2022 16:59:43 by 1.7.2