summaryrefslogtreecommitdiff
path: root/src/app/energybench/main.cc
blob: a585639f80736191889d35d4a80df10b570eb98a (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
/*
 * Copyright 2020 Daniel Friesel
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
#include "arch.h"
#include "driver/gpio.h"
#include "driver/stdout.h"
#include "driver/uptime.h"

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

	gpio.output(GPIO::p1_1);

	arch.delay_ms(5000);

	gpio.write(GPIO::p1_1, 1);
	__delay_cycles(64000); // 8 ms
	__delay_cycles(64000); // 8 ms
	gpio.write(GPIO::p1_1, 0);
	__delay_cycles(64000); // 8 ms
	__delay_cycles(64000); // 8 ms
	gpio.write(GPIO::p1_1, 1);
	__delay_cycles(64000); // 8 ms
	__delay_cycles(64000); // 8 ms
	gpio.write(GPIO::p1_1, 0);

	for (uint8_t i = 0; i < 200; i++) {
		arch.sleep_ms(50);
		gpio.write(GPIO::p1_1, 1);
		arch.sleep_ms(i);
		gpio.write(GPIO::p1_1, 0);
		arch.sleep_ms(i);
		gpio.write(GPIO::p1_1, 1);
		arch.sleep_ms(i);
		gpio.write(GPIO::p1_1, 0);
	}

	for (uint8_t i = 0; i < 200; i++) {
		arch.delay_ms(50);
		gpio.write(GPIO::p1_1, 1);
		arch.delay_ms(i);
		gpio.write(GPIO::p1_1, 0);
		arch.delay_ms(i);
		gpio.write(GPIO::p1_1, 1);
		arch.delay_ms(i);
		gpio.write(GPIO::p1_1, 0);
	}

	while(1) {
		arch.idle();
	}

	return 0;
}