Hardware Reference
In-Depth Information
Header Files
The following header files should be included in an I2C program:
#include <sys/ioctl.h>
#include <linux/i2c−dev.h>
open(2)
Working with I2C devices is much like working with files. You'll open a file descriptor, do
some I/O operations with it, and then close it. The one difference is that you'll want to use
ioctl(2) calls instead of the usual read(2) / write(2) calls.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char
pathname, int flags, mode_t mode);
where
pathname is the name of the file/directory/driver that you need
to open/create.
flags is the list of optional flags (use O_RDWR for reading and
writing).
mode is the permission bits to create a file (omit argument, or
supply zero when not creating).
returns -1 (error code in errno ) or open file descriptor >= 0 .
Error
Description
EACCES
Access to the file is not allowed.
EFAULT
The pathname points outside your accessible address space.
EMFILE
The process already has the maximum number of files open.
ENFILE
The system limit on the total number of open files has been reached.
ENOMEM
Insufficient kernel memory was available.
 
 
Search WWH ::




Custom Search