-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject0.cpp
More file actions
101 lines (88 loc) · 1.86 KB
/
Copy pathproject0.cpp
File metadata and controls
101 lines (88 loc) · 1.86 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
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
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "led.h"
#define LED_DATA GPIO_PIN_5
#define LED_EN GPIO_PIN_0
#define NOP __asm("\tNOP\n\t")
LED led1;
LED led2;
LED led3;
void sendLEDs(void) {
GPIOPinWrite(GPIO_PORTB_BASE, LED_EN, LED_EN);
for (int i = 0; i < 4; ++i) {
led1.send();
led2.send();
led3.send();
}
_enable_interrupts();
GPIOPinWrite(GPIO_PORTB_BASE, LED_EN | LED_DATA, 0);
}
void blankLEDs(int leds)
{
LED blank;
for (int i = 0; i < leds; ++i) {
blank.send();
}
}
int main(void) {
//
// Setup the system clock to run at 50 Mhz from PLL with crystal reference
//
SysCtlClockSet(
SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ
| SYSCTL_OSC_MAIN);
//
// Enable and configure the GPIO port for the LED operation.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, LED_DATA | LED_EN);
GPIOPinWrite(GPIO_PORTB_BASE, LED_DATA, 0);
blankLEDs(12);
SysCtlDelay(100000);
//
// Loop Forever
//
while (1) {
for (int i = 0; i < 64; ++i) {
int ii = 64 - i;
led1.setColor(i, ii, 0);
led3.setColor(0, i, ii);
led2.setColor(ii, 0, i);
sendLEDs();
SysCtlDelay(200000);
}
for (int i = 0; i < 64; ++i) {
int ii = 64 - i;
led3.setColor(i, ii, 0);
led2.setColor(0, i, ii);
led1.setColor(ii, 0, i);
sendLEDs();
SysCtlDelay(200000);
}
for (int i = 0; i < 64; ++i) {
int ii = 64 - i;
led2.setColor(i, ii, 0);
led1.setColor(0, i, ii);
led3.setColor(ii, 0, i);
sendLEDs();
SysCtlDelay(200000);
}
// SysCtlDelay(10000000);
//
// led2.setColor(64,0,0);
// led3.setColor(0,64,0);
// led1.setColor(0,0,64);
// sendLEDs();
//
// SysCtlDelay(10000000);
//
// led3.setColor(64,0,0);
// led1.setColor(0,64,0);
// led2.setColor(0,0,64);
// sendLEDs();
//
// SysCtlDelay(10000000);
}
}