i2c  1.4.2
RoadNarrows Robotics I2C Package
smbus.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: I2C
4 //
5 // Library: libi2c API
6 //
7 // File: smbus.c
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2010-03-25 08:03:07 -0600 (Thu, 25 Mar 2010) $
12  * $Rev: 309 $
13  *
14  * \brief System Management Bus (SMBus) over I<sup>2</sup>C communication
15  * interface declarations.
16  *
17  * \author Robin Knight (robin.knight@roadnarrows.com)
18  *
19  * \copyright
20  * \h_copy 2009-2017. RoadNarrows LLC.\n
21  * http://www.roadnarrows.com\n
22  * All Rights Reserved
23  *
24  * <hr>
25  * \par Original Source and Copyright:
26  * See i2c-dev.h.
27  *
28  * <hr>
29  */
30 // Permission is hereby granted, without written agreement and without
31 // license or royalty fees, to use, copy, modify, and distribute this
32 // software and its documentation for any purpose, provided that
33 // (1) The above copyright notice and the following two paragraphs
34 // appear in all copies of the source code and (2) redistributions
35 // including binaries reproduces these notices in the supporting
36 // documentation. Substantial modifications to this software may be
37 // copyrighted by their authors and need not follow the licensing terms
38 // described here, provided that the new terms are clearly indicated in
39 // all files where they apply.
40 //
41 // IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
42 // OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
43 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
44 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
45 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
46 // THE POSSIBILITY OF SUCH DAMAGE.
47 //
48 // THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
49 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
50 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
51 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
52 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
53 //
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #ifndef _SMBBUS_H
57 #define _SMBBUS_H
58 
59 #include <stdlib.h>
60 #include <unistd.h>
61 #include <fcntl.h>
62 #include <sys/types.h>
63 #include <sys/errno.h>
64 #include <sys/ioctl.h>
65 
66 #include "rnr/rnrconfig.h"
67 #include "rnr/i2c-dev.h"
68 
69 C_DECLS_BEGIN
70 
71 // ---------------------------------------------------------------------------
72 // Prototypes
73 // ---------------------------------------------------------------------------
74 
75 extern int i2c_smbus_access(int fd, byte_t read_write, byte_t command,
76  int size, i2c_smbus_data_t *data);
77 
78 extern int i2c_smbus_write_quick(int fd, byte_t value);
79 
80 extern int i2c_smbus_read_byte(int fd);
81 
82 extern int i2c_smbus_write_byte(int fd, byte_t value);
83 
84 extern int i2c_smbus_read_byte_data(int fd, byte_t command);
85 
86 extern int i2c_smbus_write_byte_data(int fd, byte_t command, byte_t value);
87 
88 extern int i2c_smbus_read_word_data(int fd, byte_t command);
89 
90 extern int i2c_smbus_write_word_data(int fd, byte_t command, ushort_t value);
91 
92 extern int i2c_smbus_process_call(int fd, byte_t command, ushort_t value);
93 
94 extern int i2c_smbus_read_block_data(int fd, byte_t command, byte_t *values);
95 
96 extern int i2c_smbus_write_block_data(int fd, byte_t command, byte_t length,
97  const byte_t *values);
98 
99 extern int i2c_smbus_read_i2c_block_data(int fd, byte_t command,
100  byte_t *values);
101 
102 extern int i2c_smbus_write_i2c_block_data(int fd, byte_t command, byte_t length,
103  const byte_t *values);
104 
105 extern int i2c_smbus_block_process_call(int fd, byte_t command, byte_t length,
106  byte_t *values);
107 
108 C_DECLS_END
109 
110 
111 #endif // _SMBBUS_H
int i2c_smbus_write_word_data(int fd, byte_t command, ushort_t value)
Write a data 2-byte word to the SMBus.
Definition: smbus.c:217
int i2c_smbus_write_block_data(int fd, byte_t command, byte_t length, const byte_t *values)
Write a data block to the SMBus.
Definition: smbus.c:297
int i2c_smbus_write_byte_data(int fd, byte_t command, byte_t value)
Write a data byte to the SMBus.
Definition: smbus.c:175
int i2c_smbus_block_process_call(int fd, byte_t command, byte_t length, byte_t *values)
Issue a block process call (write/read) to the SMBus.
Definition: smbus.c:396
int i2c_smbus_access(int fd, byte_t read_write, byte_t command, int size, i2c_smbus_data_t *data)
Execute an SMBus IOCTL.
Definition: smbus.c:81
int i2c_smbus_read_block_data(int fd, byte_t command, byte_t *values)
Read a block of data from the SMBus.
Definition: smbus.c:264
int i2c_smbus_read_i2c_block_data(int fd, byte_t command, byte_t *values)
Read a block of data from the SMBus via low-level I2C.
Definition: smbus.c:330
I2C SMBus Data Stucture.
Definition: i2c-dev.h:184
I2C character device interface.
int i2c_smbus_write_i2c_block_data(int fd, byte_t command, byte_t length, const byte_t *values)
Write a block of data to the SMBus via low-level I2C.
Definition: smbus.c:361
int i2c_smbus_write_quick(int fd, byte_t value)
Write a quick value to the SMBus.
Definition: smbus.c:104
int i2c_smbus_write_byte(int fd, byte_t value)
Write an immediate byte to the SMBus.
Definition: smbus.c:138
int i2c_smbus_read_word_data(int fd, byte_t command)
Read a data 2-byte word from the SMBus.
Definition: smbus.c:195
int i2c_smbus_process_call(int fd, byte_t command, ushort_t value)
Issue a 2-byte word process call (write/read) to the SMBus.
Definition: smbus.c:238
int i2c_smbus_read_byte_data(int fd, byte_t command)
Read a data byte from the SMBus.
Definition: smbus.c:153
int i2c_smbus_read_byte(int fd)
Read an immediate byte from the SMBus.
Definition: smbus.c:118