/** *************************************************************************** * \file i2c.h *************************************************************************** * \brief Header File for i2c.c * * \version 1.0 * \date 14.05.2010 * \author S. Andenmatten BFH-TI *************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef I2C_H #define I2C_H #define FAILED 1 #define SUCCESSFUL 0 #define I2C1_ADDRESS_EEPROM1_BLOCK0 0xA0 #define I2C1_ADDRESS_EEPROM1_BLOCK1 0xA8 #define I2C1_ADDRESS_EEPROM2_BLOCK0 0xA2 #define I2C1_ADDRESS_EEPROM2_BLOCK1 0xAA #define I2C1_ADDRESS_EEPROM3_BLOCK0 0xA4 #define I2C1_ADDRESS_EEPROM3_BLOCK1 0xAC #define I2C1_ADDRESS_EEPROM4_BLOCK0 0xA6 #define I2C1_ADDRESS_EEPROM4_BLOCK1 0xAE #define I2C1_ADDRESS_RTC 0xD0 //define locations off data in the eeprom /* Address of chip 1: 000000 - 131071 Address of chip 2: 131072 - 262143 Address of chip 3: 262144 - 393215 Address of chip 4: 393216 - 524287 */ #define EEPROM_OFFSET_PROG_DATA 0 #define EEPROM_OFFSET_AP_DATA 128000 #define EEPROM_SOMMERTIME_SET 131200 //(1 Byte) Byte, which saves the state of summertime #define EEPROM_WINTERTIME_SET 131201 //(1 Byte) Byte, which saves the state of wintertime #define EEPROM_CENTURY 131202 //(1 Byte) There is the century saved #define EEPROM_DATALOG_POINTER 131203 //(16 Bytes) This is the pointer, on wich address the next logdata have to be written #define EEPROM_ERROR_LOG_POINTER 131219 //(16 Bytes) This is the pointer on which the next error log data have to be written #define EEPROM_EXPIRY_COUNTER 131235 //(16 Bytes) This bytes saves the counter, which runs parallel to the normal watch in s #define EEPROM_OPERATION_HOURS 131251 //(16 Bytes) Saves the operating hours #define EEPROM_ABSOLUTE_TIME 131267 //(16 Bytes) When the power is switched off, it saves the actual seconds of the year, so that the next power on, it can calculate the differnence #define EEPROM_MANUFACTURER_PW 131283 //(4 Bytes) Password of manufacturer #define EEPROM_PUK 131287 //(4 Bytes) Personal unblocking key #define EEPROM_EXPIRY_PW 131291 //(4 Bytes) password which has to be entered, when the date of expiry is reached #define EEPROM_SUPERVISOR_PW 131295 //(4 Bytes) password for supervisor //memory for user passwords #define EEPROM_USER_PW_BEGIN 131299 //(400 Bytes) Start address user passwords -> 100 users #define EEPROM_USER_PW_END 131699 // End address of memory of user passwords #define EEPROM_INIT_BYTES 131699 //(4 Bytes) Bytes to control, whether the memory is already initialized #define EEPROM_EXPIRY_ACTIV 131703 //(1 Byte) When this value is 1, then the expiry date is activ. When 0, then it is not activ. #define EEPROM_MODBUS_ADDRESS 131704 //(1 Byte) On this eeprom address is the modbus slave address saved #define EEPROM_SERIAL_NUMBER 131705 //(4 Bytes) This is the personal serial number which the manufacturer can set //memory for the error log memory #define EEPROM_ERROR_LOG_BEGIN 131709 //(160 Bytes) 20* 8 Bytes. These part of the memory is to save 20 error logs. In the log data memory this messages are saved too. #define EEPROM_ERROR_LOG_END 131869 // End address of the memory part of the error log //memory for the datalogger #define EEPROM_DATALOG_BEGIN 131869 // As much bytes as are available to address EEPROM_DATALOG_END #define EEPROM_DATALOG_END 524287 // End address of memory #define LINES_MAX 500 __packed struct EEPROM_PARAMETERS { char data_value; double data_value_2; }; // ***** Extern Declarations ************************************************** extern struct EEPROM_PARAMETERS eeprom_param_default; extern struct EEPROM_PARAMETERS eeprom_param; // function prototype void init_i2c(void); unsigned char eeprom_write_bytes(int AddressMEM,int NumByte,unsigned char* pBuffer); unsigned char eeprom_read_bytes(int AddressMEM,int NumByte,u8* pBuffer); unsigned char rtc_read_time(int AddressI2C,int AddressMEM,int NumByte,u8* pBuffer); unsigned char rtc_write_time(int AddressI2C,int AddressMEM,int NumByte,u8* pBuffer); unsigned char i2c_wait_until_ready(char I2C_EEAddress); void log_date(void); void log_login(unsigned char user); void log_prog_start(unsigned char station, unsigned char prog_Nr, unsigned int ref_Nr); void log_prog_stop(unsigned char station, unsigned char prog_Nr); void log_finished_step(unsigned char station, unsigned char prog_Nr, unsigned char step_Nr,int step_time, unsigned char av_power, unsigned char av_temperature, int nom_freq); void log_error_msg(unsigned char error_ID, unsigned char generator_ID); void write_log_data_EEPROM(void); void clear_log_data_memory(void); void clear_passwords(void); void save_RAM_variables(void); #endif /*I2C_H*/ //*****************************************************************************