-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
113 lines (95 loc) · 3.31 KB
/
main.cpp
File metadata and controls
113 lines (95 loc) · 3.31 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* main program file
*
* Copyright 2013--2022
* Christian Schneider <software(at)chschneider(dot)eu>
* Peter Yu <ucla(dot)eshop(at)gmail(dot)com>
* Clayton Ho <claytonho(at)g(dot)ucla(dot)edu>
*
* This file is part of the AMO control unit firmware
* (called "program" in the following).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation, *not* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ////////////////////////////////////////////////////////////////////////
// IMPORTS
// ////////////////////////////////////////////////////////////////////////
// AVR imports
#include "config.h"
#include <stdio.h>
#include <avr/interrupt.h>
#include <util/delay.h>
// Core Device imports
#include "serial_console.h"
#include "led.h"
#include "spi_flex.h"
// AMO Imports
#include "CleO/CleO.cpp"
#include "core/amo_core.hpp"
#include "amo7.hpp"
int main(void) {
// ////////////////////////////////////////////////////////////////////////
// initialization
// ///////////////////////////////////////////////////////////////////////
// LED
led_init();
// initialize serial console and redirect printf(), getchar() etc. to it
serial_console_init(); // enables interrupt!
// AMO Core
amo6_ext_init();
amo6_screen_init();
amo6_buttons_init();
// AMO7
amo7_init();
// ////////////////////////////////////////////////////////////////////////
// boot indicator
// ////////////////////////////////////////////////////////////////////////
led_blink(3);
led_on();
// ////////////////////////////////////////////////////////////////////////
// finally: turn on interrupts
// ////////////////////////////////////////////////////////////////////////
sei();
// ////////////////////////////////////////////////////////////////////////
// give status message
// ////////////////////////////////////////////////////////////////////////
printf("%s\n", device_name);
printf("Device ID : %s\n", device_id);
printf("Hardware ID : %s\n", hardware_id);
printf("Firmware ID : %s\n", firmware_id);
printf("Device Ready\n");
// ////////////////////////////////////////////////////////////////////////
// main program loop
// ////////////////////////////////////////////////////////////////////////
uint16_t counter = 0;
bool no_op=1;
for (;;) {
// update hardware every 50 loops
if (counter % 50 == 0) {
amo7_hardware_update();
no_op = 0;
}
// update interface every 100 loops
if (counter % 100 == 0) {
amo6_buttons_update();
amo6_screen_update();
amo6_serial_update();
no_op = 0;
}
// delay 1ms if nothing happened
if (no_op) _delay_ms(1);
else no_op=1;
counter++;
}
return 0;
}