📄 sed1335f.lib
字号:
/*** BeginHeader */
#ifndef __SED1335F_LIB
#define __SED1335F_LIB
/*** EndHeader */
/* START LIBRARY DESCRIPTION *********************************************
SED1335F.LIB
Copyright (c) 2001, Z-World
DESCRIPTION: Low-level driver for the SED1335F Graphic Chip
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 320 // Number of pixels on the x-axis
#define LCD_YS 240 // 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 320 // Horz Pixels = [0..PIXEL_XS-1]
#define PIXEL_YS 240 // 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
extern unsigned int glPageAddr;
//
// 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
// _glInitStrobe();
//
//
// //Other Initialization
// // :
// // :
// // :
// }
//
//
//
//
// Requirement
// -----------
// Declare variables outside of the Start/End header section
//
/*** EndHeader */
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
unsigned int glPageAddr;
// END OF DRIVER REQUIREMENTS!!!!!
/*** BeginHeader */
#define SEDCR 0xE001 // SED1335 Command Register
#define SEDDR 0xE000 // SED1335 Data Register
#define TCYC_DELAY $\
nop $\
nop
// Use Port E bit 7 for LCD Chip Select with 4 wait states
#define LCDSTROBE 0x80
#define LCDCSREGISTER IB7CR
#define LCDCSSHADOW IB7CRShadow
#define LCDCSCONFIG 0x88
/*** EndHeader */
/*** BeginHeader _glInitStrobe */
void _glInitStrobe(void);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glInitStrobe <SED1335F.LIB>
SYNTAX: void _glInitStrobe(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 4 wait states. This function is non-
reentrant and is an internal function.
PARAMETER: None.
RETURN VALUE: None.
SEE ALSO: _glInitController
END DESCRIPTION **********************************************************/
nodebug
void _glInitStrobe(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));
}
/*** BeginHeader _glInitLCDChip */
void _glInitLCDChip(void);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glInitLCDChip <SED1335F.LIB>
SYNTAX: void _glInitLCDChip(void)
DESCRIPTION: This functions initalizes the SED1335F IC chip with the
required parameters to access an 320x240 LCD display. This
function is non-reentrant and is an internal function.
PARAMETER: None.
RETURN VALUE: None.
SEE ALSO: graphic.lib, _glDispOnOff, _glContrast, _glBackLight
_glSwapData
END DESCRIPTION **********************************************************/
nodebug
void _glInitLCDChip(void)
{
auto unsigned long timeDelay;
// Make there's a min of 3ms before accessing the controller chip
timeDelay = MS_TIMER + 4;
while( (long) (MS_TIMER - timeDelay) < 0 );
#asm
ld bc,SEDCR ; INIT DISPLAY
ld a,0x40
ioe ld (bc),a ; out (c),a
TCYC_DELAY
dec bc
ld a,0x30 ; Single Panel, LCD Mode
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,0x07h ; 8-Bit Char Width, 16-line AC Drive
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,000h ; 1-Bit Char Width
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,40 ; 40 Bytes per Line
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,51 ; Set TC/R to Reduce Jitter ***
; ld a,63 ; Set TC/R to Reduce Snow
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,239 ; 240 Lines per Frame
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,40 ; 40 Byte Virt Screen Width (LSB First)
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,0
ioe ld (bc),a ; out (c),a
TCYC_DELAY
inc bc ; SET SCROLL
ld a,044h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
dec bc
ld a,000h ; First Screen @ 00000h (SAD1)
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,000h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,239 ; First Screen Number of Lines
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,000h ; Second Screen @ 4000h (SAD2)
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,040h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,239 ; Second Screen Number of Lines
ioe ld (bc),a ; out (c),a
TCYC_DELAY
inc bc ; SET OVERLAY (Two Layer OR)
ld a,05Bh
ioe ld (bc),a ; out (c),a
TCYC_DELAY
dec bc
ld a,00Ch
ioe ld (bc),a ; out (c),a
TCYC_DELAY
inc bc ; Cursor Auto Increment (Right)
ld a,04Ch
ioe ld (bc),a ; out (c),a
TCYC_DELAY
ld a,05Ah ; Zero Horizontal Scroll (HDOT = 0)
ioe ld (bc),a ; out (c),a
TCYC_DELAY
dec bc
ld a,000h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
inc bc ; Show Page 0
ld a,059h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
dec bc
ld a,004h
ioe ld (bc),a ; out (c),a
TCYC_DELAY
#endasm
}
/*** BeginHeader _glInit */
void _glInit(void);
/*** EndHeader */
/* START _FUNCTION DESCRIPTION ********************************************
_glInit <SED1335F.LIB>
SYNTAX: void _glInit(void);
DESCRIPTION: This functions initializes the graphic chip and sets up
graphic driver for use by the application program. This
function is non-reentrant and is an internal function.
PARAMETER: None.
RETURN VALUE: None.
SEE ALSO: graphic.lib, _glDispOnOff, _glContrast, _glBackLight
_glInitLCDChip, _glSwapData, _glPlotRealtime
END DESCRIPTION **********************************************************/
nodebug
void _glInit(void)
{
_glInitStrobe();
// 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
// Initialize SED1535F controller chip
_glInitLCDChip();
// Initially set upper page (located at 0x4000) to be hidden
glPageAddr = 0x4000;
// Initially set the graphic's buffer to be unlocked
glLock = 0;
// Clear the screen before turning ON the display
glBlankScreen();
// Turn ON the display
_glDispOnOff( 1 );
// Set pixel color to Black
glSetBrushType(PIXBLACK);
// Initialize the glprintf() function stepping parameters
glSetPfStep(1,0);
// Disable Animation mode
glAnimation(0);
// Disable glPlotDot realtime LCD display accesses
glRealtime(0);
}
/*** BeginHeader _glSwapData, animation */
void _glSwapData(void);
extern int animation;
/*** EndHeader */
int animation;
/* START _FUNCTION DESCRIPTION *******************************************
_glSwapData <SED1335F.LIB>
SYNTAX: _glSwapData(void);
DESCRIPTION: This function takes the LCD display data from the graphic
buffer (glBuf) and writes it to the LCD display. This
function is non-reentrant and is an internal function.
PARAMETER1: None.
RETURN VALUE: None.
SEE ALSO: graphic.lib, _glInit, _glDispOnOff, _glContrast,
_glBackLight
END DESCRIPTION **********************************************************/
nodebug
root void _glSwapData(void)
{
static int buf_size;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -