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

📄 tidtv_usergpio.c

📁 ti的数字电视芯片 tvp9000的源码
💻 C
字号:
/*******************************************************************************
*	@ModuleName	::	TiDTV_UserGpio.c
*	
*	@Copyright	::	Copyright 2005- Texas Instruments, Inc.
*	
*	@Description::	User defined GPIO Control APIs
*	
*	@History	::
*---------------------------------------
*	07-24-2005	W.Shi	Created
*******************************************************************************/

#include	<stdio.h>
#include	<stdlib.h>
#include	"ucos_ii.h"

#include	"TvpArch.h"
#include	"TvpDefs.h"
#include	"Tvp9000.h"
#include	"TvpError.h"
#include	"TvpInt.h"
#include	"TvpHdm.h"
#include	"TvpInt926.h"
#include	"TvpUarts.h"
#include	"TvpEbi.h"
#include	"TvpTpp.h"
#include	"TvpIrrf.h"
#include	"TvpGpio.h"
#include	"TvpVideo.h"
#include	"TvpAudio.h"
#include	"TvpEncoder.h"

#include	"TiDTV_DataType.h"
#include	"TiDTV_SysCtrl.h"
#include	"TiDTV_UserApi.h"
#include	"TiDTV_Buffers.h"
#include	"TiDTV_PSIP.h"
#include	"TVP9K_I2C_Def.h"
#include	"TVP9K_NV_Def.h"
#include	"TiDTV_GLib.h"
#include	"TiDTV_GUI.h"
#include	"TiDTV_McuComm.h"
#include	"TiDTV_IrKey.h"
#include	"TiDTV_AvInput.h"

#include 	"ProviewDTV_TDA9975.h"

/*******************************************************************************
*	@RoutineName:: TiDTV_InitGPIO
*
*	@Description:: Initialize all GPIOs
*
*	@Input		:: none
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_InitGPIO(void)
{
#ifdef	TVP9K_EVM
	// Disable all GPIOs (enables all modules muxed with GPIOs)
	tvpGpioDisableAll();
	
	// GPIO-1: Output, LED Control, 0 = Off, 1 = On
	tvpGpioEnable(1, TVP_GPIO_OUTPUT, TVP_DISABLE, TVP_GPIO_HIGH_TO_LOW);
#else
	int i;
	
	//------------------------------------------------------
	// Assert the System Reset (bit-20), Turn OFF the LED (bit-28)
	//
	*TVP_GPIO_DOUT = 0x00200061;	// base addr = 0x343C0
	*TVP_GPIO_OEN  = 0x8045000C;	// 0 = Output, 1 = Input
	*TVP_GPIO_EN   = 0xf0f200ff;	// 1 = Enable GPIO, 0 = Disable
	
	//------------------------------------------------------
	// Release the System Reset (bit-20), Turn OFF the LED (bit-28)
	//
	for (i = 0; i < 80; i++)	// wait for about 160us
		;
	
	*TVP_GPIO_DOUT = 0x00300063;	// Turn OFF Audio AMP
	
	//----------------------------------------------------------
	// Hook GPIO Interrupt Service Routine
	//
	tvpIntHook(TVP_INT_GPIO, TVP_INTP_GPIO, (TvpIntExec) TiDTV_GpioISR);
	
	// GPIO-3: Input, MCU IRQ
	//tvpGpioEnable(3, TVP_GPIO_INPUT, TVP_ENABLE, TVP_GPIO_HIGH_TO_LOW);
	tvpGpioEnable(3, TVP_GPIO_INPUT, TVP_ENABLE, TVP_GPIO_LOW_TO_HIGH);	
#endif	/* TVP9K_EVM */
}

/*******************************************************************************
*	@RoutineName:: TiDTV_LedCtrl
*
*	@Description:: the LED Control
*
*	@Input		::
*		UCHAR Flag	: 1 = On, 0 = Off
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_LedCtrl(UCHAR Flag)
{
#ifdef	TVP9K_EVM
	if (Flag)
		*TVP_GPIO_DOUT |= 0x02;
	else
		*TVP_GPIO_DOUT &= ~(0x02);
#else
	if (Flag)
		*TVP_GPIO_DOUT |= 1 << 28;
	else
		*TVP_GPIO_DOUT &= ~(1 << 28);
#endif	/* TVP9K_EVM */
}

