//PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.c |
---|
117,6 → 117,7 |
uint8_t i,j; |
// Write configuration data to the DC/BC/FC/UD registers |
uint8_t DCS[GCS_LAYER_SIZE] = {0}; |
for (i = 0; i < 8; i++) { |
uint16_t offset = i * GCS_REG_SIZE; |
124,7 → 125,7 |
DCS[offset + j] = 0xFF; // Dot correction |
} |
// Warning: do not set BC > 0x6F |
// Warning: do not set BC > 0x6F ?? NEED TO VERIFY THIS !! |
DCS[offset + 21] = BC; // Global red brightness |
DCS[offset + 22] = BC; // Global green brightness |
DCS[offset + 23] = BC; // Global blue brightness |
855,26 → 856,31 |
// Read and process the ethernet packet |
if (!ETH_Read_Packet(buffer, &length)) { |
// Check the opcode (first byte) to determine what to do |
if (buffer[0] == 0x1) { |
if (buffer[0] == 0x1) { // 0x1 - Reset into Ethernet mode |
Reset_Board(BOARD_MODE_ETHERNET); |
} |
if (buffer[0] == 0x2) { |
} else if (buffer[0] == 0x2) { // 0x2 - Reset back to idle mode |
Reset_Board(BOARD_MODE_IDLE); |
} |
if (buffer[0] == 0xA) { |
} else if (buffer[0] == 0xA) { // 0xA - Clear the entire cube |
Cube_Clear(); |
} |
if (buffer[0] == 0xB) { |
ClearWDT(); |
// Update the cube |
for (i = 0; i < CUBE_LAYER_COUNT; i++) { |
for (j = 0; j < CUBE_COLUMN_COUNT; j++) { |
for (k = 0; k < CUBE_ROW_COUNT; k++) { |
Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]); |
index = index + 3; |
} else if (buffer[0] == 0xB) { // 0xB - Set the global brightness value |
Cube_Write_DCS(buffer[1]); |
} else if (buffer[0] == 0xC) { // 0xC - Set the entire cube |
if (length == 0x0601) { |
ClearWDT(); |
for (i = 0; i < CUBE_LAYER_COUNT; i++) { |
for (j = 0; j < CUBE_COLUMN_COUNT; j++) { |
for (k = 0; k < CUBE_ROW_COUNT; k++) { |
Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]); |
index = index + 3; |
} |
} |
} |
} |
} else if (buffer[0] == 0xD) { // 0xD - Rotate the cube |
Cube_Rotate(buffer[1]); |
} else if (buffer[0] == 0xE) { // 0xE - Rotate a layer |
Cube_Rotate_Shell(buffer[1], buffer[2]); |
} |
} |
} |
//PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.h |
---|
119,9 → 119,11 |
void Cube_Text_Interrupt(void); |
// Data stream in control functions |
// UART functions |
void Cube_Data_In(uint8_t c); |
void Cube_Data_In_Process_Frame(void); |
void Cube_Data_Direct_Write_All(uint8_t *buffer); |
// Ethernet functions |
void Cube_Ethernet_Frame_In(void); |
#endif /* CUBE_H */ |
//PIC Stuff/Cerebot_32MX7_LED_Cube/ETHERNET.c |
---|
115,6 → 115,7 |
} while (value & 0x8000 != 0); |
// Delay to wait for the link to be established |
// Something needs to be done about this. 5s is WAY too long to wait |
Delay_MS(5000); |
// Wait for auto-negotiation to finish |
309,14 → 310,15 |
void __ISR(_ETH_VECTOR, ipl1) __ETH_Interrupt_Handler(void) { |
// uint32_t value = ETHIRQ; |
if (ETHIRQbits.TXBUSE) { |
// TX bus error, something -should- be done |
ETHIRQbits.TXBUSE = 0; |
} |
if (ETHIRQbits.RXBUSE) { |
// RX bus error, something -should- be done |
ETHIRQbits.RXBUSE = 0; |
} |
if (ETHIRQbits.RXDONE) { |
// Call the previously saved function |
if (eth_data->rx_callback != NULL) |
(*eth_data->rx_callback)(); |
ETHIRQbits.RXDONE = 0; |
326,22 → 328,23 |
// ETHIRQbits.PKTPEND = 0; |
// } |
if (ETHIRQbits.TXDONE) { |
// Call the previously saved function |
if (eth_data->tx_callback != NULL) |
(*eth_data->tx_callback)(); |
ETHIRQbits.TXDONE = 0; |
} |
if (ETHIRQbits.TXABORT) { |
// TX aborted, do we care? |
ETHIRQbits.TXABORT = 0; |
} |
if (ETHIRQbits.RXBUFNA) { |
// This is a serious error! |
// TODO: handle this |
ETHIRQbits.RXBUFNA = 0; |
} |
if (ETHIRQbits.RXOVFLW) { |
// This is a serious error! |
// TODO: handle this |
ETHIRQbits.RXOVFLW = 0; |
} |
//PIC Stuff/Cerebot_32MX7_LED_Cube/main.c |
---|
143,6 → 143,15 |
LED3_LAT = 0; |
LED4_LAT = 0; |
// 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 |
uint8_t last_reset = Get_Reset_Condition(); |
if (last_reset == RESET_POR || last_reset == RESET_BOR || |
last_reset == RESET_PIN || last_reset == RESET_WDT || |
last_reset == RESET_CFG) { |
op_state = BOARD_MODE_IDLE; |
} |
// Initialize the SPI1 module |
SPI1_DATA spi_1_data; |
SPI1_Init(&spi_1_data, NULL); |
174,7 → 183,6 |
// Start the controller polling and overlay rotation interrupt |
TIMER4_DATA timer_4_data; |
TIMER4_Init(&timer_4_data, &Controller_Update, NULL, 0); |
// TIMER4_Init(&timer_4_data, NULL, NULL, 0); |
// Process button inputs |
BTN_DATA btn_data; |
191,15 → 199,6 |
SNAKE_DATA snake_data; |
TRON_DATA tron_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 |
uint8_t last_reset = Get_Reset_Condition(); |
if (last_reset == RESET_POR || last_reset == RESET_BOR || |
last_reset == RESET_PIN || last_reset == RESET_WDT || |
last_reset == RESET_CFG) { |
op_state = BOARD_MODE_IDLE; |
} |
PWM2_Start(); |
TIMER5_Start(); |
TIMER4_Start(); |
206,7 → 205,8 |
/* -------------------- END OF INITIALIZATION -------------------- */ |
/* ------------------------ BEGIN DISPLAY ------------------------ */ |
// Figure out what state to go into here |
switch (op_state) { |
case BOARD_MODE_IDLE: |
Idle_Animation_Sequence(); |
227,8 → 227,6 |
break; |
} |
while(1); |
} |
void Idle_Animation_Sequence(void) { |
250,7 → 248,7 |
// Start the scrolling text |
TIMER4_Stop(); |
TIMER4_Init(NULL, &Controller_Update, &Cube_Text_Interrupt, 100); |
TIMER4_Start(); |
// TIMER4_Start(); |
// int8_t start_text[] = "Cube Initialized\r\n"; |
// UART1_Write(start_text, 18); |
//PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties |
---|
1,5 → 1,5 |
# |
#Mon Jan 27 14:39:49 EST 2014 |
#Wed Jan 29 14:42:18 EST 2014 |
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=83f4565fa27ad9b8015f63d69ef74f66 |
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.31\\bin |
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1f98a0eed69cb2a45c12981fa9470927 |