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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Software/] [demos/] [XD3_I2C/] [src/] [drivers/] [i2c.c] - Rev 2

Compare with Previous | Blame | View Log

#include "i2c.h"
 
void I2C_clear(void)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
	uint32_t cmd = (1 << 8);
 
	*i2c = cmd;
}
 
void I2C_EnQ(uint8_t byte)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
 
	uint32_t cmd = (1 << 9) | (uint32_t)byte;
	*i2c = cmd;
}
 
void I2C_transmit(void)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
 
	uint32_t cmd = (1 << 10);
	*i2c = cmd;
}
 
void I2C_setReceive(uint8_t bytes)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
 
	uint32_t cmd = (1 << 12) | (uint32_t)bytes;
	*i2c = cmd;
}
 
void I2C_receive(void)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
 
	uint32_t cmd = (1 << 11);
	*i2c = cmd;
}
 
uint32_t I2C_DeQ(void)
{
	volatile uint32_t *i2c = (volatile uint32_t *)I2C_ADDRESS;
 
	uint32_t data = *i2c;
	return data;
}
 
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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