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:
mfruge
Date:
Tue Aug 13 14:42:37 2019 +0000
Revision:
142:85b71cfd617e
Parent:
105:e6ba25711c05
Added functions to ROMCommands to add Alarm Search functionality

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 104:3f48daed532b 36 #include "Slaves/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 93:e496a45ce796 61
j3 93:e496a45ce796 62 ///Result of operations
j3 80:83b0d879cc32 63 enum CmdResult
j3 80:83b0d879cc32 64 {
j3 80:83b0d879cc32 65 Success,
j3 80:83b0d879cc32 66 CommsReadError,
j3 80:83b0d879cc32 67 CommsWriteError,
j3 80:83b0d879cc32 68 OpFailure
j3 80:83b0d879cc32 69 };
j3 80:83b0d879cc32 70
j3 80:83b0d879cc32 71 /**********************************************************//**
j3 80:83b0d879cc32 72 * @brief DS1920 constructor
j3 80:83b0d879cc32 73 *
j3 80:83b0d879cc32 74 * @details
j3 80:83b0d879cc32 75 *
j3 80:83b0d879cc32 76 * On Entry:
j3 80:83b0d879cc32 77 * @param[in] selector - Reference to RandomAccessRomiteraor
j3 80:83b0d879cc32 78 * object that encapsulates owm master that has access to this
j3 80:83b0d879cc32 79 * device and ROM function commands used to a select device
j3 80:83b0d879cc32 80 *
j3 80:83b0d879cc32 81 * On Exit:
j3 80:83b0d879cc32 82 *
j3 80:83b0d879cc32 83 * @return
j3 80:83b0d879cc32 84 **************************************************************/
j3 80:83b0d879cc32 85 DS1920(RandomAccessRomIterator &selector);
j3 80:83b0d879cc32 86
j3 80:83b0d879cc32 87
j3 80:83b0d879cc32 88 /**********************************************************//**
j3 80:83b0d879cc32 89 * @brief Write Scratchpad Command
j3 80:83b0d879cc32 90 *
j3 80:83b0d879cc32 91 * @details If the result of a temperature measurement is higher
j3 80:83b0d879cc32 92 * than TH or lower than TL, an alarm flag inside the device is
j3 80:83b0d879cc32 93 * set. This flag is updated with every temperature measurement.
j3 80:83b0d879cc32 94 * As long as the alarm flag is set, the DS1920 will respond to
j3 80:83b0d879cc32 95 * the alarm search command.
j3 80:83b0d879cc32 96 *
j3 80:83b0d879cc32 97 * On Entry:
j3 80:83b0d879cc32 98 * @param[in] th - 8-bit upper temperature threshold, MSB
j3 80:83b0d879cc32 99 * indicates sign
j3 80:83b0d879cc32 100 * @param[in] tl - 8-bit lower temperature threshold, MSB
j3 80:83b0d879cc32 101 * indicates sign
j3 80:83b0d879cc32 102 *
j3 80:83b0d879cc32 103 * On Exit:
j3 80:83b0d879cc32 104 * @param[out]
j3 80:83b0d879cc32 105 *
j3 80:83b0d879cc32 106 * @return CmdResult - result of operation
j3 80:83b0d879cc32 107 **************************************************************/
j3 80:83b0d879cc32 108 CmdResult writeScratchPad(uint8_t th, uint8_t tl);
j3 80:83b0d879cc32 109
j3 80:83b0d879cc32 110
j3 80:83b0d879cc32 111 /**********************************************************//**
j3 80:83b0d879cc32 112 * @brief Read Scratchpad Command
j3 80:83b0d879cc32 113 *
j3 80:83b0d879cc32 114 * @details This command reads the complete scratchpad.
j3 80:83b0d879cc32 115 *
j3 80:83b0d879cc32 116 * On Entry:
j3 80:83b0d879cc32 117 * @param[in] scratchPadBuff - array for receiving contents of
j3 80:83b0d879cc32 118 * scratchpad, this buffer will be over written
j3 80:83b0d879cc32 119 *
j3 80:83b0d879cc32 120 * On Exit:
j3 80:83b0d879cc32 121 * @param[out] scratchPadBuff - contents of scratchpad
j3 80:83b0d879cc32 122 *
j3 80:83b0d879cc32 123 * @return CmdResult - result of operation
j3 80:83b0d879cc32 124 **************************************************************/
j3 80:83b0d879cc32 125 CmdResult readScratchPad(uint8_t * scratchPadBuff);
j3 80:83b0d879cc32 126
j3 80:83b0d879cc32 127 /**********************************************************//**
j3 80:83b0d879cc32 128 * @brief Copy Scratchpad Command
j3 80:83b0d879cc32 129 *
j3 80:83b0d879cc32 130 * @details This command copies from the scratchpad into the
j3 80:83b0d879cc32 131 * EEPROM of the DS1920, storing the temperature trigger bytes
j3 80:83b0d879cc32 132 * in nonvolatile memory.
j3 80:83b0d879cc32 133 *
j3 80:83b0d879cc32 134 * On Entry:
j3 80:83b0d879cc32 135 * @param[in]
j3 80:83b0d879cc32 136 *
j3 80:83b0d879cc32 137 * On Exit:
j3 80:83b0d879cc32 138 * @param[out]
j3 80:83b0d879cc32 139 *
j3 80:83b0d879cc32 140 * @return CmdResult - result of operation
j3 80:83b0d879cc32 141 **************************************************************/
j3 80:83b0d879cc32 142 CmdResult copyScratchPad( void );
j3 80:83b0d879cc32 143
j3 80:83b0d879cc32 144 /**********************************************************//**
j3 80:83b0d879cc32 145 * @brief Convert Temperature Command
j3 80:83b0d879cc32 146 *
j3 80:83b0d879cc32 147 * @details This command begins a temperature conversion.
j3 80:83b0d879cc32 148 *
j3 80:83b0d879cc32 149 * On Entry:
j3 80:83b0d879cc32 150 * @param[in]
j3 80:83b0d879cc32 151 *
j3 80:83b0d879cc32 152 * On Exit:
j3 80:83b0d879cc32 153 * @param[out] temp - temperature conversion results
j3 80:83b0d879cc32 154 *
j3 80:83b0d879cc32 155 * @return CmdResult - result of operation
j3 80:83b0d879cc32 156 **************************************************************/
j3 81:e2a3ad98874e 157 CmdResult convertTemperature(float & temp);
j3 80:83b0d879cc32 158
j3 80:83b0d879cc32 159
j3 80:83b0d879cc32 160 /**********************************************************//**
j3 80:83b0d879cc32 161 * @brief Recall Command
j3 80:83b0d879cc32 162 *
j3 80:83b0d879cc32 163 * @details This command recalls the temperature trigger values
j3 80:83b0d879cc32 164 * stored in EEPROM to the scratchpad
j3 80:83b0d879cc32 165 *
j3 80:83b0d879cc32 166 * On Entry:
j3 80:83b0d879cc32 167 * @param[in]
j3 80:83b0d879cc32 168 *
j3 80:83b0d879cc32 169 * On Exit:
j3 80:83b0d879cc32 170 * @param[out]
j3 80:83b0d879cc32 171 *
j3 80:83b0d879cc32 172 * @return CmdResult - result of operation
j3 80:83b0d879cc32 173 **************************************************************/
j3 80:83b0d879cc32 174 CmdResult recallEEPROM( void );
j3 80:83b0d879cc32 175
j3 80:83b0d879cc32 176 private:
j3 80:83b0d879cc32 177
j3 80:83b0d879cc32 178 };
j3 80:83b0d879cc32 179 }
j3 80:83b0d879cc32 180
IanBenzMaxim 86:2ce08ca58b9e 181 #endif /* OneWire_Temperature_DS1920 */