-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·118 lines (110 loc) · 3.29 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
116
117
118
#include "main.h"
#include "PIDPosistion.h"
/*
* System Function
*/
/*
* User Function
*/
//*****************************************************************************
//
// The System Variables
//
//*****************************************************************************
int32_t pos = 15000;
int32_t count = 10;
//*****************************************************************************
//
// Main Function
//
//*****************************************************************************
//48clk/r
int mycount=0;
int mode=1;
void main(void) {
init();
//MotorController(1000, 1000);
while (1) {
// MotorController(4000, 4000);
// SysCtlDelay(SysCtlClockGet()/2);
// MotorController(-4000, -4000);
// SysCtlDelay(SysCtlClockGet()/2);
//
UARTprintf("\r%8d%8d%8d", mode, QEIPositionGet(QEI0_BASE), QEIPositionGet(QEI1_BASE));
if(++mycount < 100)
{
mode=1;
MotorController(3000, 3000);
}
else if(mycount < 200)
{
mode=0;
MotorController(-3000, -3000);
}
else
{
mycount = 0;
}
SysCtlDelay(SysCtlClockGet()/1000);
}
}
//*****************************************************************************
//
// The Interrupt Vector
//
//*****************************************************************************
// Vector Timer 0
void Timer0IntHandler(void){
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//PIDPos(pos, pos);
}
// Vector Timer 1
void Timer1IntHandler(void){
ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
}
// Vector Timer 2
void Timer2IntHandler(void){
ROM_TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
}
void Timer3IntHandler(void){
ROM_TimerIntClear(TIMER3_BASE, TIMER_TIMA_TIMEOUT);
}
void Timer4IntHandler(void){
ROM_TimerIntClear(TIMER4_BASE, TIMER_TIMA_TIMEOUT);
}
void Timer5IntHandler(void){
ROM_TimerIntClear(TIMER5_BASE, TIMER_TIMA_TIMEOUT);
}
void SysTickIntHandler(void){
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, ~GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2));
}
// Vector UART0
void UART0IntHandler(void){
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, ~GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_3));
UARTIntClear(UART0_BASE, UART_INT_RX);
}
// Vector PORT F
void PortFIntHandler(void){
uint32_t PortFmask = GPIOIntStatus(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
if(PortFmask & GPIO_PIN_0){
/////////////////////////////////////////////////////////////////////////////////////////////
UARTprintf("\nButton 2 !");
//TimerEnable(TIMER0_BASE, TIMER_A);
/////////////////////////////////////////////////////////////////////////////////////////////
//SysCtlDelay(SysCtlClockGet()/100);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_0);
}
if(PortFmask & GPIO_PIN_4){
/////////////////////////////////////////////////////////////////////////////////////////////
UARTprintf("\nButton 1 !");
/////////////////////////////////////////////////////////////////////////////////////////////
//SysCtlDelay(SysCtlClockGet()/100);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
}
}
// Vector PORT B
void PortBIntHandler(void){
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, ~GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1));
//SysCtlDelay(SysCtlClockGet()/100);
GPIOIntClear(GPIO_PORTB_BASE, GPIO_PIN_4);
}