| 279 |
Kevin |
1 |
#include <xc.h>
|
|
|
2 |
#include "defines.h"
|
|
|
3 |
#include "INTERRUPTS.h"
|
|
|
4 |
#include "NEOPIXEL.h"
|
|
|
5 |
|
|
|
6 |
// <editor-fold defaultstate="collapsed" desc="Configuration Registers">
|
|
|
7 |
/* Config Register CONFIGL @ 0x8007 */
|
|
|
8 |
#pragma config CPD = OFF // Data memory code protection is disabled
|
|
|
9 |
#pragma config BOREN = OFF // Brown-out Reset disabled
|
|
|
10 |
#pragma config IESO = OFF // Internal/External Switchover mode is disabled
|
|
|
11 |
#pragma config FOSC = INTOSC // INTOSC oscillator: I/O function on CLKIN pin
|
|
|
12 |
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor is disabled
|
|
|
13 |
#pragma config MCLRE = ON // MCLR/VPP pin function is MCLR
|
|
|
14 |
#pragma config WDTE = OFF // WDT disabled
|
|
|
15 |
#pragma config CP = OFF // Program memory code protection is disabled
|
|
|
16 |
#pragma config PWRTE = OFF // PWRT disabled
|
|
|
17 |
#pragma config CLKOUTEN = OFF // CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
|
|
|
18 |
|
|
|
19 |
/* Config Register CONFIG2 @ 0x8008 */
|
|
|
20 |
#pragma config PLLEN = ON // 4x PLL disabled
|
|
|
21 |
#pragma config WRT = OFF // Write protection off
|
|
|
22 |
#pragma config STVREN = OFF // Stack Overflow or Underflow will not cause a Reset
|
|
|
23 |
#pragma config BORV = HI // Brown-out Reset Voltage (Vbor), high trip point selected.
|
|
|
24 |
#pragma config LVP = OFF // High-voltage on MCLR/VPP must be used for programming
|
|
|
25 |
// </editor-fold>
|
|
|
26 |
|
|
|
27 |
NEOPIXEL_DATA neopixel_data;
|
|
|
28 |
|
|
|
29 |
int main() {
|
|
|
30 |
|
|
|
31 |
// Oscillator configuration (32Mhz HFINTOSC)
|
|
|
32 |
OSCCONbits.SCS = 0b00;
|
|
|
33 |
OSCCONbits.IRCF = 0b1110;
|
|
|
34 |
|
|
|
35 |
ANSELA = 0x00; // All pins set to digital I/O
|
|
|
36 |
APFCONbits.CCP1SEL = 1; // Switch CCP1 from RA2 to RA5
|
|
|
37 |
|
|
|
38 |
// Wait for HFINTOSC to be within 0.5% of target 32Mhz
|
|
|
39 |
while (!OSCSTATbits.HFIOFS);
|
|
|
40 |
|
|
|
41 |
// Interrupt_Enable();
|
|
|
42 |
|
|
|
43 |
NeoPixel_Init(&neopixel_data);
|
|
|
44 |
|
|
|
45 |
for (char i = 0; i < 60; i++) {
|
|
|
46 |
if (i % 6 == 0)
|
|
|
47 |
NeoPixel_Set(i, RED);
|
|
|
48 |
else if (i % 6 == 1)
|
|
|
49 |
NeoPixel_Set(i, ORANGE);
|
|
|
50 |
else if (i % 6 == 2)
|
|
|
51 |
NeoPixel_Set(i, YELLOW);
|
|
|
52 |
else if (i % 6 == 3)
|
|
|
53 |
NeoPixel_Set(i, GREEN);
|
|
|
54 |
else if (i % 6 == 4)
|
|
|
55 |
NeoPixel_Set(i, BLUE);
|
|
|
56 |
else
|
|
|
57 |
NeoPixel_Set(i, PURPLE);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
while(1) {
|
|
|
61 |
NeoPixel_Write_All();
|
|
|
62 |
}
|
|
|
63 |
}
|