7da3687c561f1ce7bb247e817feebef926b52b13
[fw/sdcc] / device / examples / ds390 / ow390 / ownet.h
1 //---------------------------------------------------------------------------
2 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
18 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
21 //
22 // Except as contained in this notice, the name of Dallas Semiconductor
23 // shall not be used except as stated in the Dallas Semiconductor
24 // Branding Policy.
25 //---------------------------------------------------------------------------
26 //
27 // ownet.h - Include file for 1-Wire Net library
28 //
29 // Version: 2.00
30 //
31 // History: 1.02 -> 1.03 Make sure uchar is not defined twice.
32 //          1.03 -> 2.00  Changed 'MLan' to 'ow'.
33 //
34
35 // Typedefs
36 #ifndef OW_UCHAR
37 #define OW_UCHAR
38    typedef unsigned char  uchar;
39    typedef unsigned int ushort;
40    typedef unsigned long ulong;
41 #endif
42
43 // general defines
44 #define WRITE_FUNCTION 1
45 #define READ_FUNCTION  0
46
47 // error codes
48 #define READ_ERROR    -1
49 #define INVALID_DIR   -2
50 #define NO_FILE       -3
51 #define WRITE_ERROR   -4
52 #define WRONG_TYPE    -5
53 #define FILE_TOO_BIG  -6
54
55 // Misc
56 #define FALSE          0
57 #define TRUE           1
58 #define MAX_PORTNUM    16
59
60 // mode bit flags
61 #define MODE_NORMAL                    0x00
62 #define MODE_OVERDRIVE                 0x01
63 #define MODE_STRONG5                   0x02
64 #define MODE_PROGRAM                   0x04
65 #define MODE_BREAK                     0x08
66
67 // family codes of devices
68 #define DIR_FAMILY 0x01
69 #define TEMP_FAMILY 0x10
70 #define NVRAM64K_FAMILY 0x0c
71 #define SWITCH_FAMILY 0x12
72 #define COUNT_FAMILY 0x1D
73 #define ATOD_FAMILY 0X20
74 #define THERMO_FAM 0x21
75 #define SBATTERY_FAM  0x26
76 // this is weird, the DS2502 should be 0x09
77 #define DS2502_FAMILY 0x89
78
79 // tinilnk.c
80 extern void FlushCOM(int);
81 extern int  WriteCOM(int,int,uchar*);
82 extern int  ReadCOM(int,int,uchar*);
83 extern void BreakCOM(int);
84 extern void SetBaudCOM(int,int);
85 extern void msDelay(int);
86 extern long msGettick(void);
87 extern int OpenCOM(int,char *);
88 extern void CloseCOM(int);
89
90 // ownetu.c
91 extern int  owFirst(int,int,int);
92 extern int  owNext(int,int,int);
93 extern void owSerialNum(int,uchar *, int);
94 extern void owFamilySearchSetup(int,int);
95 extern void owSkipFamily(int);
96 extern int  owAccess(int);
97 extern int  owVerify(int,int);
98 extern int  owOverdriveAccess(int);
99 extern int bitacc(int,int,int,uchar *);
100 extern uchar SerialNum[MAX_PORTNUM][8];
101
102 // owtrnu.c
103 extern int owBlock(int,int,uchar *,int);
104 extern int owReadPacketStd(int,int,int,uchar *);
105 extern int owWritePacketStd(int,int,uchar *,int,int,int);
106 extern int owProgramByte(int,int,int,int,int,int);
107
108 // crcutil.c
109 extern void setcrc16(int,ushort);
110 extern ushort docrc16(int,ushort);
111 extern void setcrc8(int,uchar);
112 extern uchar docrc8(int,uchar);
113
114 // owllu.c
115 extern int owTouchReset(int);
116 extern int owTouchByte(int, int);
117 extern int owWriteByte(int,int);
118 extern int owReadByte(int);
119 extern int owSpeed(int,int);
120 extern int owLevel(int,int);
121 extern int owProgramPulse(int);
122
123 // owlli for the internal (TINI) ow bus
124 extern uchar iowTouchReset(void);
125 extern uchar iowReadByte(void);
126 extern uchar iowWriteByte(uchar);
127 extern uchar iowBlock(uchar, uchar*, uchar);
128 extern uchar iowFirst(uchar do_reset, uchar alarm_only);
129 extern uchar iowNext(uchar do_reset, uchar alarm_only);
130 extern uchar iowSpeed(int speed);
131 extern uchar iowLevel(int level);
132 extern uchar iowProgramPulse(void);
133 extern void iowSerialNum(uchar *, uchar);
134
135 // owsesu.c
136 extern int  owAcquire(int,char *, char *);
137 //extern int  owAcquire(int,char *);
138 extern void owRelease(int, char *);
139 //extern void owRelease(int);
140
141 // findtype.c
142 extern int FindDevices(int, uchar FamilySN[][8], int, int);
143
144 // offile.c
145 int owReadFile(int,uchar *,uchar *);
146 int owFormatWriteFile(int,uchar *, int, uchar *);
147
148 // sdcc has no exit
149 #define exit return
150 // sdcc has no double
151 #define double float
152 // sdcc has no key_abort
153 #define key_abort Serial0CharArrived