Subversion Repositories Code-Repo

Rev

Rev 231 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 234
Line 37... Line 37...
37
 
37
 
38
#include "defines.h"
38
#include "defines.h"
39
#include "UART1.h"
39
#include "UART1.h"
40
#include "SPI1.h"
40
#include "SPI1.h"
41
#include "SPI4.h"
41
#include "SPI4.h"
-
 
42
#include "I2C1.h"
42
#include "TIMER4.h"
43
#include "TIMER4.h"
43
#include "TIMER5.h"
44
#include "TIMER5.h"
44
#include "CUBE.h"
45
#include "CUBE.h"
45
#include "BTN.h"
46
#include "BTN.h"
46
#include "ANIMATIONS.h"
47
#include "ANIMATIONS.h"
Line 76... Line 77...
76
    INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
77
    INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
77
 
78
 
78
    // Set all analog I/O pins to digital
79
    // Set all analog I/O pins to digital
79
    AD1PCFGSET = 0xFFFF;
80
    AD1PCFGSET = 0xFFFF;
80
 
81
 
-
 
82
    LED1_TRIS = 0;
-
 
83
    LED2_TRIS = 0;
-
 
84
    LED3_TRIS = 0;
-
 
85
    LED4_TRIS = 0;
-
 
86
    LED1_LAT = 0;
-
 
87
    LED2_LAT = 0;
-
 
88
    LED3_LAT = 0;
-
 
89
    LED4_LAT = 0;
-
 
90
 
81
    // Initialize the SPI1 module
91
    // Initialize the SPI1 module
82
    SPI1_DATA spi_1_data;
92
    SPI1_DATA spi_1_data;
83
    SPI1_Init(&spi_1_data, NULL);
93
    SPI1_Init(&spi_1_data, NULL);
84
 
94
 
85
    // Initialize the SPI4 module
95
    // Initialize the SPI4 module
86
    SPI4_DATA spi_4_data;
96
    SPI4_DATA spi_4_data;
87
    SPI4_Init(&spi_4_data);
97
    SPI4_Init(&spi_4_data);
88
 
98
 
-
 
99
    I2C1_DATA i2c_1_data;
-
 
100
    I2C1_Init(&i2c_1_data, I2C1_400KHZ, 0x20);
-
 
101
 
89
    // Initialize the UART1 module
102
    // Initialize the UART1 module
90
    UART1_DATA uart_data;
103
    UART1_DATA uart_data;
91
    UART1_Init(&uart_data, &Cube_Data_In);
104
    UART1_Init(&uart_data, &Cube_Data_In);
92
 
105
 
93
    // Initializs the PWM2 output to 20MHz
106
    // Initializs the PWM2 output to 20MHz
Line 109... Line 122...
109
    TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 90000);
122
    TIMER4_Init(&timer_4_data, &Cube_Text_Interrupt, 90000);
110
 
123
 
111
    // Process button inputs
124
    // Process button inputs
112
    BTN_DATA btn_data;
125
    BTN_DATA btn_data;
113
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, &BTN3_Interrupt);
126
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, &BTN3_Interrupt);
114
    
127
 
115
    // Begin display
128
    // Begin display
116
 
129
 
117
//    Cube_Set_All(RED);
130
//    Cube_Set_All(RED);
118
//    Delay_MS(2000);
131
//    Delay_MS(2000);
119
//    Cube_Set_All(GREEN);
132
//    Cube_Set_All(GREEN);
Line 129... Line 142...
129
    uint8_t text_string[] = "Welcome to the AMP Lab     ";
142
    uint8_t text_string[] = "Welcome to the AMP Lab     ";
130
    Cube_Text_Init(text_string, 27, 0xFF, 0xFF, 0xFF);
143
    Cube_Text_Init(text_string, 27, 0xFF, 0xFF, 0xFF);
131
    TIMER4_Start();
144
    TIMER4_Start();
132
 
145
 
133
    // Loop through some preset animations
146
    // Loop through some preset animations
-
 
147
    uint8_t buffer1[2];
-
 
148
    uint8_t buffer2[2];
-
 
149
    uint8_t result, length;
-
 
150
    
134
    while(1) {
151
    while(1) {
-
 
152
//        I2C1_Master_Restart(0x24, 0xA, 1);
-
 
153
//        do {
-
 
154
//            result = I2C1_Get_Status();
-
 
155
//        } while (!result);
-
 
156
//        length = I2C1_Read_Buffer(buffer1);
-
 
157
//        buffer1[0] = ~buffer1[0];
-
 
158
//
-
 
159
//
-
 
160
//        buffer1[1] = buffer1[0];
-
 
161
//        buffer1[0] = 0xB;
-
 
162
//        I2C1_Master_Send(0x24, buffer1, 2);
-
 
163
//        do {
-
 
164
//            result = I2C1_Get_Status();
-
 
165
//        } while (!result);
-
 
166
 
-
 
167
        I2C1_Master_Restart(0x25, 0xA, 1);
-
 
168
        do {
-
 
169
            result = I2C1_Get_Status();
-
 
170
        } while (!result);
-
 
171
        length = I2C1_Read_Buffer(buffer2);
-
 
172
        buffer2[0] = ~buffer2[0];
-
 
173
 
-
 
174
        buffer2[1] = buffer2[0];
-
 
175
        buffer2[0] = 0xB;
-
 
176
        I2C1_Master_Send(0x25, buffer2, 2);
-
 
177
 
-
 
178
        Delay_MS(1);
-
 
179
 
-
 
180
//        do {
-
 
181
//            result = I2C1_Get_Status();
-
 
182
//        } while (!result);
-
 
183
//        length = I2C1_Read_Buffer(buffer);
-
 
184
        
135
//        Animation_Solid_Colors(2,300);
185
//        Animation_Solid_Colors(2,300);
136
//        Animation_Layer_Alternate(2,300);
186
//        Animation_Layer_Alternate(2,300);
137
//        Animation_Pixel_Alternate(1,200);
187
//        Animation_Pixel_Alternate(1,200);
138
//        Animation_Full_Color_Sweep(2,1000);
188
//        Animation_Full_Color_Sweep(2,1000);
139
        Animation_Row_Column_Sweep(2,40);
189
//        Animation_Row_Column_Sweep(2,40);
140
        Animation_Cube_In_Cube(4,300);
190
//        Animation_Cube_In_Cube(4,300);
141
        Animation_Double_Rotation(2,40);
191
//        Animation_Double_Rotation(2,40);
142
//        Animation_Pseudo_Random_Colors(10,300);
192
//        Animation_Pseudo_Random_Colors(10,300);
143
//        Animation_Random_Colors(10,300);
193
//        Animation_Random_Colors(10,300);
144
 
194
 
145
//        ClearWDT(); // Clear the WDT if we dont want the board to reset
195
//        ClearWDT(); // Clear the WDT if we dont want the board to reset
146
    }
196
    }