📄 init13700.c
字号:
//-----------------------------------------------------------------------------
//
// INIT13700 - S1D13700 SAMPLE CODE
//
// Copyright (c) 2003 Epson Research and Development, Inc.
// All Rights Reserved.
//
// --------------------------------------------------------------------------
//
// This sample code will perform initialization to S1D13700 controller using
// the values in s1d13700.h
//
// You will need to modify the code if you are not using our S1D13700B0B
// evaluation board.
//
// THIS IS SAMPLE CODE ONLY!
//
//-----------------------------------------------------------------------------
#include <stdio.h>
#include "s1d13700.h"
UInt8 *pIndirectCmdAddr = ( void* ) 0;
UInt8 *pIndirectDataReadAddr = ( void* ) 0;
UInt8 *pIndirectDataWriteAddr = ( void* ) 0;
void initDirect( UInt32 dwGivenVideoMemAddr, UInt32 dwGivenRegisterAddr );
void initIndirect( UInt32 dwGivenVideoMemAddr );
void indirectWriteDisplay( UInt16 Offset, UInt8 iValue, UInt16 wCount );
extern int AcquireController( UInt32 * pMem );
int main(int argc, char* argv[])
{
UInt32 dwMemAddr, dwRegAddr;
#ifdef S1D13700BOB
if ( AcquireController( &dwMemAddr ) )
dwRegAddr = dwMemAddr + REG_OFFSET;
else
{
printf("\nThe S1D13700 is not available!");
return 0;
}
#else
dwMemAddr = S1D_PHYSICAL_VMEM_ADDR;
dwRegAddr = S1D_PHYSICAL_REG_ADDR;
#endif
#ifdef INDIRECT
initIndirect( dwMemAddr );
#else
initDirect( dwMemAddr, dwRegAddr );
#endif
return 0;
}
void initDirect( UInt32 dwGivenVideoMemAddr, UInt32 dwGivenRegisterAddr )
{
UInt8 *pVideoMemAddr; // Physical address of video memory.
UInt8 *pRegisterAddr; // Physical address of registers.
UInt8 iValue = 0x20;
UInt16 i;
//
// STEP 1: GET BOTH MEMORY AND REGISTER ADDRESSES
//
// Convert the given addresses to pointers.
pVideoMemAddr = ( UInt8* ) dwGivenVideoMemAddr;
pRegisterAddr = ( UInt8* ) dwGivenRegisterAddr;
//
// STEP 2: INITIALIZE ALL REGISTERS
//
pRegisterAddr[ aS1DRegs[8].Index ] = 0; //Exit from Power Save mode.
for ( i = 0; i < sizeof( aS1DRegs ) / sizeof( aS1DRegs[0] ); i++ )
pRegisterAddr[ aS1DRegs[i].Index ] = aS1DRegs[i].Value;
//
// STEP 3: SHOW CHARACTERS
//
for( i = 0; i < PANEL_WIDTH / 8 * PANEL_HEIGHT; i++ )
{
pVideoMemAddr[i] = iValue++;
if( iValue==0x7F ) iValue = 0x20;
}
}
void initIndirect( UInt32 dwGivenVideoMemAddr )
{
UInt16 wStartAddr = 0;
UInt16 wCount;
UInt8 iValue = 0x20;
UInt16 i, j;
//
// STEP 1: GET BOTH MEMORY AND REGISTER ADDRESSES
//
// Convert the given addresses to pointers.
pIndirectCmdAddr = (UInt8 *) ( dwGivenVideoMemAddr + 1 ); //odd address for command write
pIndirectDataWriteAddr = (UInt8 *) dwGivenVideoMemAddr; //even addr for parameter write
pIndirectDataReadAddr = (UInt8 *) ( dwGivenVideoMemAddr + 1 ); //odd addr for parameter read
//
// STEP 2: INITIALIZE ALL REGISTERS
//
// SYSTEM SET
*pIndirectCmdAddr = CMD_SYSTEM_SET;
for ( i = 0; i < 8; i++ )
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
i++; // skip REG0008_SLEEPIN
i++; // skip REG0009_DISPONOFF
// DISP ON
*pIndirectCmdAddr = CMD_DISPON;
*pIndirectDataWriteAddr = aS1DRegs[i++].Value;
// SCROLL
*pIndirectCmdAddr = CMD_SCROLL;
for ( j = 0; j < 10; j++, i++ )
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
// CSRFORM
*pIndirectCmdAddr = CMD_CSRFORM;
for ( j = 0; j < 2; j++, i++ )
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
// CSDIR
*pIndirectCmdAddr = CMD_CSRDIR_RIGHT;
i++; // skip REG0017_CSRDIR_P1
// OVLAY
*pIndirectCmdAddr = CMD_OVLAY;
*pIndirectDataWriteAddr = aS1DRegs[i++].Value;
// CGRAM ADR
*pIndirectCmdAddr = CMD_CG_RAM_ADDR;
for ( j = 0; j < 2; j++, i++ )
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
// HDOT SCR
*pIndirectCmdAddr = CMD_HDOT_SCR;
*pIndirectDataWriteAddr = aS1DRegs[i++].Value;
// CSRW
*pIndirectCmdAddr = CMD_CSRW;
for ( j = 0; j < 2; j++, i++ )
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
// GRAYSCALE
*pIndirectCmdAddr = CMD_GRAY_SCALE;
*pIndirectDataWriteAddr = aS1DRegs[i].Value;
//
// STEP 3: SHOW CHARACTERS
//
wCount = PANEL_WIDTH / 8 * PANEL_HEIGHT / 8;
while( wCount-- )
{
indirectWriteDisplay( wStartAddr++, iValue++, 1 );
if( iValue == 0x7F ) iValue = 0x20;
}
}
void indirectWriteDisplay( UInt16 wOffset, UInt8 iValue, UInt16 wCount )
{
*pIndirectCmdAddr = (UInt8) CMD_CSRW;
*pIndirectDataWriteAddr = (UInt8) wOffset;
*pIndirectDataWriteAddr = (UInt8) ( wOffset >> 8 );
*pIndirectCmdAddr = (UInt8) CMD_MWRITE;
do *pIndirectDataWriteAddr = (UInt8) iValue; while( --wCount ); // Write memory
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -