Subversion Repositories Code-Repo

Rev

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

Rev 261 Rev 263
Line 141... Line 141...
141
    LED1_LAT = 0;
141
    LED1_LAT = 0;
142
    LED2_LAT = 0;
142
    LED2_LAT = 0;
143
    LED3_LAT = 0;
143
    LED3_LAT = 0;
144
    LED4_LAT = 0;
144
    LED4_LAT = 0;
145
 
145
 
-
 
146
    // Determine what to do at this point. We either choose to idle (on POR)
-
 
147
    // or go into a mode specified prior to the software reset event
-
 
148
    uint8_t last_reset = Get_Reset_Condition();
-
 
149
    if (last_reset == RESET_POR || last_reset == RESET_BOR ||
-
 
150
            last_reset == RESET_PIN || last_reset == RESET_WDT ||
-
 
151
            last_reset == RESET_CFG) {
-
 
152
        op_state = BOARD_MODE_IDLE;
-
 
153
    }
-
 
154
 
146
    // Initialize the SPI1 module
155
    // Initialize the SPI1 module
147
    SPI1_DATA spi_1_data;
156
    SPI1_DATA spi_1_data;
148
    SPI1_Init(&spi_1_data, NULL);
157
    SPI1_Init(&spi_1_data, NULL);
149
 
158
 
150
    // Initialize the SPI4 module
159
    // Initialize the SPI4 module
Line 172... Line 181...
172
    TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
181
    TIMER5_Init(&timer_5_data, &Cube_Timer_Interrupt, 500);
173
 
182
 
174
    // Start the controller polling and overlay rotation interrupt
183
    // Start the controller polling and overlay rotation interrupt
175
    TIMER4_DATA timer_4_data;
184
    TIMER4_DATA timer_4_data;
176
    TIMER4_Init(&timer_4_data, &Controller_Update, NULL, 0);
185
    TIMER4_Init(&timer_4_data, &Controller_Update, NULL, 0);
177
//    TIMER4_Init(&timer_4_data, NULL, NULL, 0);
-
 
178
 
186
 
179
    // Process button inputs
187
    // Process button inputs
180
    BTN_DATA btn_data;
188
    BTN_DATA btn_data;
181
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, NULL);
189
    BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, NULL);
182
 
190
 
Line 189... Line 197...
189
    ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
197
    ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
190
    
198
    
191
    SNAKE_DATA snake_data;
199
    SNAKE_DATA snake_data;
192
    TRON_DATA tron_data;
200
    TRON_DATA tron_data;
193
 
201
 
194
    // Determine what to do at this point. We either choose to idle (on POR)
-
 
195
    // or go into a mode specified prior to the software reset event
-
 
196
    uint8_t last_reset = Get_Reset_Condition();
-
 
197
    if (last_reset == RESET_POR || last_reset == RESET_BOR ||
-
 
198
            last_reset == RESET_PIN || last_reset == RESET_WDT ||
-
 
199
            last_reset == RESET_CFG) {
-
 
200
        op_state = BOARD_MODE_IDLE;
-
 
201
    }
-
 
202
 
-
 
203
    PWM2_Start();
202
    PWM2_Start();
204
    TIMER5_Start();
203
    TIMER5_Start();
205
    TIMER4_Start();
204
    TIMER4_Start();
206
    
205
    
207
    /* -------------------- END OF INITIALIZATION -------------------- */
206
    /* -------------------- END OF INITIALIZATION -------------------- */
208
    /* ------------------------ BEGIN DISPLAY ------------------------ */
207
    /* ------------------------ BEGIN DISPLAY ------------------------ */
209
    
208
 
-
 
209
    // Figure out what state to go into here
210
    switch (op_state) {
210
    switch (op_state) {
211
        case BOARD_MODE_IDLE:
211
        case BOARD_MODE_IDLE:
212
            Idle_Animation_Sequence();
212
            Idle_Animation_Sequence();
213
            break;
213
            break;
214
        case BOARD_MODE_SNAKE:;
214
        case BOARD_MODE_SNAKE:;
Line 225... Line 225...
225
            TIMER4_Stop();
225
            TIMER4_Stop();
226
            while(1);
226
            while(1);
227
            break;
227
            break;
228
    }
228
    }
229
 
229
 
230
    while(1);
-
 
231
 
-
 
232
}
230
}
233
 
231
 
234
void Idle_Animation_Sequence(void) {
232
void Idle_Animation_Sequence(void) {
235
      Delay_MS(250);
233
      Delay_MS(250);
236
 
234
 
Line 248... Line 246...
248
//    Animation_Pseudo_Random_Colors(200);
246
//    Animation_Pseudo_Random_Colors(200);
249
 
247
 
250
    // Start the scrolling text
248
    // Start the scrolling text
251
    TIMER4_Stop();
249
    TIMER4_Stop();
252
    TIMER4_Init(NULL, &Controller_Update, &Cube_Text_Interrupt, 100);
250
    TIMER4_Init(NULL, &Controller_Update, &Cube_Text_Interrupt, 100);
253
    TIMER4_Start();
251
//    TIMER4_Start();
254
 
252
 
255
//    int8_t start_text[] = "Cube Initialized\r\n";
253
//    int8_t start_text[] = "Cube Initialized\r\n";
256
//    UART1_Write(start_text, 18);
254
//    UART1_Write(start_text, 18);
257
 
255
 
258
    // Set the overlay text
256
    // Set the overlay text