void lcdwaitbusy(void) { char in, timeout = 40; DDRA = 0x00; PORTA = 0x00; ClrBit(RSPORT, RS); SetBit(RWPORT, RW); for(in = 30; in > 0; in--) ; do { _NOP(); _NOP(); SetBit(DMEPORT, DME); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); in = PINA; ClrBit(DMEPORT, DME); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); } while(TstBit(in, 7) == 1 && timeout-- > 0); } GLOBAL void lcdbefout(char out) { busintok = 0; ClrBit(MCUCR, SRE); lcdwaitbusy(); ClrBit(RWPORT, RW); DDRA = 0xFF; PORTA = out; _NOP(); SetBit(DMEPORT, DME); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); ClrBit(DMEPORT, DME); SetBit(MCUCR, SRE); busintok = 1; if(out > 0 && out < 4) waitms(3); } GLOBAL void lcddatout(char out) { busintok = 0; ClrBit(MCUCR, SRE); lcdwaitbusy(); SetBit(RSPORT, RS); ClrBit(RWPORT, RW); DDRA = 0xFF; PORTA = out; _NOP(); SetBit(DMEPORT, DME); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); ClrBit(DMEPORT, DME); SetBit(MCUCR, SRE); busintok = 1; } GLOBAL char lcddatin(void) { char in; busintok = 0; ClrBit(MCUCR, SRE); lcdwaitbusy(); SetBit(RSPORT, RS); _NOP(); _NOP(); _NOP(); SetBit(DMEPORT, DME); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); in = PINA; ClrBit(DMEPORT, DME); SetBit(MCUCR, SRE); busintok = 1; return in; }