Subversion Repositories Code-Repo

Rev

Rev 231 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 255
Line 1... Line 1...
1
#include "defines.h"
1
#include "defines.h"
2
#include "CUBE.h"
2
#include "CUBE.h"
3
#include "SPI1.h"
3
#include "SPI1.h"
4
#include "glcdfont.h"
4
#include "glcdfont.h"
5
#include "UART1.h"
5
#include "UART1.h"
-
 
6
#include "ETHERNET.h"
6
 
7
 
7
static CUBE_DATA *cube_data_ptr;
8
static CUBE_DATA *cube_data_ptr;
8
 
9
 
9
inline void Cube_Delay() {
10
inline void Cube_Delay() {
10
    // Small delay to ensure that latch speeds are < 30Mhz
11
    // Small delay to ensure that latch speeds are < 30Mhz
Line 841... Line 842...
841
    }
842
    }
842
}
843
}
843
 
844
 
844
void Cube_Data_Direct_Write_All(uint8_t *buffer) {
845
void Cube_Data_Direct_Write_All(uint8_t *buffer) {
845
    memcpy(cube_data_ptr->GCS, buffer, CUBE_LAYER_COUNT * GCS_LAYER_SIZE);
846
    memcpy(cube_data_ptr->GCS, buffer, CUBE_LAYER_COUNT * GCS_LAYER_SIZE);
-
 
847
}
-
 
848
 
-
 
849
void Cube_Ethernet_Frame_In(void) {
-
 
850
    uint8_t i,j,k;
-
 
851
    uint8_t buffer[2048];
-
 
852
    uint16_t length;
-
 
853
    uint16_t index = 1;
-
 
854
 
-
 
855
    // Read and process the ethernet packet
-
 
856
    if (ETH_Read_Packet(buffer, &length)) {
-
 
857
        // Check the first byte to determine what to do
-
 
858
        if (buffer[0] == 0x1) {
-
 
859
            Reset_Board(BOARD_MODE_ETHERNET);
-
 
860
        }
-
 
861
        if (buffer[0] == 0x2) {
-
 
862
            Reset_Board(BOARD_MODE_IDLE);
-
 
863
        }
-
 
864
        if (buffer[0] == 0xA) {
-
 
865
            ClearWDT();
-
 
866
            // Update the cube
-
 
867
            for (i = 0; i < CUBE_LAYER_COUNT; i++) {
-
 
868
                for (j = 0; j < CUBE_COLUMN_COUNT; j++) {
-
 
869
                    for (k = 0; k < CUBE_ROW_COUNT; k++) {
-
 
870
                        Cube_Set_Pixel(i, k, j, buffer[index], buffer[index+1], buffer[index+2]);
-
 
871
                        index += 3;
-
 
872
                    }
-
 
873
                }
-
 
874
            }
-
 
875
        }
-
 
876
    }
846
}
877
}
847
878