128 X 64 그래픽 LCD달기 위해서 만든 회로임.
5V레벨용 포트가 부족하므로, 포트 확장 목적으로 만듬.

아래는 8255에 제어용 루틴들임.

첨부파일은 OrCAD 9.0 으로 그린 회로도임.

unsigned char *volatile pucptr_byte = (unsigned char *)HwBaseAddress;


void gpio_a_out(unsigned char data)
{
pucptr_byte[HwPortA_DIR] = 0xff;
pucptr_byte[HwPortA_DIR] = 0xff;
pucptr_byte[HwPortA_DATA] = data;
}

unsigned char gpio_a_in()
{
pucptr_byte[HwPortA_DIR] = 0x00;
pucptr_byte[HwPortA_DIR] = 0x00;
return(pucptr_byte[HwPortA_DATA]);
}

void gpio_b_out(unsigned char data)
{
pucptr_byte[HwPortB_DIR] = 0xff;
pucptr_byte[HwPortB_DIR] = 0xff;
pucptr_byte[HwPortB_DATA] = data;
}

unsigned char gpio_b_in()
{
pucptr_byte[HwPortB_DIR] = 0x00;
pucptr_byte[HwPortB_DIR] = 0x00;
return(pucptr_byte[HwPortB_DATA]);
}

void gpio_d_out(unsigned char data)
{
pucptr_byte[HwPortD_DIR] = 0x00;
pucptr_byte[HwPortD_DIR] = 0x00;
pucptr_byte[HwPortD_DATA] = data;
}

unsigned char gpio_d_in()
{
pucptr_byte[HwPortD_DIR] = 0xff;
pucptr_byte[HwPortD_DIR] = 0xff;
return(pucptr_byte[HwPortD_DATA]);
}




#define _8255_PORTA 0x00
#define _8255_PORTB 0x01
#define _8255_PORTC 0x02
#define _8255_CW 0x03
#define _8255_WR 0x04
#define _8255_RD 0x08
#define _8255_CS1 0x10
#define _8255_CS2 0x20
#define _8255_RESET 0x40

#define _8255_CTR gpio_b_out
#define _8255_DATA_OUT gpio_d_out
#define _8255_DATA_IN gpio_d_in

void _8255_WR_1(unsigned char addr, unsigned char data)
{
_8255_DATA_OUT(data);
_8255_CTR(0x00 | addr & (~_8255_CS1) | _8255_CS2 & (~_8255_WR) | _8255_RD );
_8255_CTR(0x00 | addr & (~_8255_CS1) | _8255_CS2 | _8255_WR | _8255_RD );
_8255_CTR(0x00 | addr | _8255_CS1 | _8255_CS2 | _8255_WR | _8255_RD );
}