blob: d0ef9bf7620bf75d625994f61a1c97c91c2d74af (
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
|
#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_all();
void asm_load_all();
void asm_load_mem();
}
uint16_t i = 0;
class Transaction {
public:
inline Transaction() { asm_save_all(); }
inline ~Transaction() {}
inline void retry() { asm_load_all(); }
inline void abort() { asm_load_mem(); }
};
void loop(void)
{
gpio.led_toggle(1);
{
Transaction tx;
kout << dec << i << endl;
i++;
if (!gpio.read(GPIO::p4_5)) {
tx.abort();
}
}
}
int main(void)
{
arch.setup();
gpio.setup();
kout.setup();
gpio.led_on(0);
gpio.input(GPIO::p4_5, 1);
asm_load_all();
kout << "Hello, World!" << endl;
arch.idle_loop();
return 0;
}
|