[Description]
Location = "Seiko\S2100","Poineer\P2100";

Info = " Module for reading 3-Wire Serial EEPROMs.",
       " Memory types: S2100,P2100.",
       "--------------------------------------------------------------------",
       " Bus: Seiko/Pioneer.",
       " Size: 8 bytes",
       " ",
       " Note: This chip is read only.",
       " ",
       "--------------------------------------------------------------------",
       " Author: ETL (C) 2005";

Buffer1 = "EEPROM",16;
Picture = "P2100.bmp";
VCC = 8;
GND = 4;
Voltage = 5.0;

[Menu]

Read    = "&Read",ReadButton,"Read chip",F2;
Info    = "&About module",ModuleInfoButton,"Show info about module",F1;

[Interface]

[Host]

define END_ADR 8

Proc Read
{
    var Address,Error,Value;

    print("");
    print("  Reading chip...");
    Run(Read);
    Address = 0;PBPos = 0;PBMax = END_ADR;
    while(Address != END_ADR)
    {
        Value = USB;
        FBUF[Address] = Value;
        Address++;
        PBPos++;        
    }
	if(ForceCloseAfterRead != 0) { return(0x7FFFFFFF); }
    print("  Reading is done. %i bytes were read.",Address);
}

Proc Info {
  print("");
  print("  Module for reading a chip S2100/P2100.");
  print("");
  print("  Note: This chip is read only.");
  print("");
  print("  Copyright (C) 2005 ETL.");
}


[Device]

define      END_ADR 8   

define      DATAOUT POUT.0
define      DATAIN  PIN.0
define      CS      POUT.1
define      CLCK    POUT.5
define      RESET   POUT.6

var Counter,Address,Temp;

Proc Read
{

  CS = 1;RESET = 1; CLCK = 1; DATAOUT = 1;Address = 0;
  CS = 0;
  while(Address != END_ADR) 
  {
    Temp = 0;
    if(Address = 0) 
    {
      Temp.0 = DATAIN;
      Counter = 7;
      while(Counter != 0) 
      {
        Temp = Temp << 1;
        CLCK = 0;CLCK = 1;
        Temp.0 = DATAIN;
        Counter--;
      }
    }
    else 
    {
      Counter = 8;
      while(Counter != 0) 
      {
        Temp = Temp << 1;
        CLCK = 0;CLCK = 1;
        Temp.0 = DATAIN;
        Counter--;
      }
    }
    USB = Temp;
    Address++;
  }
}
