Darien Figueroa / Mbed 2 deprecated repo3

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX30205Test.cs Source File

MAX30205Test.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 NUnit.Framework;
00038 using RPCSupport.Devices;
00039 using RPCSupport;
00040 
00041 namespace RPCSupportTest
00042 {
00043     [TestFixture, Property("Hardware", "Required")]
00044     public class MAX30205Test
00045     {
00046         RPCClient rpcClient;
00047         MAX30205 max30205;
00048 
00049         [TestFixtureSetUp]
00050         public void Init()
00051         {
00052             rpcClient = new RPCClient(RPCClient.ePipeline.eSerialWrap);
00053             rpcClient.InitPipeline();
00054             rpcClient.Connect(ComPort.Port);
00055             max30205 = rpcClient.Init_MAX30205(0x90);
00056         }
00057 
00058         [TestFixtureTearDown]
00059         public void Dispose()
00060         {
00061             rpcClient.Disconnect();
00062         }
00063 
00064         [Test]
00065         public void ReadTemperature()
00066         {
00067             float temp = max30205.ReadTemp();
00068 
00069             Assert.AreEqual(true, temp > 20 && temp < 30);
00070         }
00071 
00072         [Test]
00073         public void ReadConfigurationRegister()
00074         {
00075             byte data = max30205.ReadReg(0x01);
00076 
00077             Assert.AreEqual(true, data >= 0 && data <= 0xff);
00078         }
00079 
00080         [Test]
00081         public void WriteConfigurationRegister()
00082         {
00083             byte data = max30205.ReadReg(0x01);
00084 
00085             byte flipped = (byte)(data ^ 0xFF);
00086 
00087             max30205.WriteReg(0x01, flipped);
00088 
00089             byte result = max30205.ReadReg(0x01);
00090 
00091             max30205.WriteReg(0x01, data); // Restore register value
00092 
00093             Assert.AreEqual(flipped, result);
00094         }
00095 
00096         [Test]
00097         public void WriteOverTemperatureRegister()
00098         {
00099             Assert.AreEqual(true, false);
00100         }
00101     }
00102 }