public DelegateMemoryAccess(AvrCommandManager CommandManager,
                             Func<uint, byte, AvrProgCommand.Entity> WriteCommandFactory,
                             Func<uint, AvrProgCommand.Entity> ReadCommandFactory,
                             Func<uint, AvrProgCommand.Entity> FlushCommandFactory,
                             TimeSpan FlushDelay)
 {
     _commandManager = CommandManager;
     _writeCommandFactory = WriteCommandFactory;
     _flushCommandFactory = FlushCommandFactory;
     _flushDelay = FlushDelay;
     _readCommandFactory = ReadCommandFactory;
 }
Esempio n. 2
0
        public AvrBurningContext(ISpi Spi)
        {
            _commandManager = new AvrCommandManager(Spi);

            Flash = new DelegateMemoryAccess(
                _commandManager,
                (a, v) => AvrProgCommand.Encode((byte)((byte)CommandKind.WriteFlash | ((a & 0x01) << 3)), 0, (byte)(a >> 1), v),
                a => AvrProgCommand.Encode((byte)((byte)CommandKind.ReadFlash | ((a & 0x01) << 3)), (byte)(a >> 9), (byte)(a >> 1)),
                a => CommandKind.FlushFlash.With((byte)(a >> 9), (byte)((a >> 1) & 0x80)),
                Delays.WdFlash);

            Eeprom = new DelegateMemoryAccess(
                _commandManager,
                (a, v) => CommandKind.WriteEeprom.With(0, (byte)(a & 0x07), v),
                a => CommandKind.ReadEeprom.With((byte)((a >> 8) & 0x7), (byte)a),
                a => CommandKind.FlushEeprom.With((byte)((a >> 8) & 0x0f), (byte)(a & 0xf8)),
                Delays.WdEeprom);
        }