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:
IanBenzMaxim
Date:
Wed Jun 15 15:00:06 2016 -0500
Revision:
86:2ce08ca58b9e
Parent:
Temperature/DS1920/DS1920.h@81:e2a3ad98874e
Child:
93:e496a45ce796
Updated to match new directory structure.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 80:83b0d879cc32 1 /******************************************************************//**
j3 80:83b0d879cc32 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 80:83b0d879cc32 3 *
j3 80:83b0d879cc32 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 80:83b0d879cc32 5 * copy of this software and associated documentation files (the "Software"),
j3 80:83b0d879cc32 6 * to deal in the Software without restriction, including without limitation
j3 80:83b0d879cc32 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 80:83b0d879cc32 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 80:83b0d879cc32 9 * Software is furnished to do so, subject to the following conditions:
j3 80:83b0d879cc32 10 *
j3 80:83b0d879cc32 11 * The above copyright notice and this permission notice shall be included
j3 80:83b0d879cc32 12 * in all copies or substantial portions of the Software.
j3 80:83b0d879cc32 13 *
j3 80:83b0d879cc32 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 80:83b0d879cc32 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 80:83b0d879cc32 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 80:83b0d879cc32 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 80:83b0d879cc32 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 80:83b0d879cc32 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 80:83b0d879cc32 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 80:83b0d879cc32 21 *
j3 80:83b0d879cc32 22 * Except as contained in this notice, the name of Maxim Integrated
j3 80:83b0d879cc32 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 80:83b0d879cc32 24 * Products, Inc. Branding Policy.
j3 80:83b0d879cc32 25 *
j3 80:83b0d879cc32 26 * The mere transfer of this software does not imply any licenses
j3 80:83b0d879cc32 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 80:83b0d879cc32 28 * trademarks, maskwork rights, or any other form of intellectual
j3 80:83b0d879cc32 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 80:83b0d879cc32 30 * ownership rights.
j3 80:83b0d879cc32 31 **********************************************************************/
j3 80:83b0d879cc32 32
j3 80:83b0d879cc32 33 #ifndef OneWire_Temperature_DS1920
j3 80:83b0d879cc32 34 #define OneWire_Temperature_DS1920
j3 80:83b0d879cc32 35
j3 80:83b0d879cc32 36 #include "OneWireSlave.h"
j3 80:83b0d879cc32 37
j3 80:83b0d879cc32 38 namespace OneWire
j3 80:83b0d879cc32 39 {
j3 80:83b0d879cc32 40 class OneWireMaster;
j3 80:83b0d879cc32 41
j3 80:83b0d879cc32 42 /**
j3 80:83b0d879cc32 43 * @brief DS1920 1-wire temperature i-button
j3 80:83b0d879cc32 44 *
j3 80:83b0d879cc32 45 * @details The iButton® temperature logger (DS1920) provides
j3 80:83b0d879cc32 46 * direct-to-digital 9-bit temperature readings over a range of
j3 80:83b0d879cc32 47 * -55°C to +100°C in 0.5° increments. The iButton communicates with
j3 80:83b0d879cc32 48 * a processor using the 1-Wire® protocol through a hardware port
j3 80:83b0d879cc32 49 * interface. The port interface provides both the physical link and
j3 80:83b0d879cc32 50 * handles the communication protocols that enable the processor to
j3 80:83b0d879cc32 51 * access iButton resources with simple commands. Two bytes of
j3 80:83b0d879cc32 52 * EEPROM can be used either to set alarm triggers or for storing
j3 80:83b0d879cc32 53 * user data.
j3 80:83b0d879cc32 54 *
j3 80:83b0d879cc32 55 * @code
j3 80:83b0d879cc32 56 * @endcode
j3 80:83b0d879cc32 57 */
j3 80:83b0d879cc32 58 class DS1920 : public OneWireSlave
j3 80:83b0d879cc32 59 {
j3 80:83b0d879cc32 60 public:
j3 80:83b0d879cc32 61 enum CmdResult
j3 80:83b0d879cc32 62 {
j3 80:83b0d879cc32 63 Success,
j3 80:83b0d879cc32 64 CommsReadError,
j3 80:83b0d879cc32 65 CommsWriteError,
j3 80:83b0d879cc32 66 OpFailure
j3 80:83b0d879cc32 67 };
j3 80:83b0d879cc32 68
j3 80:83b0d879cc32 69 /**********************************************************//**
j3 80:83b0d879cc32 70 * @brief DS1920 constructor
j3 80:83b0d879cc32 71 *
j3 80:83b0d879cc32 72 * @details
j3 80:83b0d879cc32 73 *
j3 80:83b0d879cc32 74 * On Entry:
j3 80:83b0d879cc32 75 * @param[in] selector - Reference to RandomAccessRomiteraor
j3 80:83b0d879cc32 76 * object that encapsulates owm master that has access to this
j3 80:83b0d879cc32 77 * device and ROM function commands used to a select device
j3 80:83b0d879cc32 78 *
j3 80:83b0d879cc32 79 * On Exit:
j3 80:83b0d879cc32 80 *
j3 80:83b0d879cc32 81 * @return
j3 80:83b0d879cc32 82 **************************************************************/
j3 80:83b0d879cc32 83 DS1920(RandomAccessRomIterator &selector);
j3 80:83b0d879cc32 84
j3 80:83b0d879cc32 85
j3 80:83b0d879cc32 86 /**********************************************************//**
j3 80:83b0d879cc32 87 * @brief Write Scratchpad Command
j3 80:83b0d879cc32 88 *
j3 80:83b0d879cc32 89 * @details If the result of a temperature measurement is higher
j3 80:83b0d879cc32 90 * than TH or lower than TL, an alarm flag inside the device is
j3 80:83b0d879cc32 91 * set. This flag is updated with every temperature measurement.
j3 80:83b0d879cc32 92 * As long as the alarm flag is set, the DS1920 will respond to
j3 80:83b0d879cc32 93 * the alarm search command.
j3 80:83b0d879cc32 94 *
j3 80:83b0d879cc32 95 * On Entry:
j3 80:83b0d879cc32 96 * @param[in] th - 8-bit upper temperature threshold, MSB
j3 80:83b0d879cc32 97 * indicates sign
j3 80:83b0d879cc32 98 * @param[in] tl - 8-bit lower temperature threshold, MSB
j3 80:83b0d879cc32 99 * indicates sign
j3 80:83b0d879cc32 100 *
j3 80:83b0d879cc32 101 * On Exit:
j3 80:83b0d879cc32 102 * @param[out]
j3 80:83b0d879cc32 103 *
j3 80:83b0d879cc32 104 * @return CmdResult - result of operation
j3 80:83b0d879cc32 105 **************************************************************/
j3 80:83b0d879cc32 106 CmdResult writeScratchPad(uint8_t th, uint8_t tl);
j3 80:83b0d879cc32 107
j3 80:83b0d879cc32 108
j3 80:83b0d879cc32 109 /**********************************************************//**
j3 80:83b0d879cc32 110 * @brief Read Scratchpad Command
j3 80:83b0d879cc32 111 *
j3 80:83b0d879cc32 112 * @details This command reads the complete scratchpad.
j3 80:83b0d879cc32 113 *
j3 80:83b0d879cc32 114 * On Entry:
j3 80:83b0d879cc32 115 * @param[in] scratchPadBuff - array for receiving contents of
j3 80:83b0d879cc32 116 * scratchpad, this buffer will be over written
j3 80:83b0d879cc32 117 *
j3 80:83b0d879cc32 118 * On Exit:
j3 80:83b0d879cc32 119 * @param[out] scratchPadBuff - contents of scratchpad
j3 80:83b0d879cc32 120 *
j3 80:83b0d879cc32 121 * @return CmdResult - result of operation
j3 80:83b0d879cc32 122 **************************************************************/
j3 80:83b0d879cc32 123 CmdResult readScratchPad(uint8_t * scratchPadBuff);
j3 80:83b0d879cc32 124
j3 80:83b0d879cc32 125 /**********************************************************//**
j3 80:83b0d879cc32 126 * @brief Copy Scratchpad Command
j3 80:83b0d879cc32 127 *
j3 80:83b0d879cc32 128 * @details This command copies from the scratchpad into the
j3 80:83b0d879cc32 129 * EEPROM of the DS1920, storing the temperature trigger bytes
j3 80:83b0d879cc32 130 * in nonvolatile memory.
j3 80:83b0d879cc32 131 *
j3 80:83b0d879cc32 132 * On Entry:
j3 80:83b0d879cc32 133 * @param[in]
j3 80:83b0d879cc32 134 *
j3 80:83b0d879cc32 135 * On Exit:
j3 80:83b0d879cc32 136 * @param[out]
j3 80:83b0d879cc32 137 *
j3 80:83b0d879cc32 138 * @return CmdResult - result of operation
j3 80:83b0d879cc32 139 **************************************************************/
j3 80:83b0d879cc32 140 CmdResult copyScratchPad( void );
j3 80:83b0d879cc32 141
j3 80:83b0d879cc32 142 /**********************************************************//**
j3 80:83b0d879cc32 143 * @brief Convert Temperature Command
j3 80:83b0d879cc32 144 *
j3 80:83b0d879cc32 145 * @details This command begins a temperature conversion.
j3 80:83b0d879cc32 146 *
j3 80:83b0d879cc32 147 * On Entry:
j3 80:83b0d879cc32 148 * @param[in]
j3 80:83b0d879cc32 149 *
j3 80:83b0d879cc32 150 * On Exit:
j3 80:83b0d879cc32 151 * @param[out] temp - temperature conversion results
j3 80:83b0d879cc32 152 *
j3 80:83b0d879cc32 153 * @return CmdResult - result of operation
j3 80:83b0d879cc32 154 **************************************************************/
j3 81:e2a3ad98874e 155 CmdResult convertTemperature(float & temp);
j3 80:83b0d879cc32 156
j3 80:83b0d879cc32 157
j3 80:83b0d879cc32 158 /**********************************************************//**
j3 80:83b0d879cc32 159 * @brief Recall Command
j3 80:83b0d879cc32 160 *
j3 80:83b0d879cc32 161 * @details This command recalls the temperature trigger values
j3 80:83b0d879cc32 162 * stored in EEPROM to the scratchpad
j3 80:83b0d879cc32 163 *
j3 80:83b0d879cc32 164 * On Entry:
j3 80:83b0d879cc32 165 * @param[in]
j3 80:83b0d879cc32 166 *
j3 80:83b0d879cc32 167 * On Exit:
j3 80:83b0d879cc32 168 * @param[out]
j3 80:83b0d879cc32 169 *
j3 80:83b0d879cc32 170 * @return CmdResult - result of operation
j3 80:83b0d879cc32 171 **************************************************************/
j3 80:83b0d879cc32 172 CmdResult recallEEPROM( void );
j3 80:83b0d879cc32 173
j3 80:83b0d879cc32 174 private:
j3 80:83b0d879cc32 175
j3 80:83b0d879cc32 176 };
j3 80:83b0d879cc32 177 }
j3 80:83b0d879cc32 178
IanBenzMaxim 86:2ce08ca58b9e 179 #endif /* OneWire_Temperature_DS1920 */