2015-07-04 09:37:54 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Rakendra Thapa <rakendrathapa@gmail.com
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_lm4f120
|
|
|
|
* @{
|
|
|
|
*
|
2015-07-16 02:56:33 +02:00
|
|
|
* @file cpu.c
|
2015-07-04 09:37:54 +02:00
|
|
|
* @brief Implementation of the CPU initialization
|
|
|
|
*
|
|
|
|
* @author Rakendra Thapa <rakendrathapa@gmail.com>
|
2015-07-21 18:08:56 +02:00
|
|
|
* @}
|
2015-07-04 09:37:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cpu.h"
|
2023-01-02 18:08:35 +01:00
|
|
|
#include "kernel_init.h"
|
2015-07-04 09:37:54 +02:00
|
|
|
#include "irq.h"
|
|
|
|
#include "sched.h"
|
|
|
|
#include "thread.h"
|
2017-10-20 17:26:10 +02:00
|
|
|
#include "irq.h"
|
2017-01-20 11:18:38 +01:00
|
|
|
#include "periph/init.h"
|
2016-05-03 13:53:20 +02:00
|
|
|
#include "periph_conf.h"
|
2019-04-10 11:07:05 +02:00
|
|
|
#include "stdio_base.h"
|
2015-07-04 09:37:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize the CPU, set IRQ priorities
|
|
|
|
*/
|
|
|
|
void cpu_init(void)
|
|
|
|
{
|
2015-07-16 02:56:33 +02:00
|
|
|
/* initializes the Cortex-M core */
|
2015-07-14 18:11:25 +02:00
|
|
|
cortexm_init();
|
2015-07-04 09:37:54 +02:00
|
|
|
|
2015-07-14 18:11:25 +02:00
|
|
|
/* initialize the clock system */
|
2015-07-18 03:16:46 +02:00
|
|
|
cpu_clock_init(CLOCK_SOURCE);
|
2017-01-20 11:18:38 +01:00
|
|
|
|
2019-04-10 11:07:05 +02:00
|
|
|
/* initialize stdio prior to periph_init() to allow use of DEBUG() there */
|
2023-01-02 18:08:35 +01:00
|
|
|
early_init();
|
2019-04-10 11:07:05 +02:00
|
|
|
|
2017-01-20 11:18:38 +01:00
|
|
|
/* trigger static peripheral initialization */
|
|
|
|
periph_init();
|
2015-07-04 09:37:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void setup_fpu(void)
|
|
|
|
{
|
2015-07-14 18:11:25 +02:00
|
|
|
ROM_FPUEnable();
|
|
|
|
ROM_FPULazyStackingEnable();
|
2015-07-04 09:37:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cpu_clock_init(int clk)
|
|
|
|
{
|
2015-07-14 18:11:25 +02:00
|
|
|
setup_fpu();
|
|
|
|
switch(clk){
|
|
|
|
case CLK80:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
case CLK50:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
case CLK40:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
case CLK16:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
case CLK1:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_XTAL_1MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
|
|
|
|
break;
|
|
|
|
}
|
2015-07-04 09:37:54 +02:00
|
|
|
}
|