📄 mscg12232.lib
字号:
/*** BeginHeader */
#ifndef __MSCG12232_LIB
#define __MSCG12232_LIB
/*** EndHeader */
/* START LIBRARY DESCRIPTION *********************************************
MSCG12232.LIB
Copyright (c) 2001, Z-World
DESCRIPTION: Low-level driver for the MSCG12232 LCD.
SUPPORT LIBS:
END DESCRIPTION **********************************************************/
/*** BeginHeader glBuf, glbuf_offset, glbuf_xpc, xpc_temp */
//
// Requirement
// -----------
// This section required for all LCD driver designs. The only values that
// will change in this section (from design to design) are the LCD_XS,
// LCD_YS, PIXEL_XS and PIXEL_XS macro's.
//
// LCD display resolution...these MACRO's are for the customer to use in
// their application program.
#define LCD_XS 122 // Number of pixels on the x-axis
#define LCD_YS 32 // Number of pixels on the y-axis
// Graphic Buffer MACRO's
// 1. PIXEL_XS needs to be evenly divisble by 8.
// 2. These MACRO's are intended for internal use only.
#define PIXEL_XS 128 // Horz Pixels = [0..PIXEL_XS-1]
#define PIXEL_YS 32 // Vert Pixels = [0..PIXEL_YS-1]
#define PIXGROUP PIXEL_XS/8 // Horz Byte Groups
#define XMEM_BUF_SIZE (PIXEL_XS * PIXEL_YS)/8
extern unsigned long glBuf; // Display buffer XMEM physical addr
extern unsigned int glbuf_offset; // Display buffer logical offset addr
extern unsigned int glbuf_xpc; // Display buffer XPC page address
extern unsigned int xpc_temp; // Temp variable for XPC control
//
// Requirement
// -----------
// The following is the list of functions that are required to be
// in this Library. If your design doesn't have one of the features
// that the function provides, then you must provide a NULL function
// so that graphic.lib will compile properly.
//
// // Initializes the LCD
// void _glInit(void);
//
// // Takes the data from the glBuf which the graphic routines created
// // and displays it on the LCD
// void _glSwapData( void );
//
// // Controls the LCD backlight
// void glBackLight( int onOff );
//
// // Controls turning ON/OFF the display...display data is retained
// void glDispOnOff( int onOff );
//
// // Control the contrast on the display..not implemented for this LCD.
// void glContrast( int Level );
//
// Requirement
// -----------
// Must have the following code in the _glInit function to allocate
// memory for the graphic routines and to convert the ulong XMEM
// pointer to a normalized offset and XPC pointer.
//
// nodebug
// void _glInit(void)
// {
// // Must initialize the Graphic buffer pointer before
// // using any graphic functions.
// glBuf = xalloc(XMEM_BUF_SIZE);
//
// // Initialize global XMEM offset and XPC pointers
// #asm
// ld de, (glBuf)
// ld bc, (glBuf + 2)
//
// ; Convert DE:BC to a normalized XMEM pointer
// call LongToXaddr ; DE = offset of glBuf, A = xpc of glBuf
// ld (glbuf_xpc),a
// ld (glbuf_offset), de
// #endasm
//
// // Initialize the I/O strobe for the LCD
// _glInitLCDPort();
//
//
// //Other Initialization
// // :
// // :
// // :
// }
//
//
//
//
/*** EndHeader */
// Requirement
// -----------
// Declare variables outside of the Start/End header section
unsigned long glBuf; // Display buffer XMEM physical address
unsigned int glbuf_offset; // Display buffer logical offset address
unsigned int glbuf_xpc; // Display buffer XPC page address
unsigned int xpc_temp; // Temp variable for XPC control
// End of driver requirements !!!!!
/*** BeginHeader */
// LCD Command Instruction Set
#define LCDON 0xAF
#define LCDOFF 0xAE
#define LCDSETLINE 0xC0 // + line no. (0-31)
#define LCDSETPAGE 0xB8 // + page no. (0-3)
#define LCDSETCOLUMN 0x00 // + column no. (0-60)
#define LCDLEFTWARD 0xA1
#define LCDRIGHTWARD 0xA0
#define LCDSTATICDRIVEON 0xA5
#define LCDSTATICDRIVEOFF 0xA4
#define LCDDUTYCYCLE1_16 0xA8
#define LCDDUTYCYCLE1_32 0xA9
#define LCDRMWBEGIN 0xE0
#define LCDRMWEND 0xEE
#define LCDRESET 0xE2
// LCD status
#define LCDBUSY 0x80 // AND mask
#define LCDDISPDIR 0x40 // AND mask
#define LCDISON 0x20 // AND mask
#define LCDRESETING 0x10 // AND mask
// LCD back light
#define BACKLIGHTOFF 0
#define BACKLIGHTON 1
// LCD display control
#define LCDDISPLAYOFF 0
#define LCDDISPLAYON 1
// Chip select control
#define LCDMASTER 0
#define LCDSLAVE 1
// Timeout for accessing the LCD
#define MAXTIMEOUT 0xff
// MASK values for converting data from glBuf
// horizontal format to the LCD vertical format.
#define LCDMASK 0x01
#define GLBUFMASK 0x80
#define GLMASKCNT 0x07
/*** EndHeader */
/*** BeginHeader _glInitLCDPort */
void _glInitLCDPort(void);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glInitLCDPort <BL21XX.LIB>
SYNTAX: void _glInitLCDPort(void);
DESCRIPTION: This function initializes I/O port E, bit 7 to access
the LCD display. Port E bit 7 is setup to be an I/O Read
and Write strobe with 7 wait states. This function is non-
reentrant and is an internal function.
PARAMETER1: None.
RETURN VALUE: None.
SEE ALSO: See glInit function in the MSCG12232.LIB
END DESCRIPTION **********************************************************/
nodebug
void _glInitLCDPort(void)
{
// Initialize Port E bit to be a normal I/O pin
WrPortI(PEFR, &PEFRShadow, (PEFRShadow|LCDSTROBE));
// Initialize Port E bit to be an output pin
WrPortI(PEDDR, &PEDDRShadow, (PEDDRShadow|LCDSTROBE));
// Initialize Port E bit to be a chip select.
// Set to be a I/O Read and Write strobe with 7 wait states.
// and writes allowed.
WrPortI(LCDCSREGISTER, &LCDCSSHADOW, LCDCSCONFIG);
// Set Port E bit to be clocked by PCLK/2
WrPortI(PECR, &PECRShadow, (PECRShadow & ~0xFF));
// Turn-off all LEDS and LCD backlight
WrPortE(LCDLEDADDR, &LEDShadow, 0x00);
// Enable LED control register
WrPortE(LCDLEDREG, NULL, 0x00);
}
/*** BeginHeader _glCommand */
void _glCommand(int command, int scope);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glCommand <MSCG12232.LIB>
SYNTAX: void _glCommand(int command, int scope);
DESCRIPTION: This functions sends a command to the LCD display. This
function is non-reentrant and is an internal function.
PARAMETER1: Command to be sent to the display.(Please see the MSCG12232
data sheet for the complete command set).
PARAMETER2: Send the command to either the MASTER or the SLAVE side of
the display.
0 = LCDMASTER
1 = LCDSLAVE
RETURN VALUE: None.
SEE ALSO: _glDispOnOff, _glContrast, _glBackLight, _glSwapData,
_glInit
END DESCRIPTION **********************************************************/
nodebug
useix void _glCommand(int command, int scope)
{
#asm
push ip ;save off IP state
ipset 1 ;set interrupt priority to level 1
ld a, (ix+scope)
ld b, LCDMASTER
cp b
jr nz, .lcdslave
ld a, (ix+command)
ioe ld (LCDMWRITEINSTR), a
jr .done
.lcdslave:
ld a, (ix+command)
ioe ld (LCDSWRITEINSTR), a
.done: pop ip
#endasm
}
/*** BeginHeader _glInit */
void _glInit(void);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glInit <MSCG12232.LIB>
SYNTAX: void _glInit(void);
DESCRIPTION: This functions returns a data byte that represents 8 pixels
on the LCD display. This function is non-reentrant and is
an internal function.
PARAMETER1: Page (0-3) where the data byte to be returned is located.
PARAMETER2: Column (0-121) where the data byte to returned is located.
RETURN VALUE: Data byte for the LCD display representing 8 pixels.
SEE ALSO: graphic.lib, _glDispOnOff, _glContrast, _glBackLight
_glSwapData
END DESCRIPTION **********************************************************/
nodebug
void _glInit(void)
{
// Allocate XMEM for the Graphic buffer
glBuf = xalloc(XMEM_BUF_SIZE);
// Initialize global glBuf XMEM offset and XPC pointer
#asm
ld de, (glBuf)
ld bc, (glBuf + 2)
; Convert BC:DE to a normalized XMEM pointer
call LongToXaddr ; DE = offset of glBuf, A = xpc of glBuf
ld (glbuf_xpc),a
ld (glbuf_offset), de
#endasm
// Set the graphic's buffer to be not locked
glLock = 0;
// Initialize the I/O chip select for the LCD display
_glInitLCDPort();
// Reset the display to put it into a known state
_glCommand( LCDRESET, LCDMASTER );
_glCommand( LCDRESET, LCDSLAVE );
// Clear the screen before turning ON the display
glBlankScreen();
// Turn ON the display
_glDispOnOff( LCDDISPLAYON );
// Set the duty cycle to 1/32
_glCommand( LCDDUTYCYCLE1_32, LCDMASTER );
_glCommand( LCDDUTYCYCLE1_32, LCDSLAVE );
// Set the display for normal operation
_glCommand( LCDSTATICDRIVEOFF, LCDMASTER );
_glCommand( LCDSTATICDRIVEOFF, LCDSLAVE );
// Set pixel color to Black
glSetBrushType(PIXBLACK);
// Initialize the glprintf() function stepping parameters
glSetPfStep(1,0);
}
/*** BeginHeader _glData */
root char _glData(int page, int col);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION *******************************************
_glData <MSCG12232.LIB>
SYNTAX: _glData(int page, int col);
DESCRIPTION: This function returns a data byte that represents 8
pixels on the LCD display.
The data byte is created by doing a conversion from the
graphic buffer horizontal format, to the LCD vertical
format.
EXAMPLE:
-------
Graphic Buffer...horizonal format pixel (x,y) 2,0 is at
location glBuf[0] with bit 5 set.
00100000
00000000
TRANSLATES TO:
LCD Display......vertical format pixel (x,y) 2,0 is at
location LCD[2] bit 0 set.
0010
0000
0000
0000
0000
0000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -