/*
 * MD_POT.h
 *
 * Created: 13.1.2013 16:51:12
 *  Author: MichalM11x
 */
#ifndef POT_H
#define POT_H 
//

#include <stdint.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <avr/io.h>
#include <util/delay.h>

#define POT_UD (1<<PC4)		//Deciding whether Dig Pot will be inc 1 or dec 0
#define POT_INC (1<<PC5)	//change from high to low moves the wiper position
#define POT_CS1 (1<<PC3)	//Choose dig pot 1 (assert = 0)
#define POT_CS2 (1<<PC2)	
#define POT_CS3 (1<<PC1)
#define POT_CHANGE (iPot_Act!=iPot_Des) //self-explanitory
#define STATUS_LED (1<<PC0)

typedef struct				//Used to store informations about traffic lights
{
	
	unsigned char number;	//Number of used TLs
	unsigned char state[6];	//Current state of individual TLs
	uint8_t pinstate[6];	//Corresponding pin state 
}semafors;

typedef struct
{
	unsigned char newvalue;	//Informf whetehr a change took place
	unsigned char new[3];	//After arrival new value is stored here
	unsigned char previous[3];//The current position of wiper
}digpot;

//extern uint8_t  iPot_Act; //keeps track of actual position of wiper
//extern uint8_t  iPot_Des; //Destination of wiper
//extern uint8_t  iCS_Port; //used to address individual dig pots
void fPot_null();
void fPot_ChangeTemp(unsigned char new, unsigned char previous, unsigned char index);
void fPot_ChangePerm(digpot*data, unsigned char index);


#endif