Merge pull request #58 from ktand/call_init_first
Force init() to be called before static object allocation
This commit is contained in:
commit
8d5f6722b2
|
@ -31,20 +31,25 @@ void initVariant() { }
|
|||
void setupUSB() __attribute__((weak));
|
||||
void setupUSB() { }
|
||||
|
||||
// Force init to be called *first*, i.e. before static object allocation.
|
||||
// Otherwise, statically allocated objects that need HAL may fail.
|
||||
__attribute__(( constructor (101))) void premain() {
|
||||
|
||||
// Required by FreeRTOS, see http://www.freertos.org/RTOS-Cortex-M3-M4.html
|
||||
#ifdef NVIC_PRIORITYGROUP_4
|
||||
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||
#endif
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
//Used by FreeRTOS, see http://www.freertos.org/RTOS-Cortex-M3-M4.html
|
||||
#ifdef NVIC_PRIORITYGROUP_4
|
||||
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||
#endif
|
||||
|
||||
#ifdef STM32F7
|
||||
SCB_EnableICache();
|
||||
SCB_EnableDCache();
|
||||
#endif
|
||||
|
||||
init();
|
||||
|
||||
initVariant();
|
||||
|
||||
#if defined(MENU_DEBUG_DISABLED)
|
||||
|
|
Loading…
Reference in New Issue