📄 lcd_drv.c
字号:
#include "AT91SAM7S64.h"
#include "Board.h"
#include "type.h"
#include "spi.h"
#include "port.h"
#include "lcd_drv.h"
/*
#define LCD_CMD_ADD 0xbe //b10111110
#define LCD_DATA_ADD 0xbf //b10111111
///////////////////////////////////////////////////////////
void vLcdSendCmd(INT8U data)
{
port_SetAddress(LCD_CMD_ADD);
LCDWR_LOW();
*AT91C_PIOA_ODSR = (INT32U)data;
LCDEN_HIGH();
port_Delay(5);
LCDEN_LOW();
}
///////////////////////////////////////////////////////////
void vLcdSendData(INT8U data)
{
port_SetAddress(LCD_DATA_ADD);
LCDWR_LOW();
*AT91C_PIOA_ODSR = (INT32U)data;
LCDEN_HIGH();
port_Delay(5);
LCDEN_LOW();
}
//////////////////////////////////////////////////////////
INT8U u8LcdReadData(void)
{
INT32U temp32;
INT8U temp8;
port_SetAddress(LCD_CMD_ADD); //set address first
LCDWR_HIGH(); //set read mode
*AT91C_PIOA_ODR |= (PORT_8BIT); //output disable
LCDEN_HIGH(); //en high
port_Delay(5);
temp32 = *AT91C_PIOA_PDSR; //read data
LCDEN_LOW(); //en low
*AT91C_PIOA_OER |= (PORT_8BIT); //output active
temp8 = (INT8U)temp32;
return temp8;
}
//////////////////////////////////////////////////////////
void vBusyWait(void)
{
INT8U busy;
do
{
busy = u8LcdReadData();
}
while(busy & 0x80);
}
//////////////////////////////////////////////////////////
void vLcdInit(void)
{
vLcdSendCmd(0x30);
vLcdSendCmd(0x04);
vBusyWait();
vLcdSendCmd(0x0c);
vBusyWait();
vLcdSendCmd(0x01);
vBusyWait();
vLcdSendCmd(0x02);
}
//////////////////////////////////////////////////////////
void vPrintString(INT8U x, INT8U y, INT8U u8Length, char *string)
{
INT8U i;
if(0 == y)
{
vBusyWait();
vLcdSendCmd(0x80 + x);
}
else
{
vBusyWait();
vLcdSendCmd(0x90 + x);
}
for(i=0; i<u8Length; i++)
{
vBusyWait();
vLcdSendData(*string ++);
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -