1 /******************************************************************************
2 ** File Name: I2C_reg_v0.h *
5 ** Copyright: 2010 Spreatrum, Incoporated. All Rights Reserved. *
6 ** Description: This file define the basic hw interfaces of I2C device. *
7 ******************************************************************************
9 ******************************************************************************
11 ** ------------------------------------------------------------------------- *
12 ** DATE NAME DESCRIPTION *
13 ** 06/28/2010 liuhao Create. *
14 ******************************************************************************/
15 #ifndef _I2C_REG_V0_H_
16 #define _I2C_REG_V0_H_
17 /*----------------------------------------------------------------------------*
19 **------------------------------------------------------------------------- */
21 /**---------------------------------------------------------------------------*
23 **--------------------------------------------------------------------------*/
28 /**---------------------------------------------------------------------------*
30 **---------------------------------------------------------------------------*/
31 /*----------I2C Register----------*/
33 #define I2C_CTL (I2C_BASE + 0x0000)
34 #define I2C_CMD (I2C_BASE + 0x0004)
35 #define I2C_CLKD0 (I2C_BASE + 0x0008)
36 #define I2C_CLKD1 (I2C_BASE + 0x000C)
37 #define I2C_RST (I2C_BASE + 0x0010)
38 #define I2C_CMD_BUF (I2C_BASE + 0x0014)
40 //The corresponding bit of I2C_CTL register.
41 #define I2CCTL_INT (1 << 0) //I2c interrupt
42 #define I2CCTL_ACK (1 << 1) //I2c received ack value
43 #define I2CCTL_BUSY (1 << 2) //I2c data line value
44 #define I2CCTL_IE (1 << 3) //I2c interrupt enable
45 #define I2CCTL_EN (1 << 4) //I2c module enable
46 #define I2CCTL_CMDBUF_EN (1 << 5) //Enable the cmd buffer mode
47 #define I2CCTL_CMDBUF_EXEC (1 << 6) //Start to exec the cmd in the cmd buffer
48 #define I2CCTL_ST_CMDBUF (7 << 7) //The state of I2c cmd buffer state machine.
49 #define I2CCTL_CMDBUF_WPTR (7 << 7) //I2c command buffer write pointer
51 //The corresponding bit of I2C_CMD register.
52 #define I2CCMD_INT_ACK (1 << 0) //I2c interrupt clear bit
53 #define I2CCMD_TX_ACK (1 << 1) //I2c transmit ack that need to be send
54 #define I2CCMD_WRITE (1 << 2) //I2c write command
55 #define I2CCMD_READ (1 << 3) //I2c read command
56 #define I2CCMD_STOP (1 << 4) //I2c stop command
57 #define I2CCMD_START (1 << 5) //I2c start command
58 #define I2CCMD_ACK (1 << 6) //I2c received ack value
59 #define I2CCMD_BUS (1 << 7) //I2c busy in exec commands
60 #define I2CCMD_DATA 0xFF00 //I2c data received or data need to be transmitted
62 /**----------------------------------------------------------------------------*
63 ** Local Function Prototype **
64 **----------------------------------------------------------------------------*/
65 //I2C control register
66 typedef struct i2c_tag
73 VOLATILE uint32 cmd_buf;
76 /**----------------------------------------------------------------------------*
78 **----------------------------------------------------------------------------*/
82 /**---------------------------------------------------------------------------*/