Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 260 → Rev 261

/PIC Stuff/Cerebot_32MX7_LED_Cube/CUBE.c
848,13 → 848,13
 
void Cube_Ethernet_Frame_In(void) {
uint8_t i,j,k;
uint8_t buffer[2048];
uint8_t buffer[2048] = {0};
uint16_t length;
uint16_t index = 1;
 
// Read and process the ethernet packet
if (ETH_Read_Packet(buffer, &length)) {
// Check the first byte to determine what to do
if (!ETH_Read_Packet(buffer, &length)) {
// Check the opcode (first byte) to determine what to do
if (buffer[0] == 0x1) {
Reset_Board(BOARD_MODE_ETHERNET);
}
862,6 → 862,9
Reset_Board(BOARD_MODE_IDLE);
}
if (buffer[0] == 0xA) {
Cube_Clear();
}
if (buffer[0] == 0xB) {
ClearWDT();
// Update the cube
for (i = 0; i < CUBE_LAYER_COUNT; i++) {
868,7 → 871,7
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 += 3;
index = index + 3;
}
}
}
/PIC Stuff/Cerebot_32MX7_LED_Cube/ETHERNET.c
179,14 → 179,14
 
ETHIENbits.TXBUSEIE = 1; // Enable interrupt on transmit BVCI bus error
ETHIENbits.RXBUSEIE = 1; // Enable interrupt on receive BVCI bus error
// ETHIENbits.RXDONEIE = 1; // Enable interrupt on packet received
ETHIENbits.PKTPENDIE = 1; // Enable interrupt on packet pending
ETHIENbits.RXDONEIE = 1; // Enable interrupt on packet received
// ETHIENbits.PKTPENDIE = 1; // Enable interrupt on packet pending
// ETHIENbits.RXACTIE = 1;
ETHIENbits.TXDONEIE = 1; // Enable interrupt on packet sent
ETHIENbits.TXABORTIE = 1; // Enable interrupt on packet send aborted
 
IPC12bits.ETHIP = 2; // Set interrupt priority to 2
IPC12bits.ETHIS = 2; // Set intererupt sub-priority to 2
IPC12bits.ETHIP = 1; // Set interrupt priority to 2
IPC12bits.ETHIS = 1; // Set intererupt sub-priority to 2
IEC1bits.ETHIE = 1; // Enable ethernet interrupts
 
EMAC1SUPPbits.RESETRMII = 0; // Bring the RMII module out of reset
233,10 → 233,10
 
// Read the packet data values into the buffer
size = eth_data->RX_ED_table.descriptor[descriptor_index].BYTE_COUNT - 18;
*length = size;
for (j = 0; j < size - 18; j++) {
for (j = 0; j < size; j++) {
buffer[j] = eth_data->RX_ED_buffer[descriptor_index][j+14];
}
*length = size;
 
// Reset the descriptors
eth_data->RX_ED_table.descriptor[descriptor_index].SOP = 0;
307,7 → 307,7
}
 
void __ISR(_ETH_VECTOR, ipl1) __ETH_Interrupt_Handler(void) {
uint32_t value = ETHIRQ;
// uint32_t value = ETHIRQ;
if (ETHIRQbits.TXBUSE) {
 
ETHIRQbits.TXBUSE = 0;
316,14 → 316,15
 
ETHIRQbits.RXBUSE = 0;
}
// if (ETHIRQbits.RXDONE) {
// ETHIRQbits.RXDONE = 0;
// }
if (ETHIRQbits.PKTPEND) {
if (ETHIRQbits.RXDONE) {
if (eth_data->rx_callback != NULL)
(*eth_data->rx_callback)();
ETHIRQbits.PKTPEND = 0;
ETHIRQbits.RXDONE = 0;
}
// if (ETHIRQbits.PKTPEND) {
//
// ETHIRQbits.PKTPEND = 0;
// }
if (ETHIRQbits.TXDONE) {
if (eth_data->tx_callback != NULL)
(*eth_data->tx_callback)();
/PIC Stuff/Cerebot_32MX7_LED_Cube/README.txt
23,7 → 23,7
TIMER5 - Priority 3, Subpriority 1
TIMER4 - Priority 1, Subpriority 1
UART1 - Priority 2, Subpriority 1
ETHERNET - Priority 2, Subpriority 2
ETHERNET - Priority 1, Subpriority 1
 
 
PIN I/Os:
/PIC Stuff/Cerebot_32MX7_LED_Cube/defines.h
42,15 → 42,11
#define RESET_CFG 0x06 // Config mismatch reset
 
// Board 'modes' (idle/games/etc)
#define BOARD_MODE_IDLE 0x01
#define BOARD_MODE_SNAKE 0x02
#define BOARD_MODE_TRON 0x03
#define BOARD_MODE_ETHERNET 0x04
#define BOARD_MODE_IDLE 0x1
#define BOARD_MODE_SNAKE 0x2
#define BOARD_MODE_TRON 0x3
#define BOARD_MODE_ETHERNET 0x4
 
typedef struct {
uint8_t cube_mode;
} BOARD_STATE;
 
void Delay_MS(uint32_t delay_ms);
void Delay_US(uint32_t delay_us);
uint8_t Get_Reset_Condition(void);
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
90,14 → 90,14
}
 
// Initialize a persistent operational state machine
static BOARD_STATE op_state __attribute__((persistent));
volatile static uint8_t op_state __attribute__((persistent));
 
uint8_t Get_Board_State(void) {
return op_state.cube_mode;
return op_state;
}
 
void Reset_Board(uint8_t next_state) {
op_state.cube_mode = next_state;
op_state = next_state;
// Executes a software reset
INTDisableInterrupts();
143,10 → 143,6
LED3_LAT = 0;
LED4_LAT = 0;
 
// Initialize the Ethernet module
ETH_DATA eth_data;
ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
 
// Initialize the SPI1 module
SPI1_DATA spi_1_data;
SPI1_Init(&spi_1_data, NULL);
159,9 → 155,9
I2C1_DATA i2c_1_data;
I2C1_Init(&i2c_1_data, I2C1_400KHZ, 0x20);
 
// Initialize the UART1 module
UART1_DATA uart_data;
UART1_Init(&uart_data, &Cube_Data_In);
// // Initialize the UART1 module
// UART1_DATA uart_data;
// UART1_Init(&uart_data, &Cube_Data_In);
 
// Initializs the PWM2 output to 20MHz
PWM2_Init();
178,6 → 174,7
// 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;
186,6 → 183,10
// Initialize controllers
CONTROLLER_DATA ctrl_data;
Controller_Init(&ctrl_data, NULL);
 
// Initialize the Ethernet module
ETH_DATA eth_data;
ETH_Init(&eth_data, NULL, &Cube_Ethernet_Frame_In);
SNAKE_DATA snake_data;
TRON_DATA tron_data;
196,7 → 197,7
if (last_reset == RESET_POR || last_reset == RESET_BOR ||
last_reset == RESET_PIN || last_reset == RESET_WDT ||
last_reset == RESET_CFG) {
op_state.cube_mode = BOARD_MODE_IDLE;
op_state = BOARD_MODE_IDLE;
}
 
PWM2_Start();
206,7 → 207,10
/* -------------------- END OF INITIALIZATION -------------------- */
/* ------------------------ BEGIN DISPLAY ------------------------ */
switch (op_state.cube_mode) {
switch (op_state) {
case BOARD_MODE_IDLE:
Idle_Animation_Sequence();
break;
case BOARD_MODE_SNAKE:;
Controller_Init(&ctrl_data, &Snake_Update_Direction);
Snake_Init(&snake_data);
218,14 → 222,13
Tron_Main();
break;
case BOARD_MODE_ETHERNET:
TIMER4_Stop();
while(1);
break;
case BOARD_MODE_IDLE:
default:
Idle_Animation_Sequence();
break;
}
 
while(1);
 
}
 
void Idle_Animation_Sequence(void) {
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Sat Jan 25 17:19:01 EST 2014
#Mon Jan 27 14:39:49 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
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/configurations.xml
92,6 → 92,7
<property key="exclude-floating-point" value="false"/>
<property key="extra-include-directories" value=""/>
<property key="generate-16-bit-code" value="false"/>
<property key="generate-micro-compressed-code" value="false"/>
<property key="isolate-each-function" value="false"/>
<property key="make-warnings-into-errors" value="false"/>
<property key="optimization-level" value="-O1"/>
131,6 → 132,7
<property key="extra-lib-directories" value=""/>
<property key="generate-16-bit-code" value="false"/>
<property key="generate-cross-reference-file" value="false"/>
<property key="generate-micro-compressed-code" value="false"/>
<property key="heap-size" value=""/>
<property key="input-libraries" value=""/>
<property key="linker-symbols" value=""/>
158,6 → 160,7
<property key="exclude-floating-point" value="false"/>
<property key="extra-include-directories" value=""/>
<property key="generate-16-bit-code" value="false"/>
<property key="generate-micro-compressed-code" value="false"/>
<property key="isolate-each-function" value="false"/>
<property key="make-warnings-into-errors" value="false"/>
<property key="optimization-level" value="-O1"/>
182,7 → 185,6
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="firmware.download.all" value="false"/>
<property key="memories.bootflash" value="false"/>
<property key="memories.configurationmemory" value="false"/>
<property key="memories.eeprom" value="false"/>
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/private/configurations.xml
4,7 → 4,7
<defaultConf>0</defaultConf>
<confs>
<conf name="default" type="2">
<platformToolSN>:=MPLABCommUSB:=04D8:=8108:=0002:=Digilent:=Cerebot 32MX7:=D370400:=x:=en</platformToolSN>
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>8108:=&lt;rev>0002:=&lt;man>Digilent:=&lt;prod>Cerebot 32MX7:=&lt;sn>D370400:=&lt;drv>x:=&lt;xpt>h:=end</platformToolSN>
<languageToolchainDir>C:\Program Files (x86)\Microchip\xc32\v1.31\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>