/** **************************************************************************************** * @brief Reads data from I2C EEPROM to memory position of given pointer. * * @param[in] rd_data_ptr Read data pointer. * @param[in] address Starting memory address. * @param[in] size Size of the data to be read. * * @return Bytes that were actually read (due to memory size limitation). **************************************************************************************** */ uint32_t i2c_eeprom_read_data(uint8_t *rd_data_ptr, uint32_t address, uint32_t size) { uint32_t tmp_size; uint32_t bytes_read; if (size == 0) return 0; if (size > I2C_EEPROM_SIZE - address) // Check for max bytes to be read from a (MAX_SIZE x 8) EEPROM { tmp_size = I2C_EEPROM_SIZE - address; bytes_read = tmp_size; } else { tmp_size = size; bytes_read = size; } i2c_wait_until_eeprom_ready(); // Read 32 bytes at a time while (tmp_size >= 32) { read_data_single(&rd_data_ptr, address, 32); address += 32; // Update base address for read tmp_size -= 32; // Update tmp_size for bytes remaining to be read } if (tmp_size) read_data_single(&rd_data_ptr, address, tmp_size); return bytes_read; }
void test_read_single(void) { Posdict positions; Angdict angles; std::vector<unsigned int> times = {1, 2, 3}; read_data_single("test.txt", positions, angles, times); assert(positions.size() == 3); }