Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 237 → Rev 240

/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
87,7 → 87,16
return ret;
}
 
void Reset_Board(void) {
// Initialize a persistent operational state machine
static BOARD_STATE op_state __attribute__((persistent));
 
uint8_t Get_Board_State(void) {
return op_state.cube_mode;
}
 
void Reset_Board(uint8_t next_state) {
op_state.cube_mode = next_state;
// Executes a software reset
INTDisableInterrupts();
SYSKEY = 0x00000000; // Write invalid key to force lock
132,9 → 141,6
LED3_LAT = 0;
LED4_LAT = 0;
 
// Initialize a persistent operational state machine
BOARD_STATE op_state __attribute__((persistent));
 
// Initialize the SPI1 module
SPI1_DATA spi_1_data;
SPI1_Init(&spi_1_data, NULL);
171,8 → 177,11
BTN_DATA btn_data;
BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, NULL);
 
// Initialize controllers
CONTROLLER_DATA ctrl_data;
Controller_Init(&ctrl_data, &op_state, &Controller_Set_Leds);
Controller_Init(&ctrl_data, &Snake_Update_Direction);
SNAKE_DATA snake_data;
 
// Determine what to do at this point. We either choose to idle (on POR)
// or go into a mode specified prior to the software reset event
197,15 → 206,10
switch (op_state.cube_mode) {
case BOARD_MODE_SNAKE:
LED3_LAT = 1;
LED4_LAT = 0;
SNAKE_DATA snake_data;
Snake_Init(&snake_data);
while(1);
Snake_Main();
break;
case BOARD_MODE_TRON:
LED3_LAT = 0;
LED4_LAT = 1;
while(1);
break;
case BOARD_MODE_IDLE:
217,6 → 221,7
}
 
void Idle_Animation_Sequence(void) {
Delay_MS(250);
 
// Cube_Set_All(RED);
// Delay_MS(2000);
224,12 → 229,12
// Delay_MS(2000);
// Cube_Set_All(BLUE);
// Delay_MS(2000);
Animation_Pseudo_Random_Colors(200);
Animation_Pseudo_Random_Colors(200);
Animation_Pseudo_Random_Colors(200);
Animation_Pseudo_Random_Colors(200);
Animation_Pseudo_Random_Colors(200);
Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
// Animation_Pseudo_Random_Colors(200);
 
// Start the scrolling text
TIMER4_Stop();