Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
OneWire_Masters/OneWireMaster.h@0:19ec8044b826, 2016-01-30 (annotated)
- Committer:
- j3
- Date:
- Sat Jan 30 17:41:03 2016 +0000
- Revision:
- 0:19ec8044b826
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:19ec8044b826 | 1 | /******************************************************************//** |
j3 | 0:19ec8044b826 | 2 | * @file OneWireMaster.h |
j3 | 0:19ec8044b826 | 3 | * |
j3 | 0:19ec8044b826 | 4 | * @author Justin Jordan |
j3 | 0:19ec8044b826 | 5 | * |
j3 | 0:19ec8044b826 | 6 | * @version 0.0 |
j3 | 0:19ec8044b826 | 7 | * |
j3 | 0:19ec8044b826 | 8 | * Started: 29JAN16 |
j3 | 0:19ec8044b826 | 9 | * |
j3 | 0:19ec8044b826 | 10 | * Updated: |
j3 | 0:19ec8044b826 | 11 | * |
j3 | 0:19ec8044b826 | 12 | * @brief Header file for abstract class that defines 1-wire interface |
j3 | 0:19ec8044b826 | 13 | *********************************************************************** |
j3 | 0:19ec8044b826 | 14 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:19ec8044b826 | 15 | * |
j3 | 0:19ec8044b826 | 16 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:19ec8044b826 | 17 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:19ec8044b826 | 18 | * to deal in the Software without restriction, including without limitation |
j3 | 0:19ec8044b826 | 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:19ec8044b826 | 20 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:19ec8044b826 | 21 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:19ec8044b826 | 22 | * |
j3 | 0:19ec8044b826 | 23 | * The above copyright notice and this permission notice shall be included |
j3 | 0:19ec8044b826 | 24 | * in all copies or substantial portions of the Software. |
j3 | 0:19ec8044b826 | 25 | * |
j3 | 0:19ec8044b826 | 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:19ec8044b826 | 27 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:19ec8044b826 | 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:19ec8044b826 | 29 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:19ec8044b826 | 30 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:19ec8044b826 | 31 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:19ec8044b826 | 32 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:19ec8044b826 | 33 | * |
j3 | 0:19ec8044b826 | 34 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:19ec8044b826 | 35 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:19ec8044b826 | 36 | * Products, Inc. Branding Policy. |
j3 | 0:19ec8044b826 | 37 | * |
j3 | 0:19ec8044b826 | 38 | * The mere transfer of this software does not imply any licenses |
j3 | 0:19ec8044b826 | 39 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:19ec8044b826 | 40 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:19ec8044b826 | 41 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:19ec8044b826 | 42 | * ownership rights. |
j3 | 0:19ec8044b826 | 43 | **********************************************************************/ |
j3 | 0:19ec8044b826 | 44 | |
j3 | 0:19ec8044b826 | 45 | |
j3 | 0:19ec8044b826 | 46 | #ifndef ONEWIREMASTER_H |
j3 | 0:19ec8044b826 | 47 | #define ONEWIREMASTER_H |
j3 | 0:19ec8044b826 | 48 | |
j3 | 0:19ec8044b826 | 49 | |
j3 | 0:19ec8044b826 | 50 | /* |
j3 | 0:19ec8044b826 | 51 | |
j3 | 0:19ec8044b826 | 52 | http://www.learncpp.com/cpp-tutorial/126-pure-virtual-functions-abstract-base-classes-and-interface-classes/ |
j3 | 0:19ec8044b826 | 53 | |
j3 | 0:19ec8044b826 | 54 | Interface classes |
j3 | 0:19ec8044b826 | 55 | |
j3 | 0:19ec8044b826 | 56 | An interface class is a class that has no members variables, and where |
j3 | 0:19ec8044b826 | 57 | all of the functions are pure virtual! In other words, the class is purely |
j3 | 0:19ec8044b826 | 58 | a definition, and has no actual implementation. Interfaces are useful when |
j3 | 0:19ec8044b826 | 59 | you want to define the functionality that derived classes must implement, |
j3 | 0:19ec8044b826 | 60 | but leave the details of how the derived class implements that functionality |
j3 | 0:19ec8044b826 | 61 | entirely up to the derived class. |
j3 | 0:19ec8044b826 | 62 | |
j3 | 0:19ec8044b826 | 63 | */ |
j3 | 0:19ec8044b826 | 64 | |
j3 | 0:19ec8044b826 | 65 | //interface taken from AN3684 |
j3 | 0:19ec8044b826 | 66 | //https://www.maximintegrated.com/en/app-notes/index.mvp/id/3684 |
j3 | 0:19ec8044b826 | 67 | |
j3 | 0:19ec8044b826 | 68 | class OneWireMaster |
j3 | 0:19ec8044b826 | 69 | { |
j3 | 0:19ec8044b826 | 70 | public: |
j3 | 0:19ec8044b826 | 71 | |
j3 | 0:19ec8044b826 | 72 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 73 | * @brief Reset all of the devices on the 1-Wire Net and return |
j3 | 0:19ec8044b826 | 74 | * the result. |
j3 | 0:19ec8044b826 | 75 | * |
j3 | 0:19ec8044b826 | 76 | * @details |
j3 | 0:19ec8044b826 | 77 | * |
j3 | 0:19ec8044b826 | 78 | * On Entry: |
j3 | 0:19ec8044b826 | 79 | * |
j3 | 0:19ec8044b826 | 80 | * On Exit: |
j3 | 0:19ec8044b826 | 81 | * @return TRUE(1): presence pulse(s) detected, device(s) reset |
j3 | 0:19ec8044b826 | 82 | * FALSE(0): no presence pulses detected |
j3 | 0:19ec8044b826 | 83 | **************************************************************/ |
j3 | 0:19ec8044b826 | 84 | virtual uint8_t OWReset() = 0; |
j3 | 0:19ec8044b826 | 85 | |
j3 | 0:19ec8044b826 | 86 | |
j3 | 0:19ec8044b826 | 87 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 88 | * @brief Send 1 bit of communication to the 1-Wire Net. |
j3 | 0:19ec8044b826 | 89 | * The parameter 'sendbit' least significant bit is used. |
j3 | 0:19ec8044b826 | 90 | * |
j3 | 0:19ec8044b826 | 91 | * @details |
j3 | 0:19ec8044b826 | 92 | * |
j3 | 0:19ec8044b826 | 93 | * On Entry: |
j3 | 0:19ec8044b826 | 94 | * @param[in] 'sendbit' - 1 bit to send (least significant byte) |
j3 | 0:19ec8044b826 | 95 | * |
j3 | 0:19ec8044b826 | 96 | * On Exit: |
j3 | 0:19ec8044b826 | 97 | * @return |
j3 | 0:19ec8044b826 | 98 | **************************************************************/ |
j3 | 0:19ec8044b826 | 99 | virtual void OWWriteBit(uint8_t sendbit) = 0; |
j3 | 0:19ec8044b826 | 100 | |
j3 | 0:19ec8044b826 | 101 | |
j3 | 0:19ec8044b826 | 102 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 103 | * @brief Reads 1 bit of communication from the 1-Wire Net and |
j3 | 0:19ec8044b826 | 104 | * returns the result |
j3 | 0:19ec8044b826 | 105 | * |
j3 | 0:19ec8044b826 | 106 | * @details |
j3 | 0:19ec8044b826 | 107 | * |
j3 | 0:19ec8044b826 | 108 | * On Entry: |
j3 | 0:19ec8044b826 | 109 | * |
j3 | 0:19ec8044b826 | 110 | * On Exit: |
j3 | 0:19ec8044b826 | 111 | * @return 1 bit read from 1-Wire Net |
j3 | 0:19ec8044b826 | 112 | **************************************************************/ |
j3 | 0:19ec8044b826 | 113 | virtual uint8_t OWReadBit() = 0; |
j3 | 0:19ec8044b826 | 114 | |
j3 | 0:19ec8044b826 | 115 | |
j3 | 0:19ec8044b826 | 116 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 117 | * @brief Send 1 bit of communication to the 1-Wire Net and return |
j3 | 0:19ec8044b826 | 118 | * the result 1 bit read from the 1-Wire Net. The |
j3 | 0:19ec8044b826 | 119 | * parameter 'sendbit' least significant bit is used and |
j3 | 0:19ec8044b826 | 120 | * the least significant bit of the result is the return |
j3 | 0:19ec8044b826 | 121 | * bit. |
j3 | 0:19ec8044b826 | 122 | * |
j3 | 0:19ec8044b826 | 123 | * @details |
j3 | 0:19ec8044b826 | 124 | * |
j3 | 0:19ec8044b826 | 125 | * On Entry: |
j3 | 0:19ec8044b826 | 126 | * @param[in] 'sendbit' - the least significant bit is the bit to send |
j3 | 0:19ec8044b826 | 127 | * |
j3 | 0:19ec8044b826 | 128 | * On Exit: |
j3 | 0:19ec8044b826 | 129 | * @return 0: 0 bit read from sendbit |
j3 | 0:19ec8044b826 | 130 | * 1: 1 bit read from sendbit |
j3 | 0:19ec8044b826 | 131 | **************************************************************/ |
j3 | 0:19ec8044b826 | 132 | virtual uint8_t OWTouchBit(uint8_t sendbit) = 0; |
j3 | 0:19ec8044b826 | 133 | |
j3 | 0:19ec8044b826 | 134 | |
j3 | 0:19ec8044b826 | 135 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 136 | * @brief Send 8 bits of communication to the 1-Wire Net and |
j3 | 0:19ec8044b826 | 137 | * verify that the 8 bits read from the 1-Wire Net is the |
j3 | 0:19ec8044b826 | 138 | * same (write operation).The parameter 'sendbyte' least |
j3 | 0:19ec8044b826 | 139 | * significant 8 bits are used. |
j3 | 0:19ec8044b826 | 140 | * |
j3 | 0:19ec8044b826 | 141 | * @details |
j3 | 0:19ec8044b826 | 142 | * |
j3 | 0:19ec8044b826 | 143 | * On Entry: |
j3 | 0:19ec8044b826 | 144 | * @param[in] 'sendbyte' - 8 bits to send (least significant byte) |
j3 | 0:19ec8044b826 | 145 | * |
j3 | 0:19ec8044b826 | 146 | * On Exit: |
j3 | 0:19ec8044b826 | 147 | * @return TRUE: bytes written and echo was the same |
j3 | 0:19ec8044b826 | 148 | * FALSE: echo was not the same |
j3 | 0:19ec8044b826 | 149 | **************************************************************/ |
j3 | 0:19ec8044b826 | 150 | virtual void OWWRiteByte(uint8_t sendbyte) = 0; |
j3 | 0:19ec8044b826 | 151 | |
j3 | 0:19ec8044b826 | 152 | |
j3 | 0:19ec8044b826 | 153 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 154 | * @brief Send 8 bits of read communication to the 1-Wire Net and |
j3 | 0:19ec8044b826 | 155 | * return the result 8 bits read from the 1-Wire Net. |
j3 | 0:19ec8044b826 | 156 | * |
j3 | 0:19ec8044b826 | 157 | * @details |
j3 | 0:19ec8044b826 | 158 | * |
j3 | 0:19ec8044b826 | 159 | * On Entry: |
j3 | 0:19ec8044b826 | 160 | * |
j3 | 0:19ec8044b826 | 161 | * On Exit: |
j3 | 0:19ec8044b826 | 162 | * @return 8 bits read from 1-Wire Net |
j3 | 0:19ec8044b826 | 163 | **************************************************************/ |
j3 | 0:19ec8044b826 | 164 | virtual uint8_t OWReadByte(void) = 0; |
j3 | 0:19ec8044b826 | 165 | |
j3 | 0:19ec8044b826 | 166 | |
j3 | 0:19ec8044b826 | 167 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 168 | * @brief Send 8 bits of communication to the 1-Wire Net and |
j3 | 0:19ec8044b826 | 169 | * return the result 8 bits read from the 1-Wire Net. The |
j3 | 0:19ec8044b826 | 170 | * parameter 'sendbyte' least significant 8 bits are used |
j3 | 0:19ec8044b826 | 171 | * and the least significant 8 bits of the result is the |
j3 | 0:19ec8044b826 | 172 | * return byte. |
j3 | 0:19ec8044b826 | 173 | * |
j3 | 0:19ec8044b826 | 174 | * @details |
j3 | 0:19ec8044b826 | 175 | * |
j3 | 0:19ec8044b826 | 176 | * On Entry: |
j3 | 0:19ec8044b826 | 177 | * @param[in] 'sendbyte' - 8 bits to send (least significant byte) |
j3 | 0:19ec8044b826 | 178 | * |
j3 | 0:19ec8044b826 | 179 | * On Exit: |
j3 | 0:19ec8044b826 | 180 | * @return 8 bits read from sendbyte |
j3 | 0:19ec8044b826 | 181 | **************************************************************/ |
j3 | 0:19ec8044b826 | 182 | virtual uint8_t OWTouchByte(uint8_t sendbyte) = 0; |
j3 | 0:19ec8044b826 | 183 | |
j3 | 0:19ec8044b826 | 184 | |
j3 | 0:19ec8044b826 | 185 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 186 | * @brief The 'OWBlock' transfers a block of data to and from the |
j3 | 0:19ec8044b826 | 187 | * 1-Wire Net. The result is returned in the same buffer. |
j3 | 0:19ec8044b826 | 188 | * |
j3 | 0:19ec8044b826 | 189 | * @details |
j3 | 0:19ec8044b826 | 190 | * |
j3 | 0:19ec8044b826 | 191 | * On Entry: |
j3 | 0:19ec8044b826 | 192 | * @param[in] 'tran_buf' - pointer to a block of unsigned |
j3 | 0:19ec8044b826 | 193 | * chars of length 'tran_len' that |
j3 | 0:19ec8044b826 | 194 | * will be sent to the 1-Wire Net |
j3 | 0:19ec8044b826 | 195 | * @param[in] 'tran_len' - length in bytes to transfer |
j3 | 0:19ec8044b826 | 196 | * |
j3 | 0:19ec8044b826 | 197 | * On Exit: |
j3 | 0:19ec8044b826 | 198 | * @return |
j3 | 0:19ec8044b826 | 199 | **************************************************************/ |
j3 | 0:19ec8044b826 | 200 | virtual void OWBlock(uint8_t *tran_buf, uint8_t tran_len) = 0; |
j3 | 0:19ec8044b826 | 201 | |
j3 | 0:19ec8044b826 | 202 | |
j3 | 0:19ec8044b826 | 203 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 204 | * @brief Find the 'first' devices on the 1-Wire network |
j3 | 0:19ec8044b826 | 205 | * |
j3 | 0:19ec8044b826 | 206 | * @details |
j3 | 0:19ec8044b826 | 207 | * |
j3 | 0:19ec8044b826 | 208 | * On Entry: |
j3 | 0:19ec8044b826 | 209 | * |
j3 | 0:19ec8044b826 | 210 | * On Exit: |
j3 | 0:19ec8044b826 | 211 | * @return TRUE : device found, ROM number in ROM_NO buffer |
j3 | 0:19ec8044b826 | 212 | * FALSE : no device present |
j3 | 0:19ec8044b826 | 213 | **************************************************************/ |
j3 | 0:19ec8044b826 | 214 | virtual void OWFirst(void) = 0; |
j3 | 0:19ec8044b826 | 215 | |
j3 | 0:19ec8044b826 | 216 | |
j3 | 0:19ec8044b826 | 217 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 218 | * @brief Find the 'next' devices on the 1-Wire network |
j3 | 0:19ec8044b826 | 219 | * |
j3 | 0:19ec8044b826 | 220 | * @details |
j3 | 0:19ec8044b826 | 221 | * |
j3 | 0:19ec8044b826 | 222 | * On Entry: |
j3 | 0:19ec8044b826 | 223 | * |
j3 | 0:19ec8044b826 | 224 | * On Exit: |
j3 | 0:19ec8044b826 | 225 | * @return TRUE : device found, ROM number in ROM_NO buffer |
j3 | 0:19ec8044b826 | 226 | * FALSE : device not found, end of search |
j3 | 0:19ec8044b826 | 227 | **************************************************************/ |
j3 | 0:19ec8044b826 | 228 | virtual uint8_t OWNext(void) = 0; |
j3 | 0:19ec8044b826 | 229 | |
j3 | 0:19ec8044b826 | 230 | |
j3 | 0:19ec8044b826 | 231 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 232 | * @brief Verify the device with the ROM number in ROM_NO buffer |
j3 | 0:19ec8044b826 | 233 | * is present. |
j3 | 0:19ec8044b826 | 234 | * |
j3 | 0:19ec8044b826 | 235 | * @details |
j3 | 0:19ec8044b826 | 236 | * |
j3 | 0:19ec8044b826 | 237 | * On Entry: |
j3 | 0:19ec8044b826 | 238 | * |
j3 | 0:19ec8044b826 | 239 | * On Exit: |
j3 | 0:19ec8044b826 | 240 | * @return TRUE : device verified present |
j3 | 0:19ec8044b826 | 241 | * FALSE : device not present |
j3 | 0:19ec8044b826 | 242 | **************************************************************/ |
j3 | 0:19ec8044b826 | 243 | virtual uint8_t OWVerify(void) = 0; |
j3 | 0:19ec8044b826 | 244 | |
j3 | 0:19ec8044b826 | 245 | |
j3 | 0:19ec8044b826 | 246 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 247 | * @brief Setup the search to find the device type 'family_code' |
j3 | 0:19ec8044b826 | 248 | * on the next call to OWNext() if it is present. |
j3 | 0:19ec8044b826 | 249 | * |
j3 | 0:19ec8044b826 | 250 | * @details |
j3 | 0:19ec8044b826 | 251 | * |
j3 | 0:19ec8044b826 | 252 | * On Entry: |
j3 | 0:19ec8044b826 | 253 | * @param[in] family_code - family code of device |
j3 | 0:19ec8044b826 | 254 | * |
j3 | 0:19ec8044b826 | 255 | * On Exit: |
j3 | 0:19ec8044b826 | 256 | * @return |
j3 | 0:19ec8044b826 | 257 | **************************************************************/ |
j3 | 0:19ec8044b826 | 258 | virtual void OWTargetSetup(uint8_t family_code) = 0; |
j3 | 0:19ec8044b826 | 259 | |
j3 | 0:19ec8044b826 | 260 | |
j3 | 0:19ec8044b826 | 261 | /**********************************************************//** |
j3 | 0:19ec8044b826 | 262 | * @brief Setup the search to skip the current device type on the |
j3 | 0:19ec8044b826 | 263 | * next call to OWNext(). |
j3 | 0:19ec8044b826 | 264 | * |
j3 | 0:19ec8044b826 | 265 | * @details |
j3 | 0:19ec8044b826 | 266 | * |
j3 | 0:19ec8044b826 | 267 | * On Entry: |
j3 | 0:19ec8044b826 | 268 | * |
j3 | 0:19ec8044b826 | 269 | * On Exit: |
j3 | 0:19ec8044b826 | 270 | * @return |
j3 | 0:19ec8044b826 | 271 | **************************************************************/ |
j3 | 0:19ec8044b826 | 272 | virtual void OWFamilySkipSetup(void) = 0; |
j3 | 0:19ec8044b826 | 273 | |
j3 | 0:19ec8044b826 | 274 | |
j3 | 0:19ec8044b826 | 275 | **********************************************************//** |
j3 | 0:19ec8044b826 | 276 | * @brief The 'OWSearch' function does a general search. This |
j3 | 0:19ec8044b826 | 277 | * function continues from the previous search state. The |
j3 | 0:19ec8044b826 | 278 | * search state can be reset by using the 'OWFirst' |
j3 | 0:19ec8044b826 | 279 | * function. This function contains one parameter |
j3 | 0:19ec8044b826 | 280 | * 'alarm_only'. When 'alarm_only' is TRUE (1) the find |
j3 | 0:19ec8044b826 | 281 | * alarm command 0xEC is sent instead of the normal search |
j3 | 0:19ec8044b826 | 282 | * command 0xF0. Using the find alarm command 0xEC will |
j3 | 0:19ec8044b826 | 283 | * limit the search to only 1-Wire devices that are in an |
j3 | 0:19ec8044b826 | 284 | * 'alarm' state. |
j3 | 0:19ec8044b826 | 285 | * |
j3 | 0:19ec8044b826 | 286 | * @details |
j3 | 0:19ec8044b826 | 287 | * |
j3 | 0:19ec8044b826 | 288 | * On Entry: |
j3 | 0:19ec8044b826 | 289 | * |
j3 | 0:19ec8044b826 | 290 | * On Exit: |
j3 | 0:19ec8044b826 | 291 | * @return TRUE (1) : when a 1-Wire device was found and its |
j3 | 0:19ec8044b826 | 292 | * Serial Number placed in the global ROM |
j3 | 0:19ec8044b826 | 293 | * FALSE (0): when no new device was found. Either the |
j3 | 0:19ec8044b826 | 294 | * last search was the last device or there |
j3 | 0:19ec8044b826 | 295 | * are no devices on the 1-Wire Net. |
j3 | 0:19ec8044b826 | 296 | **************************************************************/ |
j3 | 0:19ec8044b826 | 297 | virtual uint8_t OWSearch(void) = 0; |
j3 | 0:19ec8044b826 | 298 | |
j3 | 0:19ec8044b826 | 299 | |
j3 | 0:19ec8044b826 | 300 | **********************************************************//** |
j3 | 0:19ec8044b826 | 301 | * @brief Set the 1-Wire Net communication speed. |
j3 | 0:19ec8044b826 | 302 | * |
j3 | 0:19ec8044b826 | 303 | * @details |
j3 | 0:19ec8044b826 | 304 | * |
j3 | 0:19ec8044b826 | 305 | * On Entry: |
j3 | 0:19ec8044b826 | 306 | * @param[in] 'new_speed' - new speed defined as |
j3 | 0:19ec8044b826 | 307 | * MODE_STANDARD 0x00 |
j3 | 0:19ec8044b826 | 308 | * MODE_OVERDRIVE 0x01 |
j3 | 0:19ec8044b826 | 309 | * |
j3 | 0:19ec8044b826 | 310 | * On Exit: |
j3 | 0:19ec8044b826 | 311 | * @return current 1-Wire Net speed |
j3 | 0:19ec8044b826 | 312 | **************************************************************/ |
j3 | 0:19ec8044b826 | 313 | virtual uint8_t OWSpeed(uint8_t new_speed) = 0; |
j3 | 0:19ec8044b826 | 314 | |
j3 | 0:19ec8044b826 | 315 | |
j3 | 0:19ec8044b826 | 316 | **********************************************************//** |
j3 | 0:19ec8044b826 | 317 | * @brief Set the 1-Wire Net line level pull-up to normal. The |
j3 | 0:19ec8044b826 | 318 | * ds2484 does only allows enabling strong pull-up on a |
j3 | 0:19ec8044b826 | 319 | * bit or byte event. Consequently this function only |
j3 | 0:19ec8044b826 | 320 | * allows the MODE_STANDARD argument. To enable strong |
j3 | 0:19ec8044b826 | 321 | * pull-up use OWWriteBytePower or OWReadBitPower. |
j3 | 0:19ec8044b826 | 322 | * |
j3 | 0:19ec8044b826 | 323 | * @details |
j3 | 0:19ec8044b826 | 324 | * |
j3 | 0:19ec8044b826 | 325 | * On Entry: |
j3 | 0:19ec8044b826 | 326 | * @param[in] 'new_level' - new level defined as |
j3 | 0:19ec8044b826 | 327 | * MODE_STANDARD 0x00 |
j3 | 0:19ec8044b826 | 328 | * |
j3 | 0:19ec8044b826 | 329 | * On Exit: |
j3 | 0:19ec8044b826 | 330 | * @return current 1-Wire Net level |
j3 | 0:19ec8044b826 | 331 | **************************************************************/ |
j3 | 0:19ec8044b826 | 332 | virtual uint8_t OWLevel(uint8_t new_level) = 0; |
j3 | 0:19ec8044b826 | 333 | |
j3 | 0:19ec8044b826 | 334 | |
j3 | 0:19ec8044b826 | 335 | **********************************************************//** |
j3 | 0:19ec8044b826 | 336 | * @brief Send 8 bits of communication to the 1-Wire Net and |
j3 | 0:19ec8044b826 | 337 | * verify that the 8 bits read from the 1-Wire Net is the |
j3 | 0:19ec8044b826 | 338 | * same (write operation). The parameter 'sendbyte' least |
j3 | 0:19ec8044b826 | 339 | * significant 8 bits are used. After the 8 bits are sent |
j3 | 0:19ec8044b826 | 340 | * change the level of the 1-Wire net. |
j3 | 0:19ec8044b826 | 341 | * |
j3 | 0:19ec8044b826 | 342 | * @details |
j3 | 0:19ec8044b826 | 343 | * |
j3 | 0:19ec8044b826 | 344 | * On Entry: |
j3 | 0:19ec8044b826 | 345 | * @param[in] 'sendbyte' - 8 bits to send (least significant bit) |
j3 | 0:19ec8044b826 | 346 | * |
j3 | 0:19ec8044b826 | 347 | * On Exit: |
j3 | 0:19ec8044b826 | 348 | * @return TRUE: bytes written and echo was the same, strong pullup now on |
j3 | 0:19ec8044b826 | 349 | * FALSE: echo was not the same |
j3 | 0:19ec8044b826 | 350 | **************************************************************/ |
j3 | 0:19ec8044b826 | 351 | virtual uint8_t OWWriteBytePower(uint8_t sendbyte) = 0; |
j3 | 0:19ec8044b826 | 352 | |
j3 | 0:19ec8044b826 | 353 | |
j3 | 0:19ec8044b826 | 354 | **********************************************************//** |
j3 | 0:19ec8044b826 | 355 | * @brief Send 1 bit of communication to the 1-Wire Net and verify |
j3 | 0:19ec8044b826 | 356 | * that the response matches the 'applyPowerResponse' bit |
j3 | 0:19ec8044b826 | 357 | * and apply power delivery to the 1-Wire net. Note that |
j3 | 0:19ec8044b826 | 358 | * some implementations may apply the power first and then |
j3 | 0:19ec8044b826 | 359 | * turn it off if the response is incorrect. |
j3 | 0:19ec8044b826 | 360 | * |
j3 | 0:19ec8044b826 | 361 | * @details |
j3 | 0:19ec8044b826 | 362 | * |
j3 | 0:19ec8044b826 | 363 | * On Entry: |
j3 | 0:19ec8044b826 | 364 | * @param[in] 'applyPowerResponse' - 1 bit response to check, |
j3 | 0:19ec8044b826 | 365 | * if correct |
j3 | 0:19ec8044b826 | 366 | * then start power delivery |
j3 | 0:19ec8044b826 | 367 | * |
j3 | 0:19ec8044b826 | 368 | * On Exit: |
j3 | 0:19ec8044b826 | 369 | * @return |
j3 | 0:19ec8044b826 | 370 | **************************************************************/ |
j3 | 0:19ec8044b826 | 371 | virtual uint8_t OWReadBitPower(uint8_t applyPowerResponse) = 0; |
j3 | 0:19ec8044b826 | 372 | |
j3 | 0:19ec8044b826 | 373 | |
j3 | 0:19ec8044b826 | 374 | **********************************************************//** |
j3 | 0:19ec8044b826 | 375 | * @brief Calculate the CRC8 of the byte value provided with the |
j3 | 0:19ec8044b826 | 376 | * current global 'crc8' value. |
j3 | 0:19ec8044b826 | 377 | * |
j3 | 0:19ec8044b826 | 378 | * @details |
j3 | 0:19ec8044b826 | 379 | * |
j3 | 0:19ec8044b826 | 380 | * On Entry: |
j3 | 0:19ec8044b826 | 381 | * @param[in] data |
j3 | 0:19ec8044b826 | 382 | * |
j3 | 0:19ec8044b826 | 383 | * On Exit: |
j3 | 0:19ec8044b826 | 384 | * @return current global crc8 value |
j3 | 0:19ec8044b826 | 385 | **************************************************************/ |
j3 | 0:19ec8044b826 | 386 | virtual uint8_t calc_crc8(uint8_t data) = 0; |
j3 | 0:19ec8044b826 | 387 | |
j3 | 0:19ec8044b826 | 388 | }; |
j3 | 0:19ec8044b826 | 389 | |
j3 | 0:19ec8044b826 | 390 | #endif /*ONEWIREMASTER_H*/ |