/*
  OWImain.h
*/
#ifndef _OWI_MAIN_H_
#define _OWI_MAIN_H_

/*****************************************************************************
 User defines
*****************************************************************************/
                                    // Port conf registers for 1-Wire buses.
                                    // all three registers to the same port !!
#ifdef A_GMESS_TEST                                    
#define     OWI_PORT        PORTD   // 1-Wire PORT Data register.
#define     OWI_PIN         PIND    // 1-Wire Input pin register.
#define     OWI_DDR         DDRD    // 1-Wire Data direction register.
#endif

#ifdef A_GMESS                                    
#define     OWI_PORT        PORTC   // 1-Wire PORT Data register.
#define     OWI_PIN         PINC    // 1-Wire Input pin register.
#define     OWI_DDR         DDRC    // 1-Wire Data direction register.
#endif

#ifdef A_MASTER
#define     OWI_PORT        PORTC   // 1-Wire PORT Data register.
#define     OWI_PIN         PINC    // 1-Wire Input pin register.
#define     OWI_DDR         DDRC    // 1-Wire Data direction register.
#endif

#ifdef A_TEST168
#define     OWI_PORT        PORTC   // 1-Wire PORT Data register.
#define     OWI_PIN         PINC    // 1-Wire Input pin register.
#define     OWI_DDR         DDRC    // 1-Wire Data direction register.
#endif


// flag definitionen

#define DS_INIT_OK        0x80
#define DS_TEMP_S1        0x01
#define DS_TEMP_DA        0x02
#define DS_CRC_DATA_ERROR 0x20
#define DS_NICHT_DA       0x40    

typedef struct
{
   unsigned char busbit;
   unsigned char kennung;         // 0xff = kein termometer
   unsigned char flag;            // siehe Bit Definitionen
   char korrektur;                // korrektur wert 
   int tempwert; 
   unsigned char sim_eeprom[8];   // serial number
   unsigned char mdata[9];        // messdaten dazu
} DALLAS;


void OWI_Init( DALLAS *pdallas , unsigned char bit, char korr_wert );
void DS1820_ReadTempStep1( DALLAS *pdallas ); 
void DS1820_ReadTempStep2( DALLAS *pdallas ); 
void edit_temperatur( DALLAS *pdallas, char *ziel);

#endif
