summaryrefslogtreecommitdiff
path: root/src/arch/stm32f446re-nucleo/arch.cc
blob: 12a612a23e0eab08b9ffc7fc2715caeca8a1f3a3 (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
#include "arch.h"

#ifdef __acweaving
#define __delay_cycles(x)
#endif

void Arch::setup(void)
{
}

#ifdef WITH_WAKEUP
extern void wakeup();
#endif

#if defined(WITH_LOOP)
extern void loop();
volatile char run_loop = 0;
#endif

void Arch::delay_us(unsigned int const us)
{
	volatile int x = us * 2;
	while (x--) {
		__asm("nop");
	}
}
void Arch::delay_ms(unsigned int const ms)
{
	for (unsigned int i = 0; i < ms; i++) {
		volatile int x = 2000;
		while (x--) {
			__asm("nop");
		}
	}
}

void Arch::idle_loop(void)
{
	while (1) {
		delay_ms(1000);
#ifdef WITH_LOOP
		loop();
#endif
	}
}

void Arch::idle(void)
{
#ifdef WITH_WAKEUP
	wakeup();
#endif
}

Arch arch;