Sensorian  1.0
C API Reference Guide Library
i2c.c File Reference

I2C driver. More...

#include <stdlib.h>
#include "i2c.h"

Go to the source code of this file.

Functions

void I2C_Initialize (unsigned char address)
 Initializes the I2C peripheral. More...
 
void I2C_WriteByte (char bdata)
 Writes a byte value to the I2C bus. This assumes the register pointer is preset. More...
 
void I2C_WriteByteRegister (unsigned char reg, unsigned char data)
 Writes a byte value to a register address. More...
 
void I2C_WriteWordRegister (unsigned char reg, unsigned char *data)
 Writes a word value (16 bit) to a register address. More...
 
void I2C_WriteByteArray (char reg, char *data, unsigned int length)
 Writes a buffer array to the registers. More...
 
unsigned char I2C_ReadByteRegister (char reg)
 Reads a byte from a register. More...
 
void I2C_ReadByteArray (char reg, char *buffer, unsigned int length)
 Initializes the I2C peripheral. More...
 
unsigned int I2C_ReadWordRegisterRS (char reg)
 Readm result from a word length register. More...
 
unsigned int I2C_ReadWordPresetPointer (void)
 Read the value of a register that has already been select via the address pointer. More...
 
void I2C_Close (void)
 Closes the I2C peripheral. More...
 

Detailed Description

I2C driver.

Author
D.Qendri
Date
30 May 2015

Definition in file i2c.c.

Function Documentation

void I2C_Close ( void  )

Closes the I2C peripheral.

Returns
none

Definition at line 175 of file i2c.c.

void I2C_Initialize ( unsigned char  address)

Initializes the I2C peripheral.

Parameters
addressAddress the I2C peripheral is communicating with.
Returns
none

Definition at line 37 of file i2c.c.

void I2C_ReadByteArray ( char  reg,
char *  buffer,
unsigned int  length 
)

Initializes the I2C peripheral.

Parameters
regAddress of sensor register, address autoincrements
*bufferPointer to byte data buffer array
lengthlength of buffer array
Returns
none

Definition at line 139 of file i2c.c.

unsigned char I2C_ReadByteRegister ( char  reg)

Reads a byte from a register.

Parameters
regAddress of sensor register.
Returns
val Byte value of register.

Definition at line 123 of file i2c.c.

unsigned int I2C_ReadWordPresetPointer ( void  )

Read the value of a register that has already been select via the address pointer.

Returns
Data Value of preset register

Definition at line 162 of file i2c.c.

unsigned int I2C_ReadWordRegisterRS ( char  reg)

Readm result from a word length register.

Parameters
regregister to read from
Returns
val Word value of register

Definition at line 149 of file i2c.c.

void I2C_WriteByte ( char  bdata)

Writes a byte value to the I2C bus. This assumes the register pointer is preset.

Parameters
bdataSend single byte to I2C bus
Returns
none

Definition at line 56 of file i2c.c.

void I2C_WriteByteArray ( char  reg,
char *  data,
unsigned int  length 
)

Writes a buffer array to the registers.

Parameters
regAddress of sensor register, address autoincrements
dataPointer to byte data buffer array
lengthlength of buffer array
Returns
none

Definition at line 101 of file i2c.c.

void I2C_WriteByteRegister ( unsigned char  reg,
unsigned char  data 
)

Writes a byte value to a register address.

Parameters
regAddress of sensor register.
dataData byte to be written on register.
Returns
none

Definition at line 67 of file i2c.c.

void I2C_WriteWordRegister ( unsigned char  reg,
unsigned char *  data 
)

Writes a word value (16 bit) to a register address.

Parameters
regAddress of sensor register.
dataData word to be written on word size register.
Returns
none

Definition at line 83 of file i2c.c.