/*************************************************************************** * Copyright (C) 2006 Nicolas Hadacek * * Copyright (C) 2003-2005 Alain Gibaud * * * * 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 "direct_18F.h" #include "direct_data.h" //----------------------------------------------------------------------------- bool Direct::P18F::skipMaskWords(Pic::MemoryRangeType type, const Device::Array &data, uint &i, uint nb, bool forceProgram) { if (forceProgram) return false; for (uint k=0; k> 16)); pulseEngine("k0,S,k0,X6EF7,", 0x0E00 | ((address & 0x00FF00) >> 8)); pulseEngine("k0,S,k0,X6EF6,", 0x0E00 | (address & 0x0000FF)); } void Direct::P18F::setPointer(Pic::MemoryRangeType type, uint offset) { if ( type==Pic::MemoryRangeType::Eeprom ) { pulseEngine("k0,S,k0,X6EA9,", 0x0E00 | (offset & 0x00FF)); pulseEngine("k0,S,k0,X6EAA,", 0x0E00 | ((offset & 0xFF00) >> 8)); } else setCodePointer(device().range(type).start.toUInt() + offset); } void Direct::P18F::directAccess(Pic::MemoryRangeType type) { if ( type==Pic::MemoryRangeType::Code || type==Pic::MemoryRangeType::UserId || type==Pic::MemoryRangeType::Eeprom ) pulseEngine("k0,X9CA6"); // unset EECON1:CFGS else pulseEngine("k0,X8CA6"); // set EECON1:CFGS if ( type==Pic::MemoryRangeType::Eeprom ) pulseEngine("k0,X9EA6"); // unset EECON1::EEPGD else pulseEngine("k0,X8EA6"); // set EECON1::EEPGD } bool Direct::P18F::doRead(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) { data.resize(device().nbWords(type)); uint offset = 0; uint nbWords = data.count(); if (vdata) { if ( vdata->actions & ::Programmer::OnlyProgrammedVerify ) { const Device::Array wdata = static_cast(vdata->memory).arrayForWriting(type); offset = findNonMaskStart(type, wdata); nbWords = findNonMaskEnd(type, wdata)+1; } } BitValue mask = device().mask(type); //qDebug("read %s %i", Pic::MEMORY_RANGE_TYPE_DATA[type].label, device().nbWords(type)); //pulseEngine("w300000"); // what for ? directAccess(type); switch (type.type()) { case Pic::MemoryRangeType::Eeprom: for (uint i = 0; i> 8; if ( vdata && !hardware().verifyWord(offset+i+1, data[i+1], type, *vdata) ) return false; } break; default: Q_ASSERT(false); break; } return true; } bool Direct::P18F::doWrite(Pic::MemoryRangeType type, const Device::Array &data, bool force) { uint inc = device().addressIncrement(type); //qDebug("write %s %i/%i %i", Pic::MEMORY_RANGE_TYPE_DATA[type].label, nbWords, data.count(), inc); //pulseEngine("w300000"); ?? configureSinglePanel(); directAccess(type); switch (type.type()) { case Pic::MemoryRangeType::UserId: { setPointer(type, 0); Q_ASSERT( device().nbWords(Pic::MemoryRangeType::UserId)==8 ); uint i = 0; for (uint k=0; k<4; k++) { BitValue word = data[i] | data[i+1] << 8; if ( (k+1)==4 ) pulseEngine("k15,S,", word); else pulseEngine("k13,S,", word); i += 2; } program(Code); break; } case Pic::MemoryRangeType::Code: { uint progWidth = device().nbWordsWriteAlignment(Pic::MemoryRangeType::Code); for (uint i = 0; i