blob: c87af2f40dbf8f1c9cb5a6d0c49296322fb0f747 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
* Copyright 2021 Daniel Friesel
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "arch.h"
#ifdef TIMER_S
#include "driver/uptime.h"
#endif
extern "C" {
#include "lm4f_cpp_wrapper.h"
};
#ifdef __acweaving
#define __delay_cycles(x)
#endif
void Arch::setup(void)
{
arch_clock_init();
#if defined(WITH_LOOP)
arch_init_loop();
#endif
}
#ifdef WITH_WAKEUP
extern void wakeup();
#endif
#if defined(WITH_LOOP)
extern void loop();
extern volatile char run_loop;
#endif
// for 80 MHz
void Arch::delay_us(unsigned int const us)
{
volatile int x = us * 77;
while (x--) {
__asm("nop");
}
}
void Arch::delay_ms(unsigned int const ms)
{
for (unsigned int i = 0; i < ms; i++) {
volatile int x = 10000;
while (x--) {
__asm("nop");
}
}
}
void Arch::idle_loop(void)
{
while (1) {
__asm__("wfi");
#ifdef WITH_LOOP
if (run_loop) {
#ifdef TIMER_S
uptime.tick_s();
#endif
loop();
run_loop = 0;
}
#endif
}
}
void Arch::idle(void)
{
__asm__("wfi");
#ifdef WITH_WAKEUP
wakeup();
#endif
}
Arch arch;
|