#include "DSP2833x_Device.h"     // DSP281x Headerfile Include File

extern int Mode,Desk,TermoAD,TermoRS,TermoSW,Kurrent,Kalibro;

void setup_leds_line(void);

#define led1_toggle()	GpioDataRegs.GPBTOGGLE.bit.GPIO32=1
#define led2_toggle()	GpioDataRegs.GPBTOGGLE.bit.GPIO48=1
#define led1_off()	GpioDataRegs.GPBSET.bit.GPIO32=1
#define led2_off()	GpioDataRegs.GPBSET.bit.GPIO48=1
#define led1_on()	GpioDataRegs.GPBCLEAR.bit.GPIO32=1
#define led2_on()	GpioDataRegs.GPBCLEAR.bit.GPIO48=1


//	READY	---------------------------------------------------------
static inline void dat_READY(int x)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPBDAT.bit.GPIO61=!x;	else
						GpioDataRegs.GPBDAT.bit.GPIO59=!x;	}
static inline void set_READY(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPBCLEAR.bit.GPIO61=1;	else
						GpioDataRegs.GPBCLEAR.bit.GPIO59=1;	}
static inline void clear_READY(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPBSET.bit.GPIO61=1;	else
						GpioDataRegs.GPBSET.bit.GPIO59=1;	}
static inline void toggle_READY(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPBTOGGLE.bit.GPIO61=1;else
						GpioDataRegs.GPBTOGGLE.bit.GPIO59=1;}

//	LED OUT 1	-----------------------------------------------------
static inline void dat_LED_OUT_1(int x)
{	if(Desk==dsk_BKST || Desk==dsk_COMM)	
						GpioDataRegs.GPBDAT.bit.GPIO60=!x;	else
	if(Desk==dsk_LOAD)	GpioDataRegs.GPADAT.bit.GPIO7=!x;	else
						GpioDataRegs.GPBDAT.bit.GPIO60=x;	}
static inline void set_LED_OUT_1(void)
{	if(Desk==dsk_BKST || Desk==dsk_COMM)	
						GpioDataRegs.GPBCLEAR.bit.GPIO60=1;	else
	if(Desk==dsk_LOAD)	GpioDataRegs.GPACLEAR.bit.GPIO7=1;	else
						GpioDataRegs.GPBSET.bit.GPIO60=1;	}
static inline void clear_LED_OUT_1(void)
{	if(Desk==dsk_BKST || Desk==dsk_COMM)	
						GpioDataRegs.GPBSET.bit.GPIO60=1;	else
	if(Desk==dsk_LOAD)	GpioDataRegs.GPASET.bit.GPIO7=1;	else
						GpioDataRegs.GPBCLEAR.bit.GPIO60=1;	}
static inline void toggle_LED_OUT_1(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPATOGGLE.bit.GPIO7=1;	else
						GpioDataRegs.GPBTOGGLE.bit.GPIO60=1;}

//	LED OUT 2	-----------------------------------------------------
static inline void dat_LED_OUT_2(int x)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPADAT.bit.GPIO1=!x;	else
	if(Desk==dsk_BKST)	GpioDataRegs.GPBDAT.bit.GPIO62=!x;	else
	if(Desk==dsk_COMM)	GpioDataRegs.GPBDAT.bit.GPIO63=!x;	else
						GpioDataRegs.GPBDAT.bit.GPIO63=x;	}
static inline void set_LED_OUT_2(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPACLEAR.bit.GPIO1=1;	else
	if(Desk==dsk_BKST)	GpioDataRegs.GPBCLEAR.bit.GPIO62=1;	else
	if(Desk==dsk_COMM)	GpioDataRegs.GPBCLEAR.bit.GPIO63=1;	else
						GpioDataRegs.GPBSET.bit.GPIO63=1;	}
static inline void clear_LED_OUT_2(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPASET.bit.GPIO7=1;	else
	if(Desk==dsk_BKST)	GpioDataRegs.GPBSET.bit.GPIO62=1;	else
	if(Desk==dsk_COMM)	GpioDataRegs.GPBSET.bit.GPIO63=1;	else
						GpioDataRegs.GPBCLEAR.bit.GPIO63=1;	}
