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.
Dependencies: mbed MAX14720 MAX30205 USBDevice
MAX30001.cs
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 using System; 00037 using System.Collections.Generic; 00038 using System.Linq; 00039 using System.Text; 00040 using System.Globalization; 00041 using System.Threading; 00042 00043 namespace RPCSupport.Devices 00044 { 00045 /* ECG */ 00046 public class MAX30001 : ClientDevice, IRegisterDevice 00047 { 00048 00049 public enum max30001_intrpt_Location { 00050 MAX30001_NO_INT = 0, // No interrupt 00051 MAX30001_INT_B = 1, // INTB selected for interrupt 00052 MAX30001_INT_2B = 2, // INT2B selected for interrupt 00053 test1 = 3, 00054 test2 = 4, 00055 test3 = 5, 00056 test4 = 6, 00057 test5 = 7, 00058 test6 = 8, 00059 test7 = 9, 00060 test8 = 10, 00061 test9 = 11, 00062 test10 = 12, 00063 test11 = 13, 00064 test12 = 14, 00065 test13 = 15, 00066 test14 = 16, 00067 test15 = 17 00068 }; 00069 00070 public enum max30001_intrpt_type { 00071 MAX30001_INT_DISABLED = 0x00, 00072 MAX30001_INT_CMOS = 0x01, 00073 MAX30001_INT_ODN = 0x02, 00074 MAX30001_INT_ODNR = 0x03, 00075 test1 = 18, 00076 test2 = 19 00077 }; 00078 00079 public const string CLASSNAME = "MAX30001"; 00080 public MAX30001(RPCClient client) 00081 : base(client) 00082 { 00083 } 00084 public int ReadReg(byte addr) 00085 { 00086 int val; 00087 string reply = Call(CLASSNAME, "ReadReg", addr.ToString("X2")); 00088 int.TryParse(reply, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val); 00089 return val; 00090 //return GetReturnValue_Byte(); 00091 } 00092 00093 public void WriteReg(byte addr, int data) 00094 { 00095 Call(CLASSNAME, "WriteReg", addr.ToString("X2"), data.ToString("X2")); 00096 } 00097 public void StartConv() 00098 { 00099 Call(CLASSNAME, "StartConv"); 00100 } 00101 00102 private void InitStreaming() 00103 { 00104 client.pipeline.Discard(); 00105 client.streaming.Init(client.pipeline); 00106 client.streaming.Start(); 00107 //Call(CLASSNAME, "StreamTest"); 00108 //CallNoReply(CLASSNAME, "StreamTest"); 00109 } 00110 00111 00112 public int Rbias_FMSTR_Init( 00113 int En_rbias, 00114 int Rbiasv, 00115 int Rbiasp, 00116 int Rbiasn, 00117 int Fmstr) 00118 { 00119 Call(CLASSNAME, "Rbias_FMSTR_Init", En_rbias.ToString("X2"), Rbiasv.ToString("X2"), Rbiasp.ToString("X2"), Rbiasn.ToString("X2"), Fmstr.ToString("X2")); 00120 return 0; 00121 } 00122 00123 00124 // old 12/15/15 for reference 00125 /* 00126 public int CAL_InitStart( 00127 int Vmode, 00128 int Vmag, 00129 int Fcal, 00130 int Thigh, 00131 int Fifty, 00132 int En_Vcal) 00133 { 00134 Call(CLASSNAME, "CAL_InitStart", Vmode.ToString("X2"), Vmag.ToString("X2"), Fcal.ToString("X2"), Thigh.ToString("X2"), Fifty.ToString("X2"), En_Vcal.ToString("X2")); 00135 return 0; 00136 } 00137 00138 */ 00139 public int CAL_InitStart( 00140 int En_Vcal, 00141 int Vmode, 00142 int Vmag, 00143 int Fcal, 00144 int Thigh, 00145 int Fifty 00146 ) 00147 { 00148 Call(CLASSNAME, "CAL_InitStart", En_Vcal.ToString("X2"), Vmode.ToString("X2"), Vmag.ToString("X2"), Fcal.ToString("X2"), Thigh.ToString("X2"), Fifty.ToString("X2")); 00149 return 0; 00150 } 00151 00152 00153 // old 12/15/15 for reference 00154 /* public int ECG_InitStart( 00155 int Openp, 00156 int Openn, 00157 int Pol, 00158 int Calp_sel, 00159 int Caln_sel, 00160 int En_ecg, 00161 int E_fit, 00162 int Clr_rrint, 00163 int Rate, 00164 int Gain, 00165 int Dhpf, 00166 int Dlpf) 00167 { 00168 Call(CLASSNAME, "ECG_InitStart", Openp.ToString("X2"), Openn.ToString("X2"), Pol.ToString("X2"), Calp_sel.ToString("X2"), Caln_sel.ToString("X2"), En_ecg.ToString("X2"), E_fit.ToString("X2"), Clr_rrint.ToString("X2"), Rate.ToString("X2"), Gain.ToString("X2"), Dhpf.ToString("X2"), Dlpf.ToString("X2")); 00169 return 0; 00170 }*/ 00171 public int ECG_InitStart( 00172 int En_ecg, 00173 int Openp, 00174 int Openn, 00175 int Pol, 00176 int Calp_sel, 00177 int Caln_sel, 00178 int E_fit, 00179 int Rate, 00180 int Gain, 00181 int Dhpf, 00182 int Dlpf) 00183 { 00184 Call(CLASSNAME, "ECG_InitStart", En_ecg.ToString("X2"), Openp.ToString("X2"), Openn.ToString("X2"), Pol.ToString("X2"), Calp_sel.ToString("X2"), Caln_sel.ToString("X2"), 00185 E_fit.ToString("X2"), Rate.ToString("X2"), Gain.ToString("X2"), Dhpf.ToString("X2"), Dlpf.ToString("X2")); 00186 return 0; 00187 } 00188 00189 00190 public int ECGFast_Init( 00191 int Clr_Fast, 00192 int Fast, 00193 int Fast_Th) 00194 { 00195 Call(CLASSNAME, "ECGFast_Init", Clr_Fast.ToString("X2"), Fast.ToString("X2"), Fast_Th.ToString("X2")); 00196 return 0; 00197 } 00198 00199 public int PACE_InitStart( 00200 int En_pace, 00201 int Clr_pedge, 00202 int Pol, 00203 int Gn_diff_off, 00204 int Gain, 00205 int Aout_lbw, 00206 int Aout, 00207 int Dacp, 00208 int Dacn) 00209 { 00210 Call(CLASSNAME, "PACE_InitStart", En_pace.ToString("X2"), Clr_pedge.ToString("X2"), Pol.ToString("X2"), Gn_diff_off.ToString("X2"), Gain.ToString("X2"), Aout_lbw.ToString("X2"), Aout.ToString("X2"), Dacp.ToString("X2"), Dacn.ToString("X2")); 00211 return 0; 00212 } 00213 00214 // old 12/15/15 for reference 00215 /* public int BIOZ_InitStart( 00216 int Openp, 00217 int Openn, 00218 int Calp_sel, 00219 int Caln_sel, 00220 int CG_mode, 00221 int En_bioz, 00222 int B_fit, 00223 int Rate, 00224 int Ahpf, 00225 int Ext_rbias, 00226 int Gain, 00227 int Dhpf, 00228 int Dlpf, 00229 int Fcgen, 00230 int Cgmon, 00231 int Cgmag, 00232 int Phoff) 00233 { 00234 Call(CLASSNAME, "BIOZ_InitStart", Openp.ToString("X2"), Openn.ToString("X2"), Calp_sel.ToString("X2"), Caln_sel.ToString("X2"), CG_mode.ToString("X2"), 00235 En_bioz.ToString("X2"), B_fit.ToString("X2"), Rate.ToString("X2"), Ahpf.ToString("X2"), Ext_rbias.ToString("X2"), Gain.ToString("X2"), 00236 Dhpf.ToString("X2"), Dlpf.ToString("X2"), Fcgen.ToString("X2"), Cgmon.ToString("X2"), Cgmag.ToString("X2"), Phoff.ToString("X2")); 00237 return 0; 00238 }*/ 00239 public int BIOZ_InitStart( 00240 int En_bioz, 00241 int Openp, 00242 int Openn, 00243 int Calp_sel, 00244 int Caln_sel, 00245 int CG_mode, 00246 int B_fit, 00247 int Rate, 00248 int Ahpf, 00249 int Ext_rbias, 00250 int Gain, 00251 int Dhpf, 00252 int Dlpf, 00253 int Fcgen, 00254 int Cgmon, 00255 int Cgmag, 00256 int Phoff) 00257 { 00258 Call(CLASSNAME, "BIOZ_InitStart", En_bioz.ToString("X2"), Openp.ToString("X2"), Openn.ToString("X2"), Calp_sel.ToString("X2"), Caln_sel.ToString("X2"), CG_mode.ToString("X2"), 00259 B_fit.ToString("X2"), Rate.ToString("X2"), Ahpf.ToString("X2"), Ext_rbias.ToString("X2"), Gain.ToString("X2"), 00260 Dhpf.ToString("X2"), Dlpf.ToString("X2"), Fcgen.ToString("X2"), Cgmon.ToString("X2"), Cgmag.ToString("X2"), Phoff.ToString("X2")); 00261 return 0; 00262 } 00263 00264 // old 12/15/15 for reference 00265 /* public int RtoR_InitStart( 00266 int Wndw, 00267 int Gain, 00268 int En_rtor, 00269 int Pavg, 00270 int Ptsf, 00271 int Hoff, 00272 int Ravg, 00273 int Rhsf) 00274 { 00275 Call(CLASSNAME, "RtoR_InitStart", Wndw.ToString("X2"), Gain.ToString("X2"), En_rtor.ToString("X2"), Pavg.ToString("X2"), Ptsf.ToString("X2"), 00276 Hoff.ToString("X2"), Ravg.ToString("X2"), Rhsf.ToString("X2")); 00277 return 0; 00278 }*/ 00279 public int RtoR_InitStart( 00280 int En_rtor, 00281 int Wndw, 00282 int Gain, 00283 int Pavg, 00284 int Ptsf, 00285 int Hoff, 00286 int Ravg, 00287 int Rhsf, 00288 int Clr_rrint) 00289 { 00290 Call(CLASSNAME, "RtoR_InitStart", En_rtor.ToString("X2"), Wndw.ToString("X2"), Gain.ToString("X2"), Pavg.ToString("X2"), Ptsf.ToString("X2"), 00291 Hoff.ToString("X2"), Ravg.ToString("X2"), Rhsf.ToString("X2"), Clr_rrint.ToString("X2")); 00292 return 0; 00293 } 00294 00295 public int Stop_ECG() 00296 { 00297 Call(CLASSNAME, "Stop_ECG"); 00298 return 0; 00299 } 00300 00301 public int Stop_PACE() 00302 { 00303 Call(CLASSNAME, "Stop_PACE"); 00304 return 0; 00305 } 00306 00307 public int Stop_Cal() 00308 { 00309 //Call(CLASSNAME, "Stop_Cal"); 00310 return 0; 00311 } 00312 00313 public int Stop_BIOZ() 00314 { 00315 Call(CLASSNAME, "Stop_BIOZ"); 00316 return 0; 00317 } 00318 00319 public int Stop_RtoR() 00320 { 00321 Call(CLASSNAME, "Stop_RtoR"); 00322 return 0; 00323 } 00324 00325 public void StartStreaming() 00326 { 00327 client.pipeline.Discard(); 00328 InitStreaming(); 00329 CallNoReply(CLASSNAME, "Start"); 00330 //Call(CLASSNAME, "StartTest"); 00331 } 00332 00333 public void StartTest() 00334 { 00335 client.pipeline.Discard(); 00336 InitStreaming(); 00337 CallNoReply(CLASSNAME, "StartTest"); 00338 //Call(CLASSNAME, "StartTest"); 00339 } 00340 00341 public void StopStreaming() 00342 { 00343 StopStreaming(true); 00344 } 00345 00346 public void StopStreaming(bool connected) 00347 { 00348 if (connected) 00349 client.pipeline.SendSingleByte(' '); 00350 00351 client.streaming.Stop(); 00352 00353 if (connected) 00354 { 00355 client.pipeline.Discard(); 00356 Thread.Sleep(500); 00357 client.pipeline.Discard(); 00358 } 00359 } 00360 00361 public void INT_assignment( 00362 max30001_intrpt_Location max30001_intrpt_Location, max30001_intrpt_Location max30001_intrpt_Location_2, max30001_intrpt_Location max30001_intrpt_Location_3, 00363 max30001_intrpt_Location max30001_intrpt_Location_4, max30001_intrpt_Location max30001_intrpt_Location_5, max30001_intrpt_Location max30001_intrpt_Location_6, 00364 max30001_intrpt_Location max30001_intrpt_Location_7, max30001_intrpt_Location max30001_intrpt_Location_8, max30001_intrpt_Location max30001_intrpt_Location_9, 00365 max30001_intrpt_Location max30001_intrpt_Location_10, max30001_intrpt_Location max30001_intrpt_Location_11, max30001_intrpt_Location max30001_intrpt_Location_12, 00366 max30001_intrpt_Location max30001_intrpt_Location_13, max30001_intrpt_Location max30001_intrpt_Location_14, max30001_intrpt_Location max30001_intrpt_Location_15, 00367 max30001_intrpt_type max30001_intrpt_type, max30001_intrpt_type max30001_intrpt_type_2) 00368 { 00369 Call(CLASSNAME, "INT_assignment", 00370 max30001_intrpt_Location.ToString("x") , max30001_intrpt_Location_2.ToString("x") , max30001_intrpt_Location_3.ToString("x") , 00371 max30001_intrpt_Location_4.ToString("x") , max30001_intrpt_Location_5.ToString("x") , max30001_intrpt_Location_6.ToString("x") , 00372 max30001_intrpt_Location_7.ToString("x") , max30001_intrpt_Location_8.ToString("x") , max30001_intrpt_Location_9.ToString("x") , 00373 max30001_intrpt_Location_10.ToString("x") , max30001_intrpt_Location_11.ToString("x") , max30001_intrpt_Location_12.ToString("x") , 00374 max30001_intrpt_Location_13.ToString("x") , max30001_intrpt_Location_14.ToString("x") , max30001_intrpt_Location_15.ToString("x") , 00375 max30001_intrpt_type.ToString("x") , max30001_intrpt_type_2.ToString("x") 00376 ); 00377 } 00378 } 00379 } 00380 00381 00382
Generated on Thu Jul 28 2022 18:07:15 by
1.7.2