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

📄 tvpi2c_fw.h

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

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

//  TEMPORARY CONSTANT
#define TVP_I2C_INT_PRIORITY  10

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

/* I2c Memory addresses using word addresses/addition */

#define TVP_I2CCR   (TVP_I2C_BASE + 0)
#define TVP_I2CAR   (TVP_I2C_BASE + 1)
#define TVP_I2CSR   (TVP_I2C_BASE + 2)

/* I2C Master Mode States */
#define TVP_ST_IDLE               0x100           // idle state           

#define TVP_ADDR_WRITE            0x120
#define TVP_ADDR_WRITE_10_BIT     0x140

#define TVP_MASTER_WRITE          0x200
#define TVP_MASTER_WRITE_COMPLETE 0x220

#define TVP_MASTER_ADDR_ACK       0x300
#define TVP_MASTER_READ           0x320
#define TVP_MASTER_READ_LAST      0x340

/* I2C Slave Mode States*/
#define TVP_SLAVE_WRITE          0x400
#define TVP_SLAVE_READ           0x600
#define TVP_SLAVE_ADDR_READY     0x800          
#define TVP_SLAVE_READY          0x820
#define TVP_SLAVE_RW_DONE        0x1000
#define TVP_SLAVE_ERROR          0x2000
/* i2cEndSequence_l parameters */
#define TVP_I2C_COMPLETE    0
#define TVP_I2C_BUS_ERROR   1
#define TVP_I2C_ACK_FAULT   2
#define TVP_I2C_SEQ_ERROR   4
#define TVP_I2C_TIMEOUT     8
#define TVP_I2C_MEMORY_ERROR  16        //the memory address of the slave operation is out of the range
/* Hardware bit mappings */
//define TVP_I2C_RESET             1

#define TVP_ACK_BIT               0x40000
#define TVP_TO_ENABLE             0x20000
#define TVP_MASK_ALL              0x1f000
#define TVP_MASK_SLAVE            0x03000
#define TVP_MASK_MRD              0x08000
#define TVP_MASK_MWR              0x04000
#define TVP_STOP_BIT              0x00800
#define TVP_RESTART_BIT           0x00400
#define TVP_START_BIT             0x00200
#define TVP_VALID_DATA_BIT        0x00100

#define TVP_START_CTRL    (TVP_MASK_SLAVE | TVP_MASK_MRD | \
                           TVP_ACK_BIT | TVP_TO_ENABLE | \
                           TVP_START_BIT | TVP_VALID_DATA_BIT)

/*************************************************/
/* I2C Address Register Bit Defines              */                            
/*************************************************/
#define TVP_I2C_SLOW_MODE        0
#define TVP_I2C_FAST_MODE            (unsigned int)(1 << 19) 
#define TVP_I2C_ENABLE_10_BIT        (unsigned int)(1 << 18) 
#define TVP_I2C_ENABLE_7_BIT         (unsigned int)(1 << 17) 
#define TVP_I2C_DISABLE_SLAVE        (unsigned int)(0xfffcffff)
#define TVP_I2C_ADDRESS_CLEAR        (0x1ffff)
#define TVP_I2C_10_BIT_ADD_SHIFT     7

/*************************************************/
/* I2C Control Register Bit Defines              */                            
/*************************************************/

#define TVP_I2C_RESET         (unsigned int)(0x80000000) // Soft reset
#define TVP_I2C_ACK		  	   (unsigned int)(0) 	  // Acknowledge value for bit18
#define TVP_I2C_NACK	         (unsigned int)(1 << 18) // Nack value
#define TVP_I2C_REC_DISABLE   (unsigned int)(1 << 17) // Active High masks slave receiver
#define TVP_I2C_ERR_INT_MSK   (unsigned int)(1 << 16) // Error Interrupt Mask
#define TVP_I2C_SLAVE_WR_MSK  (unsigned int)(1 << 15) // Slave Write Mask
#define TVP_I2C_SLAVE_RD_MSK  (unsigned int)(1 << 14) // Slave Read Mask
#define TVP_I2C_MSTR_WR_MSK   (unsigned int)(1 << 13) // Master Write Mask
#define TVP_I2C_MSTR_RD_MSK   (unsigned int)(1 << 12) // Master Read Mask

#define TVP_I2C_MASK_ALL_INTS (TVP_I2C_ERR_INT_MSK | TVP_I2C_SLAVE_WR_MSK | \
                       		   TVP_I2C_SLAVE_RD_MSK | TVP_I2C_MSTR_WR_MSK | \
							   TVP_I2C_MSTR_RD_MSK )

#define TVP_I2C_STOP          (unsigned int)(1 << 11) // Stop after next byte 
#define TVP_I2C_RESTART       (unsigned int)(1 << 10) // restart before next byte
#define TVP_I2C_START         (unsigned int)(1 <<  9) // start before next byte
#define TVP_I2C_VALID_DATA    (unsigned int)(1 <<  8) // control word valid
 
