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

📄 tvpi2c.h

📁 ti的数字电视芯片 tvp9000的源码
💻 H
字号:
#ifndef TVPI2C_DOT_H_IS_DEFINED
#define TVPI2C_DOT_H_IS_DEFINED

/***************************************************************************** 
*    Property of Texas Instruments Incorporated, Copyright 2004
*    All rights reserved
******************************************************************************
*
* TvpI2c.h contains all structure and i2c specific definitions
*  
*
*
* $Revision: $   
*
* $History: TvpI2c.h $    
* 
******************************************************************************/

/***************************************************************/
/* constants                                                   */                                  
/***************************************************************/

#define TVP_RESET_LOW             0x00
#define TVP_RESET_HIGHT           0x01

#define TVP_I2C_SLAVE_MODE        0
#define TVP_I2C_MASTER_MODE       1
                                   
#define TVP_I2C_100K_MODE         0
#define TVP_I2C_400K_MODE         1
                                   
#define TVP_I2C_ACK_LAST_BYTE     0
#define TVP_I2C_NACK_LAST_BYTE    1

#define TVP_I2C_SLAVE_WRITE_IRQ  0x80
#define TVP_I2C_SLAVE_READ_IRQ   0xFF


#define TVP_TEN_BIT_ADDRESS       0x80000000
#define TVP_I2C_MAX_LENGTH    0x10000         //the max length of the memory application can access

typedef enum {
	TVP_I2C_0=0,	 
	TVP_I2C_1,
	TVP_NUM_I2C 
} TvpI2cNum;

typedef unsigned char TvpI2cSeqNum;
typedef unsigned long TvpI2cIntNum;

/***************************************************************/
/* i2c io sequence type                                        */                      
/***************************************************************/

typedef struct {
    unsigned long   Address;                // addr of slave device              
    unsigned char   *data;                  // data pointer for read/write 
    unsigned char   dataLength;             // length of data                            
}TvpI2cSequence;

/***************************************************************/
/* irq result status word                                      */                          
/***************************************************************/

typedef  struct {
    unsigned int sequence   :8;     // sequence -- NOT USED IN CALLBACK                                                
    unsigned int position   :16;    // data byte within current sequence -- NOT USED IN CALLBACK                                                        
    unsigned int spare      :1;     // spare                                                        
    unsigned int readFlag   :1;      //1: slave read,0:slave write;  
    unsigned int memErr     :1;     // slave mode memory err
    unsigned int intSeqErr  :1;     // I/O Transmission error
    unsigned int busErr     :1;     // Bus arbitration error
    unsigned int timeOut    :1;     // When a byte to byte timeout happens          
    unsigned int ackFault   :1;     // When an ack is expected and not received 
    unsigned int complete   :1;     // Previous command complete                
    unsigned short   offset;        //offset where master write to or read from at DDR ---SLAVE MODE ONLY
}TvpI2cResult;

/***************************************************************/
/* irq init block                                              */                              
/***************************************************************/

typedef struct {
    unsigned long address;    // local device address for transactions matching         
    unsigned long mode;       // 0=Slave; 1=Master  
    unsigned long speed;      // 0=Default; 1=Fast Mode;                             
}TvpI2cInit;

