Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 233 → Rev 234

/PIC Stuff/Cerebot_32MX7_LED_Cube/I2C1.c
0,0 → 1,447
#include "defines.h"
#include "I2C1.h"
 
static I2C1_DATA *i2c_data_p;
 
// Initialize the data structures, should be called once before any I2C routines are called
void I2C1_Init(I2C1_DATA *data, uint8_t speed, uint8_t address) {
i2c_data_p = data;
 
i2c_data_p->buffer_in_len = 0;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
i2c_data_p->buffer_out_ind = 0;
i2c_data_p->buffer_out_len = 0;
 
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->return_status = 0;
 
i2c_data_p->slave_in_last_byte = 0;
i2c_data_p->slave_sending_data = 0;
 
i2c_data_p->master_dest_addr = 0;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
 
INTDisableInterrupts();
 
// Enable the I2C module and set the clock stretch enable bit
// Note: Automatically overrides any other pin settings
I2C1CONSET = 0x00008040;
I2C1ADD = address;
if (!speed) I2C1BRG = 0x05A; // Operate at 400kHZ (80MHz)
else I2C1BRG = 0x186; // Operate at 100kHZ (80MHz)
IFS0CLR = 0xE0000000; // Clear any existing events
IPC6CLR = 0x00001F00; // Reset priority levels
IPC6SET = 0x00001500; // Set IPL=5, Subpriority 1
IEC0SET = 0xE0000000; // Enable I2C1 interrupts
 
INTEnableInterrupts();
}
 
// Sends length number of bytes in msg to specified address (no R/W bit)
void I2C1_Master_Send(uint8_t address, uint8_t *msg, uint32_t length) {
uint32_t i;
if (length == 0)
return;
 
// Copy message to send into buffer and save length/address
for (i = 0; i < length; i++) {
i2c_data_p->buffer_in[i] = msg[i];
}
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C1_SEND_ADDR;
i2c_data_p->master_status = I2C1_MASTER_SEND;
 
// Generate start condition
I2C1CONbits.SEN = 1;
}
 
// Reads length number of bytes from address (no R/W bit)
void I2C1_Master_Recv(uint8_t address, uint32_t length) {
if (length == 0)
return;
 
// Save length and address to get data from
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C1_SEND_ADDR;
i2c_data_p->master_status = I2C1_MASTER_RECV;
 
// Generate start condition
I2C1CONbits.SEN = 1;
}
 
// Writes msg to address then reads length number of bytes from address
void I2C1_Master_Restart(uint8_t address, uint8_t msg, uint32_t length) {
uint8_t c;
if (length == 0) {
c = msg;
I2C1_Master_Send(address, &c, 1);
return;
}
 
// Save length and address to get data from
i2c_data_p->buffer_in[0] = msg;
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C1_SEND_ADDR;
i2c_data_p->master_status = I2C1_MASTER_RESTART;
 
// Generate start condition
I2C1CONbits.SEN = 1;
}
 
void __ISR(_I2C_1_VECTOR, ipl5) __I2C_1_Interrupt_Handler(void) {
// Bus collision event
if (IFS0bits.I2C1BIF) {
// This should be handled at some point
IFS0CLR = 0x20000000;
}
// Slave event
if (IFS0bits.I2C1SIF) {
I2C1_Interrupt_Slave();
IFS0CLR = 0x40000000;
}
// Master event
if (IFS0bits.I2C1MIF) {
I2C1_Interrupt_Master();
IFS0CLR = 0x80000000;
}
}
 
