liblpc2000_iap_command documenation?
HI,
I'm trying to use the liblpc2000_iap_command function to update application code, unfortunately I can't find any documentation on this function?
I've done some testing and it looks like it's not a good idea to disable interrupts before calling this function.
/*------------------------------------------------------------------------------------*/
/* No interrupt disabling before calling liblpc2000_iap_command */
/*------------------------------------------------------------------------------------*/
unsigned long result ;
liblpc2000_iap_command ( IAP_CMD_READ_PART_ID, 0, 0, 0, 0, &result ) ;
printf ( "Part ID %x", result )
Produces
Part ID = 4FF11 (correct)
/*------------------------------------------------------------------------------------*/
/* Disabling interrupt before calling liblpc2000_iap_command */
/*------------------------------------------------------------------------------------*/
unsigned long result ;
libarm_isr_disable_irq ( ) ;
liblpc2000_iap_command ( IAP_CMD_READ_PART_ID, 0, 0, 0, 0, &result ) ;
libarm_isr_enable_irq ( ) ;
printf ( "Part ID %x", result )
Produces
Part ID = 1c200 (wrong)
Is there anything else I should be aware of when using this function or should I implement this function myself (more portable, no worries about black box undocumented functions)?
-
There are a some words in the liblpc1000.h header file describing the liblpc2000_iap_command function - there isn't much too it, here is the implementation:
#include "liblpc2000.h" #define IAP_LOCATION 0x7FFFFFF1 typedef void (*IAP)(unsigned long [], unsigned long[]); unsigned long liblpc2000_iap_command(unsigned long cmd, unsigned long p0, unsigned long p1, unsigned long p2, unsigned long p3, unsigned long *r0) { unsigned long command[5] = {cmd, p0, p1, p2, p3}; unsigned long result[2]; ((IAP)IAP_LOCATION)(command, result); if (r0) *r0 = result[1]; return result[0]; }I think the problem you are observing is because you are using libarm_isr_enable_irq and libarm_isr_disable_irq rather than libarm_enable_irq and libarm_disable_irq - the former functions are used for re-enabling interrupts from within an ISR and change the processor mode (and therefore the current stack).
Please sign in to leave a comment.
Comments
1 comment