#include "LCD1602.h"
void LCD1602Write(UINT8 type, UINT8 data)
{
uint8_t i ;
uint16_t val, tmp = data;
if(type == CMD)
GPIO_ResetBits(LCD1602PROT, RS); //RS=0 writing instruction
else
GPIO_SetBits(LCD1602PROT, RS); //RS=1 writes
GPIO_ResetBits(LCD1602PROT, RW); //RW = 0 ;
for(i=0; i<2; i++)
{
GPIO_SetBits(LCD1602PROT, EN); //EN = 1;
val = GPIO_ReadOutputData(LCD1602PROT);
val = (0x0FFF&val) | (((Tmp>>4) &0x000F) <<12);//sent 4 high
GPIO_Write(LCD1602PROT, val);
tmp <<= 4;
Delay(1);
GPIO_ResetBits(LCD1602PROT, EN); //EN = 0; Falling edge
DelayUs(5);
}
}