forked from achilikin/RdSpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pi2c.h
52 lines (41 loc) · 1.55 KB
/
pi2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Basic I2C wrapper for Raspberry Pi.
Copyright (c) 2014 Andrey Chilikin (https://github.com/achilikin)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
Basic I2C wrapper for Raspberry Pi.
Make sure that RPi i2c driver is enabled, check following files:
/etc/modprobe.d/raspi-blacklist.conf
#blacklist i2c-bcm2708
/etc/modules
i2c-dev
/etc/modprobe.d/i2c.conf
options i2c_bcm2708 baudrate=400000
*/
#ifndef __PI2C_H__
#define __PI2C_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PI2C_BUS0 0 /*< P5 header I2C bus */
#define PI2C_BUS1 1 /*< P1 header I2C bus */
#define PI2C_BUS PI2C_BUS1 // default bus
int pi2c_open(uint8_t bus); /*< open I2C bus */
int pi2c_close(uint8_t bus); /*< close I2C bus */
int pi2c_select(uint8_t bus, uint8_t slave); /*< select I2C slave */
int pi2c_read(uint8_t bus, uint8_t *data, uint32_t len);
int pi2c_write(uint8_t bus, const uint8_t *data, uint32_t len);
#ifdef __cplusplus
}
#endif
#endif