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

I2C driver. More...

#include <stdio.h>
#include "bcm2835.h"

Go to the source code of this file.

Macros

#define baudrate   100000
 

Functions

void I2C_Initialize (unsigned char address)
 Initializes the I2C peripheral. More...
 
void I2C_WriteByte (char byte)
 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_ReadWordRegister (char reg)
 
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
28 May 2015

Definition in file i2c.h.

Macro Definition Documentation

#define baudrate   100000

Definition at line 34 of file i2c.h.

Function Documentation

void I2C_Close ( void  )

Closes the I2C peripheral.

Returns
none

Definition at line 174 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 36 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 138 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 122 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 161 of file i2c.c.

unsigned int I2C_ReadWordRegister ( char  reg)
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 148 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 55 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 100 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 66 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 82 of file i2c.c.