You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.3 KiB

#ifndef __I2C_PORT_HEADERS__
#define __I2C_PORT_HEADERS__
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#undef _LINUX_I2C_DEV_H
#include "../../data/transport/transportBus.h"
#define I2C_PAGE_BYTES 128 //64
class i2cPort {
private:
int m_nFID;
basicLogCollection * m_pLog;
uint8_t m_bAddress;
uint8_t m_bRegAddrBytes;
int _write( int fd, int device_addr, uint16_t offset, const char* data, int data_len );
int _read( int fd, int device_addr, uint16_t offset, char* data, int data_len );
public:
explicit i2cPort( CSTR DevicePath, uint8_t DevBusAddr, int Speed = 0, uint8_t RegAddrBytes = 1 );
virtual ~i2cPort();
bool readMZ( uint16_t offset, uint8_t *buffer, int len );
bool writeMZ( uint16_t offset, uint8_t *buffer, int len );
uint8_t read8( uint16_t offset );
bool write8( uint16_t offset, uint8_t byte );
};
#endif