Example #1
0
        public static void Write(this Eeprom93C46B eeprom, ushort address, ushort data)
        {
            eeprom.Pulse(false);
            eeprom.Pulse(true);
            address &= 0x3F;
            for (int i = 0; i < 6; i++)
            {
                eeprom.Pulse(((address >> (5 - i) & 0x01) != 0x00));
            }

            for (int i = 0; i < 16; i++)
            {
                bool value = ((data >> (15 - i)) & 0x01) == 1;
                eeprom.Pulse(value);
            }
        }
Example #2
0
 public static void DisableEraseWrite(this Eeprom93C46B eeprom)
 {
     // Opcode for EWDS is 0000XXXX
     for (int i = 0; i < 8; i++)
     {
         eeprom.Pulse(false);
     }
 }
Example #3
0
 public static void EnableEraseWrite(this Eeprom93C46B eeprom)
 {
     // Opcode for EWEN is 0011XXXX
     eeprom.Pulse(false);
     eeprom.Pulse(false);
     eeprom.Pulse(true);
     eeprom.Pulse(true);
     eeprom.Pulse(false);
     eeprom.Pulse(false);
     eeprom.Pulse(false);
     eeprom.Pulse(false);
 }
Example #4
0
        public static ushort Read(this Eeprom93C46B eeprom, ushort address)
        {
            eeprom.Pulse(true);
            eeprom.Pulse(false);
            address &= 0x3F;
            for (int i = 0; i < 6; i++)
            {
                eeprom.Pulse(((address >> (5 - i) & 0x01) != 0x00));
            }

            ushort value = 0;

            for (int i = 0; i < 16; i++)
            {
                eeprom.Pulse(false);
                value |= (ushort)((eeprom.DO ? 1 : 0) << (15 - i));
            }
            return(value);
        }
Example #5
0
        public static void WriteAll(this Eeprom93C46B eeprom, ushort data)
        {
            eeprom.Pulse(false);
            eeprom.Pulse(false);
            eeprom.Pulse(false);
            eeprom.Pulse(true);
            eeprom.Pulse(true);
            eeprom.Pulse(true);
            eeprom.Pulse(true);
            eeprom.Pulse(true);

            for (int i = 0; i < 16; i++)
            {
                bool value = ((data >> (15 - i)) & 0x01) == 1;
                eeprom.Pulse(value);
            }
        }
Example #6
0
        public void Clocking8BitsShouldExecuteInstruction()
        {
            // Arrange
            eeprom.Start();
            eeprom.EnableEraseWrite();
            eeprom.Start();
            Instruction instruction = null;

            eeprom.InstructionDone += (sender, args) => { instruction = args.ExecutedInstruction; };

            // Act
            for (int i = 0; i < 8; i++)
            {
                eeprom.Pulse(true);
            }

            // Assert
            Assert.AreEqual <OperationState>(OperationState.Standby, eeprom.State,
                                             "After 8 cycles state should change to Standby for ERASE.");
            Assert.IsNotNull(instruction, "An instruction should have executed.");
            Assert.AreEqual <Opcode>(Opcode.ERASE, instruction.Opcode, "ERASE should have executed.");
            Assert.AreEqual <ushort>(0x3F, instruction.Address, "Address for instruction should be lower 6 bits at one.");
        }