#define SPI_DELAY_TICKS (410*40) //I43_GSIU_CLOCK_CLOCK_DIVISOR_2048 //66Kb //For C10p
VOID
Delay(UINT uiMS)
{
UINT32 uiDelay = 0;
for(uiDelay=0; uiDelay<SPI_DELAY_TICKS; uiDelay++){}
}
VOID
LCDSetBit(BYTE byData, BYTE byCnt)
{
BYTE i;
for(i=0; i<byCnt; i++)
{
if((byData&0x80) == 0)
{
SetPin(LCD_PIN_DATA, 0);
}
else
{
SetPin(LCD_PIN_DATA, 1);
}
SetPin(LCD_PIN_WR, 0);
Delay(1);
SetPin(LCD_PIN_WR, 1);
Delay(1);
byData <<= 1;
}
}
VOID
SendDataBit(BYTE byData, BYTE byCnt)
{
BYTE i = 0;
for(i=0; i<byCnt; i++)
{
if((byData&0x01) == 0)
{
SetPin(LCD_PIN_DATA, 0);
}
else
{
SetPin(LCD_PIN_DATA, 1);
}
SetPin(LCD_PIN_WR, 0);
Delay(1);
SetPin(LCD_PIN_WR, 1);
Delay(1);
byData >>= 1;
}
}
VOID
SendCmd(BYTE byCmd)
{
SetPin(LCD_PIN_CS, 0);
//send flag "100"
LCDSetBit(0x80, 3);
LCDSetBit(byCmd, 9);
SetPin(LCD_PIN_CS, 1);
}
VOID
WriteByte(BYTE byAddress, BYTE byData)
{
BYTE i = 0;
SetPin(LCD_PIN_CS, 0);
//send flag "101"
LCDSetBit(0xA0, 3);
//Send 6 bits address
LCDSetBit(byAddress<<2, 6);
SendDataBit(byData, 4);
SetPin(LCD_PIN_CS, 1);
}
VOID
WriteBlockData(BYTE byAddress, PBYTE pbyData, BYTE byCnt)
{
BYTE i = 0;
SetPin(LCD_PIN_CS, 0);
//send flag "101"
LCDSetBit(0xA0, 3);
//Send 6 bits address
LCDSetBit(byAddress<<2, 6);
for(i=0; i<byCnt; i++, pbyData++)
{
SendDataBit(*pbyData, 8);
}
SetPin(LCD_PIN_CS, 1);
}
VOID
LCDTest()
{
BYTE byData[5] = {0x21, 0x43, 0x65, 0x87, 0xa9};
BYTE byData2[17] = {0xbe,0x06,0x7c,0x5e,0xc6,
0xda,0xfa,0x0e,0xfe,0xde,
0xe6,0xb0,0x20,0x02,0x00,//H,L, 前后冒号
0xee,0xa8};// R, T
LCDPinsConfig();
SetPin(LCD_PIN_CS, 1);
SetPin(LCD_PIN_WR, 1);
SetPin(LCD_PIN_DATA, 1);
SendCmd(LCD_SYS_EN);
SendCmd(LCD_OSC_IN);
SendCmd(LCD_BIAS);
SendCmd(LCD_PWR_ON);
memset(byData2, 0, 17);
//WriteByte(0x09, 0x01);
WriteBlockData(0, byData2, 4);
OsThreadSleepMS(6000);
WriteByte(0x00, 1);
WriteByte(0x01, 2);
WriteByte(0x02, 3);
WriteByte(0x03, 4);
WriteByte(0x04, 5);
WriteByte(0x05, 6);
//SendCmd(LCD_PWR_OFF);
}