📄 hwmd.c
字号:
/****************************************************************************
+----------------------------------------------------------------------+
| Copyright Trumpion Microelectronics Inc. 1999 |
| Trumpion Microelectronics Inc. reserves the right to change products |
| or specifications without notice. |
+----------------------------------------------------------------------+
Project : LCD monitor
Version : 0.94
File Name : hwmd.c
Functions : hardware mode detect interface function
Revision :
1999-05-18 OriginalTeam First Created
1999-10-11 Andrew WU FPGA test
2000-07-17 Glen Chang Add Csync,SOG and SEP switch
****************************************************************************/
//**************************************************************************
//INCLUDE FILES
//*************************************************************************/
#include "lib\extent.h"
#include "lib\wreg516.h"
#include "lib\declare.h"
#include "lib\global.h"
#include "lib\hwmd.h"
#include "lib\ttfc.h"
#include "lib\initial.h"
// /************************************************************************
// * Name : HWMD_FreeRun *
// * Description : Set ZURAC2 HWMD free run *
// * Input : none *
// * Output : none *
// ************************************************************************/
// void HWMD_FreeRun ( void )
// {
// #if ZURAC_HWMD
// ZuracWriteByte( Z2_PULCNT, 0xC2 );
// #endif
// }
//
/************************************************************************
* Name : HWMD_Init *
* Description : Zurac2 H/W Sync Processor initialization *
* Input : none *
* Output : none *
************************************************************************/
void HWMD_Init ( void )
{
#if ZURAC_HWMD
ZuracWriteByte( Z2_HWDCNT, SyncSource );
// H/V Output mode & H/V Tolerance
ZuracWriteByte( Z2_PULCNT, 0xFC ); //FE
// FreeRun timing
TrmBuf[0] = Z2_HVPWTH; // free running mode set to 1024x768/60
TrmBuf[1] = 0x00; // D7
if( FgInterlace ) TrmBuf[1] |= 0x80;
TrmBuf[2] = (Z2_OUTPUTVPOL << 1 ) | (Z2_OUTPUTHPOL); // D8
TrmBuf[2] = (~TrmBuf[2]) & 0x03;
TrmBuf[3] = 0x4a; // D9
TrmBuf[4] = 0x18; // DA
TrmBuf[5] = 0x32; // DB
ByteCnt = 0x06;
SendData ();
// Clear interrupt
ZuracRead( Z2_INTSRC, 1 );
#endif
}
// /************************************************************************
// * Name : HWMD_LoopThrough *
// * Description : Set ZURAC2 HWMD Loop through function *
// * Input : none *
// * Output : none *
// ************************************************************************/
// void HWMD_LoopThrough ( void )
// {
// #if ZURAC_HWMD
// // loopthrough with substitute for H V
// ZuracWriteByte( Z2_PULCNT, 0xD4 );
// #endif
// }
//
/************************************************************************
* Name : HWMD_ReadStatus *
* Description : Get ZURAC2 HWMD status *
* Input : none *
* Output : Zurac2 HWMD status *
************************************************************************/
Byte HWMD_ReadStatus ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_INTSRC, 1 );
return ( TrmBuf[0] );
#else
return ( 0 );
#endif
}
// /************************************************************************
// * Name : HWMD_CurrentPolarity *
// * Description : Get Input H/V polarity *
// * Input : none *
// * Output : polarity *
// ************************************************************************/
// Byte HWMD_CurrentPolarity ( void )
// {
// #if ZURAC_HWMD
// ZuracRead( Z2_SYNCSTATUS, 1 );
// return ( TrmBuf[0] & 0x03 );
// #else
// return ( 0 );
// #endif
// }
//
/************************************************************************
* Name : HWMD_HfHigh *
* Description : Get High byte of H Freq counter *
* Input : none *
* Output : H Freq high byte *
************************************************************************/
Byte HWMD_HfHigh ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_HPERHIGH, 1 );
return ( TrmBuf[0] );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_VfHigh *
* Description : Get High byte of V Freq counter *
* Input : none *
* Output : V Freq high byte *
************************************************************************/
Byte HWMD_VfHigh ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_VPERHIGH, 1 );
return ( TrmBuf[0] );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_HfCounter *
* Description : Get H Freq counter *
* Input : none *
* Output : H Freq counter *
************************************************************************/
Word HWMD_HfCounter ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_HPERHIGH, 2 );
return ((TrmBuf[0]*16) & 0x0FF0) + ((TrmBuf[1] & 0x0F));
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_VfCounter *
* Description : Get V Freq counter *
* Input : none *
* Output : V Freq counter *
************************************************************************/
Word HWMD_VfCounter ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_VHPERLOW, 2 );
return (((TrmBuf[1]*16) & 0x0FF0) + ((TrmBuf[0]>>4) & 0x0f) );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_HFrequency *
* Description : Get H Frequency *
* Input : none *
* Output : H Frequency : HFreq * 100 KHz *
************************************************************************/
Word HWMD_HFrequency ( void )
{
#if ZURAC_HWMD
return( 5727200 / HWMD_HfCounter() );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_VFrequency *
* Description : Get V Frequency *
* Input : none *
* Output : V Frequency : VFreq * 100 Hz *
************************************************************************/
Word HWMD_VFrequency ( void )
{
#if ZURAC_HWMD
return ( 16270454 / HWMD_VfCounter() );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_VideoStatus *
* Description : Get HWMD video status *
* Input : none *
* Output : H/V presence status *
************************************************************************/
Byte HWMD_VideoStatus ( void )
{
#if ZURAC_HWMD
ZuracRead( Z2_SYNCSTATUS, 1);
return ( TrmBuf[0] );
#else
return ( 0 );
#endif
}
/************************************************************************
* Name : HWMD_ChangeSource *
* Description : Change HWMD H/V sync source *
* Input : none *
* Output : none *
************************************************************************/
void HWMD_ChangeSource ( void )
{
#if ZURAC_HWMD
ZuracWriteByte( Z2_HWDCNT, SyncSource );
Delay(2);
ZuracRead( Z2_INTSRC, 1 );
return;
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -