1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.

Dependents:   MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more

Superseded by MaximInterface.

Committer:
j3
Date:
Mon Jun 20 20:02:28 2016 +0000
Revision:
92:aa40c49b8563
Child:
104:3f48daed532b
Updated DS2482 class names to work with doxygen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 92:aa40c49b8563 1 /**********************************************************************
j3 92:aa40c49b8563 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 92:aa40c49b8563 3 *
j3 92:aa40c49b8563 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 92:aa40c49b8563 5 * copy of this software and associated documentation files (the "Software"),
j3 92:aa40c49b8563 6 * to deal in the Software without restriction, including without limitation
j3 92:aa40c49b8563 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 92:aa40c49b8563 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 92:aa40c49b8563 9 * Software is furnished to do so, subject to the following conditions:
j3 92:aa40c49b8563 10 *
j3 92:aa40c49b8563 11 * The above copyright notice and this permission notice shall be included
j3 92:aa40c49b8563 12 * in all copies or substantial portions of the Software.
j3 92:aa40c49b8563 13 *
j3 92:aa40c49b8563 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 92:aa40c49b8563 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 92:aa40c49b8563 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 92:aa40c49b8563 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 92:aa40c49b8563 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 92:aa40c49b8563 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 92:aa40c49b8563 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 92:aa40c49b8563 21 *
j3 92:aa40c49b8563 22 * Except as contained in this notice, the name of Maxim Integrated
j3 92:aa40c49b8563 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 92:aa40c49b8563 24 * Products, Inc. Branding Policy.
j3 92:aa40c49b8563 25 *
j3 92:aa40c49b8563 26 * The mere transfer of this software does not imply any licenses
j3 92:aa40c49b8563 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 92:aa40c49b8563 28 * trademarks, maskwork rights, or any other form of intellectual
j3 92:aa40c49b8563 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 92:aa40c49b8563 30 * ownership rights.
j3 92:aa40c49b8563 31 **********************************************************************/
j3 92:aa40c49b8563 32
j3 92:aa40c49b8563 33
j3 92:aa40c49b8563 34 #include "OneWire/Masters/DS248x/DS2482EightChannel/DS2482EightChannel.h"
j3 92:aa40c49b8563 35
j3 92:aa40c49b8563 36 using OneWire::OneWireMaster;
j3 92:aa40c49b8563 37 using OneWire::DS2482EightChannel;
j3 92:aa40c49b8563 38
j3 92:aa40c49b8563 39
j3 92:aa40c49b8563 40 //*********************************************************************
j3 92:aa40c49b8563 41 DS2482EightChannel::DS2482EightChannel(mbed::I2C & i2c_bus, uint8_t adrs)
j3 92:aa40c49b8563 42 :DS248x(i2c_bus, adrs)
j3 92:aa40c49b8563 43 {
j3 92:aa40c49b8563 44 }
j3 92:aa40c49b8563 45
j3 92:aa40c49b8563 46
j3 92:aa40c49b8563 47 //*********************************************************************
j3 92:aa40c49b8563 48 DS2482EightChannel::DS2482EightChannel(mbed::I2C & i2c_bus, I2CAddress adrs)
j3 92:aa40c49b8563 49 :DS248x(i2c_bus, adrs)
j3 92:aa40c49b8563 50 {
j3 92:aa40c49b8563 51 }
j3 92:aa40c49b8563 52
j3 92:aa40c49b8563 53
j3 92:aa40c49b8563 54 //*********************************************************************
j3 92:aa40c49b8563 55 OneWireMaster::CmdResult DS2482EightChannel::selectChannel(uint8_t channel)
j3 92:aa40c49b8563 56 {
j3 92:aa40c49b8563 57 OneWireMaster::CmdResult result;
j3 92:aa40c49b8563 58 uint8_t ch, ch_read;
j3 92:aa40c49b8563 59
j3 92:aa40c49b8563 60 // Channel Select (Case A)
j3 92:aa40c49b8563 61 // S AD,0 [A] CHSL [A] CC [A] Sr AD,1 [A] [RR] A\ P
j3 92:aa40c49b8563 62 // [] indicates from slave
j3 92:aa40c49b8563 63 // CC channel value
j3 92:aa40c49b8563 64 // RR channel read back
j3 92:aa40c49b8563 65
j3 92:aa40c49b8563 66 switch (channel)
j3 92:aa40c49b8563 67 {
j3 92:aa40c49b8563 68 default:
j3 92:aa40c49b8563 69 case 0:
j3 92:aa40c49b8563 70 ch = 0xF0;
j3 92:aa40c49b8563 71 ch_read = 0xB8;
j3 92:aa40c49b8563 72 break;
j3 92:aa40c49b8563 73 case 1:
j3 92:aa40c49b8563 74 ch = 0xE1;
j3 92:aa40c49b8563 75 ch_read = 0xB1;
j3 92:aa40c49b8563 76 break;
j3 92:aa40c49b8563 77 case 2:
j3 92:aa40c49b8563 78 ch = 0xD2;
j3 92:aa40c49b8563 79 ch_read = 0xAA;
j3 92:aa40c49b8563 80 break;
j3 92:aa40c49b8563 81 case 3:
j3 92:aa40c49b8563 82 ch = 0xC3;
j3 92:aa40c49b8563 83 ch_read = 0xA3;
j3 92:aa40c49b8563 84 break;
j3 92:aa40c49b8563 85 case 4:
j3 92:aa40c49b8563 86 ch = 0xB4;
j3 92:aa40c49b8563 87 ch_read = 0x9C;
j3 92:aa40c49b8563 88 break;
j3 92:aa40c49b8563 89 case 5:
j3 92:aa40c49b8563 90 ch = 0xA5;
j3 92:aa40c49b8563 91 ch_read = 0x95;
j3 92:aa40c49b8563 92 break;
j3 92:aa40c49b8563 93 case 6:
j3 92:aa40c49b8563 94 ch = 0x96;
j3 92:aa40c49b8563 95 ch_read = 0x8E;
j3 92:aa40c49b8563 96 break;
j3 92:aa40c49b8563 97 case 7:
j3 92:aa40c49b8563 98 ch = 0x87;
j3 92:aa40c49b8563 99 ch_read = 0x87;
j3 92:aa40c49b8563 100 break;
j3 92:aa40c49b8563 101 };
j3 92:aa40c49b8563 102
j3 92:aa40c49b8563 103 result = sendCommand(ChannelSelectCmd, ch);
j3 92:aa40c49b8563 104 if (result == OneWireMaster::Success)
j3 92:aa40c49b8563 105 {
j3 92:aa40c49b8563 106 result = readRegister(ChannelSelectReg, ch, true);
j3 92:aa40c49b8563 107 if (result == OneWireMaster::Success)
j3 92:aa40c49b8563 108 {
j3 92:aa40c49b8563 109 // check for failure due to incorrect read back of channel
j3 92:aa40c49b8563 110 if (ch != ch_read)
j3 92:aa40c49b8563 111 {
j3 92:aa40c49b8563 112 result = OneWireMaster::OperationFailure;
j3 92:aa40c49b8563 113 }
j3 92:aa40c49b8563 114 }
j3 92:aa40c49b8563 115 }
j3 92:aa40c49b8563 116
j3 92:aa40c49b8563 117 return result;
j3 92:aa40c49b8563 118 }