2016-10-28 18:27:22 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Open-RnD Sp. z o.o.
|
|
|
|
* Copyright (c) 2016 Linaro Limited.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-10-28 18:27:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief System/hardware module for STM32F4 processor
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <arch/cpu.h>
|
2017-01-25 23:12:00 +08:00
|
|
|
#include <cortex_m/exc.h>
|
2016-10-28 18:27:22 +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 st_stm32f4_init(struct device *arg)
|
|
|
|
{
|
2017-04-21 02:30:33 +08:00
|
|
|
u32_t key;
|
2016-10-28 18:27:22 +08:00
|
|
|
|
|
|
|
ARG_UNUSED(arg);
|
|
|
|
|
|
|
|
key = irq_lock();
|
|
|
|
|
2017-01-25 23:12:00 +08:00
|
|
|
_ClearFaults();
|
2016-10-28 18:27:22 +08:00
|
|
|
|
|
|
|
/* Install default handler that simply resets the CPU
|
|
|
|
* if configured in the kernel, NOP otherwise
|
|
|
|
*/
|
|
|
|
NMI_INIT();
|
|
|
|
|
|
|
|
irq_unlock(key);
|
|
|
|
|
2017-04-18 20:24:04 +08:00
|
|
|
/* Update CMSIS SystemCoreClock variable (HCLK) */
|
2017-12-23 05:00:12 +08:00
|
|
|
/* At reset, system core clock is set to 16 MHz from HSI */
|
|
|
|
SystemCoreClock = 16000000;
|
2016-11-14 18:53:52 +08:00
|
|
|
|
2016-10-28 18:27:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-09 03:06:55 +08:00
|
|
|
SYS_INIT(st_stm32f4_init, PRE_KERNEL_1, 0);
|