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

📄 ad9884a.c

📁 此为ADI公司AD9884A型号芯片的控制及设备,多应用于TV.PVR等产品
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  ad9884a.c - AD9884A driver
 *
 *  description:
 *  ------------
 *  Includes all interface functions rquired for AD9884A operation
 *
 *
 *  Functions:
 *  ----------
 *
 *
 * AD9884A_Init
 * AD9884A_SetHSYNCPolarity
 * AD9884A_SetCoastPolarity
 * AD9884A_SetGain
 * AD9884A_SetOffset
 * AD9884A_SetPhase
 * AD9884A_GetPhase
 * AD9884A_SetClamp
 * AD9884A_SetPLL
 * AD9884A_Read
 * AD9884A_Write
 *
 *  history:
 * $History: $
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 * $NoKeywords :$
 */

/* defines */
#define	MAX_PIXEL_CLOCK   140000000L //140 MSPS

#include <stdio.h>
#include "types.h"
#include "fp.h"
#include "i2c.h"
#include "a2d.h"
#include "ad9884a.h"
#include "logic.h"

/******************************************************************************/
/* AD9884A registers access functions */
static TA2D_Result AD9884A_Read(TAD9884A_Registers Reg, TBYTE *Data);
static TA2D_Result AD9884A_Write(TAD9884A_Registers Reg, TBYTE Data);
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_Init- A2D module init
 *
 *
 *  description:
 *  ------------
 *
 *  Verify device exists - get its id
 *  Set A/D fixed parameters:
 *  	Extclamp = external
 *  	Clamppol = Active high
 *  	Extclk   = internal
 *  	Outphase = PortA
 *  	Parallel = Simoltaneous data
 *
 *  Protoype:
 *  ----------
 *  TA2D_ResultAD9884A_Init(void)
 *  Where:
 *  Returns:
 *  A2D_OK or A2D_DeviceNotSupported
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_Init(void)
{
	TA2D_Result rc = A2D_OK;
	TBYTE Control2Val;
	union {
		TAD9884A_Control1 bits;
		TBYTE byte;
		} Control1Val;

	/* Verify device exists - get its revision id    */
	rc = AD9884A_Read(AD9884A_CONTROL2, &Control2Val);

	/* Set A/D fixed parameters:
		Extclamp = external
		Clamppol = Active high
		Extclk   = internal
		Outphase = PortA
		Parallel = Simoltaneous data
		Clamp placement = 10, duration = 30 */
	if (rc == A2D_OK)
		 {
		 rc = AD9884A_Read(AD9884A_CONTROL1, &Control1Val.byte);
		 Control1Val.bits.extclmp = 0;	/* internal clamp */
		 Control1Val.bits.clampol = TRUE;	/* active high polarity */
		 Control1Val.bits.extclk = 0;	   /* internal clock */
		 Control1Val.bits.par = 1;		   /* Simoltaneous data */
		 rc = AD9884A_Write(AD9884A_CONTROL1, Control1Val.byte);
		 rc = AD9884A_Write(AD9884A_CONTROL2, Control2Val & ~AD9884A_OUTPHASE);
		 AD9884A_SetClamp(10, 10);
		 }

   //LOGIC_SetGraphicsSource(A2D_Graphics);
	return (rc);
}  /* AD9884A_Init */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_GetInputVSYNCPolarity(Boolean *Polarity)
{
	return(A2D_DeviceNotSupported);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_GetInputHSYNCPolarity(Boolean *Polarity)
{
	return(A2D_DeviceNotSupported);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
TA2D_Result AD9884A_SetPLLInHSYNCPolarity(Boolean Polarity)
{
	TA2D_Result rc = A2D_OK;
	union {
		TAD9884A_Control1 bits;
		TBYTE byte;
		} Control1Val;

	rc = AD9884A_Read(AD9884A_CONTROL1, &Control1Val.byte);
	Control1Val.bits.hspol = Polarity;
	rc = AD9884A_Write(AD9884A_CONTROL1, Control1Val.byte);

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

/******************************************************************************/
TA2D_Result AD9884A_GetPLLInHSYNCPolarity(Boolean *Polarity)
{
	TA2D_Result rc;

	union {
		TAD9884A_Control1 bits;
		TBYTE byte;
		} Control1Val;

	rc = AD9884A_Read(AD9884A_CONTROL1, &Control1Val.byte);
   *Polarity = Control1Val.bits.hspol;
	return (rc);
}
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_SetOutHSYNCPolarity(Boolean Polarity)
{
	return(A2D_DeviceNotSupported);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
#pragma option -w-par   /* Turn off, temporarily, the warning for unused parameter */
TA2D_Result AD9884A_GetOutHSYNCPolarity(Boolean *Polarity)
{
	return(A2D_DeviceNotSupported);
}
#pragma option -w.      /* Back to normal waning mode */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetCoastPolarity- Set Coast polarity
 *
 *
 *  description:
 *  ------------
 *  Set the polarity of the coast signal that is applied to the COAST input.
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetCoastPolarity(TA2D_SignalPolarity Polarity)
 *  Where:
 *  Polarity - required COAST signal polarity
 *  Returns:
 *  A2D_OK
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_SetCoastPolarity(Boolean Polarity)
{
	TA2D_Result rc = A2D_OK;
	union {
		TAD9884A_Control1 bits;
		TBYTE byte;
		} Control1Val;

	rc = AD9884A_Read(AD9884A_CONTROL1, &Control1Val.byte);
	Control1Val.bits.cstpol = Polarity;
	rc = AD9884A_Write(AD9884A_CONTROL1, Control1Val.byte);

	return (rc);

} /* AD9884A_SetCoastPolarity */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetGain- Set color channel gain
 *
 *
 *  description:
 *  ------------
 *  Set the gain for the specific color channel (R/G/B).
 *  The function actually calls to the on-board A2D function.
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetGain (TA2D_Channel Channel, signed char Val)
 *  Where:
 *  Channel - required channel: R/G/B
 *  Val - Gain value
 *  Returns:
 *  A2D_OK 
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_SetGain (TA2D_Channel Channel, TBYTE Val)
{
	TA2D_Result rc = A2D_OK;
	
	switch (Channel)
	  {
	  case A2D_Red:
		rc = AD9884A_Write(AD9884A_REDGAIN, Val);
	  	break;
	  case A2D_Green:
		rc = AD9884A_Write(AD9884A_GRNGAIN, Val);
		break;
	  case A2D_Blue:
		rc = AD9884A_Write(AD9884A_BLUGAIN, Val);
	  	break;
	  default:
	  	rc = A2D_NoSuchChannel;
	  	break;	
	  }

  return (rc);

}  /* AD9884A_SetGain */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetOffset- Set color channel DC offset
 *
 *
 *  description:
 *  ------------
 *  Set the color channel DC offset.
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetOffset (TA2D_Channel Channel, signed char	Val)
 *  Where:
 *  Channel - required channel: R/G/B
 *  Val - Offset value
 *  Returns:
 *  A2D_OK 
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_SetOffset (TA2D_Channel Channel, TBYTE	Val)
{
	TA2D_Result rc = A2D_OK;

	switch (Channel)
	  {
	  case A2D_Red:
		rc = AD9884A_Write(AD9884A_REDOFST, Val);
	  	break;
	  case A2D_Green:
		rc = AD9884A_Write(AD9884A_GRNOFST, Val);
	  	break;
	  case A2D_Blue:
		rc = AD9884A_Write(AD9884A_BLUOFST, Val);
	  	break;
	  default:
		rc = A2D_NoSuchChannel;
		break;
	  }

	return (rc);

} /* AD9884A_SetOffset */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_SetPhase- Set clock phase
 *
 *
 *  description:
 *  ------------
 *  Adjust the sampling phase. Range is 0 to 349.75 (32*11.25) degrees.
 *
 *
 *  Protoype:
 *  ----------
 *  TA2D_Result AD9884A_SetPhase (TBYTE Phase)
 *  Where:
 *  Phase - Phase value in degrees
 *  Returns:
 *  A2D_OK
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TA2D_Result AD9884A_SetPhase (TBYTE Phase)
{
	union {
	TAD9884A_Phase bits;
	TBYTE byte;
	} PhaseReg;
	TA2D_Result rc;

	if (Phase <= A2D_PHASEMAX)
		{
		PhaseReg.bits.phase = Phase;
		rc = AD9884A_Write(AD9884A_PHASE, PhaseReg.byte);
		}
	else
		rc = A2D_IllegalValue;

	return (rc);

} /* AD9884A_SetPhase */
/******************************************************************************/

/******************************************************************************/
/*
 *  Copyright (c) 1999-2000 Oplus Technologies INC.  All Rights resreved.
 *
 *  AD9884A_GetPhase- Returns clock phase
 *
 *
 *  description:
 *  ------------
 *  Returns the sampling phase. Range is 0 to 349.75 (32*11.25) degrees.
 *
 *
 *  Protoype:
 *  ----------
 *  TBYTE AD9884A_GetPhase (void)
 *  Where:
 *  Returns:
 *  Phase - Phase value in degrees
 *
 *  history:
 *
 *  who  	when        what
 *  ---  	----------  ----
 *  Avi	   21/02/2000  creation
 *
 */

TBYTE AD9884A_GetPhase (void)
{
	TAD9884A_Phase PhaseReg;

	AD9884A_Read(AD9884A_PHASE, (TBYTE *)&PhaseReg);

⌨️ 快捷键说明

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