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); |
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); |
|