-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
114 lines (87 loc) · 1.44 KB
/
main.cpp
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
114
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include "config.h"
#include "version.h"
#include "portAccess.h"
#include "State.h"
#include "eepromConfig.h"
#include "HostComm.h"
#include "uart.h"
#include "rs485.h"
#include "Timer.h"
#include "StepperController.h"
#include "psu.h"
#include "mmc/mmc.h"
#include "utils.h"
#include "fpmath.h"
const char spBuildId[] PROGMEM = BUILD_ID;
const char FIRMWARE_NAME[] PROGMEM = NAME " " VERSIONSTRING " " BUILD_ID "\r\n";
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));
void wdt_init()
{
wdt_reset();
wdt_disable();
return;
}
void initSystem()
{
stepperController.setPoint(0,0,0);
}
void setup()
{
DDR(LED_PORT) |= _BV(LED_PIN);
clock_init();
// fpinit();
LED_ON();
#ifdef USE_SDCARD
mmcInit();
#endif
initSystem();
/* if (!eepromConfigValid())
{
eepromWriteDefaults();
}
*/
/*
uint8_t b;
uint8_t p=0;
while((b=pgm_read_byte(FIRMWARE_NAME+p)))
{
DEBUG_OUTB(b);
p++;
}
*/
#ifdef USE_PSU
psu_init();
#endif
LED_OFF();
sei();
}
void loop()
{
led_update();
hostComm.update();
switch(mainState)
{
case STATE_RUNNING:
hostComm.processCommandBuffer();
break;
case STATE_DELAY:
updateDelayState();
break;
case STATE_WAIT_FOR_SLAVE:
hostComm.updateSlaveWaitState();
break;
}
stepperController.update();
}
void main() __attribute__ ((noreturn));
void main()
{
setup();
while(true)
{
loop();
}
}