We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
In my project I have a bootloader in flash that can load several applications into sdram, and run it, which works fine.... but The application then needs to access one function in the bootloader at a fixed address. Using normal function pointers result in hard faults.
// Global defs typedef int (*pFunction)(uint16_t call_id,uint16_t num,...); pFunction call_bios; uint8_t *Buffer = (uint8_t*)0x08080000; // Flash address of bootloader function // within a function call_bios = (pFunction)&Buffer[1];// sets to 0x08080001 for thumb code call_bios(0,0);
Also is there a better way of declaring the function pointer so I don't have to set its address every time as its in a fixed location..
This is an example of a function pointer to a fixed-location thumb function:
enum { IAP_LOCATION = 0x7ffffff1 }; typedef void (*IAP)(unsigned[],unsigned[]); IAP iap_entry = (IAP)IAP_LOCATION; ... iap_entry(cmd,res);
But you can go for a direct typecast also when calling. Or you can tell the linker you have a symbol at an absolute address.