56 lines
1.7 KiB
C
56 lines
1.7 KiB
C
/* *************************************************************** *
|
|
* Z80 LCD interface header file *
|
|
* (c) 27.09.2017 Paolo Iocco *
|
|
* *
|
|
***************************************************************** *
|
|
* please connect the hardware as follows (the standard 14 pin
|
|
* LCD connector is used):
|
|
*
|
|
* PORT bits 0-3 are connected to the LCD data bits 4-7 (high nibble)
|
|
* PORT bit 6 is connected to the LCD RS input (register select)
|
|
* PORT bit 7 is connected to the LCD EN bit (enable)
|
|
*
|
|
***************************************************************** */
|
|
|
|
__sfr __at 0x80 Display; // IN/OUT port at 0x80
|
|
#define CMD 0
|
|
#define DATA 1
|
|
#define EN_PIN 7
|
|
#define RS_PIN 6
|
|
#define setb(port, bitno) port |= 1<< bitno
|
|
#define clrb(port, bitno) port &= ~(1<< bitno)
|
|
/*#define BVAL(p,b) (b)
|
|
#define IO(p,b) (p)
|
|
#define SETB(io) setb(IO(io),BVAL(io))
|
|
#define CLRB(io) clrb(IO(io), BVAL(io))*/
|
|
|
|
/* easy delay procedure */
|
|
void delay(int tempo);
|
|
|
|
/* generates the strobe pulse and sends the data out */
|
|
void lcd_strobe(void);
|
|
|
|
/* sets or clears the RS bit: CMD/DATA bit */
|
|
void lcd_rs(unsigned char command);
|
|
|
|
/* write a byte to the LCD in 4 bit mode */
|
|
void lcd_write(unsigned char);
|
|
|
|
/* Clear and home the LCD */
|
|
void lcd_clear(void);
|
|
|
|
/* write a string of characters to the LCD */
|
|
void lcd_puts(const char *s);
|
|
|
|
/* write a character to the LCD */
|
|
void lcd_putch(char);
|
|
|
|
/* Go to the specified position */
|
|
void lcd_goto(unsigned char pos);
|
|
|
|
/* intialize the LCD - call before anything else */
|
|
extern void lcd_init(void);
|
|
|
|
/* Set the cursor position */
|
|
#define lcd_cursor(x) lcd_write(((x)&0x7F)|0x80)
|