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 Aug 22 21:35:47 2016 +0000
Revision:
116:8058bb54e959
Parent:
115:a1ca2f3bf46d
Child:
117:632abc887f95
DS2431 cleanup, made write/read/copy scratchpad private

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 110:a3b5e2a4fdf2 39 {
j3 115:a1ca2f3bf46d 40 class OneWireMaster;
j3 115:a1ca2f3bf46d 41
j3 110:a3b5e2a4fdf2 42 /**
j3 110:a3b5e2a4fdf2 43 * @brief DS2431
j3 110:a3b5e2a4fdf2 44 */
j3 110:a3b5e2a4fdf2 45 class DS2431 : public OneWireSlave
j3 110:a3b5e2a4fdf2 46 {
j3 110:a3b5e2a4fdf2 47 public:
j3 110:a3b5e2a4fdf2 48
j3 110:a3b5e2a4fdf2 49 /**********************************************************//**
j3 110:a3b5e2a4fdf2 50 * @brief DS2431 constructor
j3 110:a3b5e2a4fdf2 51 *
j3 115:a1ca2f3bf46d 52 * @details Instantiate a DS2431 object that encapsulates the
j3 115:a1ca2f3bf46d 53 * 1-Wire master and ROM commands for selecting the device via
j3 116:8058bb54e959 54 * the RandomAccessRomIterator sub-class passed as an argument
j3 115:a1ca2f3bf46d 55 * to the constructor.
j3 115:a1ca2f3bf46d 56 *
j3 115:a1ca2f3bf46d 57 * This allows the user to focus on the use of the DS2431 in
j3 115:a1ca2f3bf46d 58 * their application vs. the low level details of the 1-Wire
j3 115:a1ca2f3bf46d 59 * protocol.
j3 110:a3b5e2a4fdf2 60 *
j3 110:a3b5e2a4fdf2 61 * On Entry:
j3 115:a1ca2f3bf46d 62 * @param[in] selector - reference to RandomAccessRomIterator
j3 115:a1ca2f3bf46d 63 * sub-class; i.e. SingledropRomIterator, MultidropRomIterator, etc.
j3 115:a1ca2f3bf46d 64 * See RomId/RomIterator.h
j3 110:a3b5e2a4fdf2 65 *
j3 110:a3b5e2a4fdf2 66 * On Exit:
j3 110:a3b5e2a4fdf2 67 *
j3 110:a3b5e2a4fdf2 68 * @return
j3 110:a3b5e2a4fdf2 69 **************************************************************/
j3 110:a3b5e2a4fdf2 70 DS2431(RandomAccessRomIterator &selector);
j3 115:a1ca2f3bf46d 71
j3 115:a1ca2f3bf46d 72 /**********************************************************//**
j3 116:8058bb54e959 73 * @brief writeMemory
j3 116:8058bb54e959 74 *
j3 116:8058bb54e959 75 * @details Writes data to EEPROM. Wraps up writeScratchPad,
j3 116:8058bb54e959 76 * readScratchPad and copyScratchPad into single function.
j3 116:8058bb54e959 77 *
j3 116:8058bb54e959 78 * On Entry:
j3 116:8058bb54e959 79 * @param[in] targetAddress - EEPROM memory address to start
j3 116:8058bb54e959 80 * writing at.
j3 116:8058bb54e959 81 *
j3 116:8058bb54e959 82 * @param[in] data - Pointer to memory holding data.
j3 116:8058bb54e959 83 *
j3 116:8058bb54e959 84 * @param[in] numBytes - Number of bytes to write.
j3 116:8058bb54e959 85 *
j3 116:8058bb54e959 86 * On Exit:
j3 116:8058bb54e959 87 *
j3 116:8058bb54e959 88 * @return Result of operation
j3 116:8058bb54e959 89 **************************************************************/
j3 116:8058bb54e959 90 OneWireSlave::CmdResult writeMemory(uint16_t targetAddress, const uint8_t *data, uint8_t numBytes);
j3 116:8058bb54e959 91
j3 116:8058bb54e959 92 /**********************************************************//**
j3 116:8058bb54e959 93 * @brief readMemory
j3 116:8058bb54e959 94 *
j3 116:8058bb54e959 95 * @details Reads block of data from EEPROM memory.
j3 116:8058bb54e959 96 *
j3 116:8058bb54e959 97 * On Entry:
j3 116:8058bb54e959 98 * @param[in] targetAddress - EEPROM memory address to start.
j3 116:8058bb54e959 99 * reading from
j3 116:8058bb54e959 100 *
j3 116:8058bb54e959 101 * @param[out] data - Pointer to memory for storing data.
j3 116:8058bb54e959 102 *
j3 116:8058bb54e959 103 * @param[in] numBytes - Number of bytes to read.
j3 116:8058bb54e959 104 *
j3 116:8058bb54e959 105 * On Exit:
j3 116:8058bb54e959 106 *
j3 116:8058bb54e959 107 * @return Result of operation
j3 116:8058bb54e959 108 **************************************************************/
j3 116:8058bb54e959 109 OneWireSlave::CmdResult readMemory(uint16_t targetAddress, uint8_t *data, uint8_t numBytes);
j3 116:8058bb54e959 110
j3 116:8058bb54e959 111 private:
j3 116:8058bb54e959 112
j3 116:8058bb54e959 113 typedef array<uint8_t, 8> Scratchpad;
j3 116:8058bb54e959 114
j3 116:8058bb54e959 115 /**********************************************************//**
j3 116:8058bb54e959 116 * @brief writeScratchpad
j3 115:a1ca2f3bf46d 117 *
j3 115:a1ca2f3bf46d 118 * @details Writes 8 bytes to the scratchpad.
j3 115:a1ca2f3bf46d 119 *
j3 115:a1ca2f3bf46d 120 * On Entry:
j3 115:a1ca2f3bf46d 121 * @param[in] targetAddress - EEPROM memory address that this data
j3 115:a1ca2f3bf46d 122 * will be copied to. Must be on row boundary.
j3 115:a1ca2f3bf46d 123 *
j3 116:8058bb54e959 124 * @param[in] data - reference to bounded array type Scratchpad.
j3 115:a1ca2f3bf46d 125 *
j3 115:a1ca2f3bf46d 126 * On Exit:
j3 115:a1ca2f3bf46d 127 *
j3 115:a1ca2f3bf46d 128 * @return Result of operation
j3 115:a1ca2f3bf46d 129 **************************************************************/
j3 116:8058bb54e959 130 OneWireSlave::CmdResult writeScratchpad(uint16_t targetAddress, const Scratchpad &data);
j3 115:a1ca2f3bf46d 131
j3 115:a1ca2f3bf46d 132 /**********************************************************//**
j3 116:8058bb54e959 133 * @brief readScratchpad
j3 115:a1ca2f3bf46d 134 *
j3 115:a1ca2f3bf46d 135 * @details Reads contents of scratchpad.
j3 115:a1ca2f3bf46d 136 *
j3 115:a1ca2f3bf46d 137 * On Entry:
j3 116:8058bb54e959 138 * @param[out] data - reference to bounded array type Scratchpad.
j3 115:a1ca2f3bf46d 139 *
j3 115:a1ca2f3bf46d 140 * On Exit:
j3 115:a1ca2f3bf46d 141 *
j3 115:a1ca2f3bf46d 142 * @return Result of operation
j3 115:a1ca2f3bf46d 143 **************************************************************/
j3 116:8058bb54e959 144 OneWireSlave::CmdResult readScratchpad(Scratchpad &data, uint8_t &esByte);
j3 115:a1ca2f3bf46d 145
j3 115:a1ca2f3bf46d 146 /**********************************************************//**
j3 116:8058bb54e959 147 * @brief copyScratchpad
j3 115:a1ca2f3bf46d 148 *
j3 115:a1ca2f3bf46d 149 * @details Copies contents of sractshpad to EEPROM.
j3 115:a1ca2f3bf46d 150 *
j3 115:a1ca2f3bf46d 151 * On Entry:
j3 115:a1ca2f3bf46d 152 * @param[in] targetAddress - EEPROM memory address that this data
j3 115:a1ca2f3bf46d 153 * will be copied to. Must be on row boundary.
j3 115:a1ca2f3bf46d 154 *
j3 115:a1ca2f3bf46d 155 * @param[in] esByte - Returned from reading scratchpad.
j3 115:a1ca2f3bf46d 156 *
j3 115:a1ca2f3bf46d 157 * On Exit:
j3 115:a1ca2f3bf46d 158 *
j3 115:a1ca2f3bf46d 159 * @return Result of operation
j3 115:a1ca2f3bf46d 160 **************************************************************/
j3 116:8058bb54e959 161 OneWireSlave::CmdResult copyScratchpad(uint16_t targetAddress, uint8_t esByte);
j3 110:a3b5e2a4fdf2 162 };
j3 110:a3b5e2a4fdf2 163 }
j3 110:a3b5e2a4fdf2 164
j3 115:a1ca2f3bf46d 165 #endif /*OneWire_Slaves_Memory_DS2431*/