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

Subversion Repositories minsoc

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

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

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

powered by: WebSVN 2.1.0

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