#define GLCD_DATABUS PORTA
#define GLCD_CONTROL PORTF
// #define GLCD_CONTROL_RS 0
// #define GLCD_CONTROL_RW 1
// #define GLCD_CONTROL_EN 2
// #define GLCD_CONTROL_CS1 3
// #define GLCD_CONTROL_CS2 4
// #define GLCD_CONTROL_RSTB 5
void GLCD_Instruction (unsigned char Inst, unsigned char Data) {
GLCD_CONTROL = Inst & 0x38; // RS 0, E 0
delay_us(10);
GLCD_DATABUS = Data;
GLCD_CONTROL = (Inst & 0x38) | 0x04; // RS 0, E 1
delay_us(10);
GLCD_CONTROL = Inst & 0x38; // RS 0, E 0
GLCD_CONTROL = 0x20; // All Clear
delay_us(100);
}
void GLCD_Data (unsigned char Inst, unsigned char Data) {
GLCD_CONTROL = (Inst & 0x38) | 0x01; // RS 1, E 0
delay_us(10);
GLCD_DATABUS = Data;
GLCD_CONTROL = (Inst & 0x38) | 0x05; // RS 1, E 1
delay_us(10);
GLCD_CONTROL = (Inst & 0x38) | 0x01; // RS 1, E 0
GLCD_CONTROL = 0x20; // All Clear
delay_us(100);
}
void GLCD_Init (void) {
unsigned char i, j, k;
GLCD_CONTROL = 0x00; // All Clear
GLCD_Instruction(0x38, 0x3F); // CS1, CS2 Display On
GLCD_Instruction(0x38, 0xC0); // CS1, CS2 Display Position
k = 0xB8;
for(i=0; i<=7; i++) {
GLCD_Instruction(0x38, k); // X Start Address
GLCD_Instruction(0x38, 0x40); // Y Start Address
for(j=0; j<=63; j++)
GLCD_Data(0x38, 0x00); // Clear CS1, CS2
k++;
}
}