--- /dev/null
+//---------------------------------------------------------------------------\r
+// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining a\r
+// copy of this software and associated documentation files (the "Software"),\r
+// to deal in the Software without restriction, including without limitation\r
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+// and/or sell copies of the Software, and to permit persons to whom the\r
+// Software is furnished to do so, subject to the following conditions:\r
+//\r
+// The above copyright notice and this permission notice shall be included\r
+// in all copies or substantial portions of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
+// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES\r
+// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\r
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r
+// OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+// Except as contained in this notice, the name of Dallas Semiconductor\r
+// shall not be used except as stated in the Dallas Semiconductor\r
+// Branding Policy.\r
+//---------------------------------------------------------------------------\r
+//\r
+// ownet.h - Include file for 1-Wire Net library\r
+//\r
+// Version: 2.10\r
+//\r
+// History: 1.02 -> 1.03 Make sure uchar is not defined twice.\r
+// 1.03 -> 2.00 Changed 'MLan' to 'ow'.\r
+// 2.00 -> 2.01 Added error handling. Added circular-include check.\r
+// 2.01 -> 2.10 Added raw memory error handling and SMALLINT\r
+// 2.10 -> 3.00 Added memory bank functionality\r
+// Added file I/O operations\r
+//\r
+\r
+#ifndef OWNET_H\r
+#define OWNET_H\r
+\r
+//--------------------------------------------------------------//\r
+// Common Includes to ownet applications\r
+//--------------------------------------------------------------//\r
+#include <stdlib.h>\r
+#include <stdint.h>\r
+\r
+\r
+//--------------------------------------------------------------//\r
+// Target Specific Information\r
+//--------------------------------------------------------------//\r
+//--------------------------------------------------------------//\r
+// Handhelds (PalmOS, WinCE)\r
+//--------------------------------------------------------------//\r
+#ifdef __MC68K__\r
+ //MC68K is the type of processor in the PILOT\r
+ //Metrowerk's CodeWarrior defines this symbol\r
+ #include <string.h>\r
+ #ifndef strcmp\r
+ #include <StringMgr.h>\r
+ #define strcmp StrCompare\r
+ #endif\r
+ #include <file_struc.h>\r
+#endif\r
+\r
+#ifdef _WIN32_WCE\r
+ //All of our projects had this flag defined by default (_WIN32_WCE),\r
+ //but I'm not 100% positive that this is _the_ definitive\r
+ //flag to use to identify a WinCE system.\r
+ #include "WinCElnk.h"\r
+ #ifndef FILE\r
+ #define FILE int\r
+ extern int sprintf(char *buffer, char *format,...);\r
+ extern void fprintf(FILE *fp, char *format,...);\r
+ extern void printf(char *format,...);\r
+ #endif\r
+#endif\r
+\r
+#if !defined(_WIN32_WCE) && !defined(__MC68K__)\r
+ #include <stdio.h>\r
+#endif\r
+\r
+#ifdef __C51__\r
+ #define FILE int\r
+ #define exit(c) return\r
+ typedef unsigned int ushort;\r
+ typedef unsigned long ulong;\r
+ #define SMALLINT uchar\r
+#endif\r
+\r
+#ifdef __ICCMAXQ__\r
+ #define FILE int\r
+ #define stdout 0\r
+ #define stdin 1\r
+ #define stderr 2\r
+ typedef unsigned int ushort;\r
+ typedef unsigned long ulong;\r
+ #define SMALLINT short\r
+ #define main micro_main\r
+ #define real_main main\r
+ #define SMALL_MEMORY_TARGET\r
+#endif\r
+\r
+\r
+//--------------------------------------------------------------//\r
+// Typedefs\r
+//--------------------------------------------------------------//\r
+#ifndef SMALLINT\r
+ //\r
+ // purpose of smallint is for compile-time changing of formal\r
+ // parameters and return values of functions. For each target\r
+ // machine, an integer is alleged to represent the most "simple"\r
+ // number representable by that architecture. This should, in\r
+ // most cases, produce optimal code for that particular arch.\r
+ // BUT... The majority of compilers designed for embedded\r
+ // processors actually keep an int at 16 bits, although the\r
+ // architecture might only be comfortable with 8 bits.\r
+ // The default size of smallint will be the same as that of\r
+ // an integer, but this allows for easy overriding of that size.\r
+ //\r
+ // NOTE:\r
+ // In all cases where a smallint is used, it is assumed that\r
+ // decreasing the size of this integer to something as low as\r
+ // a single byte _will_not_ change the functionality of the\r
+ // application. e.g. a loop counter that will iterate through\r
+ // several kilobytes of data should not be SMALLINT. The most\r
+ // common place you'll see smallint is for boolean return types.\r
+ //\r
+ #define SMALLINT int\r
+#endif\r
+\r
+// setting max baud\r
+#ifdef _WINDOWS\r
+ // 0x02 = PARAMSET_19200\r
+#define MAX_BAUD 0x02\r
+#else\r
+ // 0x06 = PARMSET_115200\r
+#define MAX_BAUD 0x06\r
+#endif\r
+\r
+#ifndef OW_UCHAR\r
+ #define OW_UCHAR\r
+ typedef unsigned char uchar;\r
+ #if !defined(__MINGW32__) && (defined(__CYGWIN__) || defined(__GNUC__))\r
+ typedef unsigned long ulong;\r
+ //ushort already defined in sys/types.h\r
+ #include <sys/types.h>\r
+ #else\r
+ #if defined(_WIN32) || defined(WIN32) || defined(__MC68K__) || defined(_WIN32_WCE) || defined(_DOS) || defined(_WINDOWS) || defined(__MINGW32__)\r
+ typedef unsigned short ushort;\r
+ typedef unsigned long ulong;\r
+ #endif\r
+ #endif\r
+ #ifdef __sun__\r
+ #include <sys/types.h>\r
+ #endif\r
+ #ifdef SDCC\r
+ //intent of ushort is 2 bytes unsigned.\r
+ //for ds390 in sdcc, an int, not a short,\r
+ //is 2 bytes.\r
+ typedef unsigned int ushort;\r
+ #endif\r
+#endif\r
+\r
+// general defines\r
+#define WRITE_FUNCTION 1\r
+#define READ_FUNCTION 0\r
+\r
+// error codes\r
+// todo: investigate these and replace with new Error Handling library\r
+#define READ_ERROR -1\r
+#define INVALID_DIR -2\r
+#define NO_FILE -3\r
+#define WRITE_ERROR -4\r
+#define WRONG_TYPE -5\r
+#define FILE_TOO_BIG -6\r
+\r
+// Misc\r
+#define FALSE 0\r
+#define TRUE 1\r
+\r
+#ifndef MAX_PORTNUM\r
+ #define MAX_PORTNUM 16\r
+#endif\r
+\r
+// mode bit flags\r
+#define MODE_NORMAL 0x00\r
+#define MODE_OVERDRIVE 0x01\r
+#define MODE_STRONG5 0x02\r
+#define MODE_PROGRAM 0x04\r
+#define MODE_BREAK 0x08\r
+\r
+// Output flags\r
+#define LV_ALWAYS 2\r
+#define LV_OPTIONAL 1\r
+#define LV_VERBOSE 0\r
+\r
+//--------------------------------------------------------------//\r
+// Error handling\r
+//--------------------------------------------------------------//\r
+extern int owGetErrorNum(void);\r
+extern int owHasErrors(void);\r
+\r
+//Clears the stack.\r
+#define OWERROR_CLEAR() while(owHasErrors()) owGetErrorNum();\r
+\r
+#ifdef DEBUG\r
+ //Raises an exception with extra debug info\r
+ #define OWERROR(err) owRaiseError(err,__LINE__,__FILE__)\r
+ extern void owRaiseError(int,int,char*);\r
+ #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err),__LINE__,__FILE__);return (ret);}\r
+#else\r
+ //Raises an exception with just the error code\r
+ #define OWERROR(err) owRaiseError(err)\r
+ extern void owRaiseError(int);\r
+ #define OWASSERT(s,err,ret) if(!(s)){owRaiseError((err));return (ret);}\r
+#endif\r
+\r
+#ifdef SMALL_MEMORY_TARGET\r
+ #define OWERROR_DUMP(fileno) /*no-op*/;\r
+#else\r
+ //Prints the stack out to the given file.\r
+ #define OWERROR_DUMP(fileno) while(owHasErrors()) owPrintErrorMsg(fileno);\r
+ extern void owPrintErrorMsg(FILE *);\r
+ extern void owPrintErrorMsgStd();\r
+ extern char *owGetErrorMsg(int);\r
+#endif\r
+\r
+#define OWERROR_NO_ERROR_SET 0\r
+#define OWERROR_NO_DEVICES_ON_NET 1\r
+#define OWERROR_RESET_FAILED 2\r
+#define OWERROR_SEARCH_ERROR 3\r
+#define OWERROR_ACCESS_FAILED 4\r
+#define OWERROR_DS2480_NOT_DETECTED 5\r
+#define OWERROR_DS2480_WRONG_BAUD 6\r
+#define OWERROR_DS2480_BAD_RESPONSE 7\r
+#define OWERROR_OPENCOM_FAILED 8\r
+#define OWERROR_WRITECOM_FAILED 9\r
+#define OWERROR_READCOM_FAILED 10\r
+#define OWERROR_BLOCK_TOO_BIG 11\r
+#define OWERROR_BLOCK_FAILED 12\r
+#define OWERROR_PROGRAM_PULSE_FAILED 13\r
+#define OWERROR_PROGRAM_BYTE_FAILED 14\r
+#define OWERROR_WRITE_BYTE_FAILED 15\r
+#define OWERROR_READ_BYTE_FAILED 16\r
+#define OWERROR_WRITE_VERIFY_FAILED 17\r
+#define OWERROR_READ_VERIFY_FAILED 18\r
+#define OWERROR_WRITE_SCRATCHPAD_FAILED 19\r
+#define OWERROR_COPY_SCRATCHPAD_FAILED 20\r
+#define OWERROR_INCORRECT_CRC_LENGTH 21\r
+#define OWERROR_CRC_FAILED 22\r
+#define OWERROR_GET_SYSTEM_RESOURCE_FAILED 23\r
+#define OWERROR_SYSTEM_RESOURCE_INIT_FAILED 24\r
+#define OWERROR_DATA_TOO_LONG 25\r
+#define OWERROR_READ_OUT_OF_RANGE 26\r
+#define OWERROR_WRITE_OUT_OF_RANGE 27\r
+#define OWERROR_DEVICE_SELECT_FAIL 28\r
+#define OWERROR_READ_SCRATCHPAD_VERIFY 29\r
+#define OWERROR_COPY_SCRATCHPAD_NOT_FOUND 30\r
+#define OWERROR_ERASE_SCRATCHPAD_NOT_FOUND 31\r
+#define OWERROR_ADDRESS_READ_BACK_FAILED 32\r
+#define OWERROR_EXTRA_INFO_NOT_SUPPORTED 33\r
+#define OWERROR_PG_PACKET_WITHOUT_EXTRA 34\r
+#define OWERROR_PACKET_LENGTH_EXCEEDS_PAGE 35\r
+#define OWERROR_INVALID_PACKET_LENGTH 36\r
+#define OWERROR_NO_PROGRAM_PULSE 37\r
+#define OWERROR_READ_ONLY 38\r
+#define OWERROR_NOT_GENERAL_PURPOSE 39\r
+#define OWERROR_READ_BACK_INCORRECT 40\r
+#define OWERROR_INVALID_PAGE_NUMBER 41\r
+#define OWERROR_CRC_NOT_SUPPORTED 42\r
+#define OWERROR_CRC_EXTRA_INFO_NOT_SUPPORTED 43\r
+#define OWERROR_READ_BACK_NOT_VALID 44\r
+#define OWERROR_COULD_NOT_LOCK_REDIRECT 45\r
+#define OWERROR_READ_STATUS_NOT_COMPLETE 46\r
+#define OWERROR_PAGE_REDIRECTION_NOT_SUPPORTED 47\r
+#define OWERROR_LOCK_REDIRECTION_NOT_SUPPORTED 48\r
+#define OWERROR_READBACK_EPROM_FAILED 49\r
+#define OWERROR_PAGE_LOCKED 50\r
+#define OWERROR_LOCKING_REDIRECTED_PAGE_AGAIN 51\r
+#define OWERROR_REDIRECTED_PAGE 52\r
+#define OWERROR_PAGE_ALREADY_LOCKED 53\r
+#define OWERROR_WRITE_PROTECTED 54\r
+#define OWERROR_NONMATCHING_MAC 55\r
+#define OWERROR_WRITE_PROTECT 56\r
+#define OWERROR_WRITE_PROTECT_SECRET 57\r
+#define OWERROR_COMPUTE_NEXT_SECRET 58\r
+#define OWERROR_LOAD_FIRST_SECRET 59\r
+#define OWERROR_POWER_NOT_AVAILABLE 60\r
+#define OWERROR_XBAD_FILENAME 61\r
+#define OWERROR_XUNABLE_TO_CREATE_DIR 62\r
+#define OWERROR_REPEAT_FILE 63\r
+#define OWERROR_DIRECTORY_NOT_EMPTY 64\r
+#define OWERROR_WRONG_TYPE 65\r
+#define OWERROR_BUFFER_TOO_SMALL 66\r
+#define OWERROR_NOT_WRITE_ONCE 67\r
+#define OWERROR_FILE_NOT_FOUND 68\r
+#define OWERROR_OUT_OF_SPACE 69\r
+#define OWERROR_TOO_LARGE_BITNUM 70\r
+#define OWERROR_NO_PROGRAM_JOB 71\r
+#define OWERROR_FUNC_NOT_SUP 72\r
+#define OWERROR_HANDLE_NOT_USED 73\r
+#define OWERROR_FILE_WRITE_ONLY 74\r
+#define OWERROR_HANDLE_NOT_AVAIL 75\r
+#define OWERROR_INVALID_DIRECTORY 76\r
+#define OWERROR_HANDLE_NOT_EXIST 77\r
+#define OWERROR_NONMATCHING_SNUM 78\r
+#define OWERROR_NON_PROGRAM_PARTS 79\r
+#define OWERROR_PROGRAM_WRITE_PROTECT 80\r
+#define OWERROR_FILE_READ_ERR 81\r
+#define OWERROR_ADDFILE_TERMINATED 82\r
+#define OWERROR_READ_MEMORY_PAGE_FAILED 83\r
+#define OWERROR_MATCH_SCRATCHPAD_FAILED 84\r
+#define OWERROR_ERASE_SCRATCHPAD_FAILED 85\r
+#define OWERROR_READ_SCRATCHPAD_FAILED 86\r
+#define OWERROR_SHA_FUNCTION_FAILED 87\r
+#define OWERROR_NO_COMPLETION_BYTE 88\r
+#define OWERROR_WRITE_DATA_PAGE_FAILED 89\r
+#define OWERROR_COPY_SECRET_FAILED 90\r
+#define OWERROR_BIND_SECRET_FAILED 91\r
+#define OWERROR_INSTALL_SECRET_FAILED 92\r
+#define OWERROR_VERIFY_SIG_FAILED 93\r
+#define OWERROR_SIGN_SERVICE_DATA_FAILED 94\r
+#define OWERROR_VERIFY_AUTH_RESPONSE_FAILED 95\r
+#define OWERROR_ANSWER_CHALLENGE_FAILED 96\r
+#define OWERROR_CREATE_CHALLENGE_FAILED 97\r
+#define OWERROR_BAD_SERVICE_DATA 98\r
+#define OWERROR_SERVICE_DATA_NOT_UPDATED 99\r
+#define OWERROR_CATASTROPHIC_SERVICE_FAILURE 100\r
+#define OWERROR_LOAD_FIRST_SECRET_FAILED 101\r
+#define OWERROR_MATCH_SERVICE_SIGNATURE_FAILED 102\r
+#define OWERROR_KEY_OUT_OF_RANGE 103\r
+#define OWERROR_BLOCK_ID_OUT_OF_RANGE 104\r
+#define OWERROR_PASSWORDS_ENABLED 105\r
+#define OWERROR_PASSWORD_INVALID 106\r
+#define OWERROR_NO_READ_ONLY_PASSWORD 107\r
+#define OWERROR_NO_READ_WRITE_PASSWORD 108\r
+#define OWERROR_OW_SHORTED 109\r
+#define OWERROR_ADAPTER_ERROR 110\r
+#define OWERROR_EOP_COPY_SCRATCHPAD_FAILED 111\r
+#define OWERROR_EOP_WRITE_SCRATCHPAD_FAILED 112\r
+#define OWERROR_HYGRO_STOP_MISSION_UNNECESSARY 113\r
+#define OWERROR_HYGRO_STOP_MISSION_ERROR 114\r
+#define OWERROR_PORTNUM_ERROR 115\r
+#define OWERROR_LEVEL_FAILED 116\r
+#define OWERROR_PASSWORD_NOT_SET 117\r
+#define OWERROR_LATCH_NOT_SET 118\r
+#define OWERROR_LIBUSB_OPEN_FAILED 119\r
+#define OWERROR_LIBUSB_DEVICE_ALREADY_OPENED 120\r
+#define OWERROR_LIBUSB_SET_CONFIGURATION_ERROR 121\r
+#define OWERROR_LIBUSB_CLAIM_INTERFACE_ERROR 122\r
+#define OWERROR_LIBUSB_SET_ALTINTERFACE_ERROR 123\r
+#define OWERROR_LIBUSB_NO_ADAPTER_FOUND 124\r
+ \r
+\r
+ // One Wire functions defined in ownetu.c\r
+ SMALLINT owFirst_(int portnum, SMALLINT do_reset, SMALLINT alarm_only);\r
+ SMALLINT owNext_(int portnum, SMALLINT do_reset, SMALLINT alarm_only);\r
+ void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read);\r
+ void owFamilySearchSetup(int portnum, SMALLINT search_family);\r
+ void owSkipFamily(int portnum);\r
+ SMALLINT owAccess(int portnum);\r
+ SMALLINT owVerify(int portnum, SMALLINT alarm_only);\r
+ SMALLINT owOverdriveAccess(int portnum);\r
+\r
+\r
+ // external One Wire functions defined in owsesu.c\r
+ SMALLINT owAcquire(int portnum, char *port_zstr);\r
+ int owAcquireEx(char *port_zstr);\r
+ void owRelease(int portnum);\r
+\r
+ // external One Wire functions defined in findtype.c\r
+ // SMALLINT FindDevices(int,uchar FamilySN[][8],SMALLINT,int);\r
+\r
+ // external One Wire functions from link layer owllu.c\r
+ SMALLINT owTouchReset(int portnum);\r
+ SMALLINT owTouchBit(int portnum, SMALLINT sendbit);\r
+ SMALLINT owTouchByte(int portnum, SMALLINT sendbyte);\r
+ SMALLINT owWriteByte(int portnum, SMALLINT sendbyte);\r
+ SMALLINT owReadByte(int portnum);\r
+ SMALLINT owSpeed(int portnum, SMALLINT new_speed);\r
+ SMALLINT owLevel(int portnum, SMALLINT new_level);\r
+ SMALLINT owProgramPulse(int portnum);\r
+ SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte);\r
+ SMALLINT owReadBytePower(int portnum);\r
+ SMALLINT owHasPowerDelivery(int portnum);\r
+ SMALLINT owHasProgramPulse(int portnum);\r
+ SMALLINT owHasOverDrive(int portnum);\r
+ SMALLINT owReadBitPower(int portnum, SMALLINT applyPowerResponse);\r
+ // external One Wire global from owllu.c\r
+ extern SMALLINT FAMILY_CODE_04_ALARM_TOUCHRESET_COMPLIANCE;\r
+\r
+ // external One Wire functions from transaction layer in owtrnu.c\r
+ SMALLINT owBlock(int portnum, SMALLINT do_reset, uchar *tran_buf, SMALLINT tran_len);\r
+ SMALLINT owReadPacketStd(int portnum, SMALLINT do_access, int start_page, uchar *read_buf);\r
+ SMALLINT owWritePacketStd(int portnum, int start_page, uchar *write_buf,\r
+ SMALLINT write_len, SMALLINT is_eprom, SMALLINT crc_type);\r
+ SMALLINT owProgramByte(int portnum, SMALLINT write_byte, int addr, SMALLINT write_cmd,\r
+ SMALLINT crc_type, SMALLINT do_access);\r
+\r
+ // link functions\r
+ void msDelay(int len);\r
+ long msGettick(void);\r
+\r
+ // ioutil.c functions prototypes\r
+ int EnterString(char *msg, char *buf, int min, int max);\r
+ int EnterNum(char *msg, int numchars, long *value, long min, long max);\r
+ int EnterHex(char *msg, int numchars, ulong *value);\r
+ int ToHex(char ch);\r
+ int getkeystroke(void);\r
+ int key_abort(void);\r
+ void ExitProg(char *msg, int exit_code);\r
+ int getData(uchar *write_buff, int max_len, SMALLINT gethex);\r
+ void PrintHex(uchar* buffer, int cnt);\r
+ void PrintChars(uchar* buffer, int cnt);\r
+ void PrintSerialNum(uchar* buffer);\r
+\r
+ // external functions defined in crcutil.c\r
+ void setcrc16(int portnum, ushort reset);\r
+ ushort docrc16(int portnum, ushort cdata);\r
+ void setcrc8(int portnum, uchar reset);\r
+ uchar docrc8(int portnum, uchar x);\r
+\r
+ extern int owInUse;\r
+\r
+#endif //OWNET_H\r