Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Slaves/Memory/DS2431/DS2431.h
- Committer:
- j3
- Date:
- 2016-08-22
- Revision:
- 116:8058bb54e959
- Parent:
- 115:a1ca2f3bf46d
- Child:
- 117:632abc887f95
File content as of revision 116:8058bb54e959:
/******************************************************************//** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Maxim Integrated * Products, Inc. shall not be used except as stated in the Maxim Integrated * Products, Inc. Branding Policy. * * The mere transfer of this software does not imply any licenses * of trade secrets, proprietary technology, copyrights, patents, * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. **********************************************************************/ #ifndef OneWire_Slaves_Memory_DS2431 #define OneWire_Slaves_Memory_DS2431 #include "Slaves/OneWireSlave.h" namespace OneWire { class OneWireMaster; /** * @brief DS2431 */ class DS2431 : public OneWireSlave { public: /**********************************************************//** * @brief DS2431 constructor * * @details Instantiate a DS2431 object that encapsulates the * 1-Wire master and ROM commands for selecting the device via * the RandomAccessRomIterator sub-class passed as an argument * to the constructor. * * This allows the user to focus on the use of the DS2431 in * their application vs. the low level details of the 1-Wire * protocol. * * On Entry: * @param[in] selector - reference to RandomAccessRomIterator * sub-class; i.e. SingledropRomIterator, MultidropRomIterator, etc. * See RomId/RomIterator.h * * On Exit: * * @return **************************************************************/ DS2431(RandomAccessRomIterator &selector); /**********************************************************//** * @brief writeMemory * * @details Writes data to EEPROM. Wraps up writeScratchPad, * readScratchPad and copyScratchPad into single function. * * On Entry: * @param[in] targetAddress - EEPROM memory address to start * writing at. * * @param[in] data - Pointer to memory holding data. * * @param[in] numBytes - Number of bytes to write. * * On Exit: * * @return Result of operation **************************************************************/ OneWireSlave::CmdResult writeMemory(uint16_t targetAddress, const uint8_t *data, uint8_t numBytes); /**********************************************************//** * @brief readMemory * * @details Reads block of data from EEPROM memory. * * On Entry: * @param[in] targetAddress - EEPROM memory address to start. * reading from * * @param[out] data - Pointer to memory for storing data. * * @param[in] numBytes - Number of bytes to read. * * On Exit: * * @return Result of operation **************************************************************/ OneWireSlave::CmdResult readMemory(uint16_t targetAddress, uint8_t *data, uint8_t numBytes); private: typedef array<uint8_t, 8> Scratchpad; /**********************************************************//** * @brief writeScratchpad * * @details Writes 8 bytes to the scratchpad. * * On Entry: * @param[in] targetAddress - EEPROM memory address that this data * will be copied to. Must be on row boundary. * * @param[in] data - reference to bounded array type Scratchpad. * * On Exit: * * @return Result of operation **************************************************************/ OneWireSlave::CmdResult writeScratchpad(uint16_t targetAddress, const Scratchpad &data); /**********************************************************//** * @brief readScratchpad * * @details Reads contents of scratchpad. * * On Entry: * @param[out] data - reference to bounded array type Scratchpad. * * On Exit: * * @return Result of operation **************************************************************/ OneWireSlave::CmdResult readScratchpad(Scratchpad &data, uint8_t &esByte); /**********************************************************//** * @brief copyScratchpad * * @details Copies contents of sractshpad to EEPROM. * * On Entry: * @param[in] targetAddress - EEPROM memory address that this data * will be copied to. Must be on row boundary. * * @param[in] esByte - Returned from reading scratchpad. * * On Exit: * * @return Result of operation **************************************************************/ OneWireSlave::CmdResult copyScratchpad(uint16_t targetAddress, uint8_t esByte); }; } #endif /*OneWire_Slaves_Memory_DS2431*/