📄 opb_lcd_controller.c
字号:
//////////////////////////////////////////////////////////////////////////////
//
// ***************************************************************************
// ** **
// ** Copyright (c) 2004 Xilinx, Inc. All Rights Reserved. **
// ** **
// ** You may copy and modify these files for your own internal use solely **
// ** with Xilinx programmable logic devices and Xilinx EDK system or **
// ** create IP modules solely for Xilinx programmable logic devices and **
// ** Xilinx EDK system. No rights are granted to distribute any files **
// ** unless they are distributed in Xilinx programmable logic devices. **
// ** **
// ***************************************************************************
//
//////////////////////////////////////////////////////////////////////////////
// Filename: D:\Data\ppc_espw_opb_mem_controller_custom_ip\drivers\opb_lcd_controller_v1_00_a\src\opb_lcd_controller.c
// Version: 1.00.a
// Description: opb_lcd_controller Driver Source File
// Date: Sat Aug 21 11:28:31 2004 (by Create and Import Peripheral Wizard)
//////////////////////////////////////////////////////////////////////////////
/***************************** Include Files *******************************/
#include "opb_lcd_controller.h"
/************************** Function Definitions ***************************/
/******************************************************************************
* Function name : lcd.c
* returns :
* Created by : Nasser Poureh
* Date Created : 10/25/02
* Company : Insight Electronics
* Description : lcd driver
* Notes :
******************************************************************************/
// The following function generates a variable delay
void _wait(loop_count)
int loop_count;
{
int sum, data;
sum = 0;
for (data = 0; data < loop_count; data++) {
sum = (data << 8);
}
return;
}
// The following function write a byte of data to the lcd panel according
// to the following table:
//
// mode operation performed
// -----------------------------------------------------------------------
// 0 write to the lcd control register
// 1 read from lcd control register (not used)
// 2 write to the lcd data register
// 3 read from lcd data registre (not used)
//
// It should be noted that the MBS of node is used as the lcd_rs signal,
// while the LSB of the mode is used as the lcd_rw signal. Hence, mode
// and 8 bits of data are used to form a 10-bit quantity that will be
// writen to the lcd panel over the OPB data bus.
void display_update(base_addr, data, mode)
char data;
int mode;
unsigned int base_addr;
{
int lcd_control_data, extended_mode, extended_data, lcd_data_read;
unsigned int* lcd_location = (unsigned int *) base_addr;
extended_mode = (mode << 8) & 0x00000300;
extended_data = data & 0x000000ff;
lcd_control_data = extended_mode | extended_data;
*lcd_location = lcd_control_data;
_wait(5000);
return;
}
// The following function performs the lcd initializations. This function most
// be called in the main program before any access to the lcd panel is performed.
void lcd_init(base_addr)
unsigned int base_addr;
{
int lcd_count;
static char lcd_data_init[6] = {0x38, 0x06, 0x0e, 0x01, 0x80, 0x0c};
_wait(150000);
for (lcd_count = 0; lcd_count < 6; lcd_count++) {
display_update(base_addr, (lcd_data_init[lcd_count]), 0);
_wait(500000);
}
_wait(500000);
return;
}
// This function is used to write a string of characters to the lcd panel.
void lcd_write(unsigned int base_addr, char *s)
{
while (*s)
{
display_update(base_addr, *s, 2);
s++;
}
return;
}
// The following function is used to clear the lcd panel.
void lcd_clear(base_addr)
unsigned int base_addr;
{
display_update(base_addr, 0x01, 0);
return;
}
// The following function is used to select which line os the lcd is being
// writen to (line 1 or 2).
void lcd_line(base_addr, line)
unsigned int base_addr;
int line;
{
switch (line)
{
case 1: display_update(base_addr, 0x80, 0);
break;
case 2: display_update(base_addr, 0xc0, 0);
break;
default:
display_update(base_addr, 0x80, 0);
break;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -