-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
69 lines (50 loc) · 1.56 KB
/
Copy pathmain.c
File metadata and controls
69 lines (50 loc) · 1.56 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
#include <stdbool.h>
#include <stdint.h>
#include "timing.h"
#include "task.h"
#include "uart.h"
#include "buffer.h"
#include "subsys.h"
#include "system.h"
#include "sensor.h"
#include "midi.h"
#include "motor.h"
#include "major.h"
#include "limits.h"
#include <driverlib/eeprom.h>
version_t TESLA_VERSION;
void main (void){
// Set the clock to 40MHz
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN);
TESLA_VERSION.word = 0x14081000LU;
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
EEPROMInit();
TimerInit();
TaskInit();
SystemInit();
// Input on GPIO PC6 (Active Low) Disables Reset and Calibrate Functionality
GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_6);
DelayMs(2000);
uint8_t type = !(GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_6) >> 6);
MotorsInit(type);
MidiInit();
SensorInit();
MajorInit();
LimitsInit(type);
SubsystemInit(TESLA, MESSAGE, "TESLA", TESLA_VERSION);
LogMsg(TESLA, MESSAGE, "Tesla System Initialized!");
RegisterReceiverUART1(ProcessMidi);
TaskScheduleAdd(MidiChannelUpdate, TASK_LOW_PRIORITY, 100, 1000);
while(1){
SystemTick();
// We want to do this as often as possible without doing it every step
LimitsCheck();
}
}