OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [sw/] [drivers/] [i2c.h] - Blame information for rev 94

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 rfajardo
struct i2c_type
2
{
3
    unsigned char address;
4
    unsigned char pointer;
5
    unsigned short data;
6
};
7
 
8
struct i2c_mode
9
{
10
    unsigned char read_write;
11
    unsigned char byte_word;
12
    unsigned char ptr_set;
13
};
14
 
15
typedef struct i2c_type i2c_type;
16
typedef struct i2c_mode i2c_mode;
17
 
18
 
19 53 ConX.
 
20 36 rfajardo
void i2c_init(void);
21
void i2c_irq(void);
22
 
23
i2c_type * i2c_get(void);                           //return pointer to first non read received data
24
 
25
void i2c_set_ack_lvl(int ack_lvl, int final_ack_lvl);
26
int i2c_trans(i2c_mode * mode, i2c_type * data);   //return (-1) or length (still processing previous) or asserted
27
 
28 53 ConX.
#define I2C_BUF_LEN             10
29
#define I2C_PRESC_LO            0x00
30
#define I2C_PRESC_HI            0x01
31 36 rfajardo
 
32 53 ConX.
#define I2C_CTR                 0x02
33 36 rfajardo
 
34 53 ConX.
#define I2C_TXR                 0x03
35
#define I2C_RXR                 0x03
36 36 rfajardo
 
37 53 ConX.
#define I2C_CR                  0x04
38
#define I2C_SR                  0x04
39 36 rfajardo
 
40
//BITS
41 53 ConX.
#define I2C_CTR_EN              0x80
42
#define I2C_CTR_IRQ_EN          0x40
43 36 rfajardo
 
44 53 ConX.
#define I2C_TXR_ADR             0xFE
45
#define I2C_TXR_W               0x00
46
#define I2C_TXR_R               0x01
47 36 rfajardo
 
48 53 ConX.
#define I2C_CR_STA              0x80
49
#define I2C_CR_STO              0x40
50
#define I2C_CR_RD               0x20
51
#define I2C_CR_WR               0x10
52
#define I2C_CR_ACK              0x00
53
#define I2C_CR_NACK             0x08
54
#define I2C_CR_CLR_IRQ          0x01
55 36 rfajardo
 
56 53 ConX.
#define I2C_SR_R_ACK            0x80
57
#define I2C_SR_BUSY             0x40
58
#define I2C_SR_ARB_LOST         0x20
59
#define I2C_SR_TX_BUSY          0x02
60
#define I2C_SR_IRQ_FLAG         0x01

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.