/***************************************************************/
/* Status register                                             */                               
/***************************************************************/
typedef struct {
   unsigned int spare         : 4; 
   unsigned int slave_restart : 1;
   unsigned int slave_start   : 1;
   unsigned int bit_count     : 4;
   unsigned int arbitration   : 1;
   unsigned int slave_err     : 1;
   unsigned int timeout_err   : 1;
   unsigned int bus_err       : 1;
   unsigned int read_flag     : 1;
   unsigned int master_flag   : 1;
   unsigned int slave_flag    : 1;
   unsigned int stop_flag     : 1;
   unsigned int restart_flag  : 1;
   unsigned int start_flag    : 1;
   unsigned int ack_value     : 1;  // Last ACK/NAK received
   unsigned int active_flag   : 1;
   unsigned int mask_mrd      : 1;  // Mask Master Read interrupt
   unsigned int mask_mwr      : 1;  // Mask Master Write interrupt
   unsigned int mask_srd      : 1;  // Mask Slave Read interrupt
   unsigned int mask_swr      : 1;  // Mask Slave Write interrupt
   unsigned int mask_err      : 1;  // Mask Error Interrupt
   unsigned int mrd_int       : 1;  // Raw Master Read interrupt
   unsigned int mwr_int       : 1;  // Raw Master Write interrupt
   unsigned int srd_int       : 1;  // Raw Slave Read interrupt
   unsigned int swr_int       : 1;  // Raw Slave Write interrupt
   unsigned int err_int       : 1;  // Raw Error interrupt
} TvpI2cStatusReg;

/***************************************************************/
/* Control Register                                            */                                
/***************************************************************/
typedef struct {
   unsigned int reset         : 1;  // Soft reset
   unsigned int               :12;  // spare
   unsigned int acknowledge   : 1;  // Acknowledge value
   unsigned int to_enable     : 1;  // Enable Timeout
   unsigned int err_int_msk   : 1;  // Error Interrupt Mask
   unsigned int slave_wr_msk  : 1;  // Slave Write Mask
   unsigned int slave_rd_msk  : 1;  // Slave Read Mask
   unsigned int mstr_wr_msk   : 1;  // Master Write Mask
   unsigned int mstr_rd_msk   : 1;  // Master Read Mask
   unsigned int stop          : 1;  // Stop after next byte 
   unsigned int restart       : 1;  // restart before next byte
   unsigned int start         : 1;  // start before next byte
   unsigned int valid_data    : 1;  // control word valid
   unsigned int data          : 8;  // data transmitted or received
} TvpI2cControlReg;
    

/***************************************************************/
/* Address register                                            */                                
/***************************************************************/
typedef struct {
   unsigned int               :11;
   unsigned int fast          : 1;
   unsigned int enable_addr   : 2;
   unsigned int address_10_bit:10;
   unsigned int address_7_bit : 7;
} TvpI2cAddressReg;


/*************************************************/
/* status word                                   */                            
/*************************************************/

typedef struct {
    TvpI2cStatusReg     status;        // status                 
    TvpI2cControlReg    control;       // control               
    TvpI2cAddressReg    addrSet;       // address set
}TvpI2cStatus;

/*----------------------------**
** Control Register Structure **
**----------------------------*/
typedef struct {
    unsigned int   ctrl;        // control               
    unsigned int   addr;        // address set 
    unsigned int   stat;        // status                 
} TvpI2cRegs;


/*************************************************/ 
/* prototypes                                    */                                
/*************************************************/
#ifdef __cplusplus
extern "C" {
#endif

TVP_FERROR			tvpI2cDrvrInit(TvpI2cNum i2cNum,
                                   TvpI2cInit *pblock, 
                                   TvpI2cResult *sresult, 
                                   TvpI2cIntNum int_num);
TVP_FERROR			tvpI2cStat(TvpI2cNum i2cNum, 
                               TvpI2cStatus *pblock);
Tvp_True_False  	tvpI2cBusy(TvpI2cNum i2cNum);
TVP_FERROR  		tvpI2cIOSequence(TvpI2cNum i2cNum,
                                     TvpI2cSeqNum numberOfSequence, 
                      				 TvpI2cSequence *sequenceArray);
/*******************************************************************
*     Slave Mode Function                                          *
*******************************************************************/
TVP_FERROR tvpI2cSlaveInit(TvpI2cNum i2cNum,TvpI2cInit *pblock,TvpI2cResult *sresult,unsigned long memBaseAddr,unsigned long length,TvpI2cIntNum intNum);
TVP_FERROR tvpI2cSlaveReset(TvpI2cNum i2cNum);

#ifdef __cplusplus
};
#endif

#endif

⌨️ 快捷键说明

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