1-Wire implementation, using DS2480B controller interfaced with serial port, working example to read DS18B20, based on work already in progress / Dallas - Public domain code

Dependencies:   mbed

Committer:
pwheels
Date:
Thu Mar 24 17:21:29 2011 +0000
Revision:
0:1193dbfe28e2

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pwheels 0:1193dbfe28e2 1 /*
pwheels 0:1193dbfe28e2 2 * ownet.h
pwheels 0:1193dbfe28e2 3 *
pwheels 0:1193dbfe28e2 4 * Created on: Feb 6, 2009
pwheels 0:1193dbfe28e2 5 * Author: scv
pwheels 0:1193dbfe28e2 6 */
pwheels 0:1193dbfe28e2 7 //---------------------------------------------------------------------------
pwheels 0:1193dbfe28e2 8 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
pwheels 0:1193dbfe28e2 9 //
pwheels 0:1193dbfe28e2 10 // Permission is hereby granted, free of charge, to any person obtaining a
pwheels 0:1193dbfe28e2 11 // copy of this software and associated documentation files (the "Software"),
pwheels 0:1193dbfe28e2 12 // to deal in the Software without restriction, including without limitation
pwheels 0:1193dbfe28e2 13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
pwheels 0:1193dbfe28e2 14 // and/or sell copies of the Software, and to permit persons to whom the
pwheels 0:1193dbfe28e2 15 // Software is furnished to do so, subject to the following conditions:
pwheels 0:1193dbfe28e2 16 //
pwheels 0:1193dbfe28e2 17 // The above copyright notice and this permission notice shall be included
pwheels 0:1193dbfe28e2 18 // in all copies or substantial portions of the Software.
pwheels 0:1193dbfe28e2 19 //
pwheels 0:1193dbfe28e2 20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
pwheels 0:1193dbfe28e2 21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
pwheels 0:1193dbfe28e2 22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
pwheels 0:1193dbfe28e2 23 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
pwheels 0:1193dbfe28e2 24 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
pwheels 0:1193dbfe28e2 25 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
pwheels 0:1193dbfe28e2 26 // OTHER DEALINGS IN THE SOFTWARE.
pwheels 0:1193dbfe28e2 27 //
pwheels 0:1193dbfe28e2 28 // Except as contained in this notice, the name of Dallas Semiconductor
pwheels 0:1193dbfe28e2 29 // shall not be used except as stated in the Dallas Semiconductor
pwheels 0:1193dbfe28e2 30 // Branding Policy.
pwheels 0:1193dbfe28e2 31 //---------------------------------------------------------------------------
pwheels 0:1193dbfe28e2 32 //
pwheels 0:1193dbfe28e2 33 // ownet.h - Include file for 1-Wire Net library
pwheels 0:1193dbfe28e2 34 //
pwheels 0:1193dbfe28e2 35 // Version: 2.10
pwheels 0:1193dbfe28e2 36 //
pwheels 0:1193dbfe28e2 37 // History: 1.02 -> 1.03 Make sure uchar is not defined twice.
pwheels 0:1193dbfe28e2 38 // 1.03 -> 2.00 Changed 'MLan' to 'ow'.
pwheels 0:1193dbfe28e2 39 // 2.00 -> 2.01 Added error handling. Added circular-include check.
pwheels 0:1193dbfe28e2 40 // 2.01 -> 2.10 Added raw memory error handling and SMALLINT
pwheels 0:1193dbfe28e2 41 // 2.10 -> 3.00 Added memory bank functionality
pwheels 0:1193dbfe28e2 42 // Added file I/O operations
pwheels 0:1193dbfe28e2 43 //
pwheels 0:1193dbfe28e2 44
pwheels 0:1193dbfe28e2 45 #ifndef OWNET_H
pwheels 0:1193dbfe28e2 46 #define OWNET_H
pwheels 0:1193dbfe28e2 47
pwheels 0:1193dbfe28e2 48
pwheels 0:1193dbfe28e2 49 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 50 // Common Includes to ownet applications
pwheels 0:1193dbfe28e2 51 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 52 #include <stdlib.h>
pwheels 0:1193dbfe28e2 53
pwheels 0:1193dbfe28e2 54 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 55 // Typedefs
pwheels 0:1193dbfe28e2 56 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 57 #ifndef SMALLINT
pwheels 0:1193dbfe28e2 58 //
pwheels 0:1193dbfe28e2 59 // purpose of smallint is for compile-time changing of formal
pwheels 0:1193dbfe28e2 60 // parameters and return values of functions. For each target
pwheels 0:1193dbfe28e2 61 // machine, an integer is alleged to represent the most "simple"
pwheels 0:1193dbfe28e2 62 // number representable by that architecture. This should, in
pwheels 0:1193dbfe28e2 63 // most cases, produce optimal code for that particular arch.
pwheels 0:1193dbfe28e2 64 // BUT... The majority of compilers designed for embedded
pwheels 0:1193dbfe28e2 65 // processors actually keep an int at 16 bits, although the
pwheels 0:1193dbfe28e2 66 // architecture might only be comfortable with 8 bits.
pwheels 0:1193dbfe28e2 67 // The default size of smallint will be the same as that of
pwheels 0:1193dbfe28e2 68 // an integer, but this allows for easy overriding of that size.
pwheels 0:1193dbfe28e2 69 //
pwheels 0:1193dbfe28e2 70 // NOTE:
pwheels 0:1193dbfe28e2 71 // In all cases where a smallint is used, it is assumed that
pwheels 0:1193dbfe28e2 72 // decreasing the size of this integer to something as low as
pwheels 0:1193dbfe28e2 73 // a single byte _will_not_ change the functionality of the
pwheels 0:1193dbfe28e2 74 // application. e.g. a loop counter that will iterate through
pwheels 0:1193dbfe28e2 75 // several kilobytes of data should not be SMALLINT. The most
pwheels 0:1193dbfe28e2 76 // common place you'll see smallint is for boolean return types.
pwheels 0:1193dbfe28e2 77 //
pwheels 0:1193dbfe28e2 78 #define SMALLINT int
pwheels 0:1193dbfe28e2 79 #endif
pwheels 0:1193dbfe28e2 80
pwheels 0:1193dbfe28e2 81 #define MAX_BAUD 0x06
pwheels 0:1193dbfe28e2 82
pwheels 0:1193dbfe28e2 83
pwheels 0:1193dbfe28e2 84 #ifndef OW_UCHAR
pwheels 0:1193dbfe28e2 85 #define OW_UCHAR
pwheels 0:1193dbfe28e2 86 typedef unsigned char uchar;
pwheels 0:1193dbfe28e2 87 #if !defined(__MINGW32__) && (defined(__CYGWIN__) || defined(__GNUC__))
pwheels 0:1193dbfe28e2 88 typedef unsigned long ulong;
pwheels 0:1193dbfe28e2 89 //ushort already defined in sys/types.h
pwheels 0:1193dbfe28e2 90 // Commented out 11/23/2010 sv #include <sys/types.h>
pwheels 0:1193dbfe28e2 91 #else
pwheels 0:1193dbfe28e2 92 #if defined(_WIN32) || defined(WIN32) || defined(__MC68K__) || defined(_WIN32_WCE) || defined(_DOS) || defined(_WINDOWS) || defined(__MINGW32__)
pwheels 0:1193dbfe28e2 93 typedef unsigned short ushort;
pwheels 0:1193dbfe28e2 94 typedef unsigned long ulong;
pwheels 0:1193dbfe28e2 95 #endif
pwheels 0:1193dbfe28e2 96 #endif
pwheels 0:1193dbfe28e2 97
pwheels 0:1193dbfe28e2 98 #endif
pwheels 0:1193dbfe28e2 99
pwheels 0:1193dbfe28e2 100 // general defines
pwheels 0:1193dbfe28e2 101 #define WRITE_FUNCTION 1
pwheels 0:1193dbfe28e2 102 #define READ_FUNCTION 0
pwheels 0:1193dbfe28e2 103
pwheels 0:1193dbfe28e2 104 // error codes
pwheels 0:1193dbfe28e2 105 #define READ_ERROR -1
pwheels 0:1193dbfe28e2 106 #define INVALID_DIR -2
pwheels 0:1193dbfe28e2 107 #define NO_FILE -3
pwheels 0:1193dbfe28e2 108 #define WRITE_ERROR -4
pwheels 0:1193dbfe28e2 109 #define WRONG_TYPE -5
pwheels 0:1193dbfe28e2 110 #define FILE_TOO_BIG -6
pwheels 0:1193dbfe28e2 111
pwheels 0:1193dbfe28e2 112 // Misc
pwheels 0:1193dbfe28e2 113 #ifndef FALSE
pwheels 0:1193dbfe28e2 114 #define FALSE 0
pwheels 0:1193dbfe28e2 115 #endif
pwheels 0:1193dbfe28e2 116
pwheels 0:1193dbfe28e2 117 #ifndef TRUE
pwheels 0:1193dbfe28e2 118 #define TRUE 1
pwheels 0:1193dbfe28e2 119 #endif
pwheels 0:1193dbfe28e2 120
pwheels 0:1193dbfe28e2 121 #ifndef MAX_PORTNUM
pwheels 0:1193dbfe28e2 122 #define MAX_PORTNUM 16
pwheels 0:1193dbfe28e2 123 #endif
pwheels 0:1193dbfe28e2 124
pwheels 0:1193dbfe28e2 125 // mode bit flags
pwheels 0:1193dbfe28e2 126 #define MODE_NORMAL 0x00
pwheels 0:1193dbfe28e2 127 #define MODE_OVERDRIVE 0x01
pwheels 0:1193dbfe28e2 128 #define MODE_STRONG5 0x02
pwheels 0:1193dbfe28e2 129 #define MODE_PROGRAM 0x04
pwheels 0:1193dbfe28e2 130 #define MODE_BREAK 0x08
pwheels 0:1193dbfe28e2 131
pwheels 0:1193dbfe28e2 132 // Output flags
pwheels 0:1193dbfe28e2 133 #define LV_ALWAYS 2
pwheels 0:1193dbfe28e2 134 #define LV_OPTIONAL 1
pwheels 0:1193dbfe28e2 135 #define LV_VERBOSE 0
pwheels 0:1193dbfe28e2 136
pwheels 0:1193dbfe28e2 137 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 138 // Error handling
pwheels 0:1193dbfe28e2 139 //--------------------------------------------------------------//
pwheels 0:1193dbfe28e2 140 extern int owGetErrorNum(void);
pwheels 0:1193dbfe28e2 141 extern int owHasErrors(void);
pwheels 0:1193dbfe28e2 142
pwheels 0:1193dbfe28e2 143
pwheels 0:1193dbfe28e2 144 //Clears the stack.
pwheels 0:1193dbfe28e2 145 #define OWERROR_CLEAR() while(owHasErrors()) owGetErrorNum();
pwheels 0:1193dbfe28e2 146
pwheels 0:1193dbfe28e2 147 #ifdef DEBUG
pwheels 0:1193dbfe28e2 148 //Raises an exception with extra debug info
pwheels 0:1193dbfe28e2 149 #define OWERROR(err) owRaiseError(err,__LINE__,__FILE__)
pwheels 0:1193dbfe28e2 150 extern void owRaiseError(int,int,char*);
pwheels 0:1193dbfe28e2 151 #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err),__LINE__,__FILE__);return (ret);}
pwheels 0:1193dbfe28e2 152 #else
pwheels 0:1193dbfe28e2 153 //Raises an exception with just the error code
pwheels 0:1193dbfe28e2 154 #define OWERROR(err) printf( "Debug Error: %u\r\n", err );
pwheels 0:1193dbfe28e2 155 extern void owRaiseError(int);
pwheels 0:1193dbfe28e2 156 #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err));return (ret);}
pwheels 0:1193dbfe28e2 157 #endif
pwheels 0:1193dbfe28e2 158
pwheels 0:1193dbfe28e2 159 #ifdef SMALL_MEMORY_TARGET
pwheels 0:1193dbfe28e2 160 #define OWERROR_DUMP(fileno) /*no-op*/;
pwheels 0:1193dbfe28e2 161 #else
pwheels 0:1193dbfe28e2 162 //Prints the stack out to the given file.
pwheels 0:1193dbfe28e2 163 #define OWERROR_DUMP(fileno) iprintf("Debug Error: %u", fileno);
pwheels 0:1193dbfe28e2 164 // #define OWERROR_DUMP(fileno) while(owHasErrors()) owPrintErrorMsg(fileno);
pwheels 0:1193dbfe28e2 165 // extern void owPrintErrorMsg(FILE *);
pwheels 0:1193dbfe28e2 166 extern void owPrintErrorMsgStd();
pwheels 0:1193dbfe28e2 167 extern char *owGetErrorMsg(int);
pwheels 0:1193dbfe28e2 168 #endif
pwheels 0:1193dbfe28e2 169
pwheels 0:1193dbfe28e2 170 #define OWERROR_NO_ERROR_SET 0
pwheels 0:1193dbfe28e2 171 #define OWERROR_NO_DEVICES_ON_NET 1
pwheels 0:1193dbfe28e2 172 #define OWERROR_RESET_FAILED 2
pwheels 0:1193dbfe28e2 173 #define OWERROR_SEARCH_ERROR 3
pwheels 0:1193dbfe28e2 174 #define OWERROR_ACCESS_FAILED 4
pwheels 0:1193dbfe28e2 175 #define OWERROR_DS2480_NOT_DETECTED 5
pwheels 0:1193dbfe28e2 176 #define OWERROR_DS2480_WRONG_BAUD 6
pwheels 0:1193dbfe28e2 177 #define OWERROR_DS2480_BAD_RESPONSE 7
pwheels 0:1193dbfe28e2 178 #define OWERROR_OPENCOM_FAILED 8
pwheels 0:1193dbfe28e2 179 #define OWERROR_WRITECOM_FAILED 9
pwheels 0:1193dbfe28e2 180 #define OWERROR_READCOM_FAILED 10
pwheels 0:1193dbfe28e2 181 #define OWERROR_BLOCK_TOO_BIG 11
pwheels 0:1193dbfe28e2 182 #define OWERROR_BLOCK_FAILED 12
pwheels 0:1193dbfe28e2 183 #define OWERROR_PROGRAM_PULSE_FAILED 13
pwheels 0:1193dbfe28e2 184 #define OWERROR_PROGRAM_BYTE_FAILED 14
pwheels 0:1193dbfe28e2 185 #define OWERROR_WRITE_BYTE_FAILED 15
pwheels 0:1193dbfe28e2 186 #define OWERROR_READ_BYTE_FAILED 16
pwheels 0:1193dbfe28e2 187 #define OWERROR_WRITE_VERIFY_FAILED 17
pwheels 0:1193dbfe28e2 188 #define OWERROR_READ_VERIFY_FAILED 18
pwheels 0:1193dbfe28e2 189 #define OWERROR_WRITE_SCRATCHPAD_FAILED 19
pwheels 0:1193dbfe28e2 190 #define OWERROR_COPY_SCRATCHPAD_FAILED 20
pwheels 0:1193dbfe28e2 191 #define OWERROR_INCORRECT_CRC_LENGTH 21
pwheels 0:1193dbfe28e2 192 #define OWERROR_CRC_FAILED 22
pwheels 0:1193dbfe28e2 193 #define OWERROR_GET_SYSTEM_RESOURCE_FAILED 23
pwheels 0:1193dbfe28e2 194 #define OWERROR_SYSTEM_RESOURCE_INIT_FAILED 24
pwheels 0:1193dbfe28e2 195 #define OWERROR_DATA_TOO_LONG 25
pwheels 0:1193dbfe28e2 196 #define OWERROR_READ_OUT_OF_RANGE 26
pwheels 0:1193dbfe28e2 197 #define OWERROR_WRITE_OUT_OF_RANGE 27
pwheels 0:1193dbfe28e2 198 #define OWERROR_DEVICE_SELECT_FAIL 28
pwheels 0:1193dbfe28e2 199 #define OWERROR_READ_SCRATCHPAD_VERIFY 29
pwheels 0:1193dbfe28e2 200 #define OWERROR_COPY_SCRATCHPAD_NOT_FOUND 30
pwheels 0:1193dbfe28e2 201 #define OWERROR_ERASE_SCRATCHPAD_NOT_FOUND 31
pwheels 0:1193dbfe28e2 202 #define OWERROR_ADDRESS_READ_BACK_FAILED 32
pwheels 0:1193dbfe28e2 203 #define OWERROR_EXTRA_INFO_NOT_SUPPORTED 33
pwheels 0:1193dbfe28e2 204 #define OWERROR_PG_PACKET_WITHOUT_EXTRA 34
pwheels 0:1193dbfe28e2 205 #define OWERROR_PACKET_LENGTH_EXCEEDS_PAGE 35
pwheels 0:1193dbfe28e2 206 #define OWERROR_INVALID_PACKET_LENGTH 36
pwheels 0:1193dbfe28e2 207 #define OWERROR_NO_PROGRAM_PULSE 37
pwheels 0:1193dbfe28e2 208 #define OWERROR_READ_ONLY 38
pwheels 0:1193dbfe28e2 209 #define OWERROR_NOT_GENERAL_PURPOSE 39
pwheels 0:1193dbfe28e2 210 #define OWERROR_READ_BACK_INCORRECT 40
pwheels 0:1193dbfe28e2 211 #define OWERROR_INVALID_PAGE_NUMBER 41
pwheels 0:1193dbfe28e2 212 #define OWERROR_CRC_NOT_SUPPORTED 42
pwheels 0:1193dbfe28e2 213 #define OWERROR_CRC_EXTRA_INFO_NOT_SUPPORTED 43
pwheels 0:1193dbfe28e2 214 #define OWERROR_READ_BACK_NOT_VALID 44
pwheels 0:1193dbfe28e2 215 #define OWERROR_COULD_NOT_LOCK_REDIRECT 45
pwheels 0:1193dbfe28e2 216 #define OWERROR_READ_STATUS_NOT_COMPLETE 46
pwheels 0:1193dbfe28e2 217 #define OWERROR_PAGE_REDIRECTION_NOT_SUPPORTED 47
pwheels 0:1193dbfe28e2 218 #define OWERROR_LOCK_REDIRECTION_NOT_SUPPORTED 48
pwheels 0:1193dbfe28e2 219 #define OWERROR_READBACK_EPROM_FAILED 49
pwheels 0:1193dbfe28e2 220 #define OWERROR_PAGE_LOCKED 50
pwheels 0:1193dbfe28e2 221 #define OWERROR_LOCKING_REDIRECTED_PAGE_AGAIN 51
pwheels 0:1193dbfe28e2 222 #define OWERROR_REDIRECTED_PAGE 52
pwheels 0:1193dbfe28e2 223 #define OWERROR_PAGE_ALREADY_LOCKED 53
pwheels 0:1193dbfe28e2 224 #define OWERROR_WRITE_PROTECTED 54
pwheels 0:1193dbfe28e2 225 #define OWERROR_NONMATCHING_MAC 55
pwheels 0:1193dbfe28e2 226 #define OWERROR_WRITE_PROTECT 56
pwheels 0:1193dbfe28e2 227 #define OWERROR_WRITE_PROTECT_SECRET 57
pwheels 0:1193dbfe28e2 228 #define OWERROR_COMPUTE_NEXT_SECRET 58
pwheels 0:1193dbfe28e2 229 #define OWERROR_LOAD_FIRST_SECRET 59
pwheels 0:1193dbfe28e2 230 #define OWERROR_POWER_NOT_AVAILABLE 60
pwheels 0:1193dbfe28e2 231 #define OWERROR_XBAD_FILENAME 61
pwheels 0:1193dbfe28e2 232 #define OWERROR_XUNABLE_TO_CREATE_DIR 62
pwheels 0:1193dbfe28e2 233 #define OWERROR_REPEAT_FILE 63
pwheels 0:1193dbfe28e2 234 #define OWERROR_DIRECTORY_NOT_EMPTY 64
pwheels 0:1193dbfe28e2 235 #define OWERROR_WRONG_TYPE 65
pwheels 0:1193dbfe28e2 236 #define OWERROR_BUFFER_TOO_SMALL 66
pwheels 0:1193dbfe28e2 237 #define OWERROR_NOT_WRITE_ONCE 67
pwheels 0:1193dbfe28e2 238 #define OWERROR_FILE_NOT_FOUND 68
pwheels 0:1193dbfe28e2 239 #define OWERROR_OUT_OF_SPACE 69
pwheels 0:1193dbfe28e2 240 #define OWERROR_TOO_LARGE_BITNUM 70
pwheels 0:1193dbfe28e2 241 #define OWERROR_NO_PROGRAM_JOB 71
pwheels 0:1193dbfe28e2 242 #define OWERROR_FUNC_NOT_SUP 72
pwheels 0:1193dbfe28e2 243 #define OWERROR_HANDLE_NOT_USED 73
pwheels 0:1193dbfe28e2 244 #define OWERROR_FILE_WRITE_ONLY 74
pwheels 0:1193dbfe28e2 245 #define OWERROR_HANDLE_NOT_AVAIL 75
pwheels 0:1193dbfe28e2 246 #define OWERROR_INVALID_DIRECTORY 76
pwheels 0:1193dbfe28e2 247 #define OWERROR_HANDLE_NOT_EXIST 77
pwheels 0:1193dbfe28e2 248 #define OWERROR_NONMATCHING_SNUM 78
pwheels 0:1193dbfe28e2 249 #define OWERROR_NON_PROGRAM_PARTS 79
pwheels 0:1193dbfe28e2 250 #define OWERROR_PROGRAM_WRITE_PROTECT 80
pwheels 0:1193dbfe28e2 251 #define OWERROR_FILE_READ_ERR 81
pwheels 0:1193dbfe28e2 252 #define OWERROR_ADDFILE_TERMINATED 82
pwheels 0:1193dbfe28e2 253 #define OWERROR_READ_MEMORY_PAGE_FAILED 83
pwheels 0:1193dbfe28e2 254 #define OWERROR_MATCH_SCRATCHPAD_FAILED 84
pwheels 0:1193dbfe28e2 255 #define OWERROR_ERASE_SCRATCHPAD_FAILED 85
pwheels 0:1193dbfe28e2 256 #define OWERROR_READ_SCRATCHPAD_FAILED 86
pwheels 0:1193dbfe28e2 257 #define OWERROR_SHA_FUNCTION_FAILED 87
pwheels 0:1193dbfe28e2 258 #define OWERROR_NO_COMPLETION_BYTE 88
pwheels 0:1193dbfe28e2 259 #define OWERROR_WRITE_DATA_PAGE_FAILED 89
pwheels 0:1193dbfe28e2 260 #define OWERROR_COPY_SECRET_FAILED 90
pwheels 0:1193dbfe28e2 261 #define OWERROR_BIND_SECRET_FAILED 91
pwheels 0:1193dbfe28e2 262 #define OWERROR_INSTALL_SECRET_FAILED 92
pwheels 0:1193dbfe28e2 263 #define OWERROR_VERIFY_SIG_FAILED 93
pwheels 0:1193dbfe28e2 264 #define OWERROR_SIGN_SERVICE_DATA_FAILED 94
pwheels 0:1193dbfe28e2 265 #define OWERROR_VERIFY_AUTH_RESPONSE_FAILED 95
pwheels 0:1193dbfe28e2 266 #define OWERROR_ANSWER_CHALLENGE_FAILED 96
pwheels 0:1193dbfe28e2 267 #define OWERROR_CREATE_CHALLENGE_FAILED 97
pwheels 0:1193dbfe28e2 268 #define OWERROR_BAD_SERVICE_DATA 98
pwheels 0:1193dbfe28e2 269 #define OWERROR_SERVICE_DATA_NOT_UPDATED 99
pwheels 0:1193dbfe28e2 270 #define OWERROR_CATASTROPHIC_SERVICE_FAILURE 100
pwheels 0:1193dbfe28e2 271 #define OWERROR_LOAD_FIRST_SECRET_FAILED 101
pwheels 0:1193dbfe28e2 272 #define OWERROR_MATCH_SERVICE_SIGNATURE_FAILED 102
pwheels 0:1193dbfe28e2 273 #define OWERROR_KEY_OUT_OF_RANGE 103
pwheels 0:1193dbfe28e2 274 #define OWERROR_BLOCK_ID_OUT_OF_RANGE 104
pwheels 0:1193dbfe28e2 275 #define OWERROR_PASSWORDS_ENABLED 105
pwheels 0:1193dbfe28e2 276 #define OWERROR_PASSWORD_INVALID 106
pwheels 0:1193dbfe28e2 277 #define OWERROR_NO_READ_ONLY_PASSWORD 107
pwheels 0:1193dbfe28e2 278 #define OWERROR_NO_READ_WRITE_PASSWORD 108
pwheels 0:1193dbfe28e2 279 #define OWERROR_OW_SHORTED 109
pwheels 0:1193dbfe28e2 280 #define OWERROR_ADAPTER_ERROR 110
pwheels 0:1193dbfe28e2 281 #define OWERROR_EOP_COPY_SCRATCHPAD_FAILED 111
pwheels 0:1193dbfe28e2 282 #define OWERROR_EOP_WRITE_SCRATCHPAD_FAILED 112
pwheels 0:1193dbfe28e2 283 #define OWERROR_HYGRO_STOP_MISSION_UNNECESSARY 113
pwheels 0:1193dbfe28e2 284 #define OWERROR_HYGRO_STOP_MISSION_ERROR 114
pwheels 0:1193dbfe28e2 285 #define OWERROR_PORTNUM_ERROR 115
pwheels 0:1193dbfe28e2 286 #define OWERROR_LEVEL_FAILED 116
pwheels 0:1193dbfe28e2 287 #define OWERROR_PASSWORD_NOT_SET 117
pwheels 0:1193dbfe28e2 288 #define OWERROR_LATCH_NOT_SET 118
pwheels 0:1193dbfe28e2 289 #define OWERROR_LIBUSB_OPEN_FAILED 119
pwheels 0:1193dbfe28e2 290 #define OWERROR_LIBUSB_DEVICE_ALREADY_OPENED 120
pwheels 0:1193dbfe28e2 291 #define OWERROR_LIBUSB_SET_CONFIGURATION_ERROR 121
pwheels 0:1193dbfe28e2 292 #define OWERROR_LIBUSB_CLAIM_INTERFACE_ERROR 122
pwheels 0:1193dbfe28e2 293 #define OWERROR_LIBUSB_SET_ALTINTERFACE_ERROR 123
pwheels 0:1193dbfe28e2 294 #define OWERROR_LIBUSB_NO_ADAPTER_FOUND 124
pwheels 0:1193dbfe28e2 295
pwheels 0:1193dbfe28e2 296 // One Wire functions defined in ownetu.c
pwheels 0:1193dbfe28e2 297 SMALLINT owFirst(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
pwheels 0:1193dbfe28e2 298 SMALLINT owNext(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
pwheels 0:1193dbfe28e2 299 void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read);
pwheels 0:1193dbfe28e2 300 void owFamilySearchSetup(int portnum, SMALLINT search_family);
pwheels 0:1193dbfe28e2 301 void owSkipFamily(int portnum);
pwheels 0:1193dbfe28e2 302 SMALLINT owAccess(int portnum);
pwheels 0:1193dbfe28e2 303 SMALLINT owVerify(int portnum, SMALLINT alarm_only);
pwheels 0:1193dbfe28e2 304 SMALLINT owOverdriveAccess(int portnum);
pwheels 0:1193dbfe28e2 305
pwheels 0:1193dbfe28e2 306
pwheels 0:1193dbfe28e2 307 // external One Wire functions defined in owsesu.c
pwheels 0:1193dbfe28e2 308 SMALLINT owAcquire(int portnum, char *port_zstr);
pwheels 0:1193dbfe28e2 309 int owAcquireEx(char *port_zstr);
pwheels 0:1193dbfe28e2 310 void owRelease(int portnum);
pwheels 0:1193dbfe28e2 311
pwheels 0:1193dbfe28e2 312 // external One Wire functions defined in findtype.c
pwheels 0:1193dbfe28e2 313 // SMALLINT FindDevices(int,uchar FamilySN[][8],SMALLINT,int);
pwheels 0:1193dbfe28e2 314
pwheels 0:1193dbfe28e2 315 // external One Wire functions from link layer owllu.c
pwheels 0:1193dbfe28e2 316 SMALLINT owTouchReset(int portnum);
pwheels 0:1193dbfe28e2 317 SMALLINT owTouchBit(int portnum, SMALLINT sendbit);
pwheels 0:1193dbfe28e2 318 SMALLINT owTouchByte(int portnum, SMALLINT sendbyte);
pwheels 0:1193dbfe28e2 319 SMALLINT owWriteByte(int portnum, SMALLINT sendbyte);
pwheels 0:1193dbfe28e2 320 SMALLINT owReadByte(int portnum);
pwheels 0:1193dbfe28e2 321 SMALLINT owSpeed(int portnum, SMALLINT new_speed);
pwheels 0:1193dbfe28e2 322 SMALLINT owLevel(int portnum, SMALLINT new_level);
pwheels 0:1193dbfe28e2 323 SMALLINT owProgramPulse(int portnum);
pwheels 0:1193dbfe28e2 324 SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte);
pwheels 0:1193dbfe28e2 325 SMALLINT owReadBytePower(int portnum);
pwheels 0:1193dbfe28e2 326 SMALLINT owHasPowerDelivery(int portnum);
pwheels 0:1193dbfe28e2 327 SMALLINT owHasProgramPulse(int portnum);
pwheels 0:1193dbfe28e2 328 SMALLINT owHasOverDrive(int portnum);
pwheels 0:1193dbfe28e2 329 SMALLINT owReadBitPower(int portnum, SMALLINT applyPowerResponse);
pwheels 0:1193dbfe28e2 330 // external One Wire global from owllu.c
pwheels 0:1193dbfe28e2 331 extern SMALLINT FAMILY_CODE_04_ALARM_TOUCHRESET_COMPLIANCE;
pwheels 0:1193dbfe28e2 332
pwheels 0:1193dbfe28e2 333 // external One Wire functions from transaction layer in owtrnu.c
pwheels 0:1193dbfe28e2 334 SMALLINT owBlock(int portnum, SMALLINT do_reset, uchar *tran_buf, SMALLINT tran_len);
pwheels 0:1193dbfe28e2 335 SMALLINT owReadPacketStd(int portnum, SMALLINT do_access, int start_page, uchar *read_buf);
pwheels 0:1193dbfe28e2 336 SMALLINT owWritePacketStd(int portnum, int start_page, uchar *write_buf,
pwheels 0:1193dbfe28e2 337 SMALLINT write_len, SMALLINT is_eprom, SMALLINT crc_type);
pwheels 0:1193dbfe28e2 338 SMALLINT owProgramByte(int portnum, SMALLINT write_byte, int addr, SMALLINT write_cmd,
pwheels 0:1193dbfe28e2 339 SMALLINT crc_type, SMALLINT do_access);
pwheels 0:1193dbfe28e2 340
pwheels 0:1193dbfe28e2 341 // link functions
pwheels 0:1193dbfe28e2 342 void msDelay(int len);
pwheels 0:1193dbfe28e2 343 long msGettick(void);
pwheels 0:1193dbfe28e2 344
pwheels 0:1193dbfe28e2 345 // ioutil.c functions prototypes
pwheels 0:1193dbfe28e2 346 int EnterString(char *msg, char *buf, int min, int max);
pwheels 0:1193dbfe28e2 347 int EnterNum(char *msg, int numchars, long *value, long min, long max);
pwheels 0:1193dbfe28e2 348 int EnterHex(char *msg, int numchars, ulong *value);
pwheels 0:1193dbfe28e2 349 int ToHex(char ch);
pwheels 0:1193dbfe28e2 350 int getkeystroke(void);
pwheels 0:1193dbfe28e2 351 int key_abort(void);
pwheels 0:1193dbfe28e2 352 void ExitProg(char *msg, int exit_code);
pwheels 0:1193dbfe28e2 353 int getData(uchar *write_buff, int max_len, SMALLINT gethex);
pwheels 0:1193dbfe28e2 354 void PrintHex(uchar* buffer, int cnt);
pwheels 0:1193dbfe28e2 355 void PrintChars(uchar* buffer, int cnt);
pwheels 0:1193dbfe28e2 356 void PrintSerialNum(uchar* buffer);
pwheels 0:1193dbfe28e2 357
pwheels 0:1193dbfe28e2 358 // external functions defined in crcutil.c
pwheels 0:1193dbfe28e2 359 void setcrc16(int portnum, unsigned short reset);
pwheels 0:1193dbfe28e2 360 unsigned short docrc16(int portnum, unsigned short cdata);
pwheels 0:1193dbfe28e2 361 void setcrc8(int portnum, uchar reset);
pwheels 0:1193dbfe28e2 362 uchar docrc8(int portnum, uchar x);
pwheels 0:1193dbfe28e2 363
pwheels 0:1193dbfe28e2 364 #endif //OWNET_H