/******************************************************************************
I2CLINE Header file

Michael Simmons
Master Project:
Date Created:	25 Oct 2008
Date Modified:	25 Oct 2008

*******************************************************************************

Description:
	The I2CLINE is designed to handle the communication from the 
gumstix to the
	other devices that are connected to the robostix.

******************************************************************************/

#ifndef I2CDEF_H
#define I2CDEF_H

#include <iostream>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <linux/i2c.h>

using namespace std;

const uint8_t I2C_READ_IO = 7;
const uint8_t I2C_WRITE_IO = 9;
const uint8_t I2c_max_len = 32;

struct I2c_read_t
{
  uint8_t reg; // Index of register to read
};

struct I2c_write_t
{
  uint8_t reg; // Index of register to read
  uint8_t pad; // For length?
  uint16_t val; // Value to write to register
};

struct I2c_msg
{
  __u16 addr;
  unsigned short flags;
  short len;
  char *buf;
};

struct I2c_rdwr_ioctl_data
{
  struct I2c_msg *msgs;
  int nmsgs;
};

#endif
