summaryrefslogtreecommitdiff
path: root/src/app/transactiontest/main.cc
blob: e359e67a2e63a7da1db17f11968f64239987dd51 (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
#include "arch.h"
#include "driver/gpio.h"
#include "driver/stdout.h"
#include "driver/uptime.h"

#ifndef TIMER_CYCLES
#error makeflag timer_cycles=1 required
#endif

extern "C" {
	void asm_save_toc();
	void asm_load_toc();
}

volatile bool __attribute__((section(".text"))) have_state = false;
uint16_t i = 0;

void restore_state()
{
	if (!have_state) {
		return;
	}
	asm_load_toc();
}

void save_state()
{
	asm_save_toc();
	have_state = true;
}

void loop(void)
{
	gpio.led_toggle(1);
	kout << dec << i << endl;
	i++;
	if (i == 5) {
		save_state();
	}
	if (i == 10) {
		restore_state();
	}
}

int main(void)
{
	arch.setup();
	gpio.setup();
	kout.setup();

	restore_state();

	gpio.led_on(0);
	kout << "Hello, World!" << endl;
	kout << "Test, World!" << endl;
	kout << dec << uptime.get_cycles() << endl;
	kout << dec << uptime.get_cycles() << endl;
	kout << dec << uptime.get_cycles() << endl;
	kout << dec << uptime.get_cycles() << endl;

	arch.idle_loop();

	return 0;
}