/*************************************************************************** * 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_16.h" #include "common/global/global.h" //---------------------------------------------------------------------------- void Direct::pic16::send_bits(BitValue d, uint nbb) { hardware().setWrite(); for (uint x = nbb; x; --x) { hardware().setPin(Clock, High); if ( d.bit(0) ) hardware().setPin(DataOut, High); else hardware().setPin(DataOut, Low); Port::usleep(1+_clockDelay); hardware().setPin(Clock, Low); Port::usleep(1+_clockDelay); d >>= 1; } hardware().setPin(DataOut, High); hardware().setRead(); } void Direct::pic16::send_word(BitValue d) { hardware().setWrite(); d <<= 1; // insert start bit for (uint x = 0; x<16; x++) { hardware().setPin(Clock, High); if ( d.bit(0) ) hardware().setPin(DataOut, High); else hardware().setPin(DataOut, Low); Port::usleep(1+_clockDelay) ; // needed for slow programmers/fast PCs hardware().setPin(Clock, Low); Port::usleep(1+_clockDelay) ; d >>= 1; // Move the data over 1 bit } hardware().setPin(DataOut, High); // Added for ITU-1 support hardware().setRead(); } // Read 14 bits of data from the PIC // clock idles low, change data. 1 start bit, 1 stop bit, data valid on falling edge. BitValue Direct::pic16::get_word() { hardware().setRead(); BitValue ind = 0; hardware().setPin(DataOut, High); for (uint x = 16; x ; --x) { hardware().setPin(Clock, High); Port::usleep(1+_clockDelay); if ( hardware().readBit() ) ind |= 0x8000; else ind = ind.maskWith(0x7FFF); ind >>= 1; hardware().setPin(Clock, Low); Port::usleep(1+_clockDelay); } return ind; } bool Direct::pic16::incrementPC(uint steps) { for (uint i=0; iactions & ::Programmer::OnlyProgrammedVerify; const Device::Array wdata = static_cast(vdata->memory).arrayForWriting(type); if (only) nbWords = findNonMaskEnd(type, wdata)+1; } BitValue mask = device().mask(type); for (uint i = 0; i