/*******************************************************************************
*	@RoutineName:: TiDTV_ExtDvSel
*
*	@Description:: External Digital Video Selection
*
*	@Input		::
*		UCHAR ExtDvFlag	: 1 = TVP5160, 0 = HDMI
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_ExtDvSel(UCHAR ExtDvFlag)
{
	if (ExtDvFlag == TI_DTV_EXT_DV_TVP5160) {
		// set HDMI to Hi-Z mode
		TiDTV_I2cWriteByte(0, 1, 0x98, 1, 0xff, 0x00, OS_TICKS_PER_SEC / 2);
		TiDTV_I2cWriteByte(0, 1, 0x98, 1, 0xe5, 0x9b, OS_TICKS_PER_SEC / 2);
#if	1
		TiDTV_I2cWriteByte(0, 1, 0xB8, 1, 0x34, 0x11, OS_TICKS_PER_SEC / 2);
		*TVP_GPIO_DOUT &= ~(1 << 5);	// select TVP5160
#else
		*TVP_GPIO_DOUT |= 1 << 1;		// select TVP5160
#endif
	} else {
		// set TVP5160 to Hi-Z mode
#if	1
		TiDTV_I2cWriteByte(0, 1, 0xB8, 1, 0x34, 0x00, OS_TICKS_PER_SEC / 2);
		*TVP_GPIO_DOUT |= 1 << 5;		// select HDMI
#else
		*TVP_GPIO_DOUT &= ~(1 << 1);	// select HDMI
#endif
	}
}

/*******************************************************************************
*	@RoutineName:: TiDTV_AudioSel
*
*	@Description:: Analog switch for Audio Input Selection
*
*	@Input		::
*		UCHAR AudioSel	: Audio Selection:
*						0 = A-Tuner, 1 = CVBS/S-Video, 2 = YPbPr
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_AudioSel(ULONG AudioSel)
{
	ULONG WorkULONG = *TVP_GPIO_DOUT & 0x9FFFFFFF;
	
	*TVP_GPIO_DOUT = WorkULONG | (AudioSel << 29) | (1 << 6);	// Power On Audio ADC
}

/*******************************************************************************
*	@RoutineName:: TiDTV_AudioAmpCtrl
*
*	@Description:: Audio AMP power Control
*
*	@Input		::
*		UCHAR Flag	: 1 = On, 0 = Off
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_AudioAmpCtrl(UCHAR Flag)
{
	if (Flag)
		*TVP_GPIO_DOUT |= 1 << 4;
	else
		*TVP_GPIO_DOUT &= ~(1 << 4);
}

/*******************************************************************************
*	@RoutineName:: TiDTV_GpioISR
*
*	@Description:: GPIO ISR
*
*	@Input		:: none
*
*	@Output		:: none
*
*	@Return		:: none
*******************************************************************************/
void TiDTV_GpioISR(void)
{
	ULONG GpioStatus = tvpGpioIrqRead();	// pending IRQ interrupt events
	INT8U uCosRetStatus;
	
	GpioStatus = tvpGpioIrqRead();	// pending IRQ interrupt events
	if (GpioStatus & (1U << 3)) {
		// MCU IRQ
		tvpGpioIrqClear(3);
		OSFlagPost(pTiDTV_SysFLAG, TI_DTV_MCU_CMD_READY, OS_FLAG_SET, &uCosRetStatus);
	}
	
	if (GpioStatus & (1U << 22)) {
		// Flash Busy/Ready IRQ
		tvpGpioIrqClear(22);
	}
	
	if (GpioStatus & (1U << 31)) {
		// TVP5160 IRQ
		tvpGpioIrqClear(31);
	}
}

⌨️ 快捷键说明

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