📄 c_lcd.c
字号:
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* source\c_lcd.c 1.0 */
/* */
/* DESCRIPTION */
/* */
/* DIAGNOSTIC CODE for S3C4510B0 */
/* */
/* */
/* DATA STRUCTURES */
/* */
/* FUNCTIONS : Character LCD 16x2 Initialization and strings */
/* */
/* DEPENDENCIES */
/* */
/* */
/* NAME: Nicolas Park */
/* The last Modification date: 18-April-2002 */
/* REMARKS: Created initial version 1.0 */
/* */
/* Copyright (C) 2002 AIJISYSTEM CO.,LTD */
/*************************************************************************/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "s3c4510b0.h"
#include "uart.h"
#include "pollio.h"
#include "c_lcd.h"
#include "system.h"
void LCDTest(void)
{
Print("\n\r -- Waiting Key in .. ") ;
Print("\n\r Received Data : ") ;
}
void LTestPutString(char *ptr)
{
while(*ptr )
{
lPut_byte(*ptr++ );
WaitLcd(5000);
}
}
/*
* Function : LCDInit
* Description : Initialize LCD
*/
void LCDInit(void)
{
// Initialize EXTDBWTH : 8Byte Operation
// Initialize EXTACON0
EXTDBWTH &= 0xFFCFFFFF ;
EXTDBWTH |= DSX0 ;
EXTACON0 = LTCOS0 | LTACS0 | LTCOH0 | LTACC0 ;
// Initialize
WaitLcd(200) ;
/* ---
* Function Set
* Interface Data Length is : 8 bit
* Display Numer of Line is 2
* --- */
LInstRegWrite((U8)0x38) ; WaitLcd(100) ;
/* ---
* Display On/Off Control
* Display On
* Cursor Display/off
* Cursor Blink/off
* --- */
LInstRegWrite((U8)0x0c) ; WaitLcd(100) ;
/* ---
* Clear Display
* --- */
LInstRegWrite((U8)0x01) ; WaitLcd(100) ;
/* ---
* Cursor or Display Shift
* Shift Left
* --- */
LInstRegWrite((U8)0x18) ; WaitLcd(100) ;
/* ---
* Entry Mode Set
* Increment DD Ram Address
* --- */
LInstRegWrite((U8)0x06) ; WaitLcd(100) ;
ClearLcdDisplay() ;
}
/*
* Function : LInstRegWrite
* Description : LCD Control Register Write
*/
void LInstRegWrite(U8 DATA)
{
U8 *LcdInstWrAddr ;
LcdInstWrAddr = (U8 *)LINSTWR ;
*LcdInstWrAddr= DATA ;
}
/*
* Function : LInstRegRead, LDataRegRead
* Description : LCD Control Register Write
*/
U8 LInstRegRead(void)
{
U8 ReadData ;
ReadData = (U8)LINSTRD ;
return ReadData ;
}
U8 LDataRegRead(void)
{
U8 ReadData ;
ReadData = (U8)LDATARD ;
return ReadData ;
}
/*
* Function : WaitLcd
* Description : LCD Control Register Write
*/
void WaitLcd(int milisec)
{
int second ;
if (!CACHE_ENABLED) second = milisec * 40 ;
else second = milisec * 200 ;
while(second--) ;
}
/*
* Function : LcdBusyCheck
* Description : Wait Until LCD Busy Flag is Cleared
*/
void LcdBusyCheck(void)
{
U8 ReadData ;
ReadData = (U8)LINSTRD ;
while (!ReadData) ;
}
/*
* Function : Mv2LcdLine
* Description : Move Second LCD Line
*/
void Mv2LcdLine(void)
{
// Set DD Ram Address to
LInstRegWrite((U8)0x0c) ; WaitLcd(100) ;
LInstRegWrite((U8)0xA8) ; WaitLcd(100) ;
}
/*
* Function : ClearLcdDisplay
* Description : Clear LCD Displayed Character
*/
void ClearLcdDisplay(void)
{
LInstRegWrite((U8)0x01) ; WaitLcd(100) ;
l2Print("-NBC board v1.0-","Network BaseCamp") ;
Mv2LcdLine() ; // Change LCD Line to 2'th Line
}
void lPut_byte(U8 DATA)
{
U8 *LcdDataWrAddr ;
LcdDataWrAddr = (U8 *)LDATAWR ;
*LcdDataWrAddr= DATA ;
WaitLcd(3) ;
}
void lPrint(char *ptr )
{
LInstRegWrite((U8)0x0F) ; WaitLcd(100) ;
while(*ptr )
lPut_byte(*ptr++ );
}
void l1Print(char *prt)
{
LInstRegWrite((U8)0x01) ; WaitLcd(100) ;
lPrint(prt) ;
Mv2LcdLine() ; // Change LCD Line to 2'th Line
}
void l2Print(char *L1,char *L2)
{
LInstRegWrite((U8)0x01) ; WaitLcd(100) ;
lPrint(L1) ;
Mv2LcdLine() ; // Change LCD Line to 2'th Line
lPrint(L2) ;
}
void lfPrint(char *L2,char *fmt,...)
{
va_list argptr;
char temp_buf[LCD_DIGIT_NO];
va_start(argptr, fmt);
vsprintf(temp_buf, fmt, argptr);
LInstRegWrite((U8)0x01) ; WaitLcd(100) ;
l2Print(temp_buf,L2);
va_end(argptr);
}
void LcdUsrModeSet()
{
LInstRegWrite((U8)0x30) ; WaitLcd(100) ;
LInstRegWrite((U8)0x01) ; WaitLcd(100) ; // Clear
LInstRegWrite((U8)0x8F) ; WaitLcd(100) ;
LInstRegWrite((U8)0x07) ; WaitLcd(100) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -