📄 lcd.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 2003, Micrium, Inc., Weston, FL
* All Rights Reserved
*
* EDK38024
* LCD DRIVER
*
* File : lcd.c
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* LCD DIGITS for VI422 DISPLAY
*
* LCD_DIG_1 LCD_DIG_2 LCD_DIG_3 LCD_DIG_4
*
* a a C1 a a
* ------- ------- ------- -------
* | | | | | | | |
* f| | b f| | b f| | b f| | b
* | g | | g | # | g | | g |
* ------- ------- ------- -------
* | | | | # | | | |
* e| | c e| | c e| | c e| | c
* | | | | | | | |
* ------- ------- ------- -------
* d # d # d # d
* DP1 DP2 DP3
*
* Data byte mapping:
*
* Bit: B7 B6 B5 B4 B3 B2 B1 B0
*
* DIGIT1 g f e d c b a
* DIGIT2: DP2 g f e d c b a
* DIGIT3: DP3 g f e d c b a
* DIGIT4: DP4 g f e d c b a
*********************************************************************************************************
*/
#define LCD_LPCR (*(volatile INT8U *)(0xFFC0))
#define LCD_LCR (*(volatile INT8U *)(0xFFC1))
#define LCD_LCR2 (*(volatile INT8U *)(0xFFC2))
#define LCD_CLK_STOP_R2 (*(volatile INT8U *)(0xFFFB))
#define LCD_DIG_1 (*(volatile INT8U *)(0xF740))
#define LCD_DIG_2 (*(volatile INT8U *)(0xF741))
#define LCD_DIG_3 (*(volatile INT8U *)(0xF742))
#define LCD_DIG_4 (*(volatile INT8U *)(0xF743))
/*
*********************************************************************************************************
* ASCII to SEVEN-SEGMENT conversion table
* a
* ------
* f | | b
* | g |
* Note: The segments are mapped as follows: ------
* e | | c
* g f e d c b a | d |
* -- -- -- -- -- -- -- -- ------
* B7 B6 B5 B4 B3 B2 B1 B0
*********************************************************************************************************
*/
const INT8U LCD_ASCIItoSegTbl[] = { /* ASCII to SEVEN-SEGMENT conversion table */
0x00, /* ' ' */
0x00, /* '!', No seven-segment conversion for exclamation point */
0x22, /* '"', Double quote */
0x00, /* '#', Pound sign */
0x00, /* '$', No seven-segment conversion for dollar sign */
0x00, /* '%', No seven-segment conversion for percent sign */
0x00, /* '&', No seven-segment conversion for ampersand */
0x02, /* ''', Single quote */
0x39, /* '(', Same as '[' */
0x0F, /* ')', Same as ']' */
0x00, /* '*', No seven-segment conversion for asterix */
0x00, /* '+', No seven-segment conversion for plus sign */
0x00, /* ',', No seven-segment conversion for comma */
0x40, /* '-', Minus sign */
0x00, /* '.', No seven-segment conversion for period */
0x00, /* '/', No seven-segment conversion for slash */
0x3F, /* '0' */
0x06, /* '1' */
0x5B, /* '2' */
0x4F, /* '3' */
0x66, /* '4' */
0x6D, /* '5' */
0x7D, /* '6' */
0x07, /* '7' */
0x7F, /* '8' */
0x6F, /* '9' */
0x00, /* ':', No seven-segment conversion for colon */
0x00, /* ';', No seven-segment conversion for semi-colon */
0x00, /* '<', No seven-segment conversion for less-than sign */
0x48, /* '=', Equal sign */
0x00, /* '>', No seven-segment conversion for greater-than sign */
0x53, /* '?', Question mark */
0x00, /* '@', No seven-segment conversion for commercial at-sign */
0x77, /* 'A' */
0x7C, /* 'B', Actually displayed as 'b' */
0x39, /* 'C' */
0x5E, /* 'D', Actually displayed as 'd' */
0x79, /* 'E' */
0x71, /* 'F' */
0x6F, /* 'G', Actually displayed as 'g' */
0x76, /* 'H' */
0x06, /* 'I', Same as '1' */
0x1E, /* 'J' */
0x00, /* 'K', No seven-segment conversion */
0x38, /* 'L' */
0x00, /* 'M', No seven-segment conversion */
0x54, /* 'N', Actually displayed as 'n' */
0x3F, /* 'O', Same as '0' */
0x73, /* 'P' */
0x00, /* 'Q', No seven-segment conversion */
0x50, /* 'R', Actually displayed as 'r' */
0x6D, /* 'S', Same as '5' */
0x78, /* 'T', Actually displayed as 't' */
0x3E, /* 'U' */
0x00, /* 'V', No seven-segment conversion */
0x00, /* 'W', No seven-segment conversion */
0x00, /* 'X', No seven-segment conversion */
0x6E, /* 'Y' */
0x00, /* 'Z', No seven-segment conversion */
0x00, /* '[' */
0x00, /* '\', No seven-segment conversion */
0x00, /* ']' */
0x00, /* '^', No seven-segment conversion */
0x00, /* '_', Underscore */
0x00, /* '`', No seven-segment conversion for reverse quote */
0x5F, /* 'a' */
0x7C, /* 'b' */
0x58, /* 'c' */
0x5E, /* 'd' */
0x7B, /* 'e' */
0x71, /* 'f', Actually displayed as 'F' */
0x6F, /* 'g' */
0x74, /* 'h' */
0x04, /* 'i' */
0x1E, /* 'j', Actually displayed as 'J' */
0x00, /* 'k', No seven-segment conversion */
0x38, /* 'l', Actually displayed as 'L' */
0x00, /* 'm', No seven-segment conversion */
0x54, /* 'n' */
0x5C, /* 'o' */
0x73, /* 'p', Actually displayed as 'P' */
0x00, /* 'q', No seven-segment conversion */
0x50, /* 'r' */
0x6D, /* 's', Actually displayed as 'S' */
0x78, /* 't' */
0x1C, /* 'u' */
0x00, /* 'v', No seven-segment conversion */
0x00, /* 'w', No seven-segment conversion */
0x00, /* 'x', No seven-segment conversion */
0x6E, /* 'y', Actually displayed as 'Y' */
0x00 /* 'z', No seven-segment conversion */
};
/*
*********************************************************************************************************
* HEXADECIMAL to SEVEN-SEGMENT conversion table
* a
* ------
* f | | b
* | g |
* Note: The segments are mapped as follows: ------
* e | | c
* a b c d e f g | d |
* -- -- -- -- -- -- -- -- ------
* B7 B6 B5 B4 B3 B2 B1 B0
*********************************************************************************************************
*/
const INT8U LCD_HexToSegTbl[] = { /* HEXADECIMAL to SEVEN-SEGMENT conversion table */
0x3F, /* '0' */
0x06, /* '1' */
0x5B, /* '2' */
0x4F, /* '3' */
0x66, /* '4' */
0x6D, /* '5' */
0x7D, /* '6' */
0x07, /* '7' */
0x7F, /* '8' */
0x6F, /* '9' */
0x77, /* 'A' */
0x7C, /* 'B', Actually displayed as 'b' */
0x39, /* 'C' */
0x5E, /* 'D', Actually displayed as 'd' */
0x79, /* 'E' */
0x71, /* 'F' */
};
/*
*********************************************************************************************************
* INITIALIZE THE LCD
*********************************************************************************************************
*/
void LCD_DispInit (void)
{
#if 1
LCD_LPCR = 0x08; /* Static duty cycle (COM1), all ports are LCD segment IOs */
LCD_LCR = 0xFC; /* Turn on LCD supply + disp ram data, clock=sys/32 (244 Hz with 4Meg clock) */
LCD_LCR2 = 0x00; /* Use waveform A */
LCD_CLK_STOP_R2 |= 0x01; /* Clear LCD module standby mode in module stop register */
#else
#endif
}
/*
*********************************************************************************************************
* CLEAR THE LCD
*********************************************************************************************************
*/
void LCD_DispClr (void)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
LCD_DIG_1 = 0x00;
LCD_DIG_2 = 0x00;
LCD_DIG_3 = 0x00;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -