/*****************************************************
This program was produced by the
CodeWizardAVR V1.25.7 beta 5 Standard
Automatic Program Generator
© Copyright 1998-2007 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 18.03.2008
Author  : traun                           
Company : traun inc                       
Comments: 


Chip type           : ATmega8535
Program type        : Application
Clock frequency     : 1,000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 128
*****************************************************/

#include <mega8535.h>


#include <wh-lcd.h>
#include <delay.h>

#asm
   .equ __w1_port=0x1B ;PORTA
   .equ __w1_bit=0
#endasm
#include <1wire.h>

#include <ds18b20.h> 

#include <stdlib.h>
 
 /* maximum number of DS18B20 connected to the bus */

#define MAX_DEVICES 1       

#define PIN_1W  PORTA.0


unsigned char rom_codes[MAX_DEVICES][9]; 



void Init_ports(void) // Óêàçûâàåì íåîáõîäèìûå ïîðòû êàê âûõîäû
{
DDRD=0b11111111;
DDRC=0b00000111;
DDRA=0b11111111;
PORTA.1=1;

}


   
       char str1[16]="Error";
       char str[]="Dev found";
       
    
      char devices;
 //-----------------------MAIN ---------------------       
void main(void)
{



Init_ports();
lcd_init();



/* detect how many DS18B20 devices
   are connected to the bus and
   store their ROM codes in the rom_codes array */  
        
        #asm("cli"); 
         devices=w1_search(0xf0,rom_codes);   
        #asm("sei");
         
        if (devices>0)  {
        lcd_clear();
        lcd_puts(str);	
        } 
        else 
         lcd_putsxy(5,1,str1);

while (1)
      {
        ftoa(ds18b20_temperature(&rom_codes[0][0]), 1, str1);
        lcd_putsxy(0,1,str1);       
      };
}
