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:
141:cf38f48a2a49
Added functions to ROMCommands to add Alarm Search functionality

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 110:a3b5e2a4fdf2 1 /******************************************************************//**
j3 110:a3b5e2a4fdf2 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 110:a3b5e2a4fdf2 3 *
j3 110:a3b5e2a4fdf2 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 110:a3b5e2a4fdf2 5 * copy of this software and associated documentation files (the "Software"),
j3 110:a3b5e2a4fdf2 6 * to deal in the Software without restriction, including without limitation
j3 110:a3b5e2a4fdf2 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 110:a3b5e2a4fdf2 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 110:a3b5e2a4fdf2 9 * Software is furnished to do so, subject to the following conditions:
j3 110:a3b5e2a4fdf2 10 *
j3 110:a3b5e2a4fdf2 11 * The above copyright notice and this permission notice shall be included
j3 110:a3b5e2a4fdf2 12 * in all copies or substantial portions of the Software.
j3 110:a3b5e2a4fdf2 13 *
j3 110:a3b5e2a4fdf2 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 110:a3b5e2a4fdf2 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 110:a3b5e2a4fdf2 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 110:a3b5e2a4fdf2 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 110:a3b5e2a4fdf2 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 110:a3b5e2a4fdf2 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 110:a3b5e2a4fdf2 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 110:a3b5e2a4fdf2 21 *
j3 110:a3b5e2a4fdf2 22 * Except as contained in this notice, the name of Maxim Integrated
j3 110:a3b5e2a4fdf2 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 110:a3b5e2a4fdf2 24 * Products, Inc. Branding Policy.
j3 110:a3b5e2a4fdf2 25 *
j3 110:a3b5e2a4fdf2 26 * The mere transfer of this software does not imply any licenses
j3 110:a3b5e2a4fdf2 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 110:a3b5e2a4fdf2 28 * trademarks, maskwork rights, or any other form of intellectual
j3 110:a3b5e2a4fdf2 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 110:a3b5e2a4fdf2 30 * ownership rights.
j3 110:a3b5e2a4fdf2 31 **********************************************************************/
j3 110:a3b5e2a4fdf2 32
j3 115:a1ca2f3bf46d 33 #ifndef OneWire_Slaves_Memory_DS2431
j3 115:a1ca2f3bf46d 34 #define OneWire_Slaves_Memory_DS2431
j3 110:a3b5e2a4fdf2 35
j3 110:a3b5e2a4fdf2 36 #include "Slaves/OneWireSlave.h"
j3 110:a3b5e2a4fdf2 37
j3 110:a3b5e2a4fdf2 38 namespace OneWire
j3 141:cf38f48a2a49 39 {
j3 110:a3b5e2a4fdf2 40 /**
j3 118:d184e69051ad 41 * @brief DS2431 1024-Bit 1-Wire EEPROM
j3 117:632abc887f95 42 * @details The DS2431 is a 1024-bit, 1-Wire® EEPROM chip organized
j3 117:632abc887f95 43 * as four memory pages of 256 bits each. Data is written to an 8-byte
j3 117:632abc887f95 44 * scratchpad, verified, and then copied to the EEPROM memory. As a
j3 117:632abc887f95 45 * special feature, the four memory pages can individually be write
j3 117:632abc887f95 46 * protected or put in EPROM-emulation mode, where bits can only be
j3 117:632abc887f95 47 * changed from a 1 to a 0 state. The DS2431 communicates over the
j3 117:632abc887f95 48 * single-conductor 1-Wire bus. The communication follows the standard
j3 117:632abc887f95 49 * 1-Wire protocol. Each device has its own unalterable and unique
j3 117:632abc887f95 50 * 64-bit ROM registration number that is factory lasered into the chip.
j3 117:632abc887f95 51 * The registration number is used to address the device in a multidrop,
j3 117:632abc887f95 52 * 1-Wire net environment.
j3 110:a3b5e2a4fdf2 53 */
j3 110:a3b5e2a4fdf2 54 class DS2431 : public OneWireSlave
j3 110:a3b5e2a4fdf2 55 {
j3 110:a3b5e2a4fdf2 56 public:
j3 141:cf38f48a2a49 57 typedef array<uint8_t, 8> Scratchpad;
j3 141:cf38f48a2a49 58 typedef uint16_t Address;
j3 141:cf38f48a2a49 59
j3 110:a3b5e2a4fdf2 60 /**********************************************************//**
j3 110:a3b5e2a4fdf2 61 * @brief DS2431 constructor
j3 110:a3b5e2a4fdf2 62 *
j3 115:a1ca2f3bf46d 63 * @details Instantiate a DS2431 object that encapsulates the
j3 115:a1ca2f3bf46d 64 * 1-Wire master and ROM commands for selecting the device via
j3 116:8058bb54e959 65 * the RandomAccessRomIterator sub-class passed as an argument
j3 115:a1ca2f3bf46d 66 * to the constructor.
j3 115:a1ca2f3bf46d 67 *
j3 115:a1ca2f3bf46d 68 * This allows the user to focus on the use of the DS2431 in
j3 115:a1ca2f3bf46d 69 * their application vs. the low level details of the 1-Wire
j3 115:a1ca2f3bf46d 70 * protocol.
j3 110:a3b5e2a4fdf2 71 *
j3 110:a3b5e2a4fdf2 72 * On Entry:
j3 115:a1ca2f3bf46d 73 * @param[in] selector - reference to RandomAccessRomIterator
j3 115:a1ca2f3bf46d 74 * sub-class; i.e. SingledropRomIterator, MultidropRomIterator, etc.
j3 115:a1ca2f3bf46d 75 * See RomId/RomIterator.h
j3 110:a3b5e2a4fdf2 76 *
j3 110:a3b5e2a4fdf2 77 * On Exit:
j3 110:a3b5e2a4fdf2 78 *
j3 110:a3b5e2a4fdf2 79 * @return
j3 110:a3b5e2a4fdf2 80 **************************************************************/
j3 141:cf38f48a2a49 81 DS2431(RandomAccessRomIterator & selector);
j3 115:a1ca2f3bf46d 82
j3 115:a1ca2f3bf46d 83 /**********************************************************//**
j3 116:8058bb54e959 84 * @brief writeMemory
j3 116:8058bb54e959 85 *
j3 116:8058bb54e959 86 * @details Writes data to EEPROM. Wraps up writeScratchPad,
j3 116:8058bb54e959 87 * readScratchPad and copyScratchPad into single function.
j3 116:8058bb54e959 88 *
j3 116:8058bb54e959 89 * On Entry:
j3 116:8058bb54e959 90 * @param[in] targetAddress - EEPROM memory address to start
j3 116:8058bb54e959 91 * writing at.
j3 116:8058bb54e959 92 *
j3 116:8058bb54e959 93 * @param[in] data - Pointer to memory holding data.
j3 116:8058bb54e959 94 *
j3 116:8058bb54e959 95 * @param[in] numBytes - Number of bytes to write.
j3 116:8058bb54e959 96 *
j3 116:8058bb54e959 97 * On Exit:
j3 116:8058bb54e959 98 *
j3 116:8058bb54e959 99 * @return Result of operation
j3 116:8058bb54e959 100 **************************************************************/
j3 141:cf38f48a2a49 101 OneWireSlave::CmdResult writeMemory(Address targetAddress, const Scratchpad & data);
j3 116:8058bb54e959 102
j3 116:8058bb54e959 103 /**********************************************************//**
j3 116:8058bb54e959 104 * @brief readMemory
j3 116:8058bb54e959 105 *
j3 116:8058bb54e959 106 * @details Reads block of data from EEPROM memory.
j3 116:8058bb54e959 107 *
j3 116:8058bb54e959 108 * On Entry:
j3 116:8058bb54e959 109 * @param[in] targetAddress - EEPROM memory address to start.
j3 116:8058bb54e959 110 * reading from
j3 116:8058bb54e959 111 *
j3 116:8058bb54e959 112 * @param[out] data - Pointer to memory for storing data.
j3 116:8058bb54e959 113 *
j3 116:8058bb54e959 114 * @param[in] numBytes - Number of bytes to read.
j3 116:8058bb54e959 115 *
j3 116:8058bb54e959 116 * On Exit:
j3 116:8058bb54e959 117 *
j3 116:8058bb54e959 118 * @return Result of operation
j3 116:8058bb54e959 119 **************************************************************/
j3 141:cf38f48a2a49 120 OneWireSlave::CmdResult readMemory(Address targetAddress, uint8_t numBytes, uint8_t * data);
j3 116:8058bb54e959 121
j3 141:cf38f48a2a49 122 private:
j3 116:8058bb54e959 123 /**********************************************************//**
j3 116:8058bb54e959 124 * @brief writeScratchpad
j3 115:a1ca2f3bf46d 125 *
j3 115:a1ca2f3bf46d 126 * @details Writes 8 bytes to the scratchpad.
j3 115:a1ca2f3bf46d 127 *
j3 115:a1ca2f3bf46d 128 * On Entry:
j3 115:a1ca2f3bf46d 129 * @param[in] targetAddress - EEPROM memory address that this data
j3 115:a1ca2f3bf46d 130 * will be copied to. Must be on row boundary.
j3 115:a1ca2f3bf46d 131 *
j3 116:8058bb54e959 132 * @param[in] data - reference to bounded array type Scratchpad.
j3 115:a1ca2f3bf46d 133 *
j3 115:a1ca2f3bf46d 134 * On Exit:
j3 115:a1ca2f3bf46d 135 *
j3 115:a1ca2f3bf46d 136 * @return Result of operation
j3 115:a1ca2f3bf46d 137 **************************************************************/
j3 141:cf38f48a2a49 138 OneWireSlave::CmdResult writeScratchpad(Address targetAddress, const Scratchpad & data);
j3 115:a1ca2f3bf46d 139
j3 115:a1ca2f3bf46d 140 /**********************************************************//**
j3 116:8058bb54e959 141 * @brief readScratchpad
j3 115:a1ca2f3bf46d 142 *
j3 115:a1ca2f3bf46d 143 * @details Reads contents of scratchpad.
j3 115:a1ca2f3bf46d 144 *
j3 115:a1ca2f3bf46d 145 * On Entry:
j3 116:8058bb54e959 146 * @param[out] data - reference to bounded array type Scratchpad.
j3 115:a1ca2f3bf46d 147 *
j3 115:a1ca2f3bf46d 148 * On Exit:
j3 115:a1ca2f3bf46d 149 *
j3 115:a1ca2f3bf46d 150 * @return Result of operation
j3 115:a1ca2f3bf46d 151 **************************************************************/
j3 141:cf38f48a2a49 152 OneWireSlave::CmdResult readScratchpad(Scratchpad & data, uint8_t & esByte);
j3 115:a1ca2f3bf46d 153
j3 115:a1ca2f3bf46d 154 /**********************************************************//**
j3 116:8058bb54e959 155 * @brief copyScratchpad
j3 115:a1ca2f3bf46d 156 *
j3 115:a1ca2f3bf46d 157 * @details Copies contents of sractshpad to EEPROM.
j3 115:a1ca2f3bf46d 158 *
j3 115:a1ca2f3bf46d 159 * On Entry:
j3 115:a1ca2f3bf46d 160 * @param[in] targetAddress - EEPROM memory address that this data
j3 115:a1ca2f3bf46d 161 * will be copied to. Must be on row boundary.
j3 115:a1ca2f3bf46d 162 *
j3 115:a1ca2f3bf46d 163 * @param[in] esByte - Returned from reading scratchpad.
j3 115:a1ca2f3bf46d 164 *
j3 115:a1ca2f3bf46d 165 * On Exit:
j3 115:a1ca2f3bf46d 166 *
j3 115:a1ca2f3bf46d 167 * @return Result of operation
j3 115:a1ca2f3bf46d 168 **************************************************************/
j3 141:cf38f48a2a49 169 OneWireSlave::CmdResult copyScratchpad(Address targetAddress, uint8_t esByte);
j3 110:a3b5e2a4fdf2 170 };
j3 110:a3b5e2a4fdf2 171 }
j3 110:a3b5e2a4fdf2 172
j3 115:a1ca2f3bf46d 173 #endif /*OneWire_Slaves_Memory_DS2431*/