// hlavičkový soubor k ovládání RTC obvodu ds1302

#ifndef ds1302
#define ds1302
#include <avr\io.h>
#include "lcd_h.h"
#include <stdio.h>			//funkce sprintf
#define F_CPU 4000000UL
#include <util\delay.h> 


#define uint unsigned int
#define uchar unsigned char
#define DS1302_RST 2 //pA2
#define DS1302_SDA 1 //pA1
#define DS1302_SCLK 0 //pA0
#define TLL 3
#define TLP 4
#define TLH 2
#define TLD 5
#define PINTL PIND
 

#define Set_DS1302_RST() PORTA|=1<<DS1302_RST		//DS1302_RST=1
#define Clr_DS1302_RST() PORTA&=~(1<<DS1302_RST)	//DS1302_RST=0
#define Set_DS1302_SDA() PORTA|=1<<DS1302_SDA		//DS1302_SDA=1
#define Clr_DS1302_SDA() PORTA&=~(1<<DS1302_SDA)	//DS1302_SDA=0
#define Set_DS1302_SCLK() PORTA|=1<<DS1302_SCLK		//DS1302_SCLK=1
#define Clr_DS1302_SCLK() PORTA&=~(1<<DS1302_SCLK)	//DS1302_SCLK=0
#define Set_DS1302_DDRSDA() DDRA|=1<<DS1302_SDA
#define Clr_DS1302_DDRSDA() DDRA&=~(1<<DS1302_SDA)
#define DS1302_SEC_Reg 0x80
#define DS1302_MIN_Reg 0x82
#define DS1302_HR_Reg 0x84
#define DS1302_DATE_Reg 0x86
#define DS1302_MONTH_Reg 0x88
#define DS1302_DAY_Reg 0x8a
#define DS1302_YEAR_Reg 0x8c
#define DS1302_CONTROL_Reg 0x8e
#define DS1302_CHARGER_Reg 0x90
#define DS1302_CLKBURST_Reg 0xbe

void DS1302_Write(uchar reg,uchar data);
uchar DS1302_Read(uchar reg);
uchar Check_DS1302(void);
void DS1302_Init(void);
void readtime(void);
void setdate(void);
void datedisp(void);
void datedisp(void);
void writedate(void);
char minuty(void);
char hodiny(void);
char mesice(void);
char dny(void);


unsigned char year1, year0,month1,month0,date0,date1,day,hour1,hour0,minute1,minute0,second1,second0,min,hod;



#endif
