Sensorian  1.0
C API Reference Guide Library
i2c.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2015 Sensorian
3  * *
4  * This file is part of Sensorian. *
5  * *
6  * Sensorian is free software: you can redistribute it and/or modify it *
7  * under the terms of the GNU Lesser General Public License as published *
8  * by the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * Sensorian is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with Sensorian. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
29 #ifndef __I2C1_H__
30 #define __I2C1_H__
31 
32 #include <stdio.h>
33 #include "bcm2835.h"
34 
35 #define baudrate 100000
36 
37 void I2C_Initialize(unsigned char address);
38 
39 void I2C_WriteByte(char byte);;
40 void I2C_WriteByteRegister(unsigned char reg,unsigned char data);
41 void I2C_WriteWordRegister(unsigned char reg, unsigned char* data);
42 void I2C_WriteByteArray(char reg, char* data, unsigned int length);
43 
44 unsigned char I2C_ReadByteRegister(char reg);
45 void I2C_ReadByteArray(char reg,char *buffer,unsigned int length);
46 unsigned int I2C_ReadWordRegister(char reg);
47 unsigned int I2C_ReadWordRegisterRS(char reg);
48 unsigned int I2C_ReadWordPresetPointer(void);
49 
50 void I2C_Close(void);
51 
52 #endif
53 
unsigned char I2C_ReadByteRegister(char reg)
Reads a byte from a register.
Definition: i2c.c:122
unsigned char buffer[256]
Definition: main.c:74
void I2C_WriteByteArray(char reg, char *data, unsigned int length)
Writes a buffer array to the registers.
Definition: i2c.c:100
void I2C_Close(void)
Closes the I2C peripheral.
Definition: i2c.c:174
void I2C_WriteWordRegister(unsigned char reg, unsigned char *data)
Writes a word value (16 bit) to a register address.
Definition: i2c.c:82
unsigned int I2C_ReadWordPresetPointer(void)
Read the value of a register that has already been select via the address pointer.
Definition: i2c.c:161
unsigned int I2C_ReadWordRegister(char reg)
unsigned int I2C_ReadWordRegisterRS(char reg)
Readm result from a word length register.
Definition: i2c.c:148
void I2C_ReadByteArray(char reg, char *buffer, unsigned int length)
Initializes the I2C peripheral.
Definition: i2c.c:138
void I2C_WriteByte(char byte)
Writes a byte value to the I2C bus. This assumes the register pointer is preset.
Definition: i2c.c:55
void I2C_WriteByteRegister(unsigned char reg, unsigned char data)
Writes a byte value to a register address.
Definition: i2c.c:66
unsigned long address
Definition: main.c:76
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
Definition: i2c.c:36