⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ad9884a.c

📁 此为ADI公司AD9884A型号芯片的控制及设备,多应用于TV.PVR等产品
💻 C
📖 第 1 页 / 共 3 页
字号:
            }
         else if (RefreshRate <= 75)
            {
            VcoRange = 2;
            Current = 5;
            //PixelRate = 202500l;
				Phase = 8;
            }
         else if (RefreshRate <= 85)
            {
            VcoRange = 2;
            Current = 6;
            //PixelRate = 229500l;
				Phase = 8;
            }
         break;
      default: /* unknown resolution */
         break;
      }

   RegVal.byte = 0;
	RegVal.bits.current = Current;
	RegVal.bits.vcornge = VcoRange;
	rc = AD9884A_Write(AD9884A_VCOCURRENT, RegVal.byte);

	/* Set sample phase */
	AD9884A_SetPhase(Phase);

	/*  set PLLDIV      */
   AD9884A_SetPLLDiv(HorTotalTime);

   return (rc);

} /* AD9884A_PLL */
/******************************************************************************/

/*****************************************************************************/
TA2D_Result AD9884A_InitPLL(void)
{
   TA2D_Result rc;
	rc = AD9884A_SetPLLDiv(1693);
   rc = AD9884A_Write(AD9884A_VCOCURRENT, 0x48);

   return (rc);
}
/******************************************************************************/

/******************************************************************************/
TA2D_Result AD9884A_SetVCORange(TBYTE VCORange)
{
	TA2D_Result rc;
	union {
		TAD9884A_VcoCurrent bits;
		TBYTE byte;
		} RegVal;

   if(VCORange > 3)
   	return A2D_IllegalValue;

	rc = AD9884A_Read(AD9884A_VCOCURRENT, &RegVal.byte);
	RegVal.bits.vcornge = VCORange;
	rc = AD9884A_Write(AD9884A_VCOCURRENT, RegVal.byte);

   return rc;
}
/******************************************************************************/

/******************************************************************************/
TA2D_Result AD9884A_GetVCORange(TBYTE *VCORange)
{
	TA2D_Result rc;
	union {
		TAD9884A_VcoCurrent bits;
		TBYTE byte;
		} RegVal;

	rc = AD9884A_Read(AD9884A_VCOCURRENT, &RegVal.byte);
   *VCORange = RegVal.bits.vcornge;

   return rc;
}
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetPLLDiv- Set PLL divide ratio
 *
 *
 *  description:
 *  ------------
 *  PLLDIVM = MSB(plldiv)
 *  PLLDIVL = LSB(plldiv) << 4
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetPLLDiv(TWORD plldiv)
 *  Where:
 *  plldiv - PLL divide ratio
 *  Returns:
 *  A2D_OK/A2D_ERROR
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/03/2000  creation
 *
 */

TA2D_Result AD9884A_SetPLLDiv(TWORD plldiv)
{
	TA2D_Result rc = A2D_OK;

	/* plldiv is in the range 0-0xfff */
	if (plldiv > 0xfff)
		rc = A2D_IllegalValue;
	else	/* legal value */
		{
      plldiv--;
		rc = AD9884A_Write(AD9884A_PLLDIVM, (TBYTE)(plldiv >> 4));
		rc = AD9884A_Write(AD9884A_PLLDIVL, plldiv << 4);
		}

	return (rc);

} /* AD9884A_SetPLLDiv */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_GetPLLDiv- Get PLL divide ratio
 *
 *
 *  description:
 *  ------------
 *  PLLDIVM = MSB(plldiv)
 *  PLLDIVL = LSB(plldiv) << 4
 *
 *
 *  Protoype:
 *  ----------
 *  TWORD AD9884A_GetPLLDiv(void)
 *  Where:
 *
 *  Returns:
 *  plldiv - PLL divide ratio
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/03/2000  creation
 *
 */

TWORD AD9884A_GetPLLDiv(void)
{
	TWORD plldiv = 0;
	TBYTE pllbyte;

	AD9884A_Read(AD9884A_PLLDIVM, &pllbyte);
	plldiv = (TWORD)pllbyte << 8;
	AD9884A_Read(AD9884A_PLLDIVL, &pllbyte);
	plldiv |= pllbyte;
	plldiv >>= 4;

	return (plldiv + 1);

} /* AD9884A_GetPLLDiv */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetClamp- Set clamping parameters
 *
 *
 *  description:
 *  ------------
 *  Set clamping parameters - signal source, signal polarity, placement and duration..
 *  The function actually calls to the on-board A2D function.
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetClamp(TBYTE Placement, TBYTE Duration)
 *
 *  Where:
 *  Placement - Position of the internally generated clamp in pixel periods (1-255).
 *  Duration - Clamp duration in pixel periods (1-255).
 *  Returns:
 *  A2D_OK
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_SetClamp(TBYTE Placement, TBYTE Duration)
{
	TA2D_Result rc;

	if (Placement == 0 || Duration == 0)
		rc = A2D_IllegalValue;
	else
	  {
		rc = AD9884A_Write(AD9884A_CLPLACE, Placement);
		rc = AD9884A_Write(AD9884A_CLDUR, Duration);
		}

	return (rc);

} /* AD9884A_SetClamp */
/******************************************************************************/

