forked from ckormanyos/real-time-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcal_irq.cpp
30 lines (25 loc) · 1.11 KB
/
mcal_irq.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
///////////////////////////////////////////////////////////////////////////////
// Copyright Michael Schnerr 2011 - 2013.
// 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_irq.h>
void mcal::irq::init(const config_type*)
{
// Reset the ARM(R) interrupt controller.
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, mcal::reg::intc::sysconfig, UINT32_C(2)>::reg_set();
// Wait for the interrupt reset to finish.
while(std::uint32_t(mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, mcal::reg::intc::sysstatus>::reg_get() & UINT32_C(1)) != UINT32_C(1))
{
mcal::cpu::nop();
}
// Enable the generation of all interrupts by setting the
// priority threshold appropriately.
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, mcal::reg::intc::threshold, UINT32_C(0xFF)>::reg_set();
// Enable all global interrupts.
mcal::irq::enable_all();
}