96b4ef02b1a0ae7ee526d0be816ea83449ceb5d7
[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 SWITCH_FAMILY 0x12
71 #define COUNT_FAMILY 0x1D
72 #define ATOD_FAMILY 0X20
73 #define THERMO_FAM 0x21
74 // this is weird, the DS2502 should be 0x09
75 #define DS2502_FAMILY 0x89
76
77 // tinilnk.c
78 extern void FlushCOM(int);
79 extern int  WriteCOM(int,int,uchar*);
80 extern int  ReadCOM(int,int,uchar*);
81 extern void BreakCOM(int);
82 extern void SetBaudCOM(int,int);
83 extern void msDelay(int);
84 extern long msGettick(void);
85 extern int OpenCOM(int,char *);
86 extern void CloseCOM(int);
87
88 // ownetu.c
89 extern int  owFirst(int,int,int);
90 extern int  owNext(int,int,int);
91 extern void owSerialNum(int,uchar *, int);
92 extern void owFamilySearchSetup(int,int);
93 extern void owSkipFamily(int);
94 extern int  owAccess(int);
95 extern int  owVerify(int,int);
96 extern int  owOverdriveAccess(int);
97 extern int bitacc(int,int,int,uchar *);
98 extern uchar SerialNum[MAX_PORTNUM][8];
99
100 // owtrnu.c
101 extern int owBlock(int,int,uchar *,int);
102 extern int owReadPacketStd(int,int,int,uchar *);
103 extern int owWritePacketStd(int,int,uchar *,int,int,int);   
104 extern int owProgramByte(int,int,int,int,int,int);
105
106 // crcutil.c
107 extern void setcrc16(int,ushort);
108 extern ushort docrc16(int,ushort);
109 extern void setcrc8(int,uchar);
110 extern uchar docrc8(int,uchar);
111
112 // owllu.c
113 extern int owTouchReset(int);
114 extern int owTouchByte(int, int);
115 extern int owWriteByte(int,int);
116 extern int owReadByte(int);
117 extern int owSpeed(int,int);
118 extern int owLevel(int,int);
119 extern int owProgramPulse(int);
120
121 // owlli for the internal (TINI) ow bus
122 extern uchar iowTouchReset(void);
123 extern uchar iowReadByte(void);
124 extern uchar iowWriteByte(uchar);
125 extern uchar iowBlock(uchar, uchar*, uchar);
126 extern uchar iowFirst(uchar do_reset, uchar alarm_only);
127 extern uchar iowNext(uchar do_reset, uchar alarm_only);
128 extern uchar iowSpeed(int speed);
129 extern uchar iowLevel(int level);
130 extern uchar iowProgramPulse(void);
131 extern void iowSerialNum(uchar *, uchar);
132
133 // owsesu.c
134 extern int  owAcquire(int,char *, char *);
135 //extern int  owAcquire(int,char *);
136 extern void owRelease(int, char *);
137 //extern void owRelease(int);
138
139 // findtype.c
140 extern int FindDevices(int, uchar FamilySN[][8], int, int); 
141
142 // offile.c
143 int owReadFile(int,uchar *,uchar *);
144 int owFormatWriteFile(int,uchar *, int, uchar *);
145
146 // sdcc has no exit
147 #define exit return
148 // sdcc has no double
149 #define double float
150 // sdcc has no key_abort
151 #define key_abort Serial0CharArrived