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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [i2c_master_slave/] [include/] [i2c_master_slave.h] - Blame information for rev 403

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

Line No. Rev Author Line
1 393 julius
/*************************************************************
2
 * I2C functions for Herveille i2c master_slave core         *
3
 *                                                           *
4
 * Provides functions to read from and write to the I2C bus. *
5
 * Master and slave mode are both supported                  *
6
 *                                                           *
7
 *                                                           *
8
 ************************************************************/
9
 
10
#ifndef _I2C_MASTER_SLAVE_H_
11
#define _I2C_MASTER_SLAVE_H_
12
 
13
extern const int i2c_base_adr[4];
14
//Memory mapping adresses
15
 
16 403 julius
#define I2C_MASTER_SLAVE_PRERlo 0x0     // Clock prescaler register
17
#define I2C_MASTER_SLAVE_PRERhi 0x1     // Clock prescaler register
18
#define I2C_MASTER_SLAVE_CTR    0x2     // Control register
19
#define I2C_MASTER_SLAVE_TXR    0x3     // Transmit register
20
#define I2C_MASTER_SLAVE_RXR    0x3     // Recive register
21
#define I2C_MASTER_SLAVE_CR     0x4     // Control register
22
#define I2C_MASTER_SLAVE_SR     0x4     // Status register
23
#define I2C_MASTER_SLAVE_SLADR  0x7     // Slave address register
24 393 julius
 
25 403 julius
#define I2C_MASTER_SLAVE_CTR_CORE_ENABLE 0x80
26
#define I2C_MASTER_SLAVE_CTR_INTR_ENABLE 0x40
27
#define I2C_MASTER_SLAVE_CTR_SLAVE_ENABLE 0x20
28 393 julius
 
29 403 julius
#define I2C_MASTER_SLAVE_CR_START        0x80
30
#define I2C_MASTER_SLAVE_CR_STOP         0x40
31
#define I2C_MASTER_SLAVE_CR_READ         0x20
32
#define I2C_MASTER_SLAVE_CR_WRITE        0x10
33
#define I2C_MASTER_SLAVE_CR_ACK          0x08
34
#define I2C_MASTER_SLAVE_CR_SL_CONT      0x02
35
#define I2C_MASTER_SLAVE_CR_IACK         0x01
36 393 julius
 
37 403 julius
#define I2C_MASTER_SLAVE_SR_RXACK            0x80
38
#define I2C_MASTER_SLAVE_SR_BUSY             0x40
39
#define I2C_MASTER_SLAVE_SR_ARB_LOST         0x20
40
#define I2C_MASTER_SLAVE_SR_SLAVE_MODE       0x10
41
#define I2C_MASTER_SLAVE_SR_SLAVE_DATA_AVAIL 0x08
42
#define I2C_MASTER_SLAVE_SR_SLAVE_DATA_REQ   0x04
43
#define I2C_MASTER_SLAVE_SR_TRANSFER_IN_PRG  0x02
44
#define I2C_MASTER_SLAVE_SR_IRQ_FLAG         0x01
45 393 julius
 
46 403 julius
int i2c_master_slave_init_core(int core, unsigned short prescaler,
47
                               int interrupt_enable);
48
int i2c_master_slave_deact_core(int core);
49
int i2c_master_slave_init_as_slave(int core, char addr);
50
int i2c_master_slave_deact_as_slave(int core);
51
int i2c_master_slave_master_start(int core, unsigned char addr, int read);
52
int i2c_master_slave_master_write(int core, unsigned char data,
53
                                  int check_prev_ack, int stop);
54
int i2c_master_slave_master_stop(int core);
55
int i2c_master_slave_master_read(int core, int check_prev_ack, int stop,
56
                                 char *data);
57
int i2c_master_slave_ack_interrupt(int core);
58 393 julius
#endif

powered by: WebSVN 2.1.0

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