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
MAX30205Model.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 MAX30205EVKit.Model; 00041 using RPCSupport.Devices; 00042 00043 namespace HealthSensorPlatform.Model 00044 { 00045 class MAX30205Model : ITemperatureModel 00046 { 00047 private I2cDevice i2cDevice; 00048 private 00049 byte i2cAddress; 00050 int[] registers = new int[4]; 00051 00052 public MAX30205Model(I2cDevice i2cDevice, byte i2cAddress) 00053 { 00054 this.i2cDevice = i2cDevice; 00055 this.i2cAddress = i2cAddress; 00056 } 00057 00058 /* Properties */ 00059 public bool DataFormat 00060 { 00061 get 00062 { 00063 return ((registers[1] >> 5) & 0x01) == 0x01 ? true : false; 00064 } 00065 } 00066 00067 public int[] Registers 00068 { 00069 get 00070 { 00071 return registers; 00072 } 00073 } 00074 00075 public void RegWrite(int regAddress, int regValue) 00076 { 00077 00078 if ((regAddress == 0x02 || regAddress == 0x03)) 00079 { 00080 //base.RegWrite(regAddress, new byte[] { (byte)((regValue >> 8) & 0xFF), (byte)(regValue & 0xFF) }); 00081 i2cDevice.WriteRead(1, i2cAddress, new byte[] { (byte)regAddress, (byte)((regValue >> 8) & 0xFF), (byte)(regValue & 0xFF) }, 0); 00082 } 00083 else 00084 { 00085 //base.RegWrite(regAddress, regValue); 00086 i2cDevice.WriteReg(1, i2cAddress, (byte)regAddress, (byte)regValue); 00087 } 00088 00089 00090 System.Diagnostics.Debug.Print("RegWrite: " + regAddress.ToString("X2") + " " + regValue.ToString("X4")); 00091 } 00092 00093 public int RegRead(int regAddress) 00094 { 00095 int result; 00096 byte[] readResult; 00097 00098 switch (regAddress) 00099 { 00100 case 0x00: 00101 case 0x02: 00102 case 0x03: 00103 readResult = i2cDevice.ReadMultiReg(1, (byte)i2cAddress, (byte)regAddress, 2);//base.RegRead(regAddress, 2); 00104 result = readResult[0] << 8 | readResult[1]; 00105 break; 00106 default: 00107 result = i2cDevice.ReadReg(1, (byte)i2cAddress, (byte)regAddress); //base.RegRead(regAddress, 1); 00108 break; 00109 } 00110 00111 registers[regAddress] = result; 00112 00113 System.Diagnostics.Debug.Print("RegRead: " + regAddress.ToString("X2") + " " + result.ToString("X4")); 00114 00115 return result; 00116 } 00117 } 00118 }
Generated on Thu Jul 28 2022 18:07:15 by
1.7.2