libsmbus.h 1.46 KB
Newer Older
1
/* Copyright(C) 2006,2007,2008 Jochen Roessner <jochen@lugrot.de>
jochen's avatar
jochen committed
2 3 4

 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
5
 the Free Software Foundation; either version 3 of the License, or
6
 (at your option) any later version.
jochen's avatar
jochen committed
7 8 9 10 11 12 13

 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
14 15 16
 along with this program; if not, write to the Free Software Foundation,
 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
*/
jochen's avatar
jochen committed
17 18


Jochen Roessner's avatar
Jochen Roessner committed
19 20
#ifndef _LIBSMBUS
#define _LIBSMBUS
jochen's avatar
jochen committed
21

22 23
struct i2cdev; /* device handle zeiger */

jochen's avatar
jochen committed
24 25
/* open /dev/i2c device and set things up to be ready for smbus bus 
 * communication.
stettberger's avatar
stettberger committed
26
 * returns unix file descriptor of i2c device or 0 on error
jochen's avatar
jochen committed
27
 */
28
struct i2cdev*
jochen's avatar
jochen committed
29 30 31 32
smbus_open(char *device, int addr);

/*close the device*/
int
33
smbus_close(struct i2cdev *handle);
jochen's avatar
jochen committed
34

jochen's avatar
jochen committed
35 36

/* send txdata to the smbus
Jochen Roessner's avatar
Jochen Roessner committed
37
 * return datalen on success, <= 0 on failure.
jochen's avatar
jochen committed
38 39
 */
int 
jochen's avatar
jochen committed
40
smbus_send(struct i2cdev *handle, int command, const unsigned char *txdata, unsigned int datalen);
jochen's avatar
jochen committed
41 42

/* read data from smbus 
Jochen Roessner's avatar
Jochen Roessner committed
43
 * return > 0 on success, <= 0 on failure
jochen's avatar
jochen committed
44 45
 */
int
jochen's avatar
jochen committed
46
smbus_recv(struct i2cdev *handle, int command, unsigned char *rxdata, unsigned int *recvlen);
jochen's avatar
jochen committed
47 48

#endif /* ... _SMBUS_KERNEL */