Steven Vlach / 1-WireLib
Committer:
svlach
Date:
Tue Nov 30 22:11:18 2010 +0000
Revision:
0:70c3bea805ee
Child:
1:dcf2f8359398

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
svlach 0:70c3bea805ee 1 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 2 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
svlach 0:70c3bea805ee 3 //
svlach 0:70c3bea805ee 4 // Permission is hereby granted, free of charge, to any person obtaining a
svlach 0:70c3bea805ee 5 // copy of this software and associated documentation files (the "Software"),
svlach 0:70c3bea805ee 6 // to deal in the Software without restriction, including without limitation
svlach 0:70c3bea805ee 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
svlach 0:70c3bea805ee 8 // and/or sell copies of the Software, and to permit persons to whom the
svlach 0:70c3bea805ee 9 // Software is furnished to do so, subject to the following conditions:
svlach 0:70c3bea805ee 10 //
svlach 0:70c3bea805ee 11 // The above copyright notice and this permission notice shall be included
svlach 0:70c3bea805ee 12 // in all copies or substantial portions of the Software.
svlach 0:70c3bea805ee 13 //
svlach 0:70c3bea805ee 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
svlach 0:70c3bea805ee 15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
svlach 0:70c3bea805ee 16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
svlach 0:70c3bea805ee 17 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
svlach 0:70c3bea805ee 18 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
svlach 0:70c3bea805ee 19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
svlach 0:70c3bea805ee 20 // OTHER DEALINGS IN THE SOFTWARE.
svlach 0:70c3bea805ee 21 //
svlach 0:70c3bea805ee 22 // Except as contained in this notice, the name of Dallas Semiconductor
svlach 0:70c3bea805ee 23 // shall not be used except as stated in the Dallas Semiconductor
svlach 0:70c3bea805ee 24 // Branding Policy.
svlach 0:70c3bea805ee 25 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 26 //
svlach 0:70c3bea805ee 27 // TODO.C - COM functions required to communicate with the DS2480 based
svlach 0:70c3bea805ee 28 // Universal Serial Adapter 'U'. Fill in the platform specific code.
svlach 0:70c3bea805ee 29 //
svlach 0:70c3bea805ee 30 // Version: 2.00
svlach 0:70c3bea805ee 31 //
svlach 0:70c3bea805ee 32 // History: 1.00 -> 1.01 Added function msDelay.
svlach 0:70c3bea805ee 33 //
svlach 0:70c3bea805ee 34 // 1.01 -> 1.02 Changed to generic OpenCOM/CloseCOM for easier
svlach 0:70c3bea805ee 35 // use with other platforms.
svlach 0:70c3bea805ee 36 //
svlach 0:70c3bea805ee 37 // 1.02 -> 1.03 Removed caps in #includes for Linux capatibility
svlach 0:70c3bea805ee 38 // Add function msGettick()
svlach 0:70c3bea805ee 39 // 1.03 -> 2.00 Changed 'MLan' to 'ow'. Added support for
svlach 0:70c3bea805ee 40 // multiple ports.
svlach 0:70c3bea805ee 41 //
svlach 0:70c3bea805ee 42
svlach 0:70c3bea805ee 43 #include "./Headers/ownet.h"
svlach 0:70c3bea805ee 44 #include "mbed.h"
svlach 0:70c3bea805ee 45 #include <string>
svlach 0:70c3bea805ee 46 using namespace std;
svlach 0:70c3bea805ee 47
svlach 0:70c3bea805ee 48 Serial comport(p9, p10); // tx, rx
svlach 0:70c3bea805ee 49
svlach 0:70c3bea805ee 50
svlach 0:70c3bea805ee 51 // exportable functions required
svlach 0:70c3bea805ee 52 SMALLINT OpenCOM(int,char *);
svlach 0:70c3bea805ee 53 SMALLINT WriteCOM(int,int,uchar *);
svlach 0:70c3bea805ee 54 void FlushCOM(int);
svlach 0:70c3bea805ee 55 int ReadCOM(int,int,uchar *);
svlach 0:70c3bea805ee 56 void BreakCOM(int);
svlach 0:70c3bea805ee 57 void SetBaudCOM(int,int);
svlach 0:70c3bea805ee 58 void CloseCOM(int);
svlach 0:70c3bea805ee 59 long msGettick(void);
svlach 0:70c3bea805ee 60 void msDelay(int);
svlach 0:70c3bea805ee 61 SMALLINT owHasPowerDelivery(int);
svlach 0:70c3bea805ee 62 SMALLINT owHasOverDrive(int);
svlach 0:70c3bea805ee 63 SMALLINT owHasProgramPulse(int);
svlach 0:70c3bea805ee 64 SMALLINT owWriteBytePower(int,SMALLINT);
svlach 0:70c3bea805ee 65 SMALLINT owReadBitPower(int,SMALLINT);
svlach 0:70c3bea805ee 66
svlach 0:70c3bea805ee 67
svlach 0:70c3bea805ee 68 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 69 // Attempt to open a com port. Keep the handle in ComID.
svlach 0:70c3bea805ee 70 // Set the starting baud rate to 9600.
svlach 0:70c3bea805ee 71 //
svlach 0:70c3bea805ee 72 // 'portnum' - number 0 to MAX_PORTNUM-1. This number provided will
svlach 0:70c3bea805ee 73 // be used to indicate the port number desired when calling
svlach 0:70c3bea805ee 74 // all other functions in this library.
svlach 0:70c3bea805ee 75 //
svlach 0:70c3bea805ee 76 // 'port_zstr' - zero terminate port name. For this platform
svlach 0:70c3bea805ee 77 // use format COMX where X is the port number.
svlach 0:70c3bea805ee 78 //
svlach 0:70c3bea805ee 79 //
svlach 0:70c3bea805ee 80 // Returns: TRUE(1) - success, COM port opened
svlach 0:70c3bea805ee 81 // FALSE(0) - failure, could not open specified port
svlach 0:70c3bea805ee 82 //
svlach 0:70c3bea805ee 83 SMALLINT OpenCOM(int portnum, char *port_zstr)
svlach 0:70c3bea805ee 84 {
svlach 0:70c3bea805ee 85 comport.baud( 9600);
svlach 0:70c3bea805ee 86 return 1;
svlach 0:70c3bea805ee 87 }
svlach 0:70c3bea805ee 88
svlach 0:70c3bea805ee 89 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 90 // Attempt to open a com port. Keep the handle in ComID.
svlach 0:70c3bea805ee 91 // Set the starting baud rate to 9600.
svlach 0:70c3bea805ee 92 //
svlach 0:70c3bea805ee 93 // 'portnum' - number 0 to MAX_PORTNUM-1. This number provided will
svlach 0:70c3bea805ee 94 // be used to indicate the port number desired when calling
svlach 0:70c3bea805ee 95 // all other functions in this library.
svlach 0:70c3bea805ee 96 //
svlach 0:70c3bea805ee 97 //
svlach 0:70c3bea805ee 98 // Returns: the port number if it was successful otherwise -1
svlach 0:70c3bea805ee 99 //
svlach 0:70c3bea805ee 100 int OpenCOMEx(char *port_zstr)
svlach 0:70c3bea805ee 101 {
svlach 0:70c3bea805ee 102 int portnum = -1;
svlach 0:70c3bea805ee 103
svlach 0:70c3bea805ee 104 if ( port_zstr[0] == '0')
svlach 0:70c3bea805ee 105 {
svlach 0:70c3bea805ee 106 portnum = 0;
svlach 0:70c3bea805ee 107 }
svlach 0:70c3bea805ee 108
svlach 0:70c3bea805ee 109 if ( port_zstr[0] == '1')
svlach 0:70c3bea805ee 110 {
svlach 0:70c3bea805ee 111 portnum = 1;
svlach 0:70c3bea805ee 112 }
svlach 0:70c3bea805ee 113
svlach 0:70c3bea805ee 114 if(!OpenCOM(portnum, port_zstr))
svlach 0:70c3bea805ee 115 {
svlach 0:70c3bea805ee 116 return -1;
svlach 0:70c3bea805ee 117 }
svlach 0:70c3bea805ee 118
svlach 0:70c3bea805ee 119 return portnum;
svlach 0:70c3bea805ee 120 }
svlach 0:70c3bea805ee 121
svlach 0:70c3bea805ee 122 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 123 // Closes the connection to the port.
svlach 0:70c3bea805ee 124 //
svlach 0:70c3bea805ee 125 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 126 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 127 //
svlach 0:70c3bea805ee 128 void CloseCOM(int portnum)
svlach 0:70c3bea805ee 129 {
svlach 0:70c3bea805ee 130 // add platform specific code here - Done
svlach 0:70c3bea805ee 131 }
svlach 0:70c3bea805ee 132
svlach 0:70c3bea805ee 133 //---------------------------------------------------------------------------
svlach 0:70c3bea805ee 134 // Flush the rx and tx buffers
svlach 0:70c3bea805ee 135 //
svlach 0:70c3bea805ee 136 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 137 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 138 //
svlach 0:70c3bea805ee 139 void FlushCOM(int portnum)
svlach 0:70c3bea805ee 140 {
svlach 0:70c3bea805ee 141 // add platform specific code here - Done
svlach 0:70c3bea805ee 142 while( comport.readable() )
svlach 0:70c3bea805ee 143 {
svlach 0:70c3bea805ee 144 comport.getc();
svlach 0:70c3bea805ee 145 }
svlach 0:70c3bea805ee 146 }
svlach 0:70c3bea805ee 147
svlach 0:70c3bea805ee 148 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 149 // Write an array of bytes to the COM port, verify that it was
svlach 0:70c3bea805ee 150 // sent out. Assume that baud rate has been set.
svlach 0:70c3bea805ee 151 //
svlach 0:70c3bea805ee 152 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 153 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 154 // 'outlen' - number of bytes to write to COM port
svlach 0:70c3bea805ee 155 // 'outbuf' - pointer ot an array of bytes to write
svlach 0:70c3bea805ee 156 //
svlach 0:70c3bea805ee 157 // Returns: TRUE(1) - success
svlach 0:70c3bea805ee 158 // FALSE(0) - failure
svlach 0:70c3bea805ee 159 //
svlach 0:70c3bea805ee 160 SMALLINT WriteCOM(int portnum, int outlen, uchar *outbuf)
svlach 0:70c3bea805ee 161 {
svlach 0:70c3bea805ee 162 // add platform specific code here - Done
svlach 0:70c3bea805ee 163 for ( int x=0; x < outlen; x++ )
svlach 0:70c3bea805ee 164 {
svlach 0:70c3bea805ee 165 comport.putc( outbuf[x]);
svlach 0:70c3bea805ee 166 }
svlach 0:70c3bea805ee 167
svlach 0:70c3bea805ee 168 while ( (LPC_UART3->LSR & 0x40) == 0 );
svlach 0:70c3bea805ee 169 {
svlach 0:70c3bea805ee 170 }
svlach 0:70c3bea805ee 171
svlach 0:70c3bea805ee 172 /*
svlach 0:70c3bea805ee 173 printf ("\r\n Sent Data: ");
svlach 0:70c3bea805ee 174 for ( int x=0; x < outlen; x++ )
svlach 0:70c3bea805ee 175 {
svlach 0:70c3bea805ee 176 printf ( " %X ", outbuf[x] );
svlach 0:70c3bea805ee 177 }
svlach 0:70c3bea805ee 178 printf ("\r\n");
svlach 0:70c3bea805ee 179 */
svlach 0:70c3bea805ee 180 return 1;
svlach 0:70c3bea805ee 181 }
svlach 0:70c3bea805ee 182
svlach 0:70c3bea805ee 183 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 184 // Read an array of bytes from the COM port, verify that it was
svlach 0:70c3bea805ee 185 // received. Assume that baud rate has been set.
svlach 0:70c3bea805ee 186 //
svlach 0:70c3bea805ee 187 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 188 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 189 // 'inlen' - number of bytes to read from COM port
svlach 0:70c3bea805ee 190 // 'inbuf' - pointer to a buffer to hold the incoming bytes
svlach 0:70c3bea805ee 191 //
svlach 0:70c3bea805ee 192 // Returns: number of characters read
svlach 0:70c3bea805ee 193 //
svlach 0:70c3bea805ee 194 int ReadCOM(int portnum, int inlen, unsigned char *inbuf)
svlach 0:70c3bea805ee 195 {
svlach 0:70c3bea805ee 196 // add platform specific code here - Done
svlach 0:70c3bea805ee 197 string buffer ("");
svlach 0:70c3bea805ee 198 Timer t;
svlach 0:70c3bea805ee 199 int numchar = 0;
svlach 0:70c3bea805ee 200
svlach 0:70c3bea805ee 201 t.start(); // Start timeout timer
svlach 0:70c3bea805ee 202
svlach 0:70c3bea805ee 203 while ( t.read_ms() < 1000 ) // If we haven't timed out....
svlach 0:70c3bea805ee 204 {
svlach 0:70c3bea805ee 205 if ( comport.readable() )
svlach 0:70c3bea805ee 206 {
svlach 0:70c3bea805ee 207 int read = comport.getc();
svlach 0:70c3bea805ee 208
svlach 0:70c3bea805ee 209 buffer += read;
svlach 0:70c3bea805ee 210 numchar++;
svlach 0:70c3bea805ee 211 t.reset();
svlach 0:70c3bea805ee 212 }
svlach 0:70c3bea805ee 213
svlach 0:70c3bea805ee 214 if (numchar == inlen)
svlach 0:70c3bea805ee 215 {
svlach 0:70c3bea805ee 216 break;
svlach 0:70c3bea805ee 217 }
svlach 0:70c3bea805ee 218 }
svlach 0:70c3bea805ee 219
svlach 0:70c3bea805ee 220 buffer.copy( (char*)inbuf, numchar );
svlach 0:70c3bea805ee 221 /*
svlach 0:70c3bea805ee 222 printf ("\r\n Received Data: ");
svlach 0:70c3bea805ee 223 for ( int x=0; x < numchar; x++ )
svlach 0:70c3bea805ee 224 {
svlach 0:70c3bea805ee 225 printf ( " %X ", inbuf[x] );
svlach 0:70c3bea805ee 226 }
svlach 0:70c3bea805ee 227 printf ("\r\n");
svlach 0:70c3bea805ee 228 */
svlach 0:70c3bea805ee 229 return numchar;
svlach 0:70c3bea805ee 230 }
svlach 0:70c3bea805ee 231
svlach 0:70c3bea805ee 232
svlach 0:70c3bea805ee 233 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 234 // Send a break on the com port for at least 2 ms
svlach 0:70c3bea805ee 235 //
svlach 0:70c3bea805ee 236 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 237 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 238 //
svlach 0:70c3bea805ee 239 void BreakCOM(int portnum)
svlach 0:70c3bea805ee 240 {
svlach 0:70c3bea805ee 241 // add platform specific code here - Done
svlach 0:70c3bea805ee 242 int time_BREAK = 2;
svlach 0:70c3bea805ee 243
svlach 0:70c3bea805ee 244 // BREAK
svlach 0:70c3bea805ee 245 LPC_UART3->LCR |= 0x40;
svlach 0:70c3bea805ee 246 wait_ms( time_BREAK);
svlach 0:70c3bea805ee 247
svlach 0:70c3bea805ee 248 // MARK AFTER BREAK
svlach 0:70c3bea805ee 249 LPC_UART3->LCR &= ~(0x40);
svlach 0:70c3bea805ee 250 }
svlach 0:70c3bea805ee 251
svlach 0:70c3bea805ee 252 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 253 // Set the baud rate on the com port.
svlach 0:70c3bea805ee 254 //
svlach 0:70c3bea805ee 255 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 256 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 257 // 'new_baud' - new baud rate defined as
svlach 0:70c3bea805ee 258 // PARMSET_9600 0x00
svlach 0:70c3bea805ee 259 // PARMSET_19200 0x02
svlach 0:70c3bea805ee 260 // PARMSET_57600 0x04
svlach 0:70c3bea805ee 261 // PARMSET_115200 0x06
svlach 0:70c3bea805ee 262 //
svlach 0:70c3bea805ee 263 void SetBaudCOM(int portnum, int new_baud)
svlach 0:70c3bea805ee 264 {
svlach 0:70c3bea805ee 265 // add platform specific code here
svlach 0:70c3bea805ee 266 }
svlach 0:70c3bea805ee 267
svlach 0:70c3bea805ee 268 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 269 // Description:
svlach 0:70c3bea805ee 270 // Delay for at least 'len' ms
svlach 0:70c3bea805ee 271 //
svlach 0:70c3bea805ee 272 void msDelay(int len)
svlach 0:70c3bea805ee 273 {
svlach 0:70c3bea805ee 274 // add platform specific code here
svlach 0:70c3bea805ee 275 wait_ms( len );
svlach 0:70c3bea805ee 276 }
svlach 0:70c3bea805ee 277
svlach 0:70c3bea805ee 278 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 279 // Get the current millisecond tick count. Does not have to represent
svlach 0:70c3bea805ee 280 // an actual time, it just needs to be an incrementing timer.
svlach 0:70c3bea805ee 281 //
svlach 0:70c3bea805ee 282 long msGettick(void)
svlach 0:70c3bea805ee 283 {
svlach 0:70c3bea805ee 284 // add platform specific code here
svlach 0:70c3bea805ee 285 return 0;
svlach 0:70c3bea805ee 286 }
svlach 0:70c3bea805ee 287
svlach 0:70c3bea805ee 288 /*
svlach 0:70c3bea805ee 289 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 290 // This procedure indicates wether the adapter can deliver power.
svlach 0:70c3bea805ee 291 //
svlach 0:70c3bea805ee 292 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 293 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 294 //
svlach 0:70c3bea805ee 295 // Returns: TRUE if adapter is capable of delivering power.
svlach 0:70c3bea805ee 296 //
svlach 0:70c3bea805ee 297 SMALLINT owHasPowerDelivery(int portnum)
svlach 0:70c3bea805ee 298 {
svlach 0:70c3bea805ee 299 // add adapter specific code here
svlach 0:70c3bea805ee 300 return TRUE;
svlach 0:70c3bea805ee 301 }
svlach 0:70c3bea805ee 302
svlach 0:70c3bea805ee 303 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 304 // This procedure indicates wether the adapter can deliver power.
svlach 0:70c3bea805ee 305 //
svlach 0:70c3bea805ee 306 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 307 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 308 //
svlach 0:70c3bea805ee 309 // Returns: TRUE if adapter is capable of over drive.
svlach 0:70c3bea805ee 310 //
svlach 0:70c3bea805ee 311 SMALLINT owHasOverDrive(int portnum)
svlach 0:70c3bea805ee 312 {
svlach 0:70c3bea805ee 313 // add adapter specific code here
svlach 0:70c3bea805ee 314 return TRUE;
svlach 0:70c3bea805ee 315 }
svlach 0:70c3bea805ee 316 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 317 // This procedure creates a fixed 480 microseconds 12 volt pulse
svlach 0:70c3bea805ee 318 // on the 1-Wire Net for programming EPROM iButtons.
svlach 0:70c3bea805ee 319 //
svlach 0:70c3bea805ee 320 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 321 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 322 //
svlach 0:70c3bea805ee 323 // Returns: TRUE program volatage available
svlach 0:70c3bea805ee 324 // FALSE program voltage not available
svlach 0:70c3bea805ee 325 SMALLINT owHasProgramPulse(int portnum)
svlach 0:70c3bea805ee 326 {
svlach 0:70c3bea805ee 327 // add adapter specific code here
svlach 0:70c3bea805ee 328 return TRUE;
svlach 0:70c3bea805ee 329 }
svlach 0:70c3bea805ee 330 */
svlach 0:70c3bea805ee 331 /*
svlach 0:70c3bea805ee 332 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 333 // Send 8 bits of communication to the 1-Wire Net and verify that the
svlach 0:70c3bea805ee 334 // 8 bits read from the 1-Wire Net is the same (write operation).
svlach 0:70c3bea805ee 335 // The parameter 'sendbyte' least significant 8 bits are used. After the
svlach 0:70c3bea805ee 336 // 8 bits are sent change the level of the 1-Wire net.
svlach 0:70c3bea805ee 337 //
svlach 0:70c3bea805ee 338 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 339 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 340 // 'sendbyte' - 8 bits to send (least significant byte)
svlach 0:70c3bea805ee 341 //
svlach 0:70c3bea805ee 342 // Returns: TRUE: bytes written and echo was the same
svlach 0:70c3bea805ee 343 // FALSE: echo was not the same
svlach 0:70c3bea805ee 344 //
svlach 0:70c3bea805ee 345 SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte)
svlach 0:70c3bea805ee 346 {
svlach 0:70c3bea805ee 347 // replace if platform has better implementation (faster response)
svlach 0:70c3bea805ee 348 if (!hasPowerDelivery(portnum))
svlach 0:70c3bea805ee 349 return FALSE;
svlach 0:70c3bea805ee 350
svlach 0:70c3bea805ee 351 if(owTouchByte(portnum,sendbyte) != sendbyte)
svlach 0:70c3bea805ee 352 return FALSE;
svlach 0:70c3bea805ee 353
svlach 0:70c3bea805ee 354 if(owLevel(portnum,MODE_STRONG5) != MODE_STRONG5)
svlach 0:70c3bea805ee 355 return FALSE;
svlach 0:70c3bea805ee 356
svlach 0:70c3bea805ee 357 return TRUE;
svlach 0:70c3bea805ee 358 }
svlach 0:70c3bea805ee 359 */
svlach 0:70c3bea805ee 360 /*
svlach 0:70c3bea805ee 361 //--------------------------------------------------------------------------
svlach 0:70c3bea805ee 362 // Send 1 bit of communication to the 1-Wire Net and verify that the
svlach 0:70c3bea805ee 363 // response matches the 'applyPowerResponse' bit and apply power delivery
svlach 0:70c3bea805ee 364 // to the 1-Wire net. Note that some implementations may apply the power
svlach 0:70c3bea805ee 365 // first and then turn it off if the response is incorrect.
svlach 0:70c3bea805ee 366 //
svlach 0:70c3bea805ee 367 // 'portnum' - number 0 to MAX_PORTNUM-1. This number was provided to
svlach 0:70c3bea805ee 368 // OpenCOM to indicate the port number.
svlach 0:70c3bea805ee 369 // 'applyPowerResponse' - 1 bit response to check, if correct then start
svlach 0:70c3bea805ee 370 // power delivery
svlach 0:70c3bea805ee 371 //
svlach 0:70c3bea805ee 372 // Returns: TRUE: bit written and response correct, strong pullup now on
svlach 0:70c3bea805ee 373 // FALSE: response incorrect
svlach 0:70c3bea805ee 374 //
svlach 0:70c3bea805ee 375 SMALLINT owReadBitPower(int portnum, SMALLINT applyPowerResponse)
svlach 0:70c3bea805ee 376 {
svlach 0:70c3bea805ee 377 // replace if platform has better implementation (faster response)
svlach 0:70c3bea805ee 378 if (!hasPowerDelivery(portnum))
svlach 0:70c3bea805ee 379 return FALSE;
svlach 0:70c3bea805ee 380
svlach 0:70c3bea805ee 381 if(owTouchBit(portnum,0x01) != applyPowerResponse)
svlach 0:70c3bea805ee 382 return FALSE;
svlach 0:70c3bea805ee 383
svlach 0:70c3bea805ee 384 if(owLevel(portnum,MODE_STRONG5) != MODE_STRONG5)
svlach 0:70c3bea805ee 385 return FALSE;
svlach 0:70c3bea805ee 386
svlach 0:70c3bea805ee 387 return TRUE;
svlach 0:70c3bea805ee 388 }
svlach 0:70c3bea805ee 389 */