source: ETALON/DAQ/Sensors/i2c/i2c8Bit.h @ 709

Last change on this file since 709 was 709, checked in by hodnevuc, 7 years ago
File size: 1.1 KB
Line 
1
2#ifndef I2C8BIT_H
3#define I2C8BIT_H
4
5#include <string>
6#include <stdio.h>
7#include <linux/i2c.h>
8#include <linux/i2c-dev.h>
9#include <fcntl.h>
10#include <stdlib.h>
11#include <unistd.h>
12#include <sys/ioctl.h>
13#include <string.h>
14
15
16
17class i2c8Bit
18{
19        public:
20                i2c8Bit(void); // default constructor
21                i2c8Bit(unsigned char dev_addr, std::string i2cfilename); 
22                //over loaded constructor
23                ~i2c8Bit(void); // destructor
24                int writeReg(unsigned char reg_addr, unsigned char data);
25                // function to write byte data into a register of an I2C device
26                int readReg(unsigned char reg_addr, unsigned char &data);
27                // function to read byte data from a register of an I2C device
28       
29        private:
30                //private member functions
31                int openI2C(); //open an I2C device. Called only in constructors
32                int closeI2C(); // close an I2C device. Called only in destructor
33               
34                // private member variables
35                std::string  i2cFileName; //i2c device name e.g."/dev/i2c-0" or "/dev/i2c-1"
36                int i2cDescriptor;  // i2c device descriptor
37                unsigned char deviceAddress; // i2c device address
38};
39
40#endif
41
Note: See TracBrowser for help on using the repository browser.