-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.c
117 lines (95 loc) · 2.28 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
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
115
/*
* main.c
*
* Created on: Dec 21, 2013
* Author: Nathan
*/
#include "MCN1 Headers/all.h"
Uint16 MesgID = 5;
int main(void)
{
StartUp();
//BootISRSetup();
//PowerDownISRSetup();
sys_ops.State = STATE_INIT;
while(1)
{
NextState(MesgID);
}
}
void NextState(Uint16 MesgID)
{
switch (sys_ops.State)
{
case STATE_INIT:
Initialize();
break;
case STATE_SENSOR_COV:
SensorCov();
break;
case STATE_BOOT:
Boot(MesgID);
break;
case STATE_POWER_DOWN:
PowerDown();
break;
default:
Initialize();
}
}
// Boot button removed in MCN v2.0
/*
void BootISRSetup()
{
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 0; // GPIO
GpioCtrlRegs.GPADIR.bit.GPIO28 = 0; // input
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 2; // XINT1 Synch to SYSCLKOUT only
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; //enable pull up
EDIS;
// GPIO28 is XINT1, GPIO1 is XINT2
EALLOW;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 28; // XINT1 is GPIO28
EDIS;
// Configure XINT1
XIntruptRegs.XINT1CR.bit.POLARITY = 0; // Falling edge interrupt
// Enable XINT1
XIntruptRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; // Enable PIE Group 1 INT4
IFR &= ~M_INT1;
IER |= M_INT1;
}
*/
void StartUp()
{
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitSysCtrl();
InitGpio();
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2803x_DefaultIsr.c.
// This function is found in DSP2803x_PieVect.c.
InitPieVectTable();
//Initialize Flash
InitFlash();
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
}
// INT1.4
// No longer use in MCN V2.0 since there is no longer a boot button
/*
__interrupt void XINT1_ISR(void)
{
// Insert ISR Code here
Boot(MesgID);
// To receive more interrupts from this PIE group, acknowledge this interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
*/