I2C Smart Card

Hi there,

I have an i2c smart card based with the http://www.atmel.com/dyn/resources/prod_documents/doc5279.pdf chip

how would i send commands to read and write this card?

I have a Arduino Mega 1280

thanks

Thanks richard.

I now have this code:

#include <Wire.h>

void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
  int rdata = data;
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddress >> 8)); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB
  Wire.send(rdata);
  Wire.endTransmission();
}

// WARNING: address is a page address, 6-bit end will wrap around
// also, data can be maximum of about 30 bytes, because the Wire library has a buffer of 32 bytes
void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, byte* data, byte length ) {
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddresspage >> 8)); // MSB
  Wire.send((int)(eeaddresspage & 0xFF)); // LSB
  byte c;
  for ( c = 0; c < length; c++)
    Wire.send(data[c]);
  Wire.endTransmission();
}

byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
  byte rdata = 0xFF;
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddress >> 8)); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
  Wire.requestFrom(deviceaddress,1);
  if (Wire.available()) rdata = Wire.receive();
  return rdata;
}

// maybe let's not read more than 30 or 32 bytes at a time!
void i2c_eeprom_read_buffer( int deviceaddress, unsigned int eeaddress, byte *buffer, int length ) {
  Wire.beginTransmission(deviceaddress);
  Wire.send((int)(eeaddress >> 8)); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
  Wire.requestFrom(deviceaddress,length);
  int c = 0;
  for ( c = 0; c < length; c++ )
    if (Wire.available()) buffer[c] = Wire.receive();
}


void setup() 
{
  Wire.begin();
  Serial.begin(9600);
}

void loop() 
{
  i2c_eeprom_write_byte(0x50, 1, 0xaa);
  Serial.println("waiting");
  delay(1000);
 byte temp = i2c_eeprom_read_byte(0x50, 1);
  Serial.println(temp);
  delay(2000);
  
}

Ive tried change the : i2c_eeprom_write_byte(0x50, 1, 0xaa); to : i2c_eeprom_write_byte(0x50, 2, 0xaa);
but it wont write to the second bit!! It writes well to the first but now the second or third. How can i go about to make it right beyond the 1st bit. Also was does the 0x50 represent?

Thanks,
Spooky