/** * @brief Port-related initialization code. */ void _port_init(void) { /* Initialization of the vector table and priority related settings.*/ SCB_VTOR = CORTEX_VTOR_INIT; SCB_AIRCR = AIRCR_VECTKEY | AIRCR_PRIGROUP(CORTEX_PRIGROUP_INIT); #if CORTEX_USE_FPU { register uint32_t control __asm("control"); register uint32_t fpscr __asm("fpscr"); /* Initializing the FPU context save in lazy mode.*/ SCB_FPCCR = FPCCR_ASPEN | FPCCR_LSPEN; /* CP10 and CP11 set to full access in the startup code.*/ /* SCB_CPACR |= 0x00F00000;*/ /* Enables FPU context save/restore on exception entry/exit (FPCA bit).*/ control |= 4; /* FPSCR and FPDSCR initially zero.*/ fpscr = 0; SCB_FPDSCR = 0; } #endif /* Initialization of the system vectors used by the port.*/ nvicSetSystemHandlerPriority(HANDLER_SVCALL, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SVCALL)); nvicSetSystemHandlerPriority(HANDLER_PENDSV, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_PENDSV)); nvicSetSystemHandlerPriority(HANDLER_SYSTICK, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK)); }
/** * @brief Port-related initialization code. */ void _port_init(void) { /* Initialization of the vector table and priority related settings.*/ SCB_VTOR = CORTEX_VTOR_INIT; SCB_AIRCR = AIRCR_VECTKEY | AIRCR_PRIGROUP(CORTEX_PRIGROUP_INIT); #if CORTEX_USE_FPU { /* Initializing the FPU context save in lazy mode.*/ SCB_FPCCR = FPCCR_ASPEN | FPCCR_LSPEN; /* CP10 and CP11 set to full access.*/ SCB_CPACR |= 0x00F00000; /* Enables FPU context save/restore on exception entry/exit (FPCA bit).*/ __set_CONTROL(__get_CONTROL() | 4); /* FPSCR and FPDSCR initially zero.*/ __set_FPSCR(0); SCB_FPDSCR = 0; } #endif /* Initialization of the system vectors used by the port.*/ nvicSetSystemHandlerPriority(HANDLER_SVCALL, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SVCALL)); nvicSetSystemHandlerPriority(HANDLER_PENDSV, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_PENDSV)); nvicSetSystemHandlerPriority(HANDLER_SYSTICK, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK)); }
bool_t chibios_logInit(const bool_t binaryFile) { nvicSetSystemHandlerPriority(HANDLER_PENDSV, CORTEX_PRIORITY_MASK(15)); if (sdLogInit (NULL) != SDLOG_OK) goto error; if (sdLogOpenLog (&pprzLogFile, PPRZ_LOG_DIR, PPRZ_LOG_NAME) != SDLOG_OK) goto error; #if LOG_PROCESS_STATE if (sdLogOpenLog (&processLogFile, PROCESS_LOG_NAME) != SDLOG_OK) goto error; #endif if (sdLoglaunchThread (binaryFile) != SDLOG_OK) goto error; chEvtInit (&powerOutageSource); launchBatterySurveyThread (); return TRUE; error: return FALSE; }
/** * @brief Low level ST driver initialization. * * @notapi */ void st_lld_init(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING /* Free running counter mode.*/ /* Enabling timer clock.*/ ST_ENABLE_CLOCK(); /* Initializing the counter in free running mode.*/ STM32_ST_TIM->PSC = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1; STM32_ST_TIM->ARR = ST_ARR_INIT; STM32_ST_TIM->CCMR1 = 0; STM32_ST_TIM->CCR[0] = 0; STM32_ST_TIM->DIER = 0; STM32_ST_TIM->CR2 = 0; STM32_ST_TIM->EGR = TIM_EGR_UG; STM32_ST_TIM->CR1 = TIM_CR1_CEN; /* IRQ enabled.*/ nvicEnableVector(ST_NUMBER, STM32_ST_IRQ_PRIORITY); #endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */ #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC /* Periodic systick mode, the Cortex-Mx internal systick timer is used in this mode.*/ SysTick->LOAD = (STM32_HCLK / OSAL_ST_FREQUENCY) - 1; SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk; /* IRQ enabled.*/ nvicSetSystemHandlerPriority(SysTick_IRQn, STM32_ST_IRQ_PRIORITY); #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ }
/** * @brief Low level HAL driver initialization. * * @notapi */ void hal_lld_init(void) { /* SysTick initialization using the system clock.*/ nvicSetSystemHandlerPriority(HANDLER_SYSTICK, CORTEX_PRIORITY_SYSTICK); SysTick->LOAD = LPC_SYSCLK / CH_FREQUENCY - 1; SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk; }
/** * @brief Low level ST driver initialization. * * @notapi */ void st_lld_init(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC /* Periodic systick mode, the Cortex-Mx internal systick timer is used in this mode.*/ SysTick->LOAD = (KINETIS_SYSCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk; /* IRQ enabled.*/ nvicSetSystemHandlerPriority(HANDLER_SYSTICK, KINETIS_ST_IRQ_PRIORITY); #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ }
/** * @brief Low level ST driver initialization. * * @notapi */ void st_lld_init(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC nvicSetSystemHandlerPriority(HANDLER_SYSTICK, WHG_ST_IRQ_PRIORITY); #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ }