
// this is the header file for REvaLib.c
// prototypes of the functions for easy handling of the REva board


//WARNING: these functions assume that the associated peripherals are already initialized.

//define here what we want to use...
#define USE_IO 1
#define USE_ANALOG 1
#define USE_EEPROM 1

//------------------------------------------------------------------
// IO functions
//------------------------------------------------------------------
#if USE_IO
extern void init_IO();
extern void writeIO(unsigned char);
extern unsigned char readIO();
#endif

//------------------------------------------------------------------
// Analog functions
//------------------------------------------------------------------
#if USE_ANALOG
// all these functions need to know the reference voltage,
//  which is the alimentation voltage of the ST7.
extern void init_PWM();
extern void init_I2C();
extern void init_adc();
//this function reads the value from the temperature sensor (in tenth of Celcius degrees)
extern signed short ReadTemp(unsigned short VDDmV);
//this function reads the value from the potentiometer (as a percentage)
extern unsigned char  ReadPot();
//this function reads the value from the analog input IN1 (in mV)
// precision is (VDDmV/1023)
extern unsigned short  ReadI1(unsigned short VDDmV);
//this function reads the value from the analog input IN2 (in mV)
// precision is (VDDmV/1023)
extern unsigned short  ReadI2(unsigned short VDDmV);
//this function sets Vout at NewVal (in mV)
// precision is (VDDmV/255)
extern void SetOUT(unsigned short NewVal, unsigned short VDDmV);
#endif

//------------------------------------------------------------------
// EEPROM access functions
//------------------------------------------------------------------
#if USE_EEPROM
//this function writes data from the ST7 memory to the EEPROM
extern void WriteEEPROM(unsigned char addr, unsigned char cnt, unsigned char *buf);
//this function reads data from the EEPROM to the ST7 memory
extern void ReadEEPROM(unsigned char addr, unsigned char cnt, unsigned char *buf);
#endif

//------------------------------------------------------------------
// utility functions
//------------------------------------------------------------------
//this function converts a hex digit from ascii to binary
extern unsigned char readhex(char car);


