2016-10-28 16:47:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 RnDity Sp. z o.o.
|
|
|
|
*
|
2017-01-19 23:38:51 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-10-28 16:47:15 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief System/hardware module for STM32F3 processor
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <nanokernel.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <soc.h>
|
|
|
|
#include <arch/cpu.h>
|
2017-01-25 23:12:00 +08:00
|
|
|
#include <cortex_m/exc.h>
|
2016-10-28 16:47:15 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Perform basic hardware initialization at boot.
|
|
|
|
*
|
|
|
|
* This needs to be run from the very beginning.
|
|
|
|
* So the init priority has to be 0 (zero).
|
|
|
|
*
|
|
|
|
* @return 0
|
|
|
|
*/
|
|
|
|
static int stm32f3_init(struct device *arg)
|
|
|
|
{
|
|
|
|
uint32_t key;
|
|
|
|
|
|
|
|
ARG_UNUSED(arg);
|
|
|
|
|
|
|
|
key = irq_lock();
|
|
|
|
|
2017-01-25 23:12:00 +08:00
|
|
|
_ClearFaults();
|
2016-10-28 16:47:15 +08:00
|
|
|
|
|
|
|
/* Install default handler that simply resets the CPU
|
|
|
|
* if configured in the kernel, NOP otherwise
|
|
|
|
*/
|
|
|
|
NMI_INIT();
|
|
|
|
|
|
|
|
irq_unlock(key);
|
|
|
|
|
2017-01-11 21:38:52 +08:00
|
|
|
/* Update CMSIS SystemCoreClock variable (HCLK) */
|
2017-02-09 16:15:01 +08:00
|
|
|
#ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
|
|
|
|
/* At reset, System core clock is set to 4MHz */
|
|
|
|
SystemCoreClock = 4000000;
|
|
|
|
#else
|
2017-01-11 21:38:52 +08:00
|
|
|
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
2017-02-09 16:15:01 +08:00
|
|
|
#endif /* CONFIG_CLOCK_CONTROL_STM32_CUBE */
|
2016-10-28 16:47:15 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYS_INIT(stm32f3_init, PRE_KERNEL_1, 0);
|