void glcdDataWrite(uint8_t data) { register uint8_t controller = (GrLcdState.lcdXAddr/GLCD_CONTROLLER_XPIXELS); #ifdef GLCD_PORT_INTERFACE cli(); glcdBusyWait(controller); // wait until LCD not busy sbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); outb(GLCD_DATA_DDR, 0xFF); outb(GLCD_DATA_PORT, data); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); sei(); #else //sbi(MCUCR, SRW); // enable RAM waitstate glcdBusyWait(controller); // wait until LCD not busy *(volatile unsigned char *) (GLCD_CONTROLLER0_CTRL_ADDR + GLCD_CONTROLLER_ADDR_OFFSET*controller) = data; //cbi(MCUCR, SRW); // disable RAM waitstate #endif // increment our local address counter GrLcdState.ctrlr[controller].xAddr++; GrLcdState.lcdXAddr++; if(GrLcdState.lcdXAddr >= GLCD_XPIXELS) { GrLcdState.lcdYAddr++; glcdSetYAddress(GrLcdState.lcdYAddr); glcdSetXAddress(0); } }
uint8_t glcdControlRead(uint8_t controller) { register uint8_t data; #ifdef GLCD_PORT_INTERFACE cli(); glcdBusyWait(controller); // wait until LCD not busy cbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); outb(GLCD_DATA_DDR, 0x00); sbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); data = inb(GLCD_DATA_PIN); cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); outb(GLCD_DATA_DDR, 0xFF); sei(); #else //sbi(MCUCR, SRW); // enable RAM waitstate glcdBusyWait(controller); // wait until LCD not busy data = *(volatile unsigned char *) (GLCD_CONTROLLER0_CTRL_ADDR + GLCD_CONTROLLER_ADDR_OFFSET*controller); //cbi(MCUCR, SRW); // disable RAM waitstate #endif return data; }
void glcdControlWrite(u08 controller, u08 data) { #ifdef GLCD_PORT_INTERFACE cli(); glcdBusyWait(controller); // wait until LCD not busy cbi(GLCD_CTRL_RS_PORT, GLCD_CTRL_RS); cbi(GLCD_CTRL_RW_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_E_PORT, GLCD_CTRL_E); //outb(GLCD_DATA_DDR, 0xFF); GLCD_DATAH_DDR |= 0xF0; GLCD_DATAL_DDR |= 0x0F; //outb(GLCD_DATA_PORT, data); GLCD_DATAH_PORT &= ~0xF0; // clear top nibble GLCD_DATAH_PORT |= data & 0xF0; // set top nibble GLCD_DATAL_PORT &= ~0x0F; // clear bottom nibble GLCD_DATAL_PORT |= data & 0x0F; // set bottom nibble asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); cbi(GLCD_CTRL_E_PORT, GLCD_CTRL_E); sei(); #else //sbi(MCUCR, SRW); // enable RAM waitstate glcdBusyWait(controller); // wait until LCD not busy *(volatile unsigned char *) (GLCD_CONTROLLER0_CTRL_ADDR + GLCD_CONTROLLER_ADDR_OFFSET*controller) = data; //cbi(MCUCR, SRW); // disable RAM waitstate #endif }
u08 glcdDataRead(u08 dummy) { register u08 data; register u08 controller = (GrLcdState.lcdXAddr/GLCD_CONTROLLER_XPIXELS); glcdBusyWait(controller); // wait until LCD not busy outb(GLCD_DATA_PORT, 0x00); // no pullups outb(GLCD_DATA_DDR, 0x00); // don't drive data lines GLCD_CTRL_PORT |= _BV(GLCD_CTRL_RS) | _BV(GLCD_CTRL_RW) | _BV(GLCD_CTRL_E); NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; data = inb(GLCD_DATA_PIN); GLCD_CTRL_PORT &= ~(_BV(GLCD_CTRL_RS) | _BV(GLCD_CTRL_RW) | _BV(GLCD_CTRL_E)); if(!dummy) { // increment our local address counter, not done for dummy reads GrLcdState.ctrlr[controller].xAddr++; GrLcdState.lcdXAddr++; if(GrLcdState.lcdXAddr >= GLCD_XPIXELS) { glcdSetYAddress(GrLcdState.lcdYAddr+1); glcdSetXAddress(0); } } return data; }
void glcdDataWrite(u08 data) { register u08 controller = (GrLcdState.lcdXAddr/GLCD_CONTROLLER_XPIXELS); glcdBusyWait(controller); // wait until LCD not busy outb(GLCD_DATA_DDR, 0xFF); outb(GLCD_DATA_PORT, data); sbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); // increment our local address counter GrLcdState.ctrlr[controller].xAddr++; GrLcdState.lcdXAddr++; if(GrLcdState.lcdXAddr >= GLCD_XPIXELS) { glcdSetYAddress(GrLcdState.lcdYAddr+1); glcdSetXAddress(0); } }
u08 glcdDataRead(void) { register u08 data; register u08 controller = (GrLcdState.lcdXAddr/GLCD_CONTROLLER_XPIXELS); #ifdef GLCD_PORT_INTERFACE cli(); glcdBusyWait(controller); // wait until LCD not busy sbi(GLCD_CTRL_RS_PORT, GLCD_CTRL_RS); //outb(GLCD_DATA_DDR, 0x00); GLCD_DATAH_DDR &= ~(0xF0); GLCD_DATAL_DDR &= ~(0x0F); sbi(GLCD_CTRL_RW_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_E_PORT, GLCD_CTRL_E); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); //data = inb(GLCD_DATA_PIN); data = (GLCD_DATAH_PIN & 0xF0) | (GLCD_DATAL_PIN & 0x0F); cbi(GLCD_CTRL_E_PORT, GLCD_CTRL_E); cbi(GLCD_CTRL_RW_PORT, GLCD_CTRL_RW); sei(); #else //sbi(MCUCR, SRW); // enable RAM waitstate glcdBusyWait(controller); // wait until LCD not busy data = *(volatile unsigned char *) (GLCD_CONTROLLER0_CTRL_ADDR + GLCD_CONTROLLER_ADDR_OFFSET*controller); //cbi(MCUCR, SRW); // disable RAM waitstate #endif // increment our local address counter /* GrLcdState.ctrlr[controller].xAddr++; GrLcdState.lcdXAddr++; if(GrLcdState.lcdXAddr >= GLCD_XPIXELS) { GrLcdState.lcdYAddr++; glcdSetYAddress(GrLcdState.lcdYAddr); glcdSetXAddress(0); }*/ return data; }
void glcdControlWrite(u08 controller, u08 data) { glcdBusyWait(controller); // wait until LCD not busy cbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); outb(GLCD_DATA_DDR, 0xFF); outb(GLCD_DATA_PORT, data); NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); }
void glcdControlWrite(uint8_t controller, uint8_t data) { #ifdef GLCD_PORT_INTERFACE cli(); glcdBusyWait(controller); // wait until LCD not busy cbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); outb(GLCD_DATA_DDR, 0xFF); outb(GLCD_DATA_PORT, data); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); sei(); #else //sbi(MCUCR, SRW); // enable RAM waitstate glcdBusyWait(controller); // wait until LCD not busy *(volatile unsigned char *) (GLCD_CONTROLLER0_CTRL_ADDR + GLCD_CONTROLLER_ADDR_OFFSET*controller) = data; //cbi(MCUCR, SRW); // disable RAM waitstate #endif }
u08 glcdControlRead(u08 controller) { register u08 data; glcdBusyWait(controller); // wait until LCD not busy cbi(GLCD_CTRL_PORT, GLCD_CTRL_RS); outb(GLCD_DATA_DDR, 0x00); sbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); sbi(GLCD_CTRL_PORT, GLCD_CTRL_E); NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; data = inb(GLCD_DATA_PIN); cbi(GLCD_CTRL_PORT, GLCD_CTRL_E); cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW); outb(GLCD_DATA_DDR, 0xFF); return data; }