-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.c
56 lines (47 loc) · 1.32 KB
/
main.c
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
/*
* Copyright (c) 2011 Gregory Haynes <[email protected]>
*
* Licensed under the BSD license. See LICENSE for more information.
*/
#include "sysinit.h"
#include "esc.h"
#include "logging.h"
#include "proto.h"
#include "state.h"
#include "control.h"
#include "core/uart.h"
#include "core/systick.h"
#include "sensors/itg3200.h"
#include "sensors/adxl345.h"
int main(void) {
systemInit();
// Initialize Systick to be 1ms
systickInit(1);
control_init();
// Uart is 115200 Baud, 8 N 1
uartInit(57600);
logging_send_string(LOGGING_DEBUG, "Hello!");
// Initialize motor controllers
esc_init_all();
logging_send_string(LOGGING_DEBUG, "Arming ESCs.");
esc_arm_all();
logging_send_string(LOGGING_DEBUG, "Arming ESCs complete.");
// Init sensors
logging_send_string(LOGGING_DEBUG, "Initializing gyro.");
itg3200Init();
logging_send_string(LOGGING_DEBUG, "Initializing gyro complete.");
logging_send_string(LOGGING_DEBUG, "Initializing accelerometer.");
adxl345_Init();
logging_send_string(LOGGING_DEBUG, "Initializing accelerometer complete.");
state_init();
control_init();
logging_send_string(LOGGING_DEBUG, "Entering main control loop.");
// Main loop
while(1) {
proto_update();
state_update();
control_update();
esc_update();
}
return 0;
}