📄 misc.c
字号:
//----------------------------------------------------------------------------------------------------
// ID Code : Misc.c No.0001
// Update Note :
//
//----------------------------------------------------------------------------------------------------
#define __MISC__
#include "..\Header\Include.h"
//----------------------------------------------------------------------------------------------------
// Polling Events
//----------------------------------------------------------------------------------------------------
/*
//--------------------------------------------------
// Description : Stable flag polling event
// Input Value : None
// Output Value : Return _TRUE if event occurs
//--------------------------------------------------
bit CMiscStableFlagPollingEvent(void)
{
if((bit)CScalerGetBit(_STABLE_PERIOD_H_50, _BIT4))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
//--------------------------------------------------
// Description : Measure start/end polling event
// Input Value : None
// Output Value : Return _TRUE if measure finished
//--------------------------------------------------
bit CMiscModeMeasurePollingEvent(void)
{
if(!(bit)CScalerGetBit(_MEAS_HS_PERIOD_H_52, _BIT5))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#if(_TMDS_SUPPORT == _ON)
//--------------------------------------------------
// Description : Auto measure start/end polling event
// Input Value : None
// Output Value : Return _TRUE if auto measure finished
//--------------------------------------------------
bit CMiscAutoMeasurePollingEvent(void)
{
if(!(bit)CScalerGetBit(_AUTO_ADJ_CTRL1_7D, _BIT0))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#endif
//--------------------------------------------------
// Description : Apply double buffer polling event
// Input Value : None
// Output Value : Return _TRUE if apply double buffer finished
//--------------------------------------------------
bit CMiscApplyDoubleBufferPollingEvent(void)
{
if(!(bit)CScalerGetBit(_VGIP_CTRL_05, _BIT5))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#if(_TMDS_SUPPORT == _ON)
//--------------------------------------------------
// Description : TMDS transition measure polling event
// Input Value : None
// Output Value : Return _TRUE if measure finished
//--------------------------------------------------
bit CMiscTMDSMeasureEvent(void)
{
if(!(bit)CScalerGetBit(_TMDS_MEAS_RESULT0_BD, _BIT7))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
//--------------------------------------------------
// Description : TMDS CRC measure polling event
// Input Value : None
// Output Value : Return _TRUE if CRC measure finished
//--------------------------------------------------
bit CMiscTMDSCRCEvent(void)
{
if(!(bit)CScalerGetBit(_POWER_ON_OFF_CTRL_C2, _BIT0))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#endif // End of #if(_TMDS_SUPPORT == _ON)
//----------------------------------------------------------------------------------------------------
// Misc Functions
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Description : Enable double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscEnableDoubleBuffer(void)
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT4, _BIT4);
}
//--------------------------------------------------
// Description : Disable double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscDisableDoubleBuffer(void)
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT4, 0x00);
}
//--------------------------------------------------
// Description : Apply double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscApplyDoubleBuffer(void)
{
if((bit)CScalerGetBit(_VGIP_CTRL_05, _BIT4))
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT5, _BIT5);
CTimerPollingEventProc(60, CMiscApplyDoubleBufferPollingEvent);
}
}
//--------------------------------------------------
// Description : Clear status Reg[02] and Reg[03]
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscClearStatusRegister(void)
{
CScalerSetByte(_STATUS0_02, 0x00);
CScalerSetByte(_STATUS1_03, 0x00);
}
//--------------------------------------------------
// Description : Set pin share
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscSetPinShare(void)
{
#if(_SCALER_TYPE == _RTD2323)
pData[0] = (_PIN_3 << 6) | (_PIN_4 << 4) | (_PIN_48 << 2) | (_PIN_49);
pData[1] = ((BYTE)_PIN_50_51 << 7) | (_PIN_52_53 << 6) | (_PIN_54 << 4) | (_PIN_55_56_57 << 3) | (_PIN_122_FUNC << 2) | (_PIN_110 << 1);
pData[2] = (_PIN_111 << 6) | (_PIN_112_113_114 << 4) | (_PIN_115_118_119 << 3) | (_PIN_120_121 << 1) | (_PIN_122);
CScalerWrite(_PIN_SHARE_CTRL0_8D, 3, pData, _AUTOINC);
#endif
//#if((_SCALER_TYPE == _RTD2023L) || (_SCALER_TYPE == _RTD2023S))
//versoion 200D
#if((_SCALER_TYPE == _RTD2023L) || (_SCALER_TYPE == _RTD2023S) || (_SCALER_TYPE == _RTD2023L_SHRINK))
CScalerSetBit(_PIN_SHARE_CTRL0_8D, ~(_BIT7 | _BIT6), ((_PIN_21_TO_40 << 7) | (_PIN_16_17_OR_43_44 << 6)));
#endif
}
*/
//version 200D
//--------------------------------------------------
// Description : Stable flag polling event
// Input Value : None
// Output Value : Return _TRUE if event occurs
//--------------------------------------------------
bit CMiscStableFlagPollingEvent(void)
{
if((bit)CScalerGetBit(_STABLE_PERIOD_H_50, _BIT4))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
//--------------------------------------------------
// Description : Measure start/end polling event
// Input Value : None
// Output Value : Return _TRUE if measure finished
//--------------------------------------------------
bit CMiscModeMeasurePollingEvent(void)
{
if(!(bit)CScalerGetBit(_MEAS_HS_PERIOD_H_52, _BIT5))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#if(_TMDS_SUPPORT == _ON)
//--------------------------------------------------
// Description : Auto measure start/end polling event
// Input Value : None
// Output Value : Return _TRUE if auto measure finished
//--------------------------------------------------
bit CMiscAutoMeasurePollingEvent(void)
{
if(!(bit)CScalerGetBit(_AUTO_ADJ_CTRL1_7D, _BIT0))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#endif
//--------------------------------------------------
// Description : Apply double buffer polling event
// Input Value : None
// Output Value : Return _TRUE if apply double buffer finished
//--------------------------------------------------
bit CMiscApplyDoubleBufferPollingEvent(void)
{
if(!(bit)CScalerGetBit(_VGIP_CTRL_05, _BIT5))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#if(_TMDS_SUPPORT == _ON)
//--------------------------------------------------
// Description : TMDS transition measure polling event
// Input Value : None
// Output Value : Return _TRUE if measure finished
//--------------------------------------------------
bit CMiscTMDSMeasureEvent(void)
{
if(!(bit)CScalerGetBit(_TMDS_MEAS_RESULT0_BD, _BIT7))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
//--------------------------------------------------
// Description : TMDS CRC measure polling event
// Input Value : None
// Output Value : Return _TRUE if CRC measure finished
//--------------------------------------------------
bit CMiscTMDSCRCEvent(void)
{
if(!(bit)CScalerGetBit(_POWER_ON_OFF_CTRL_C2, _BIT0))
{
return _TRUE;
}
else
{
return _FALSE;
}
}
#endif // End of #if(_TMDS_SUPPORT == _ON)
//----------------------------------------------------------------------------------------------------
// Misc Functions
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Description : Enable double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscEnableDoubleBuffer(void)
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT4, _BIT4);
}
//--------------------------------------------------
// Description : Disable double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscDisableDoubleBuffer(void)
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT4, 0x00);
}
//--------------------------------------------------
// Description : Apply double buffer
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscApplyDoubleBuffer(void)
{
if((bit)CScalerGetBit(_VGIP_CTRL_05, _BIT4))
{
CScalerSetBit(_VGIP_CTRL_05, ~_BIT5, _BIT5);
CTimerPollingEventProc(60, CMiscApplyDoubleBufferPollingEvent);
}
}
//--------------------------------------------------
// Description : Clear status Reg[02] and Reg[03]
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscClearStatusRegister(void)
{
CScalerSetByte(_STATUS0_02, 0x00);
CScalerSetByte(_STATUS1_03, 0x00);
}
//--------------------------------------------------
// Description : Set pin share
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscSetPinShare(void)
{
#if(_SCALER_TYPE == _RTD2323)
pData[0] = (_PIN_3 << 6) | (_PIN_4 << 4) | (_PIN_48 << 2) | (_PIN_49);
pData[1] = ((BYTE)_PIN_50_51 << 7) | (_PIN_52_53 << 6) | (_PIN_54 << 4) | (_PIN_55_56_57 << 3) | (_PIN_122_FUNC << 2) | (_PIN_110 << 1);
pData[2] = (_PIN_111 << 6) | (_PIN_112_113_114 << 4) | (_PIN_115_118_119 << 3) | (_PIN_120_121 << 1) | (_PIN_122);
CScalerWrite(_PIN_SHARE_CTRL0_8D, 3, pData, _AUTOINC);
#endif
#if((_SCALER_TYPE == _RTD2023L) || (_SCALER_TYPE == _RTD2023S) || (_SCALER_TYPE == _RTD2023L_SHRINK))
CScalerSetBit(_PIN_SHARE_CTRL0_8D, ~(_BIT7 | _BIT6), ((_PIN_21_TO_40 << 7) | (_PIN_16_17_OR_43_44 << 6)));
#endif
}
//----------------------------------------------------------------------------------------------------
// Debug Functions
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Description : Kingmice process
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CMiscKingmice(void)
{
#if(_DEBUG_TOOL == _KINGMICE)
static BYTE idata ucI2C_Addr;
static BYTE idata ucI2C_Data;
static BYTE idata ucRTD_Data;
do
{
while(ucROM_A4 & 0x01) // if action
{
if(ucROM_A4 & 0x02) // read
{
if(ucROM_A4 & 0x10) // if IIC_index
{
CI2cRead(ucI2C_Addr, ucROM_A3, 0x01, pData);
ucPRN_7 = pData[0];
}
else if(ucROM_A4 & 0x40) // if RTD_index
{
CScalerRead(ucROM_A3, 0x01, pData, _NON_AUTOINC);
ucPRN_7 = pData[0];
}
else if(ucROM_A4 & 0x80) // if 8051_index
{
ucPRN_7 = *((BYTE *)ucROM_A3);
}
}
else // write
{
if(ucROM_A4 & 0x04) // if IIC_addr
{
ucI2C_Addr = ucROM_A3;
}
else if(ucROM_A4 & 0x08) // if IIC_data
{
ucI2C_Data = ucROM_A3;
}
else if(ucROM_A4 & 0x10) // if IIC_index
{
CI2cWrite(ucI2C_Addr, ucROM_A3, 0x01, &ucI2C_Data);
}
else if(ucROM_A4 & 0x20) // if RTD_data
{
ucRTD_Data = ucROM_A3;
}
else if(ucROM_A4 & 0x40) // if RTD_index
{
CScalerWrite(ucROM_A3, 0x01, &ucRTD_Data, _NON_AUTOINC);
}
else if(ucROM_A4 & 0x80) // if 8051_index
{
*((BYTE *)ucROM_A3) = pData[0];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -