Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 234 → Rev 235

/PIC Stuff/Cerebot_32MX7_LED_Cube/I2C1.c
40,6 → 40,7
}
 
// Sends length number of bytes in msg to specified address (no R/W bit)
// Will return status I2C1_SEND_OK or I2C1_SEND_FAIL
void I2C1_Master_Send(uint8_t address, uint8_t *msg, uint32_t length) {
uint32_t i;
if (length == 0)
63,6 → 64,7
}
 
// Reads length number of bytes from address (no R/W bit)
// Will return status I2C1_RECV_OK or I2C1_RECV_FAIL
void I2C1_Master_Recv(uint8_t address, uint32_t length) {
if (length == 0)
return;
82,6 → 84,7
}
 
// Writes msg to address then reads length number of bytes from address
// Will return status I2C1_SEND_FAIL or I2C1_RECV_FAIL or I2C1_RECV_OK
void I2C1_Master_Restart(uint8_t address, uint8_t msg, uint32_t length) {
uint8_t c;
if (length == 0) {
137,6 → 140,11
* 7. During a slave-detected stop
*/
 
if (I2C1STATbits.IWCOL == 1) {
// TODO: Handle write collisions
I2C1STATbits.IWCOL = 0;
}
 
// If we are in the middle of sending data
if (i2c_data_p->master_status == I2C1_MASTER_SEND) {
switch (i2c_data_p->operating_state) {
156,19 → 164,21
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;
i2c_data_p->operating_state = I2C1_STOPPED;
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;
i2c_data_p->operating_state = I2C1_STOPPED;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
case I2C1_STOPPED:
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
break;
}
// If we are in the middle of receiving data
} else if (i2c_data_p->master_status == I2C1_MASTER_RECV) {
188,15 → 198,14
I2C1CONbits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->operating_state = I2C1_STOPPED;
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
// TODO: Handle possible 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) {
217,12 → 226,15
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;
// Send the stop bit
i2c_data_p->operating_state = I2C1_STOPPED;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_OK;
break;
case I2C1_STOPPED:
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
break;
}
} else if (i2c_data_p->master_status == I2C1_MASTER_RESTART) {
switch (i2c_data_p->operating_state) {
241,9 → 253,8
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;
i2c_data_p->operating_state = I2C1_STOPPED;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
253,9 → 264,8
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;
i2c_data_p->operating_state = I2C1_STOPPED;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_SEND_FAIL;
}
break;
272,15 → 282,14
I2C1CONbits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->operating_state = I2C1_STOPPED;
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
// TODO: Handle possible 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) {
301,12 → 310,15
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;
// Send the stop bit
i2c_data_p->operating_state = I2C1_STOPPED;
I2C1CONbits.PEN = 1;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
i2c_data_p->return_status = I2C1_RECV_OK;
break;
case I2C1_STOPPED:
i2c_data_p->operating_state = I2C1_IDLE;
i2c_data_p->master_status = I2C1_MASTER_IDLE;
break;
}
}
}
399,11 → 411,12
 
/* 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) {
if (i2c_data_p->master_status == I2C1_MASTER_IDLE &&
i2c_data_p->operating_state == I2C1_IDLE &&
I2C1STATbits.TBF == 0) {
return i2c_data_p->return_status;
} else {
return 0;
} else {
return i2c_data_p->return_status;
}
}
 
/PIC Stuff/Cerebot_32MX7_LED_Cube/I2C1.h
20,6 → 20,7
#define I2C1_REQ_DATA 0xA
#define I2C1_SEND_STOP 0xB
//#define I2C1_SEND_START 0xC
#define I2C1_STOPPED 0xD
 
// Operating Mode
#define I2C1_MODE_SLAVE 0x10
/PIC Stuff/Cerebot_32MX7_LED_Cube/README.txt
0,0 → 1,200
Here lies some random pieces of information that may make it easier to understand the code base
 
 
PERIPHERAL USAGE:
SPI1 - Used by the cube code to send data to the ube
SPI4 - Unused
I2C1 - Used by the controller code
TIMER4 - Used by the cube code for the overlay rotation interrupt
TIMER5 - Used by the cube code for the update layer interrupt
UART1 - Used by the cube code for reading in frame data
PWM2 - Generates a constant ~20MHz output, uses TIMER2
 
PERIPHERAL INTERRUPT PRIORITY LEVELS:
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
 
 
PIN I/Os:
 
JA-01 AN2/C2IN-/CN4/RB2 RB02
JA-02 AN3/C2IN+/CN5/RB3 RB03
JA-03 AN4/C1IN-/CN6/RB4 RB04
JA-04 PGEC2/AN6/OCFA/RB6 RB06
JA-07 PGED2/AN7/RB7 RB07
JA-08 AN8/C1OUT/RB8 RB08
JA-09 AN9/C2OUT/RB9 RB09
JA-10 CVrefout/PMA13/AN10/RB10 RB10
*
JB-01 PMD0/RE0 RE00
JB-02 PMD1/RE1 RE01
JB-03 PMD2/RE2 RE02
JB-04 PMD3/RE3 RE03
JB-07 PMD4/RE4 RE04
JB-08 PMD5/RE5 RE05
JB-09 PMD6/RE6 RE06
JB-10 PMD7/RE7 RE07
*
JC-01 T2CK/RC1 RC01
JC-02 C2RX/PMD8/RG0 RG00
JC-03 C2TX/ETXERR/PMD9/RG1 RG01
JC-04 ETXCLK/PMD15/CN16/RD7 RD07
JC-07 AN15/ERXD3/AETXD2/OCFB/PMALL/PMA0/CN12/RB15 RB15 (SFT_D)
JC-08 PMRD/CN14/RD5 RD05 (SFT_S)
JC-09 OC5/PMWR/CN13/RD4 RD04 (SFT_K)
JC-10 AN14/ERXD2/AETXD3/PMALH/PMA1/RB14 RB14 (SFT_R)
*
JD-01 SS1/IC2/RD9 RD09 (GSLAT)
JD-02 SDO1/OC1/INT0/RD0 RD00 (GSSIN)
JD-03 T5CK/SDI1/RC4 RC04 (GSSOUT)
JD-04 SCK1/IC3/PMCS2/PMA15/RD10 RD10 (GSSCK)
JD-07 OC2/RD1 RD01 (PWMCK)
JD-08 OC3/RD2 RD02 (XBLNK)
JD-09 OC4/RD3 RD03
JD-10 ETXD2/IC5/PMD12/RD12 RD12
*
JE-01 AETXD0/SS3/U4RX/U1CTS/CN20/RD14 RD14
JE-02 SCL3/SDO3/U1TX/RF8 RF08
JE-03 SDA3/SDI3/U1RX/RF2 RF02
JE-04 AETXD1/SCK3/U4TX/U1RTS/CN21/RD15 RD15
JE-07 TRCLK/RA6 RA06 on 32MX7 or INT1/RF8 on MX7CK
JE-08 TRD3/RA7 RA07
JE-09 Vref-/CVref-/AERXD2/PMA7/RA9 RA09
JE-10 Vref+/CVref+/AERXD3/PMA6/RA10 RA10
*
JF-01 AC1RX/SS4/U5RX/U2CTS/RF12 RF12 shared with CAN1 Transceiver (JP-1)
JF-02 SCL5/SDO4/U2TX/PMA8/CN18/RF5 RF05
JF-03 SDA5/SDI4/U2RX/PMA9/CN17/RF4 RF04
JF-04 AC1TX/SCK4/U5TX/U2RTS/RF13 RF13 shared with CAN1 Transceiver (JP-2)
JF-07 TMS/RA0 RA00 on 32MX7 or INT2/RF9 on MX7CK
JF-08 TCK/RA1 RA01
JF-09 TDI/RA4 RA04
JF-10 TDO/RA5 RA05
 
N/A SCL2/RA2 RA02 I2C bus #2, not shared with Pmod connector
N/A SDA2/RA3 RA03 I2C bus #2, not shared with Pmod connector
N/A AETXCLK/SCL1/INT3/RA14 RA14 I2C Bus #1, not shared with Pmod connector
N/A AETXEN/SDA1/INT4/RA15 RA15 I2C Bus #1, not shared with Pmod connector
N/A PGED1/AN0/CN2/RB0 RB00 Used by debug circuit, PGC
N/A PGEC1/AN1/CN3/RB1 RB01 Used by debug circuit, PGD
N/A AN5/C1IN+/VBUSON/CN7/RB5 RB05 USB VBUSON
N/A AN11/ERXERR/AETXERR/PMA12/RB11 RB11 Ethernet PHY
N/A AN12/ERXD0/AECRS/PMA11/RB12 RB12 Ethernet PHY
N/A AN13/ERXD1/AECOL/PMA10/RB13 RB13 Ethernet PHY
N/A OSC1/CLKI/RC12 RC12 Primary Oscillator Crystal
N/A SOSCI/CN1/RC13 RC13 Secondary Oscillator Crystal
N/A SOSCO/T1CK/CN0/RC14 RC14 Secondary Oscillator Crystal
N/A OSC2/CLKO/RC15 RC15 Primary Oscillator Crystal
N/A ETXEN/PMD14/CN15/RD6 RD06 Ethernet PHY
N/A RTCC/EMDIO/AEMDIO/IC1/RD8 RD08 Ethernet PHY
N/A EMDC/AEMDC/IC4/PMCS1/PMA14/RD11 RD11 Ethernet PHY
N/A ETXD3/PMD13/CN19/RD13 RD13 BTN3
N/A AERXD0/INT1/RE8 RE08 USB Overcurrent detect
N/A AERXD1/INT2/RE9 RE09 Ethernet PHY Reset
N/A C1RX/ETXD1/PMD11/RF0 RF00 Ethernet PHY
N/A C1TX/ETXD0/PMD10/RF1 RF01 Ethernet PHY
N/A USBID/RF3 RF03 USBID (USB-4)
N/A D+/RG2 RG02 D+ (USB-3)
N/A D-/RG3 RG03 D- (USB-2)
N/A ECOL/SCK2/U6TX/U3RTS/PMA5/CN8/RG6 RG06 BTN1
N/A ECRS/SDA4/SDI2/U3RX/PMA4/CN9/RG7 RG07 BTN2
N/A ERXDV/AERXDV/ECRSDV/AECRSDV/SCL4/SDO2/U3TX/PMA3/CN10/RG8 RG08 Ethernet PHY
N/A ERXCLK/AERXCLK/EREFCLK/AEREFCLK/SS2/U6RX/U3CTS/PMA2/CN11/RG9 RG09 Ethernet PHY
N/A TRD1/RG12 RG12 LED1
N/A TRD0/RG13 RG13 LED2
N/A TRD2/RG14 RG14 LED3
N/A AERXERR/RG15 RG15 LED4
 
 
CONNECTORS:
 
J1 - Serial USB Misc Connections (MX7CK only)
* This header contains other FTDI UART function pins (CTS, DSR, DCD, RI)
J2 - Serial USB Connector (MX7CK only)
* This connector is connected to UART1 or PMOD JE
J7 - I2C port daisy chain connector
* On the Cerebot 32MX7, this connector provides access to the I2C signals, power and ground for I2C2.
* On the Cerebot MX7CK, this connector provides access to the I2C signals, power and ground for I2C1 + INT3/4.
J8 - I2C port daisy chain connector
* On the Cerebot 32MX7, this connector provides access to the I2C signals, power and ground for I2C1.
* On the Cerebot MX7CK, this connector provides access to the I2C signals, power and ground for I2C2.
EEPROM is changed to this port on the MX7CK
J9 - CAN #1 Connector
* This connector is used to access the signals for CAN #1.
J10 - CAN #2 Connector
* This connector is used to access the signals for CAN #2.
J11 - Ethernet Connector
* This connector provides access to the 10/100 Ethernet port.
J12-J14
* Do Not Use.
J15 - Debug USB Connector
* This connector is used to connect the on-board programming and
debug circuit to the PC for use with the MPLAB IDE.
J16 - Power supply source select
* This jumper is used to select the source of main board power.
Place a shorting block in the upper, ?USB? position to have the
board powered from the USB device connector, J19.
Place a shorting block in the center, ?EXT? position to have the
board powered from one of the external power connectors, J17 or J18.
Place a shorting block in the lower, ?DBG? position to have the
board powered from the debug USB connector, J15.
J17 - External Power Connector
* This is a 2.5mm x 5.5mm, center positive, coax power connector used to
provide external power to the board. The optional Digilent 5V Switching
Power Supply is connected here.
J18 - External Power Connector
* This is a screw terminal connector used to provide external power to
the board. Be sure to observe proper polarity (marked near the connector)
when providing power via this connector, or damage to the board and/or
connected devices may result.
J19 - USB Device / OTG Connector
* This is a USB micro-AB connector. It is used when using the PIC32MX795
microcontroller to implement a USB device or OTG Host/Device.
J20 - USB Host Connector
* This is a standard sized USB type A connector. This connector is used to
connect USB devices to the board when using the PIC32MX795 microcontroller
to implement an embedded USB host.
 
JUMPERS:
 
JP1 & JP2 - CAN or Pmod Select
* These jumpers select microcontroller signals RF12 and RF13 for use with CAN
#1 or Pmod connector JF. Place these jumpers in the CAN position to use CAN
#1. Place the jumpers in the PMOD position to use then with Pmod connector JF.
JP3 & JP4 - Pull-up enable for I2C port #2
* These two jumpers are used to enable/disable the pull-up resistors on I2C
port #2. Insert shorting blocks on these two jumpers to enable the pull-up
resistors. Remove the shorting blocks to disable the pull-up resistors. Only
a single device on the I2C bus should have the pull-up resistors enabled.
JP5 - CAN #1 Termination
* This jumper is used to enable/disable the 120 ohm termination resistor for
CAN #1. Insert the shorting block to enable the termination resistor, remove
it to disable the termination resistor.
JP6 - CAN #1 5V0 Enable
* This jumper is used to enable/disable providing 5V to the CAN #1 connector.
Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
JP7 - CAN #2 Termination
* This jumper is used to enable/disable the 120 ohm termination resistor for
CAN #2. Insert the shorting block to enable the termination resistor, remove
it to disable the termination resistor.
JP8 - CAN #1 5V0 Enable
* This jumper is used to enable/disable providing 5V to the CAN #1 connector.
Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
JP9 - Do Not Use
JP10 - USB Host Power Select
* This jumper is used to select which host connector is powered when host power
is enabled. Place the shorting block in the ?MICRO? position to supply power
to the USB micro-AB OTG Connector, J19. Place the shorting block in the ?A?
position to supply power to the USB type A Host Connector, J20.
JP11 - Programmer Serial Select (MX7CK only)
* Remove the jumper to disconnect the USB serial converter's connection to the
MCLR pin. Disconnecting this when using the built in debugger is recommended.
JP17 - Do Not Use
/PIC Stuff/Cerebot_32MX7_LED_Cube/defines.h
36,199 → 36,4
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
JA-02 AN3/C2IN+/CN5/RB3 RB03
JA-03 AN4/C1IN-/CN6/RB4 RB04
JA-04 PGEC2/AN6/OCFA/RB6 RB06
JA-07 PGED2/AN7/RB7 RB07
JA-08 AN8/C1OUT/RB8 RB08
JA-09 AN9/C2OUT/RB9 RB09
JA-10 CVrefout/PMA13/AN10/RB10 RB10
*
JB-01 PMD0/RE0 RE00
JB-02 PMD1/RE1 RE01
JB-03 PMD2/RE2 RE02
JB-04 PMD3/RE3 RE03
JB-07 PMD4/RE4 RE04
JB-08 PMD5/RE5 RE05
JB-09 PMD6/RE6 RE06
JB-10 PMD7/RE7 RE07
*
JC-01 T2CK/RC1 RC01
JC-02 C2RX/PMD8/RG0 RG00
JC-03 C2TX/ETXERR/PMD9/RG1 RG01
JC-04 ETXCLK/PMD15/CN16/RD7 RD07
JC-07 AN15/ERXD3/AETXD2/OCFB/PMALL/PMA0/CN12/RB15 RB15 (SFT_D)
JC-08 PMRD/CN14/RD5 RD05 (SFT_S)
JC-09 OC5/PMWR/CN13/RD4 RD04 (SFT_K)
JC-10 AN14/ERXD2/AETXD3/PMALH/PMA1/RB14 RB14 (SFT_R)
*
JD-01 SS1/IC2/RD9 RD09 (GSLAT)
JD-02 SDO1/OC1/INT0/RD0 RD00 (GSSIN)
JD-03 T5CK/SDI1/RC4 RC04 (GSSOUT)
JD-04 SCK1/IC3/PMCS2/PMA15/RD10 RD10 (GSSCK)
JD-07 OC2/RD1 RD01 (PWMCK)
JD-08 OC3/RD2 RD02 (XBLNK)
JD-09 OC4/RD3 RD03
JD-10 ETXD2/IC5/PMD12/RD12 RD12
*
JE-01 AETXD0/SS3/U4RX/U1CTS/CN20/RD14 RD14
JE-02 SCL3/SDO3/U1TX/RF8 RF08
JE-03 SDA3/SDI3/U1RX/RF2 RF02
JE-04 AETXD1/SCK3/U4TX/U1RTS/CN21/RD15 RD15
JE-07 TRCLK/RA6 RA06 on 32MX7 or INT1/RF8 on MX7CK
JE-08 TRD3/RA7 RA07
JE-09 Vref-/CVref-/AERXD2/PMA7/RA9 RA09
JE-10 Vref+/CVref+/AERXD3/PMA6/RA10 RA10
*
JF-01 AC1RX/SS4/U5RX/U2CTS/RF12 RF12 shared with CAN1 Transceiver (JP-1)
JF-02 SCL5/SDO4/U2TX/PMA8/CN18/RF5 RF05
JF-03 SDA5/SDI4/U2RX/PMA9/CN17/RF4 RF04
JF-04 AC1TX/SCK4/U5TX/U2RTS/RF13 RF13 shared with CAN1 Transceiver (JP-2)
JF-07 TMS/RA0 RA00 on 32MX7 or INT2/RF9 on MX7CK
JF-08 TCK/RA1 RA01
JF-09 TDI/RA4 RA04
JF-10 TDO/RA5 RA05
 
N/A SCL2/RA2 RA02 I2C bus #2, not shared with Pmod connector
N/A SDA2/RA3 RA03 I2C bus #2, not shared with Pmod connector
N/A AETXCLK/SCL1/INT3/RA14 RA14 I2C Bus #1, not shared with Pmod connector
N/A AETXEN/SDA1/INT4/RA15 RA15 I2C Bus #1, not shared with Pmod connector
N/A PGED1/AN0/CN2/RB0 RB00 Used by debug circuit, PGC
N/A PGEC1/AN1/CN3/RB1 RB01 Used by debug circuit, PGD
N/A AN5/C1IN+/VBUSON/CN7/RB5 RB05 USB VBUSON
N/A AN11/ERXERR/AETXERR/PMA12/RB11 RB11 Ethernet PHY
N/A AN12/ERXD0/AECRS/PMA11/RB12 RB12 Ethernet PHY
N/A AN13/ERXD1/AECOL/PMA10/RB13 RB13 Ethernet PHY
N/A OSC1/CLKI/RC12 RC12 Primary Oscillator Crystal
N/A SOSCI/CN1/RC13 RC13 Secondary Oscillator Crystal
N/A SOSCO/T1CK/CN0/RC14 RC14 Secondary Oscillator Crystal
N/A OSC2/CLKO/RC15 RC15 Primary Oscillator Crystal
N/A ETXEN/PMD14/CN15/RD6 RD06 Ethernet PHY
N/A RTCC/EMDIO/AEMDIO/IC1/RD8 RD08 Ethernet PHY
N/A EMDC/AEMDC/IC4/PMCS1/PMA14/RD11 RD11 Ethernet PHY
N/A ETXD3/PMD13/CN19/RD13 RD13 BTN3
N/A AERXD0/INT1/RE8 RE08 USB Overcurrent detect
N/A AERXD1/INT2/RE9 RE09 Ethernet PHY Reset
N/A C1RX/ETXD1/PMD11/RF0 RF00 Ethernet PHY
N/A C1TX/ETXD0/PMD10/RF1 RF01 Ethernet PHY
N/A USBID/RF3 RF03 USBID (USB-4)
N/A D+/RG2 RG02 D+ (USB-3)
N/A D-/RG3 RG03 D- (USB-2)
N/A ECOL/SCK2/U6TX/U3RTS/PMA5/CN8/RG6 RG06 BTN1
N/A ECRS/SDA4/SDI2/U3RX/PMA4/CN9/RG7 RG07 BTN2
N/A ERXDV/AERXDV/ECRSDV/AECRSDV/SCL4/SDO2/U3TX/PMA3/CN10/RG8 RG08 Ethernet PHY
N/A ERXCLK/AERXCLK/EREFCLK/AEREFCLK/SS2/U6RX/U3CTS/PMA2/CN11/RG9 RG09 Ethernet PHY
N/A TRD1/RG12 RG12 LED1
N/A TRD0/RG13 RG13 LED2
N/A TRD2/RG14 RG14 LED3
N/A AERXERR/RG15 RG15 LED4
*/
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="Connectors">
/*
J1 - Serial USB Misc Connections (MX7CK only)
* This header contains other FTDI UART function pins (CTS, DSR, DCD, RI)
J2 - Serial USB Connector (MX7CK only)
* This connector is connected to UART1 or PMOD JE
J7 - I2C port daisy chain connector
* On the Cerebot 32MX7, this connector provides access to the I2C signals, power and ground for I2C2.
* On the Cerebot MX7CK, this connector provides access to the I2C signals, power and ground for I2C1 + INT3/4.
J8 - I2C port daisy chain connector
* On the Cerebot 32MX7, this connector provides access to the I2C signals, power and ground for I2C1.
* On the Cerebot MX7CK, this connector provides access to the I2C signals, power and ground for I2C2.
EEPROM is changed to this port on the MX7CK
J9 - CAN #1 Connector
* This connector is used to access the signals for CAN #1.
J10 - CAN #2 Connector
* This connector is used to access the signals for CAN #2.
J11 - Ethernet Connector
* This connector provides access to the 10/100 Ethernet port.
J12-J14
* Do Not Use.
J15 - Debug USB Connector
* This connector is used to connect the on-board programming and
debug circuit to the PC for use with the MPLAB IDE.
J16 - Power supply source select
* This jumper is used to select the source of main board power.
Place a shorting block in the upper, ?USB? position to have the
board powered from the USB device connector, J19.
Place a shorting block in the center, ?EXT? position to have the
board powered from one of the external power connectors, J17 or J18.
Place a shorting block in the lower, ?DBG? position to have the
board powered from the debug USB connector, J15.
J17 - External Power Connector
* This is a 2.5mm x 5.5mm, center positive, coax power connector used to
provide external power to the board. The optional Digilent 5V Switching
Power Supply is connected here.
J18 - External Power Connector
* This is a screw terminal connector used to provide external power to
the board. Be sure to observe proper polarity (marked near the connector)
when providing power via this connector, or damage to the board and/or
connected devices may result.
J19 - USB Device / OTG Connector
* This is a USB micro-AB connector. It is used when using the PIC32MX795
microcontroller to implement a USB device or OTG Host/Device.
J20 - USB Host Connector
* This is a standard sized USB type A connector. This connector is used to
connect USB devices to the board when using the PIC32MX795 microcontroller
to implement an embedded USB host.
*/
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="Jumpers">
/*
JP1 & JP2 - CAN or Pmod Select
* These jumpers select microcontroller signals RF12 and RF13 for use with CAN
#1 or Pmod connector JF. Place these jumpers in the CAN position to use CAN
#1. Place the jumpers in the PMOD position to use then with Pmod connector JF.
JP3 & JP4 - Pull-up enable for I2C port #2
* These two jumpers are used to enable/disable the pull-up resistors on I2C
port #2. Insert shorting blocks on these two jumpers to enable the pull-up
resistors. Remove the shorting blocks to disable the pull-up resistors. Only
a single device on the I2C bus should have the pull-up resistors enabled.
JP5 - CAN #1 Termination
* This jumper is used to enable/disable the 120 ohm termination resistor for
CAN #1. Insert the shorting block to enable the termination resistor, remove
it to disable the termination resistor.
JP6 - CAN #1 5V0 Enable
* This jumper is used to enable/disable providing 5V to the CAN #1 connector.
Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
JP7 - CAN #2 Termination
* This jumper is used to enable/disable the 120 ohm termination resistor for
CAN #2. Insert the shorting block to enable the termination resistor, remove
it to disable the termination resistor.
JP8 - CAN #1 5V0 Enable
* This jumper is used to enable/disable providing 5V to the CAN #1 connector.
Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
JP9 - Do Not Use
JP10 - USB Host Power Select
* This jumper is used to select which host connector is powered when host power
is enabled. Place the shorting block in the ?MICRO? position to supply power
to the USB micro-AB OTG Connector, J19. Place the shorting block in the ?A?
position to supply power to the USB type A Host Connector, J20.
JP11 - Programmer Serial Select (MX7CK only)
* Remove the jumper to disconnect the USB serial converter's connection to the
MCLR pin. Disconnecting this when using the built in debugger is recommended.
JP17 - Do Not Use
*/
// </editor-fold>
 
#endif /* DEFINES_H */
/PIC Stuff/Cerebot_32MX7_LED_Cube/main.c
149,38 → 149,44
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(0x24, 0xA, 1);
do {
result = I2C1_Get_Status();
} while (!result);
if (result == I2C1_RECV_OK) {
LED1_LAT = 1;
length = I2C1_Read_Buffer(buffer1);
buffer1[1] = ~buffer1[0];
buffer1[0] = 0xB;
} else {
LED1_LAT = 0;
}
 
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;
if (result == I2C1_RECV_OK) {
LED2_LAT = 1;
length = I2C1_Read_Buffer(buffer2);
buffer2[1] = ~buffer2[0];
buffer2[0] = 0xB;
} else {
LED2_LAT = 0;
}
I2C1_Master_Send(0x24, buffer1, 2);
do {
result = I2C1_Get_Status();
} while (!result);
I2C1_Master_Send(0x25, buffer2, 2);
do {
result = I2C1_Get_Status();
} while (!result);
 
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);
/PIC Stuff/Cerebot_32MX7_LED_Cube/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Tue Dec 10 23:01:47 EST 2013
#Wed Dec 11 18:33:39 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
40,6 → 40,7
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
<itemPath>README.txt</itemPath>
</logicalFolder>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
173,6 → 174,7
<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"/>