/* Read data from simulated EEPROM. 
Function uses TWI interface to read data from EEPROM memory. */
static ret_code_t eeprom_read(size_t addr, uint8_t *pdata, size_t size)
/* Read data from simulated EEPROM. 
Function uses TWI interface to read data from EEPROM memory. */
static ret_code_t eeprom_read(size_t addr, uint8_t *pdata, size_t size)
{
    ret_code_t ret;
    if (size > (EEPROM_SIM_SIZE))
    {
        return NRF_ERROR_INVALID_LENGTH;
    }
    do
    {
       uint8_t addr8 = (uint8_t)addr;
       ret = nrf_drv_twi_tx(&m_twi_master, EEPROM_SIM_ADDR, &addr8, 1, true);
       if (NRF_SUCCESS != ret)
       {
           break;
       }
       ret = nrf_drv_twi_rx(&m_twi_master, EEPROM_SIM_ADDR, pdata, size);
    }while (0);
    return ret;
}