//--------------------------------------------------------------------------- // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // // Except as contained in this notice, the name of Dallas Semiconductor // shall not be used except as stated in the Dallas Semiconductor // Branding Policy. //-------------------------------------------------------------------------- // // ad26.c - Reads the voltage on the 1-Wire // version 1.00 // // Include Files #include #include "ownet.h" #include "ad26.h" extern int owBlock(int,int,uchar *,int); extern void setcrc8(int,uchar); extern uchar docrc8(int,uchar); extern int owReadByte(int); extern int owWriteByte(int,int); extern void output_status(int, char *); extern void msDelay(int); extern void owSerialNum(int,uchar *,int); extern int owAccess(int); int Volt_AD(int portnum, int vdd, uchar *); float Volt_Reading(int portnum, int vdd, uchar *); double Get_Temperature(int portnum,uchar *); int Volt_AD(int portnum, int vdd, uchar *SNum) { uchar send_block[50]; uchar test; int send_cnt=0; int i; ushort lastcrc8; int busybyte; owSerialNum(portnum,SNum,FALSE); // Recall the Status/Configuration page // Recall command send_block[send_cnt++] = 0xB8; // Page to Recall send_block[send_cnt++] = 0x00; if(!owBlock(portnum,FALSE,send_block,send_cnt)) return FALSE; send_cnt = 0; if(owAccess(portnum)) { // Read the Status/Configuration byte // Read scratchpad command send_block[send_cnt++] = 0xBE; // Page for the Status/Configuration byte send_block[send_cnt++] = 0x00; for(i=0;i<9;i++) send_block[send_cnt++] = 0xFF; if(owBlock(portnum,FALSE,send_block,send_cnt)) { setcrc8(portnum,0); for(i=2;i> 3) * 0.03125; }//Access return ret; }