Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Slaves/Memory/DS2431/DS2431.h@115:a1ca2f3bf46d, 2016-08-22 (annotated)
- Committer:
- j3
- Date:
- Mon Aug 22 05:38:20 2016 +0000
- Revision:
- 115:a1ca2f3bf46d
- Parent:
- 110:a3b5e2a4fdf2
- Child:
- 116:8058bb54e959
Added support for DS2431
Who changed what in which revision?
User | Revision | Line number | New 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 | 115:a1ca2f3bf46d | 54 | * the RandomAccessRomIterator sub-class passed as an argumnent |
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 | 115:a1ca2f3bf46d | 73 | * @brief writeScratchPad |
j3 | 115:a1ca2f3bf46d | 74 | * |
j3 | 115:a1ca2f3bf46d | 75 | * @details Writes 8 bytes to the scratchpad. |
j3 | 115:a1ca2f3bf46d | 76 | * |
j3 | 115:a1ca2f3bf46d | 77 | * On Entry: |
j3 | 115:a1ca2f3bf46d | 78 | * @param[in] targetAddress - EEPROM memory address that this data |
j3 | 115:a1ca2f3bf46d | 79 | * will be copied to. Must be on row boundary. |
j3 | 115:a1ca2f3bf46d | 80 | * |
j3 | 115:a1ca2f3bf46d | 81 | * @param[in] data - Pointer to memory holding data. |
j3 | 115:a1ca2f3bf46d | 82 | * |
j3 | 115:a1ca2f3bf46d | 83 | * On Exit: |
j3 | 115:a1ca2f3bf46d | 84 | * |
j3 | 115:a1ca2f3bf46d | 85 | * @return Result of operation |
j3 | 115:a1ca2f3bf46d | 86 | **************************************************************/ |
j3 | 115:a1ca2f3bf46d | 87 | OneWireSlave::CmdResult writeScratchPad(uint16_t targetAddress, uint8_t *data); |
j3 | 115:a1ca2f3bf46d | 88 | |
j3 | 115:a1ca2f3bf46d | 89 | /**********************************************************//** |
j3 | 115:a1ca2f3bf46d | 90 | * @brief readScratchPad |
j3 | 115:a1ca2f3bf46d | 91 | * |
j3 | 115:a1ca2f3bf46d | 92 | * @details Reads contents of scratchpad. |
j3 | 115:a1ca2f3bf46d | 93 | * |
j3 | 115:a1ca2f3bf46d | 94 | * On Entry: |
j3 | 115:a1ca2f3bf46d | 95 | * @param[in] data - Pointer to memory for storing data, 11 bytes. |
j3 | 115:a1ca2f3bf46d | 96 | * |
j3 | 115:a1ca2f3bf46d | 97 | * On Exit: |
j3 | 115:a1ca2f3bf46d | 98 | * |
j3 | 115:a1ca2f3bf46d | 99 | * @return Result of operation |
j3 | 115:a1ca2f3bf46d | 100 | **************************************************************/ |
j3 | 115:a1ca2f3bf46d | 101 | OneWireSlave::CmdResult readScratchPad(uint8_t *data); |
j3 | 115:a1ca2f3bf46d | 102 | |
j3 | 115:a1ca2f3bf46d | 103 | /**********************************************************//** |
j3 | 115:a1ca2f3bf46d | 104 | * @brief copyScratchPad |
j3 | 115:a1ca2f3bf46d | 105 | * |
j3 | 115:a1ca2f3bf46d | 106 | * @details Copies contents of sractshpad to EEPROM. |
j3 | 115:a1ca2f3bf46d | 107 | * |
j3 | 115:a1ca2f3bf46d | 108 | * On Entry: |
j3 | 115:a1ca2f3bf46d | 109 | * @param[in] targetAddress - EEPROM memory address that this data |
j3 | 115:a1ca2f3bf46d | 110 | * will be copied to. Must be on row boundary. |
j3 | 115:a1ca2f3bf46d | 111 | * |
j3 | 115:a1ca2f3bf46d | 112 | * @param[in] esByte - Returned from reading scratchpad. |
j3 | 115:a1ca2f3bf46d | 113 | * |
j3 | 115:a1ca2f3bf46d | 114 | * On Exit: |
j3 | 115:a1ca2f3bf46d | 115 | * |
j3 | 115:a1ca2f3bf46d | 116 | * @return Result of operation |
j3 | 115:a1ca2f3bf46d | 117 | **************************************************************/ |
j3 | 115:a1ca2f3bf46d | 118 | OneWireSlave::CmdResult copyScratchPad(uint16_t targetAddress, uint8_t esByte); |
j3 | 115:a1ca2f3bf46d | 119 | |
j3 | 115:a1ca2f3bf46d | 120 | /**********************************************************//** |
j3 | 115:a1ca2f3bf46d | 121 | * @brief writeBlock |
j3 | 115:a1ca2f3bf46d | 122 | * |
j3 | 115:a1ca2f3bf46d | 123 | * @details Writes data to EEPROM. Wraps up writeScratchPad, |
j3 | 115:a1ca2f3bf46d | 124 | * readScratchPad and copyScratchPad into single function. |
j3 | 115:a1ca2f3bf46d | 125 | * |
j3 | 115:a1ca2f3bf46d | 126 | * On Entry: |
j3 | 115:a1ca2f3bf46d | 127 | * @param[in] targetAddress - EEPROM memory address to start |
j3 | 115:a1ca2f3bf46d | 128 | * writting at. |
j3 | 115:a1ca2f3bf46d | 129 | * |
j3 | 115:a1ca2f3bf46d | 130 | * @param[in] data - Pointer to memory holding data. |
j3 | 115:a1ca2f3bf46d | 131 | * |
j3 | 115:a1ca2f3bf46d | 132 | * @param[in] numBytes - Number of bytes to write. |
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 | 115:a1ca2f3bf46d | 138 | OneWireSlave::CmdResult writeBlock(uint16_t targetAddress, uint8_t *data, uint8_t numBytes); |
j3 | 115:a1ca2f3bf46d | 139 | |
j3 | 115:a1ca2f3bf46d | 140 | /**********************************************************//** |
j3 | 115:a1ca2f3bf46d | 141 | * @brief readBlock |
j3 | 115:a1ca2f3bf46d | 142 | * |
j3 | 115:a1ca2f3bf46d | 143 | * @details Reads block of data from EEPROM memory. |
j3 | 115:a1ca2f3bf46d | 144 | * |
j3 | 115:a1ca2f3bf46d | 145 | * On Entry: |
j3 | 115:a1ca2f3bf46d | 146 | * @param[in] targetAddress - EEPROM memory address to start. |
j3 | 115:a1ca2f3bf46d | 147 | * reading from |
j3 | 115:a1ca2f3bf46d | 148 | * |
j3 | 115:a1ca2f3bf46d | 149 | * @param[in] data - Pointer to memory for storing data. |
j3 | 115:a1ca2f3bf46d | 150 | * |
j3 | 115:a1ca2f3bf46d | 151 | * @param[in] numBytes - Number of bytes to read. |
j3 | 115:a1ca2f3bf46d | 152 | * |
j3 | 115:a1ca2f3bf46d | 153 | * On Exit: |
j3 | 115:a1ca2f3bf46d | 154 | * |
j3 | 115:a1ca2f3bf46d | 155 | * @return Result of operation |
j3 | 115:a1ca2f3bf46d | 156 | **************************************************************/ |
j3 | 115:a1ca2f3bf46d | 157 | OneWireSlave::CmdResult readBlock(uint16_t targetAddress, uint8_t *data, uint8_t numBytes); |
j3 | 115:a1ca2f3bf46d | 158 | |
j3 | 110:a3b5e2a4fdf2 | 159 | }; |
j3 | 110:a3b5e2a4fdf2 | 160 | } |
j3 | 110:a3b5e2a4fdf2 | 161 | |
j3 | 115:a1ca2f3bf46d | 162 | #endif /*OneWire_Slaves_Memory_DS2431*/ |