diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/devices/mem24/prog/mem24_prog.cpp | |
download | piklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip |
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/devices/mem24/prog/mem24_prog.cpp')
-rw-r--r-- | src/devices/mem24/prog/mem24_prog.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/devices/mem24/prog/mem24_prog.cpp b/src/devices/mem24/prog/mem24_prog.cpp new file mode 100644 index 0000000..4c4b201 --- /dev/null +++ b/src/devices/mem24/prog/mem24_prog.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "mem24_prog.h" + +#include "common/global/global.h" +#include "devices/list/device_list.h" +#include "progs/base/prog_config.h" + +//----------------------------------------------------------------------------- +bool Programmer::Mem24DeviceSpecific::read(Device::Array &data, const VerifyData *vdata) +{ + setPowerOn(); + doRead(data, vdata); + setPowerOff(); + return !hasError(); +} + +bool Programmer::Mem24DeviceSpecific::write(const Device::Array &data) +{ + setPowerOn(); + doWrite(data); + setPowerOff(); + return !hasError(); +} + +bool Programmer::Mem24DeviceSpecific::verifyByte(uint index, BitValue d, const VerifyData &vdata) +{ + BitValue v = static_cast<const Mem24::Memory &>(vdata.memory).byte(index); + v = v.maskWith(0xFF); + d = d.maskWith(0xFF); + if ( v==d ) return true; + Address address = index; + if ( vdata.actions & BlankCheckVerify ) + log(Log::LineType::Error, i18n("Device memory is not blank (at address %1: reading %2 and expecting %3).") + .arg(toHexLabel(address, device().nbCharsAddress())).arg(toHexLabel(d, 2)).arg(toHexLabel(v, 2))); + else log(Log::LineType::Error, i18n("Device memory doesn't match hex file (at address %1: reading %2 and expecting %3).") + .arg(toHexLabel(address, device().nbCharsAddress())).arg(toHexLabel(d, 2)).arg(toHexLabel(v, 2))); + return false; +} + +//---------------------------------------------------------------------------- +uint Programmer::Mem24Base::nbSteps(Task task, const Device::MemoryRange *) const +{ + uint nb = device()->nbBytes(); + if ( task==Task::Write && readConfigEntry(Config::VerifyAfterProgram).toBool() ) nb += device()->nbBytes(); + return nb; +} + +bool Programmer::Mem24Base::internalErase(const Device::MemoryRange &) +{ + initProgramming(); + Mem24::Memory memory(*device()); + return specific()->write(memory.arrayForWriting()); +} + +bool Programmer::Mem24Base::internalRead(Device::Memory *memory, const Device::MemoryRange &, const VerifyData *vdata) +{ + initProgramming(); + Device::Array data; + if ( !specific()->read(data, vdata) ) return false; + if (memory) for (uint i=0; i<data.count(); i++) static_cast<Mem24::Memory *>(memory)->setByte(i, data[i]); + return true; +} + +bool Programmer::Mem24Base::internalProgram(const Device::Memory &memory, const Device::MemoryRange &) +{ + initProgramming(); + const Mem24::Memory &pmemory = static_cast<const Mem24::Memory &>(memory); + const Device::Array &data = pmemory.arrayForWriting(); + if ( !specific()->write(data) ) return false; + if ( !readConfigEntry(Config::VerifyAfterProgram).toBool() ) return true; + VerifyActions actions = IgnoreProtectedVerify; + if ( readConfigEntry(Config::OnlyVerifyProgrammed).toBool() ) actions |= OnlyProgrammedVerify; + VerifyData vdata(actions, pmemory); + Device::Array adata; + return specific()->read(adata, &vdata); +} + +bool Programmer::Mem24Base::verifyDeviceId() +{ + return specific()->verifyPresence(); +} |