static inline void toggle_LED_OUT_2(void)
{	if(Desk==dsk_LOAD)	GpioDataRegs.GPATOGGLE.bit.GPIO1=1;	else
	if(Desk==dsk_BKST)	GpioDataRegs.GPBTOGGLE.bit.GPIO62=1;else
						GpioDataRegs.GPBTOGGLE.bit.GPIO63=1;}

//	RES OUT 1	-----------------------------------------------------
static inline void dat_RES_OUT_1(int x)
{
	if(Desk==dsk_LOAD || Desk==dsk_EPLT)
						GpioDataRegs.GPADAT.bit.GPIO9=!x;	else
	if(Desk==dsk_BKSD)	GpioDataRegs.GPBDAT.bit.GPIO62=!x;	else
						GpioDataRegs.GPBDAT.bit.GPIO58=!x;	}
static inline void set_RES_OUT_1(void)
{
	if(Desk==dsk_LOAD || Desk==dsk_EPLT)
						GpioDataRegs.GPACLEAR.bit.GPIO9=1;	else
	if(Desk==dsk_BKSD)	GpioDataRegs.GPBCLEAR.bit.GPIO62=1;	else
						GpioDataRegs.GPBCLEAR.bit.GPIO58=1;	}
static inline void clear_RES_OUT_1(void)
{
	if(Desk==dsk_LOAD || Desk==dsk_EPLT)
						GpioDataRegs.GPASET.bit.GPIO9=1;	else
	if(Desk==dsk_BKSD)	GpioDataRegs.GPBSET.bit.GPIO62=1;	else
						GpioDataRegs.GPBSET.bit.GPIO58=1;	}
static inline void toggle_RES_OUT_1(void)
{
	if(Desk==dsk_LOAD || Desk==dsk_EPLT)
						GpioDataRegs.GPATOGGLE.bit.GPIO9=1;	else
	if(Desk==dsk_BKSD)	GpioDataRegs.GPBTOGGLE.bit.GPIO62=1;else
						GpioDataRegs.GPBTOGGLE.bit.GPIO58=1;}

//	RES OUT 2	-----------------------------------------------------
static inline void dat_RES_OUT_2(int x)
{	if(Desk==dsk_LOAD || Desk==dsk_EPLT)	
						GpioDataRegs.GPADAT.bit.GPIO3=!x;	else
						GpioDataRegs.GPBDAT.bit.GPIO61=x;	}
static inline void set_RES_OUT_2(void)
{	if(Desk==dsk_LOAD || Desk==dsk_EPLT)	
						GpioDataRegs.GPACLEAR.bit.GPIO3=1;	else
						GpioDataRegs.GPBCLEAR.bit.GPIO61=1;	}
static inline void clear_RES_OUT_2(void)
{	if(Desk==dsk_LOAD || Desk==dsk_EPLT)	
						GpioDataRegs.GPASET.bit.GPIO3=1;	else
						GpioDataRegs.GPBSET.bit.GPIO61=1;	}
static inline void toggle_RES_OUT_2(void)
{	if(Desk==dsk_LOAD || Desk==dsk_EPLT)	
						GpioDataRegs.GPATOGGLE.bit.GPIO3=1;	else
						GpioDataRegs.GPBTOGGLE.bit.GPIO61=1;}

//	START DPTB	-----------------------------------------------------
static inline void dat_START_DPTB(int x)
{	GpioDataRegs.GPBDAT.bit.GPIO62=x;	}
static inline void set_START_DPTB(void)
{	GpioDataRegs.GPBSET.bit.GPIO62=1;	}
static inline void clear_START_DPTB(void)
{	GpioDataRegs.GPBCLEAR.bit.GPIO62=1;	}
static inline void toggle_START_DPTB(void)
{	GpioDataRegs.GPBTOGGLE.bit.GPIO62=1;}

//	STOP DPTB	-----------------------------------------------------
static inline void dat_STOP_DPTB(int x)
{	GpioDataRegs.GPBDAT.bit.GPIO58=x;	}
static inline void set_STOP_DPTB(void)
{	GpioDataRegs.GPBSET.bit.GPIO58=1;	}
static inline void clear_STOP_DPTB(void)
{	GpioDataRegs.GPBCLEAR.bit.GPIO58=1;	}
static inline void toggle_STOP_DPTB(void)
{	GpioDataRegs.GPBTOGGLE.bit.GPIO58=1;}

extern LONGE DigErr;

void select_tpl_canal(int n_tpl);

void get_Mode(void);
void get_Buttons(void);


