1 //---------------------------------------------------------------------------
2 // Copyright (C) 1999 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 //  DS520SES.C - Acquire and release a Session for general 1-Wire Net
28 //              library
29 //
30 //  Version: 2.00
31 //           1.03 -> 2.00  Changed 'MLan' to 'ow'. Added support for
32 //                         multiple ports.
33 //
34 
35 #include "ownet.h"
36 #include <ds8xc520.h>
37 
38 // Port for 1Wire communication.  Defaults here, but defined in Makefile also
39 // WARNING: See appnote ??? to select an appropriate port pin and
40 //          allow for appropriate protection of the pin.
41 // If this is changed, also change in link file
42 #ifndef OW_PORT
43 #define OW_PORT INT2
44 #endif
45 
46 // defined in link file
47 extern void usDelay(int);
48 
49 // local function prototypes
50 SMALLINT owAcquire(int,char *);
51 void     owRelease(int);
52 
53 //---------------------------------------------------------------------------
54 // Attempt to acquire a 1-Wire net
55 //
56 // 'portnum'    - number 0 to MAX_PORTNUM-1.  This number is provided to
57 //                indicate the symbolic port number.
58 // 'port_zstr'  - zero terminated port name.
59 //
60 // Returns: TRUE - success, port opened
61 //
owAcquire(int portnum,char * port_zstr)62 SMALLINT owAcquire(int portnum, char *port_zstr)
63 {
64    port_zstr = 0;
65    portnum = 0;
66 
67    OW_PORT = 1; // drive bus high.
68    usDelay(500); // give time for line to settle
69 
70    // checks to make sure the line is idling high.
71    return (OW_PORT==1?TRUE:FALSE);
72 }
73 
74 //---------------------------------------------------------------------------
75 // Release the previously acquired a 1-Wire net.
76 //
77 // 'portnum'    - number 0 to MAX_PORTNUM-1.  This number is provided to
78 //                indicate the symbolic port number.
79 //
owRelease(int portnum)80 void owRelease(int portnum)
81 {
82    portnum = 0;
83 }
84 
85 
86