/******************************************************************************/
static TA2D_Result AD9884A_Read(TAD9884A_Registers Reg, TBYTE *Data)
{
	TA2D_Result rc = A2D_OK;
	T_I2CERROR i2c;

	i2c = I2CReadByte(I2C_AD9884A, (TBYTE)Reg, Data, I2C_MAIN_BUS);
	if (i2c != I2C_OK)
		rc = A2D_NoResponse;

	return(rc);

}
/******************************************************************************/

/******************************************************************************/
static TA2D_Result AD9884A_Write(TAD9884A_Registers Reg, TBYTE Data)
{
	TA2D_Result rc = A2D_OK;
	T_I2CERROR i2c;

	i2c = I2CWriteByte(I2C_AD9884A, (TBYTE)Reg, Data, I2C_MAIN_BUS);
	if (i2c != I2C_OK)
		rc = A2D_NoResponse;

	return(rc);

}
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetOutput- A2D module set output mode
 *
 *
 *  description:
 *  ------------
 *
 *  Sets single or parallel output 
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetOutput(int parallel)
 *  Where:
 *  Returns:
 *  A2D_OK or A2D_DeviceNotSupported
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Iddo	24/10/2000  creation
 *
 */

TA2D_Result AD9884A_SetOutput(int parallel)
{
	TA2D_Result rc = A2D_OK;
	union {
		TAD9884A_Control1 bits;
		TBYTE byte;
		} Control1Val;

	if (rc == A2D_OK)
		 {
		 rc = AD9884A_Read(AD9884A_CONTROL1, &Control1Val.byte);
		 if (parallel)
		 {
			 Control1Val.bits.par   = 1;		   /* Simoltaneous data */
			 Control1Val.bits.demux = 1;		   /* Simoltaneous data */
		 }
		 else
		 {
			 Control1Val.bits.par   = 0;		   /* single data */
			 Control1Val.bits.demux = 0;		   /* mux  data */
		 }

		 
		 rc = AD9884A_Write(AD9884A_CONTROL1, Control1Val.byte);
		 }


	return (rc);

}  /* AD9884A_SetOutput */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *
 *
 *  description:
 *  ------------
 *
 *  Get Input Format Not support in this modal 
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetOutput(int parallel)
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  inon	 5/2/2001  creation
 *
 */

#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_SetInputFormat(TA2D_InputFormat NewFormat)
{
	return(A2D_FunctionNotImplemented);
}
/******************************************************************************/

/******************************************************************************/
TA2D_Result AD9884A_GetInputFormat(TA2D_InputFormat *Format)
{
   *Format = A2D_Graphics;
	return(A2D_OK);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
Boolean AD9884A_IsOddPixelInB(void)
{
	union {
   TAD9884A_Control2 bits;
   TBYTE byte;
   } Control2Val;

   AD9884A_Read(AD9884A_CONTROL2, &Control2Val.byte);
   return (Control2Val.bits.getoutphase);
}
/******************************************************************************/

/******************************************************************************/
void AD9884A_SetOddPixelToB(Boolean OddToB)
{
	union {
   TAD9884A_Control2 bits;
   TBYTE byte;
   } Control2Val;

  AD9884A_Read(AD9884A_CONTROL2, &Control2Val.byte);
  Control2Val.bits.setoutphase =OddToB;
  AD9884A_Write(AD9884A_CONTROL2, Control2Val.byte);
}
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_SetHSyncPulseWidth(TBYTE Width)
{
	return(A2D_FunctionNotImplemented);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_GetHSyncPulseWidth(TBYTE *Width)
{
	return(A2D_FunctionNotImplemented);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_setClockMode(TA2D_clockMode clockMode)
{
   return (A2D_FunctionNotImplemented);
}/* AD9884A_setClockMode */
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_getClockMode(TA2D_clockMode *clockMode)
{
   return (A2D_FunctionNotImplemented);
}/* AD9884A_getClockMode */
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
Boolean AD9884A_IsTimingStandardSupported(unsigned long PixelClock)
{
   if ((PixelClock * 1000L)> MAX_PIXEL_CLOCK)
		return FALSE;
   else
   	return TRUE;
}
/******************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -