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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Software/] [demos/] [XD5_Threads/] [src/] [drivers/] [i2c.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
#include "i2c.h"
2
 
3
void I2C_clear(void)
4
{
5
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
6
        uint32_t cmd = (1 << 8);
7
 
8
        *i2c = cmd;
9
}
10
 
11
void I2C_EnQ(uint8_t byte)
12
{
13
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
14
 
15
        uint32_t cmd = (1 << 9) | (uint32_t)byte;
16
        *i2c = cmd;
17
}
18
 
19
void I2C_transmit(void)
20
{
21
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
22
 
23
        uint32_t cmd = (1 << 10);
24
        *i2c = cmd;
25
}
26
 
27
void I2C_setReceive(uint8_t bytes)
28
{
29
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
30
 
31
        uint32_t cmd = (1 << 12) | (uint32_t)bytes;
32
        *i2c = cmd;
33
}
34
 
35
void I2C_receive(void)
36
{
37
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
38
 
39
        uint32_t cmd = (1 << 11);
40
        *i2c = cmd;
41
}
42
 
43
uint32_t I2C_DeQ(void)
44
{
45
        volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
46
 
47
        uint32_t data = *i2c;
48
        return data;
49
}
50
 

powered by: WebSVN 2.1.0

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