forked from ckormanyos/real-time-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcal_cpu.cpp
46 lines (40 loc) · 1.3 KB
/
mcal_cpu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2020.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <cstdint>
#include <mcal_cpu.h>
#include <mcal_cpu_detail.h>
#include <mcal_osc.h>
#include <mcal_port.h>
#include <mcal_reg.h>
#include <mcal_wdg.h>
void mcal::cpu::init()
{
// Disable OPP50 operation and enable OPP100 operation.
// Use the ratio for 24MHz to 32KHz division.
// See Chapter 9.3.8 in the am335x manual.
mcal::reg::reg_access_static<std::uint32_t,
std::uint32_t,
mcal::reg::control::clk32kdivratio_ctrl,
UINT32_C(0x00000000)>::reg_set();
mcal::wdg::init (nullptr);
mcal::port::init(nullptr);
mcal::osc::init (nullptr);
}
void mcal::cpu::fpu()
{
asm volatile("mrc p15, #0, r1, c1, c0, #2");
asm volatile("orr r1, r1, #0x00F00000");
asm volatile("mcr p15, #0, r1, c1, c0, #2");
asm volatile("isb");
asm volatile("mov r1, #0x40000000");
asm volatile("vmsr fpexc, r1");
}
void mcal::cpu::post_init()
{
detail::init();
detail::user_mode();
}