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.
Fork of mbed-os-test by
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 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, 00106 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_dcloffint_loc, en_bint_loc, en_bovf_loc, 00107 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_bover_loc, en_bundr_loc, en_bcgmon_loc, 00108 MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_pint_loc, en_povf_loc, en_pedge_loc, 00109 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, // en_lonint_loc, en_rrint_loc, en_samp_loc, 00110 MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR); // intb_Type, int2b_Type) 00111 } 00112 00113 00114 00115 static uint8_t serialNumber[6]; 00116 uint8_t *MAX30001_Helper_getVersion(void) { 00117 // read the id 00118 Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); 00119 // read id twice because it needs to be read twice 00120 Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber); 00121 return serialNumber; 00122 }
Generated on Wed Jul 13 2022 17:00:35 by
1.7.2
