Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 200 → Rev 201

/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
57,6 → 57,8
void Animation_Cube_In_Cube(int iterations, int delay_ms);
 
void Delay_MS(unsigned int delay_ms) {
// Delays the CPU for the given amount of time.
// Note: Watch out for integer overflow! (max delay_ms = 107374) ??
unsigned int delay = delay_ms * MS_TO_CT_TICKS;
unsigned int startTime = ReadCoreTimer();
while ((unsigned int)(ReadCoreTimer() - startTime) < delay) {};
63,6 → 65,8
}
 
void Delay_US(unsigned int delay_us) {
// Delays the CPU for the given amount of time.
// Note: Watch out for integer overflow!
unsigned int delay = delay_us * US_TO_CT_TICKS;
unsigned int startTime = ReadCoreTimer();
while ((unsigned int)(ReadCoreTimer() - startTime) < delay) {};
79,6 → 83,7
// Set all analog I/O pins to digital
AD1PCFGSET = 0xFFFF;
 
// Initialize peripherals
SPI1_DATA spi_data;
SPI1_Init(&spi_data);
 
89,11 → 94,14
Cube_Init(&cube_data, 0x01);
 
// 2083 = 60Hz, 500 = 250Hz, 250 = 500Hz
TIMER5_Init(&Cube_Timer_Interrupt, 500);
TIMER_DATA timer_data;
TIMER5_Init(&timer_data, &Cube_Timer_Interrupt, 500);
TIMER5_Start();
 
BTN_Init(&BTN1_Interrupt, &BTN2_Interrupt, NULL);
BTN_DATA btn_data;
BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, NULL);
 
// Begin display
Cube_Set_All(0xFF,0xFF,0xFF);
Delay_MS(3000);
 
117,16 → 125,16
TIMER5_Stop();
switch (state) {
case 0:
TIMER5_Init(&Cube_Timer_Interrupt, 500);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 500);
break;
case 1:
TIMER5_Init(&Cube_Timer_Interrupt, 2083);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 2083);
break;
case 2:
TIMER5_Init(&Cube_Timer_Interrupt, 4166);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 4166);
break;
case 3:
TIMER5_Init(&Cube_Timer_Interrupt, 13107);
TIMER5_Init(NULL, &Cube_Timer_Interrupt, 13107);
break;
}
TIMER5_Start();