/*---------------------------------------------------------------------------*/ INT8U RTC_RandomRead(INT8U Address) // Description: // Random Read Operation. Data is read from the RTC. The RTC // address is defined with the parameter Address. { INT8U data_in; #if (defined I2C_SW && I2C_SW == 1) CRITICAL_SECTION_START(); sw_i2c_start(); // Send start signal sw_i2c_write(DS1307Address); // Send identifer I2C address (10100000b) delay_time(I2C_DELAY); sw_i2c_write((INT8U) Address); // Send address to EEPROM delay_time(I2C_DELAY); sw_i2c_start(); // Send I2C Start Transfer sw_i2c_write(DS1307Address | 1); // Send identifer I2C address (10100001b) delay_time(I2C_DELAY); data_in = sw_i2c_read(0); // Read byte sw_i2c_stop(); // Send I2C Stop Transfer CRITICAL_SECTION_END(); #else IIC_transmite(DS1307Address, Address, NULL); IIC_recebe(DS1307Address, &data_in); #endif return data_in; }
/*---------------------------------------------------------------------------*/ u08 EEPROM_RandomRead(u16 Address) // Description: // Random Read Operation. Data is read from the EEPROM. The EEPROM // address is defined with the parameter Address. { char data_in; #if (defined I2C_SW && I2C_SW == 1) sw_i2c_start(); // Send start signal sw_i2c_write(EEPROMAddress);// Send identifer I2C address (10100000b) delay_time(I2C_DELAY); sw_i2c_write((unsigned char) (high_byte(Address)));// Send address to EEPROM delay_time(I2C_DELAY); sw_i2c_write((unsigned char) Address);// Send address to EEPROM delay_time(I2C_DELAY); sw_i2c_start();// Send I2C Start Transfer sw_i2c_write(EEPROMAddress + 1);// Send identifer I2C address (10100001b) delay_time(I2C_DELAY); data_in = sw_i2c_read(0);// Read byte sw_i2c_stop(); // Send I2C Stop Transfer #else /* Dummy write: Transmite NULL depois gera um sinal de start repeated */ IIC_transmite(EEPROMAddress, Address, NULL); IIC_recebe(EEPROMAddress, &data_in); #endif return data_in; }
/*---------------------------------------------------------------------------*/ INT8U RTC_CurrentAddressRead(void) // Description: // Current Address Read Operation. Data is read from the RTC. The current // address from the RTC is used. { INT8U data_in; #if (defined I2C_SW && I2C_SW == 1) CRITICAL_SECTION_START(); sw_i2c_start(); // Send I2C Start Transfer sw_i2c_write(DS1307Address | 1); // Send identifer I2C address (10100001b) data_in = sw_i2c_read(0); // Read byte sw_i2c_stop(); // Send I2C Stop Transfer CRITICAL_SECTION_END(); #else IIC_recebe(DS1307Address, &data_in); #endif return data_in; }
/*---------------------------------------------------------------------------*/ u08 EEPROM_CurrentAddressRead(void) // Description: // Current Address Read Operation. Data is read from the EEPROM. The current // address from the EEPROM is used. { u08 data_in; #if (defined I2C_SW && I2C_SW == 1) sw_i2c_start(); // Send start signal sw_i2c_write(EEPROMAddress);// Send identifer I2C address (10100000b) sw_i2c_start(); // Send I2C Start Transfer sw_i2c_write(EEPROMAddress + 1);// Send identifer I2C address (10100001b) data_in = sw_i2c_read(0);// Read byte sw_i2c_stop(); // Send I2C Stop Transfer #else IIC_recebe(EEPROMAddress, &data_in); #endif return data_in; }