#define TVP_I2C_DATA_BYT_MSK  (unsigned int)(0x000000ff) //Data byte extract mask
#define TVP_I2C_CTRL_MSK      (unsigned int)(0x40f00)      
#define TVP_I2C_CTRL_DATA_MSK (TVP_I2C_DATA_BYT_MSK | TVP_I2C_CTRL_MSK)
/***************************************************************/
/* Status register                                             */                               
/***************************************************************/ 
#define TVP_I2C_SLAVE_RESTART (unsigned int)(1 << 27)  //Rstrt occrd, xfer dir ?
#define TVP_I2C_SLAVE_START   (unsigned int)(1 << 26)  //Slv xfer has been trmntd
#define TVP_I2C_BIT_COUNT     (unsigned int)(1 << 22)  // 
#define TVP_I2C_ARBITRATION   (unsigned int)(1 << 21)  //Arbitration has occurred
#define TVP_I2C_SLAVE_ERR     (unsigned int)(1 << 20)  //Not implemented
#define TVP_I2C_TIMEOUT_ERR   (unsigned int)(1 << 19)  //Not implemented
#define TVP_I2C_BUS_ERR       (unsigned int)(1 << 18)  //Stop/Rstrt/Strt didnt occur  
#define TVP_I2C_READ_FLAG     (unsigned int)(1 << 17)  //Val of most recent r/w bit.
#define TVP_I2C_MASTER_FLAG   (unsigned int)(1 << 16)  //Currently in master mode.
#define TVP_I2C_SLAVE_FLAG    (unsigned int)(1 << 15)  //Currently in slave mode.
#define TVP_I2C_STOP_FLAG     (unsigned int)(1 << 14)  //Bus has been stopped 
#define TVP_I2C_RETART_FLAG   (unsigned int)(1 << 13)  //Bus running under a restart 
#define TVP_I2C_START_FLAG    (unsigned int)(1 << 12)  //Bus running under a start 
#define TVP_I2C_NACK_VALUE    (unsigned int)(1 << 11)  //Last ACK/NAK received
#define TVP_I2C_ACTIVE_FLAG   (unsigned int)(1 << 10)  //Val of most recent ack
#define TVP_I2C_MASK_MRD      (unsigned int)(1 << 9 )  //Mask Master Read interrupt
#define TVP_I2C_MASK_MWR      (unsigned int)(1 << 8 )  //Mask Master Write interrupt
#define TVP_I2C_MASK_SRD      (unsigned int)(1 << 7 )  //Mask Slave Read interrupt
#define TVP_I2C_MASK_SWR      (unsigned int)(1 << 6 )  //Mask Slave Write interrupt
#define TVP_I2C_MASK_ERR      (unsigned int)(1 << 5 )  //Mask Error Interrupt
#define TVP_I2C_MRD_INT       (unsigned int)(1 << 4 )  //Raw Master Read interrupt
#define TVP_I2C_MWR_INT       (unsigned int)(1 << 3 )  //Raw Master Write interrupt
#define TVP_I2C_SRD_INT       (unsigned int)(1 << 2 )  //Raw Slave Read interrupt
#define TVP_I2C_SWR_INT       (unsigned int)(1 << 1 )  //Raw Slave Write interrupt
#define TVP_I2C_ERR_INT       (unsigned int)(1 << 0 )  //Raw Error interrupt

#define TVP_I2C_CLEAR_ALL_INT_STS   (unsigned int)(0x000003ff)
#define TVP_I2C_INTS          (unsigned int)(0x3e0)

#define TVP_I2C_ACK_VALUE     (unsigned int)0          //ACK received

/*************************************************/
/* slave read struct                             */                            
/*************************************************/
typedef struct {
    unsigned char *data;                  // Where to put the data            
    unsigned long num;              // How many actually received   
    unsigned long size;             // Size of *data                            
}TvpI2cRead;

/*************************************************/
/* slave write struct                            */                            
/*************************************************/
typedef struct {
    unsigned long *data;             // Where to put the data            
    unsigned long num;               // How many actually received   
}TvpI2cWrite;


/*************************************************/
/* Global data structure                         */                            
/*************************************************/

typedef struct {
unsigned long  i2cErrCount;  	// # of errors 
unsigned long  i2cNumSent;  	// # of transactions sent     
unsigned long  i2cNumReceived;  // # of transactions received 
unsigned char *i2cData;  		// data byte pointer          
unsigned long  i2cLength;  		// msg data packet length     
unsigned long  i2cAddr;  		// current target address     
unsigned long  i2cState;  		// current driver state       
unsigned long  i2cSeq;  		// number of array commands   
unsigned long  i2cCurSeq;  		// holds current index    
TvpIntNum      i2cIntNum;       // User notification interrupt    
} TvpI2cGlbl_s;

#endif

⌨️ 快捷键说明

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