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.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
DS1920.h
00001 /******************************************************************//** 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 **********************************************************************/ 00032 00033 #ifndef OneWire_Temperature_DS1920 00034 #define OneWire_Temperature_DS1920 00035 00036 #include "Slaves/OneWireSlave.h" 00037 00038 namespace OneWire 00039 { 00040 class OneWireMaster; 00041 00042 /** 00043 * @brief DS1920 1-wire temperature i-button 00044 * 00045 * @details The iButton® temperature logger (DS1920) provides 00046 * direct-to-digital 9-bit temperature readings over a range of 00047 * -55°C to +100°C in 0.5° increments. The iButton communicates with 00048 * a processor using the 1-Wire® protocol through a hardware port 00049 * interface. The port interface provides both the physical link and 00050 * handles the communication protocols that enable the processor to 00051 * access iButton resources with simple commands. Two bytes of 00052 * EEPROM can be used either to set alarm triggers or for storing 00053 * user data. 00054 * 00055 * @code 00056 * @endcode 00057 */ 00058 class DS1920 : public OneWireSlave 00059 { 00060 public: 00061 00062 ///Result of operations 00063 enum CmdResult 00064 { 00065 Success, 00066 CommsReadError, 00067 CommsWriteError, 00068 OpFailure 00069 }; 00070 00071 /**********************************************************//** 00072 * @brief DS1920 constructor 00073 * 00074 * @details 00075 * 00076 * On Entry: 00077 * @param[in] selector - Reference to RandomAccessRomiteraor 00078 * object that encapsulates owm master that has access to this 00079 * device and ROM function commands used to a select device 00080 * 00081 * On Exit: 00082 * 00083 * @return 00084 **************************************************************/ 00085 DS1920(RandomAccessRomIterator &selector); 00086 00087 00088 /**********************************************************//** 00089 * @brief Write Scratchpad Command 00090 * 00091 * @details If the result of a temperature measurement is higher 00092 * than TH or lower than TL, an alarm flag inside the device is 00093 * set. This flag is updated with every temperature measurement. 00094 * As long as the alarm flag is set, the DS1920 will respond to 00095 * the alarm search command. 00096 * 00097 * On Entry: 00098 * @param[in] th - 8-bit upper temperature threshold, MSB 00099 * indicates sign 00100 * @param[in] tl - 8-bit lower temperature threshold, MSB 00101 * indicates sign 00102 * 00103 * On Exit: 00104 * @param[out] 00105 * 00106 * @return CmdResult - result of operation 00107 **************************************************************/ 00108 CmdResult writeScratchPad(uint8_t th, uint8_t tl); 00109 00110 00111 /**********************************************************//** 00112 * @brief Read Scratchpad Command 00113 * 00114 * @details This command reads the complete scratchpad. 00115 * 00116 * On Entry: 00117 * @param[in] scratchPadBuff - array for receiving contents of 00118 * scratchpad, this buffer will be over written 00119 * 00120 * On Exit: 00121 * @param[out] scratchPadBuff - contents of scratchpad 00122 * 00123 * @return CmdResult - result of operation 00124 **************************************************************/ 00125 CmdResult readScratchPad(uint8_t * scratchPadBuff); 00126 00127 /**********************************************************//** 00128 * @brief Copy Scratchpad Command 00129 * 00130 * @details This command copies from the scratchpad into the 00131 * EEPROM of the DS1920, storing the temperature trigger bytes 00132 * in nonvolatile memory. 00133 * 00134 * On Entry: 00135 * @param[in] 00136 * 00137 * On Exit: 00138 * @param[out] 00139 * 00140 * @return CmdResult - result of operation 00141 **************************************************************/ 00142 CmdResult copyScratchPad( void ); 00143 00144 /**********************************************************//** 00145 * @brief Convert Temperature Command 00146 * 00147 * @details This command begins a temperature conversion. 00148 * 00149 * On Entry: 00150 * @param[in] 00151 * 00152 * On Exit: 00153 * @param[out] temp - temperature conversion results 00154 * 00155 * @return CmdResult - result of operation 00156 **************************************************************/ 00157 CmdResult convertTemperature(float & temp); 00158 00159 00160 /**********************************************************//** 00161 * @brief Recall Command 00162 * 00163 * @details This command recalls the temperature trigger values 00164 * stored in EEPROM to the scratchpad 00165 * 00166 * On Entry: 00167 * @param[in] 00168 * 00169 * On Exit: 00170 * @param[out] 00171 * 00172 * @return CmdResult - result of operation 00173 **************************************************************/ 00174 CmdResult recallEEPROM( void ); 00175 00176 private: 00177 00178 }; 00179 } 00180 00181 #endif /* OneWire_Temperature_DS1920 */
Generated on Tue Jul 12 2022 15:46:20 by
