if(port->chanObj[chanNum].edcFxns!= INV) {
/* open external device */
port->chanObj[chanNum].edcHandle
=port->chanObj[chanNum].edcFxns->open(name, (Arg)INV);
}
if(chan->edcFxns!=INV){
retVal = chan->edcFxns->ctrl(chan->edcHandle,
cmd-VPORT_CMD_EDC_BASE,(Arg)args);
因此对于TVP5150,需要写三个函数TVP51xx_open,TVP51xx_close,TVP51xx_ctrl,同理对于SAA7121也一样。再将其和微驱动编译成库供主程序调用即可。以下是我简写的tvp51xx.c,只作测试用:
/* by biren
TVP51xx.c
*/
#include
#include
#include
#include
#include "tvp51xx.h"
#include "_iic.h"
#include"_tvp51xx.h"
//#define _TVP5150_IIC_ADDR (0xB8>>1)
staticvoid configTVP51xx();
static Int TVP51XX_ctrl(EDC_Handlehandle,TVP51XX_Cmd cmd, Arg param);
static EDC_HandleTVP51XX_open(String devName,Arg optArg);
static IntTVP51XX_close(EDC_Handle handle);
EDC_Fxns TVP51XX_Fxns={
TVP51XX_open,
TVP51XX_close,
TVP51XX_ctrl
};
/*localvariables and arrays*/
static I2C_Handle hI2C=INV;
/********************************/
//configTVP51xx
static void configTVP51xx()
{ //TVP5150的配置只需要设置以下两个寄存器
Uint8 *temp=0;
*temp=0x6D;
_IIC_write(hI2C, _TVP5150_IIC_ADDR,0x03, temp,1);
*temp=0x2;
_IIC_write(hI2C, _TVP5150_IIC_ADDR,0x0F, temp,1);
}
/****************************/
//tvp5100_ctrl
staticInt TVP51XX_ctrl(EDC_Handle handle,TVP51XX_Cmd cmd, Arg param)
//TVP51xx_cmd定义在tvp51xx.h中
{
IntdevId=(Int)handle;
//check if the Handle is correct
if(devId!=_TVP5150_IIC_ADDR){
return EDC_FAILED;
}
switch(cmd){
case EDC_CONFIG:{
TVP51XX_ConfParams *tvp5150Params=(TVP51XX_ConfParams*)param;//TVP51XX_ConfParams定义在tvp51xx.h中
hI2C=tvp5150Params->hI2C;
configTVP51xx();//采用默认的配置,而不管传来的Param的值
}
break;
default:
break;
}
return EDC_SUCCESS;
}
//TVP5150_open
staticEDC_Handle TVP51XX_open(String devName,Arg optArg)
{
return(EDC_Handle)_TVP5150_IIC_ADDR;//定义在_tvp51xx.h中
}
static IntTVP51XX_close(EDC_Handle handle)
{
return 0;
联系客服