HTEB1
User manual
3.5 AT-Keyboard-Interface
This demo shows the usage of the PS2
**
| */ | ||
#include "mydefs.h" |
|
| // with further includes! |
void wait(u16 wastetime) | // local LCD port delay | ||
{ |
|
|
|
); |
|
| |
} |
|
|
|
/* |
|
|
|
| |||
RS = P75, R/W | = P74, | EN | = P20, DATA = P5 |
*/ |
|
|
|
//some defines for easy access #define CLEAR_LCD_RS (PDR7 &= ~0x20)
#define SET_LCD_RS |
| (PDR7 = 0x20) |
#define CLEAR_LCD_RW | (PDR7 &= ~0x10) | |
#define SET_LCD_RW |
| (PDR7 = 0x10) |
#define CLEAR_LCD_EN | (PDR2 &= ~0x01) | |
#define SET_LCD_EN |
| (PDR2 = 0x01) |
#define LCD_DATA_PORT (PDR5) |
| |
#define LCD_DATA_CTRL (PCR5) |
| |
#define LCD_OUT | 0xff |
|
#define LCD_IN 0x00 |
|
|
#define LCD_WAIT |
| {wait(100);} |
void LCDWriteCmd(u8 cmd) | // write cmd to LCD port | |
{ |
|
|
CLEAR_LCD_RS; |
|
|
CLEAR_LCD_RW; |
|
|
SET_LCD_EN; |
|
|
LCD_DATA_PORT = cmd; |
| |
LCD_WAIT; |
|
|
CLEAR_LCD_EN; |
|
|
LCD_WAIT; |
|
|
} |
|
|
void LCDWriteData(u8 data) | // write data to LCD port | |
{ |
|
|
SET_LCD_RS; |
|
|
CLEAR_LCD_RW; |
|
|
SET_LCD_EN; |
|
|
LCD_DATA_PORT = data; |
| |
LCD_WAIT; |
|
|
CLEAR_LCD_EN; |
|
|
LCD_WAIT; |
|
|
} |
|
|
u8 LCDReadStatus(void) |
| // get the LCD status register |
{ |
|
|
u8 status; |
|
|
CLEAR_LCD_RS; |
|
|
Issue 0.2 | Page 44 | 07/2002 |