/********************************************************************
* FileName:        Transceiver.h
* Company:         KRALICEK
*
*
* Author Martin Kralicek				Date 8/4/2010        Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
********************************************************************/

//	Define
//==============================================================
#define TRUE  1
#define FALSE 0

//-------------------------------------------------------------

#define SPI_ins 		PORTB									//definice portu s transceiverem
#define SCK				7										//definice SCK pinu
#define MDO				5										//definice MDO pinu
#define CS				4										//definice CS pinu
#define LED				1										//definice LED pinu
#define SPI_int 		PINB									//definice prijimaciho registru
#define MDI				6										//definice MDI pinu
#define IRQ				0										//definice IRQ pinu
#define INT				2										//definice INT pinu

//-------------------------------------------------------------

#define SCK_1			SPI_ins |=_BV(SCK)						//definice nastaveni SCK high
#define SCK_0			SPI_ins &=~(_BV(SCK))					//definice nastaveni SCK low
#define MDO_1			SPI_ins |=_BV(MDO)						//definice nastaveni MDO high
#define MDO_0			SPI_ins &=~(_BV(MDO))					//definice nastaveni MDO low
#define CS_1			SPI_ins |=_BV(CS)						//definice nastaveni CS high
#define CS_0			SPI_ins &=~(_BV(CS))					//definice nastaveni CS low
#define LED_1			SPI_ins |=_BV(LED)						//definice nastaveni LED high
#define LED_0			SPI_ins &=~(_BV(LED))					//definice nastaveni LED low
#define REC_on			GICR	|=_BV(INT2)						//definice aktivace INT2
#define REC_off			GICR	&=~(_BV(INT2))					//definice deaktivace INT2

//==============================================================


// Declaration
//==============================================================
void Init_Transceiver(void);
void Start_SPI(void);
void Start_SPI_soft(void);
void Start_Inter(void);
void Init_RF(void);
void Low_power(void);
void FIFO_reset(void);
void receive_mode(void);
void transmit_mode(void);
void rf_sleep(void);
void Clr_VDI(void);
unsigned int Write_cmd(unsigned int cmd);
void Send_paket(void);
void Receiv_paket(void);
void Send_data(unsigned char *buffer, unsigned char size);
void Receiv_data(unsigned char *buffer, unsigned char size);

void delay(unsigned int cas);

//-------------------------------------------------------------



//==============================================================


// Define structure
//==============================================================
typedef struct 													//struktura paketu pro vysilani a prijem
{
    unsigned char   Adr_TX;           
    unsigned char   Adr_RX;           
    unsigned char   Paket_setting;    
    unsigned char   Reserved;         
    unsigned char   Data_buf[11];     
    unsigned char   CRC;              
}N_ROTE_paket;
  
