//hlavičkový soubor pro knihovnu ovládání modulu RFM12B
#ifndef rfm
#define rfm
#include <stdio.h> 			// pro funkci sprintf(xx);
#include <stdlib.h> 			// pro aritmetické fce;
#include "lcd_jednorad_h.h"
#include "ds18b20.h"

#define NIRQ 1
#define MOSI 3
#define SCK 5

#define MISO 4
#define SS 2
#define FFIT 0
#define DDR_SPI DDRB
#define PORT_SPI PORTB
#define PIN_SPI PINB
#define WAIT_NIRQ_LOW() while(PIN_SPI & _BV(NIRQ)) 
#define wait_spi_complete() while(!(SPSR & _BV(SPIF))); SPSR |= ~(_BV(SPIF))

#define PORT_PER PORTC			// port periferií (tl,senzor,VDO)
#define DDR_PER DDRC			// ddr periferií (tl,senzor,VDO)
#define PIN_PER PINC			// pin periferií (tl,senzor,VDO)
#define TLL 2					// levé tlač.
#define TLP 1					// pravé tlač.


#define TLL_STISK		if(bit_is_clear(PIN_PER,TLL))
#define TLP_STISK		if(bit_is_clear(PIN_PER,TLP))
#define RELE0_ON 		PORT_PER|=_BV(4);
#define RELE0_OFF 		PORT_PER&=~(_BV(4));
#define RELE1_ON 		PORT_PER|=_BV(5);
#define RELE1_OFF 		PORT_PER&=~(_BV(5));


unsigned int rf_writecmd(unsigned int cmd);
void rf_init(void);
void rf_send(unsigned char data);
void spi_init(void);
void rf_sleep(void);
void rf_receiver(void);
void rf_transmitter(void);
void rf_fifo_reset(void);
void rf_head(void);
void rf_end(void);
unsigned char rf_read(void);
void zprava(char *znaky);
void precist(char *kam);
void zprava4(char *znaky);
void process(void);
void compare(char *msg);
void tep_disp(void);


extern char teplota,rel0,rel1,warning,minuty,hodiny,ID2[2],par,tl2;
char minuty0;
#endif 
