Content originally posted in LPCWare by williamjsell on Thu Jan 21 13:01:17 MST 2016
The caller:
ee_section_info_t *GetEEPROMData(SectionTypes sectionIndex)
{
xSemaphoreTake(eepromMutex, portMAX_DELAY);
uint8_t *base, *offset, retval = 0;
base = (uint8_t *)ⅇ
offset = (uint8_t *)SectionPointers[sectionIndex].ptr;
retval = Chip_EEPROM_Read(offset - base, (uint8_t *)SectionPointers[sectionIndex].ptr, SectionPointers[sectionIndex].size);
if(retval != 0)
{
//generate error
WriteStatus(STATUS_EEPROM_READ_ERROR, true);
}
else
{
WriteStatus(STATUS_EEPROM_READ_ERROR, false);
}
xSemaphoreGive(eepromMutex);
return SectionPointers[sectionIndex].ptr;
}
the callee:
/* Read data from EEPROM */
uint8_t Chip_EEPROM_Read(uint32_t srcAdd, uint8_t *ptr, uint32_t bytesrd)
{
static uint32_t count = 0;
uint32_t command[5], result[4];
command[0] = IAP_EEPROM_READ;
command[1] = srcAdd;
command[2] = (uint32_t) ptr;
command[3] = bytesrd;
command[4] = SystemCoreClock / 1000;
iap_entry(command, result);
return result[0];
}