libyggdrasil  v1.0.0
cortex.hpp
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Midgard - *
9  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10  * This software can be used by students and other personal of the *
11  * Bern University of Applied Sciences under the terms of the MIT *
12  * license. *
13  * For other persons this software is under the terms of the GNU *
14  * General Public License version 2. *
15  * *
16  * Copyright © 2021, Bern University of Applied Sciences. *
17  * All rights reserved. *
18  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 #pragma once
27 
28 #include <cpp/common/types.hpp>
30 
32 
33 #include <core_cm7.h>
34 
35 namespace bsp::core {
36 
41  asm volatile ("cpsid i" : : : "memory");
42  }
43 
48  asm volatile ("cpsie i" : : : "memory");
49  }
50 
57  SCB->VTOR = address;
58  }
59 
65  ALWAYS_INLINE void delay(u32 ms) {
66  u32 startTime = HAL_GetTick();
67 
68  while (HAL_GetTick() < startTime + ms)
69  NOP();
70  }
71 
72 }
addr_t
u32 addr_t
Definition: types.h:52
instructions.hpp
Assembly instruction wrapper functions for Midgard.
types.hpp
Commonly used type definitions and helper templates.
ALWAYS_INLINE
#define ALWAYS_INLINE
Definition: attributes.h:34
u32
uint32_t u32
Definition: types.h:38
bsp::core::enableInterrupts
ALWAYS_INLINE void enableInterrupts()
Enables all interrupts.
Definition: cortex.hpp:47
bsp::core::setInterruptVectorBase
ALWAYS_INLINE void setInterruptVectorBase(addr_t address)
Sets the base address of the interrupt vector table.
Definition: cortex.hpp:56
bsp::core
Definition: cortex.hpp:33
attributes.hpp
Commonly used C++ and GNU attributes.
bsp::core::delay
ALWAYS_INLINE void delay(u32 ms)
Delays execution by a certain number of milliseconds.
Definition: cortex.hpp:39
bsp::core::disableInterrupts
ALWAYS_INLINE void disableInterrupts()
Disables all interrupts.
Definition: cortex.hpp:40