// An internal subroutine used in the master version of the i2c_interrupt_handler
void I2C1_Interrupt_Master() {
 
/* The PIC32 family has different master interrupts than the PIC8 family
* Master mode operations that generate a slave interrupt are:
* 1. Start condition
* 2. Repeated start sequence
* 3. Stop condition
* 4. Data transfer byte received
* 5. During a send ACK or NACK sequence to slave
* 6. Data transfer byte transmitted
* 7. During a slave-detected stop
*/
 
// If we are in the middle of sending data
if (i2c_data_p->master_status == I2C1_MASTER_SEND) {
switch (i2c_data_p->operating_state) {
case I2C1_IDLE:
break;
case I2C1_SEND_ADDR:
// Send the address with read bit set
i2c_data_p->operating_state = I2C1_CHECK_ACK_SEND;
I2C1TRN = (i2c_data_p->master_dest_addr << 1) | 0x0;
break;
case I2C1_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!I2C1STATbits.ACKSTAT) {
// If an ACK is received, send next byte of data
if (i2c_data_p->buffer_in_read_ind < i2c_data_p->buffer_in_len) {
I2C1TRN = i2c_data_p->buffer_in[i2c_data_p->buffer_in_read_ind];
i2c_data_p->buffer_in_read_ind++;
} else {
// If no more data is to be sent, send stop bit
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_OK;
}
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
}
// If we are in the middle of receiving data
} else if (i2c_data_p->master_status == I2C1_MASTER_RECV) {
switch (i2c_data_p->operating_state) {
case I2C1_IDLE:
break;
case I2C1_SEND_ADDR:
// Send address with write bit set
i2c_data_p->operating_state = I2C1_CHECK_ACK_RECV;
I2C1TRN = (i2c_data_p->master_dest_addr << 1) | 0x1;
break;
case I2C1_CHECK_ACK_RECV:
// Check if ACK is received
if (!I2C1STATbits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
i2c_data_p->operating_state = I2C1_RCV_DATA;
I2C1CONbits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_FAIL;
}
break;
case I2C1_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = I2C1RCV;
i2c_data_p->buffer_in_write_ind++;
if (i2c_data_p->buffer_in_write_ind < i2c_data_p->buffer_in_len) {
// If we still need to read, send an ACK to the slave
i2c_data_p->operating_state = I2C1_REQ_DATA;
I2C1CONbits.ACKDT = 0; // ACK
I2C1CONbits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
i2c_data_p->operating_state = I2C1_SEND_STOP;
I2C1CONbits.ACKDT = 1; // NACK
I2C1CONbits.ACKEN = 1;
}
break;
case I2C1_REQ_DATA:
// Set module to receive one byte of data
i2c_data_p->operating_state = I2C1_RCV_DATA;
I2C1CONbits.RCEN = 1;
break;
case I2C1_SEND_STOP:
// Send the stop bit and copy message to send to Main()
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_OK;
break;
}
} else if (i2c_data_p->master_status == I2C1_MASTER_RESTART) {
switch (i2c_data_p->operating_state) {
case I2C1_IDLE:
break;
case I2C1_SEND_ADDR:
// Send the address with read bit set
i2c_data_p->operating_state = I2C1_CHECK_ACK_SEND;
I2C1TRN = (i2c_data_p->master_dest_addr << 1) | 0x0;
break;
case I2C1_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!I2C1STATbits.ACKSTAT) {
// If an ACK is received, send first byte of data
I2C1TRN = i2c_data_p->buffer_in[0];
i2c_data_p->operating_state = I2C1_CHECK_ACK_RESTART;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
case I2C1_CHECK_ACK_RESTART:
if (!I2C1STATbits.ACKSTAT) {
I2C1CONbits.RSEN = 1;
i2c_data_p->operating_state = I2C1_SEND_ADDR_2;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
case I2C1_SEND_ADDR_2:
// Send the address with read bit set
i2c_data_p->operating_state = I2C1_CHECK_ACK_RECV;
I2C1TRN = (i2c_data_p->master_dest_addr << 1) | 0x1;
break;
case I2C1_CHECK_ACK_RECV:
// Check if ACK is received
if (!I2C1STATbits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
i2c_data_p->operating_state = I2C1_RCV_DATA;
I2C1CONbits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_FAIL;
}
break;
case I2C1_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = I2C1RCV;
i2c_data_p->buffer_in_write_ind++;
if (i2c_data_p->buffer_in_write_ind < i2c_data_p->buffer_in_len) {
// If we still need to read, send an ACK to the slave
i2c_data_p->operating_state = I2C1_REQ_DATA;
I2C1CONbits.ACKDT = 0; // ACK
I2C1CONbits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
i2c_data_p->operating_state = I2C1_SEND_STOP;
I2C1CONbits.ACKDT = 1; // NACK
I2C1CONbits.ACKEN = 1;
}
break;
case I2C1_REQ_DATA:
// Set module to receive one byte of data
i2c_data_p->operating_state = I2C1_RCV_DATA;
I2C1CONbits.RCEN = 1;
break;
case I2C1_SEND_STOP:
// Send the stop bit and copy message to send to Main()
i2c_data_p->operating_state = I2C1_IDLE;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_OK;
break;
}
}
}
 
void I2C1_Interrupt_Slave() {
// !!WARNING!! THIS CODE DOES -NOT- HAVE ANY ERROR HANDLING !!
// TODO: Add error handling to this interrupt function
 
/* The PIC32 family has different slave interrupts than the PIC8 family
* Slave mode operations that generate a slave interrupt are:
* 1. Detection of a valid device address (including general call)
* 2. Reception of data
* 3. Request to transmit data
*/
 
uint8_t received_data;
uint8_t data_read_from_buffer = 0;
uint8_t data_written_to_buffer = 0;
uint8_t overrun_error = 0;
 
// Clear SSPOV (overflow bit)
if (I2C1STATbits.I2COV == 1) {
I2C1STATbits.I2COV = 0;
overrun_error = 1;
i2c_data_p->return_status = I2C1_ERR_OVERRUN;
}
 
// Read SPPxBUF if it is full
if (I2C1STATbits.RBF == 1) {
received_data = I2C1RCV;
data_read_from_buffer = 1;
}
 
if (!overrun_error) {
if (I2C1STATbits.R_W == 0) {
// Slave is receiving data
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = received_data;
if (i2c_data_p->buffer_in_write_ind == MAXI2C1BUF - 1) {
i2c_data_p->buffer_in_write_ind = 0;
} else {
i2c_data_p->buffer_in_write_ind++;
}
if (i2c_data_p->buffer_in_len < MAXI2C1BUF - 1) {
i2c_data_p->buffer_in_len++;
}
i2c_data_p->slave_in_last_byte = received_data;
i2c_data_p->return_status = I2C1_RECV_OK;
} else {
// Slave is returning data
if (!i2c_data_p->slave_sending_data) {
// If we are not currently sending data, figure out what to reply with
if (I2C1_Process_Request(i2c_data_p->slave_in_last_byte)) {
// Data exists to be returned, send first byte
I2C1TRN = i2c_data_p->buffer_out[0];
data_written_to_buffer = 1;
i2c_data_p->buffer_out_ind = 1;
i2c_data_p->slave_sending_data = 1;
} else {
// Unknown request, fill rest of request with 0s
I2C1TRN = 0x0;
data_written_to_buffer = 1;
i2c_data_p->slave_sending_data = 0;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
} else {
// Sending remaining data back to master
if (i2c_data_p->buffer_out_ind < i2c_data_p->buffer_out_len) {
I2C1TRN = i2c_data_p->buffer_out[i2c_data_p->buffer_out_ind];
data_written_to_buffer = 1;
i2c_data_p->buffer_out_ind++;
} else {
// Nothing left to send, fill rest of request with 0s
I2C1TRN = 0x0;
data_written_to_buffer = 1;
i2c_data_p->slave_sending_data = 0;
i2c_data_p->return_status = I2C1_SEND_OK;
}
}
}
}
 
// Release the clock stretching bit (if we should)
if (data_read_from_buffer || data_written_to_buffer) {
// Release the clock
if (I2C1CONbits.SCLREL == 0) {
I2C1CONbits.SCLREL = 1;
}
}
}
 
/* Returns 0 if I2C module is currently busy, otherwise returns status code */
uint8_t I2C1_Get_Status() {
if (i2c_data_p->master_status != I2C1_MASTER_IDLE ||
i2c_data_p->buffer_in_len == 0) {
return 0;
} else {
return i2c_data_p->return_status;
}
}
 
uint8_t I2C1_Buffer_Len() {
return i2c_data_p->buffer_in_len;
}
 
/* Returns 0 if I2C module is currently busy, otherwise returns buffer length */
uint8_t I2C1_Read_Buffer(uint8_t *buffer) {
uint32_t i = 0;
while (i2c_data_p->buffer_in_len != 0) {
buffer[i] = i2c_data_p->buffer_in[i2c_data_p->buffer_in_read_ind];
i++;
if (i2c_data_p->buffer_in_read_ind == MAXI2C1BUF-1) {
i2c_data_p->buffer_in_read_ind = 0;
} else {
i2c_data_p->buffer_in_read_ind++;
}
i2c_data_p->buffer_in_len--;
}
return i;
}
 
/* Put data to be returned here */
uint8_t I2C1_Process_Request(uint8_t c) {
uint8_t ret = 0;
switch (c) {
case 0x01:
i2c_data_p->buffer_out[0] = 0x12;
i2c_data_p->buffer_out_len = 1;
ret = 1;
break;
case 0x02:
i2c_data_p->buffer_out[0] = 0x34;
i2c_data_p->buffer_out[1] = 0x56;
i2c_data_p->buffer_out_len = 2;
ret = 1;
break;
}
return ret;
}
/PIC Stuff/Cerebot_32MX7_LED_Cube/I2C1.h
0,0 → 1,77
#ifndef I2C1_H
#define I2C1_H
 
#define MAXI2C1BUF 32
 
// I2C Operating Speed
#define I2C1_400KHZ 0x0
#define I2C1_100KHZ 0x1
 
// Operating State
#define I2C1_IDLE 0x1
//#define I2C1_STARTED 0x2
#define I2C1_RCV_DATA 0x3
//#define I2C1_SEND_DATA 0x4
#define I2C1_SEND_ADDR 0x5
#define I2C1_SEND_ADDR_2 0x6
#define I2C1_CHECK_ACK_SEND 0x7
#define I2C1_CHECK_ACK_RECV 0x8
#define I2C1_CHECK_ACK_RESTART 0x9
#define I2C1_REQ_DATA 0xA
#define I2C1_SEND_STOP 0xB
//#define I2C1_SEND_START 0xC
 
// Operating Mode
#define I2C1_MODE_SLAVE 0x10
#define I2C1_MODE_MASTER 0x11
 
// Master Status
#define I2C1_MASTER_SEND 0x20
#define I2C1_MASTER_RECV 0x21
#define I2C1_MASTER_RESTART 0x22
#define I2C1_MASTER_IDLE 0x23
 
// Return Status
#define I2C1_SEND_OK 0x30
#define I2C1_SEND_FAIL 0x31
#define I2C1_RECV_OK 0x32
#define I2C1_RECV_FAIL 0x33
#define I2C1_DATA_AVAL 0x34
#define I2C1_ERR_NOADDR 0x35
#define I2C1_ERR_OVERRUN 0x36
#define I2C1_ERR_NODATA 0x37
#define I2C1_ERR_BUFFER_OVERRUN 0x38
 
typedef struct {
uint8_t buffer_in[MAXI2C1BUF];
uint32_t buffer_in_len;
uint32_t buffer_in_read_ind;
uint32_t buffer_in_write_ind;
 
uint8_t buffer_out[MAXI2C1BUF];
uint32_t buffer_out_len;
uint32_t buffer_out_ind;
 
uint8_t operating_state;
uint8_t return_status;
 
uint8_t master_dest_addr;
uint8_t master_status;
 
uint8_t slave_in_last_byte;
uint8_t slave_sending_data;
} I2C1_DATA;
 
void I2C1_Init(I2C1_DATA *data, uint8_t speed, uint8_t address);
void I2C1_Master_Send(uint8_t address, uint8_t *msg, uint32_t length);
void I2C1_Master_Recv(uint8_t address, uint32_t length);
void I2C1_Master_Restart(uint8_t address, uint8_t msg, uint32_t length);
void I2C1_Interrupt_Master(void);
void I2C1_Interrupt_Slave(void);
uint8_t I2C1_Get_Status(void);
uint8_t I2C1_Buffer_Len(void);
uint8_t I2C1_Read_Buffer(uint8_t *buffer);
uint8_t I2C1_Process_Request(uint8_t);
 
#endif /* I2C1_H */
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/TIMER4.c
32,7 → 32,7
Nop();
TMR4 = 0x0; // Clear timer register
PR4 = time; // Load period register
IPC4SET = 0x00000011; // Set priority level = 4, sub-priority level = 1
IPC4SET = 0x0000000D; // Set priority level = 3, sub-priority level = 1
IFS0CLR = 0x00010000; // Clear timer interrupt flag
IEC0SET = 0x00010000; // Enable timer interrupt
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/TIMER5.c
32,7 → 32,7
Nop();
TMR5 = 0x0; // Clear timer register
PR5 = time; // Load period register
IPC5SET = 0x00000011; // Set priority level = 4, sub-priority level = 1
IPC5SET = 0x0000000D; // Set priority level = 3, sub-priority level = 1
IFS0CLR = 0x00100000; // Clear timer interrupt flag
IEC0SET = 0x00100000; // Enable timer interrupt
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/UART1.c
38,9 → 38,6
IEC0SET = 0x0C000000; // Enable the RX and Error interrupts
 
INTEnableInterrupts();
 
TRISDbits.TRISD14 = 0;
PORTDbits.RD14 = 0;
}
 
uint8_t UART1_Write(uint8_t *string, uint32_t length) {
61,7 → 58,6
}
 
void __ISR(_UART_1_VECTOR, ipl2) __UART_1_Interrupt_Handler(void) {
PORTDbits.RD14 = 1;
// Process UART1 error flag
if (IFS0bits.U1EIF) {
if (U1STAbits.PERR) { // Process parity error
106,5 → 102,4
}
IFS0CLR = 0x10000000; // Clear the transmit flag
}
PORTDbits.RD14 = 0;
}
/PIC Stuff/Cerebot_32MX7_LED_Cube/defines.h
20,20 → 20,34
#define US_TO_CT_TICKS (CPU_CLOCK_HZ/2000000UL)
 
#define ADDRESS_EEPROM 0x50
#define ADDRESS_CONTROLLER_1 0x24
#define ADDRESS_CONTROLLER_2 0x25
 
// LED1 = G12, LED2 = G13, LED3 = G14, LED4 = G15 (active high)
#define LED1_TRIS TRISGbits.TRISG12
#define LED1_PORT PORTGbits.RG12
#define LED1_LAT LATGbits.LATG12
#define LED2_TRIS TRISGbits.TRISG13
#define LED2_PORT PORTGbits.RG13
#define LED2_LAT LATGbits.LATG13
#define LED3_TRIS TRISGbits.TRISG14
#define LED3_PORT PORTGbits.RG14
#define LED3_LAT LATGbits.LATG14
#define LED4_TRIS TRISGbits.TRISG15
#define LED4_PORT PORTGbits.RG15
#define LED4_LAT LATGbits.LATG15
 
void Delay_MS(uint32_t delay_ms);
void Delay_US(uint32_t delay_us);
 
// <editor-fold defaultstate="collapsed" desc="IPL">
/*
IPL1 = lowest, IPL7 = highest priority
SPI1 - Priority 5, Subpriority 1
SPI4 - Priority 6, Subpriority 2
I2C1 - Priority 5, Subpriority 1
TIMER4 - Priority 3, Subpriority 1
TIMER5 - Priority 3, Subpriority 1
UART1 - Priority 2, Subpriority 1
*/
// </editor-fold>
 
// <editor-fold desc="PMOD to MCU Pinouts">
/*
JA-01 AN2/C2IN-/CN4/RB2 RB02
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
39,6 → 39,7
#include "UART1.h"
#include "SPI1.h"
#include "SPI4.h"
#include "I2C1.h"
#include "TIMER4.h"
#include "TIMER5.h"
#include "CUBE.h"
78,6 → 79,15
// Set all analog I/O pins to digital
AD1PCFGSET = 0xFFFF;
 
LED1_TRIS = 0;
LED2_TRIS = 0;
LED3_TRIS = 0;
LED4_TRIS = 0;
LED1_LAT = 0;
LED2_LAT = 0;
LED3_LAT = 0;
LED4_LAT = 0;
 
// Initialize the SPI1 module
SPI1_DATA spi_1_data;
SPI1_Init(&spi_1_data, NULL);
86,6 → 96,9
SPI4_DATA spi_4_data;
SPI4_Init(&spi_4_data);
 
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);
111,7 → 124,7
// Process button inputs
BTN_DATA btn_data;
BTN_Init(&btn_data, &BTN1_Interrupt, &BTN2_Interrupt, &BTN3_Interrupt);
 
// Begin display
 
// Cube_Set_All(RED);
131,14 → 144,51
TIMER4_Start();
 
// Loop through some preset animations
uint8_t buffer1[2];
uint8_t buffer2[2];
uint8_t result, length;
while(1) {
// I2C1_Master_Restart(0x24, 0xA, 1);
// do {
// result = I2C1_Get_Status();
// } while (!result);
// length = I2C1_Read_Buffer(buffer1);
// buffer1[0] = ~buffer1[0];
//
//
// buffer1[1] = buffer1[0];
// buffer1[0] = 0xB;
// I2C1_Master_Send(0x24, buffer1, 2);
// do {
// result = I2C1_Get_Status();
// } while (!result);
 
I2C1_Master_Restart(0x25, 0xA, 1);
do {
result = I2C1_Get_Status();
} while (!result);
length = I2C1_Read_Buffer(buffer2);
buffer2[0] = ~buffer2[0];
 
buffer2[1] = buffer2[0];
buffer2[0] = 0xB;
I2C1_Master_Send(0x25, buffer2, 2);
 
Delay_MS(1);
 
// do {
// result = I2C1_Get_Status();
// } while (!result);
// length = I2C1_Read_Buffer(buffer);
// Animation_Solid_Colors(2,300);
// Animation_Layer_Alternate(2,300);
// Animation_Pixel_Alternate(1,200);
// Animation_Full_Color_Sweep(2,1000);
Animation_Row_Column_Sweep(2,40);
Animation_Cube_In_Cube(4,300);
Animation_Double_Rotation(2,40);
// Animation_Row_Column_Sweep(2,40);
// Animation_Cube_In_Cube(4,300);
// Animation_Double_Rotation(2,40);
// Animation_Pseudo_Random_Colors(10,300);
// Animation_Random_Colors(10,300);
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Mon Dec 09 23:33:34 EST 2013
#Tue Dec 10 23:01:47 EST 2013
default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=a7430524a414be59f5ce2a8f8797db6d
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc32\\v1.21\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=0d2b1469ad71adb787c711a416386331
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/configurations.xml
93,6 → 93,7
<property key="strict-ansi" value="false"/>
<property key="support-ansi" value="false"/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="use-indirect-calls" value="false"/>
</C32>
<C32-AS>
158,6 → 159,7
<property key="rtti" value="true"/>
<property key="strict-ansi" value="false"/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="use-indirect-calls" value="false"/>
</C32CPP>
<C32Global>
171,7 → 173,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/private.xml
1,7 → 1,3
<?xml version="1.0" encoding="UTF-8"?><project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
<file>file:/C:/Users/Kevin/Documents/Code/Cerebot_32MX7_LED_Cube/main.c</file>
<file>file:/C:/Users/Kevin/Documents/Code/Cerebot_32MX7_LED_Cube/defines.h</file>
</open-files>
</project-private>