lpcware

LPCOpen LPC15xx IAP Confusion

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by LabRat on Fri Aug 29 22:12:41 MST 2014
LPCOpen LPC15xx IAP code is confusing / wrong:

/**
* @brief LPC15XX IAP_ENTRY API function type
*/
static INLINE void iap_entry(unsigned int cmd_param[5],[color=#f00] unsigned int status_result[4])
{[/color]
((IAP_ENTRY_T) IAP_ENTRY_LOCATION)(cmd_param, status_result);
}

...seems to indicate that the maximum number of results is 4...

UM:

Quote:

The maximum number of results is[color=#f00] 5[/color], returned by the "ReadUID" command.


And trying to use Chip_IAP_ReadUID is showing the promised problem:


/* Read the unique ID */
uint32_t Chip_IAP_ReadUID()
{
uint32_t command[5],[color=#f00] result[4][/color];

command[0] = IAP_READ_UID_CMD;
iap_entry(command, result);

return result[1];
}

IAP ReadUID is returning Status code, Result0-Result3, so here's a result[5] required  :)

I'm not sure why result[1] is returned here (alcohol?), of course a pointer would be an easy solution...

/* Read the unique ID */
uint32_t Chip_IAP_ReadUID(uint32_t* serial_number)
{
uint32_t command[5];

command[0] = IAP_READ_UID_CMD;
iap_entry(command, (uint32_t*)serial_number);

return (uint32_t)(*(serial_number));//return status code
}

Outcomes