int Device::VerifyProg(unsigned char *localbuf) { int rval = -1; int size = GetSplitted(); int base = 0; //Verify only programmed bytes (to save time in big devices) long v_len = size; if (THEAPP->GetLastProgrammedAddress() > 0 && THEAPP->GetLastProgrammedAddress() < size ) { v_len = THEAPP->GetLastProgrammedAddress() + 1; THEAPP->ClearLastProgrammedAddress(); //reset last_programmed_addr, so next verify not preceeded by write verify all the flash } //Set blank locations to default 0xFF (erased) memset(localbuf, 0xFF, size); // read the current flash content and store it in localbuf rval = GetBus()->Read(0, localbuf, v_len); if ( rval != v_len ) { if (rval > 0) rval = OP_ABORTED; } else rval = GetBus()->CompareMultiWord(GetBufPtr()+base, localbuf+base, size, 0) == 0 ? OK : 1; return rval; }
void X2444::DefaultBankSize() { if (GetBus() == 0) { Device::DefaultBankSize(); } else { if (GetBus()->GetOrganization() == ORG16) SetBankSize(2); else SetBankSize(1); } }
int At250xx::Read(int probe, int type) { UserDebug1(UserApp1, "At250xx::Read(%d)\n", probe); if (probe || GetNoOfBank() == 0) Probe(); int size = GetNoOfBank() * GetBankSize(); UserDebug1(UserApp1, "At250xx::Read() ** Size = %d\n", size); int rv = size; if (type & PROG_TYPE) { rv = GetBus()->Read(0, GetBufPtr(), size); if (rv != size) { if (rv > 0) rv = OP_ABORTED; } } UserDebug1(UserApp1, "At250xx::Read() = %d\n", rv); return rv; }
int At250xx::Verify(int type) { if (GetNoOfBank() == 0) return BADPARAM; int size = GetNoOfBank() * GetBankSize(); unsigned char *localbuf; localbuf = new unsigned char[size]; if (localbuf == 0) return OUTOFMEMORY; int rval = 1; if (type & PROG_TYPE) { rval = GetBus()->Read(0, localbuf, size); if (rval != size) { if (rval > 0) rval = OP_ABORTED; } else { rval = ( memcmp(GetBufPtr(), localbuf, size) != 0 ) ? 0 : 1; } } delete localbuf; return rval; }
int Device::ReadCalibration(int addr) { int val; val = Probe(0); if (val >= 0) val = GetBus()->ReadCalibration(addr); return val; }
int E24xx5::Write(int probe, int type) { E24xx5::Probe(0); if (type & PROG_TYPE) { //Enable writing BYTE buffer[4]; buffer[0] = 0xFF; //last address (Write protect register) buffer[1] = 0x02; //set WEL bit if (GetBus()->StartWrite(eeprom_addr[n_bank-1], buffer, 2) != 2) return GetBus()->Error(); buffer[0] = 0xFF; //last address (Write protect register) buffer[1] = 0x06; //set RWEL+WEL bit if (GetBus()->StartWrite(eeprom_addr[n_bank-1], buffer, 2) != 2) return GetBus()->Error(); buffer[0] = 0xFF; //last address (Write protect register) buffer[1] = 0x02; //reset WPEN, BP1, BP0 (disable any write protection) if (GetBus()->Write(eeprom_addr[n_bank-1], buffer, 2) != 2) return GetBus()->Error(); //Ack polling int k; for (k = timeout_loop; k > 0 && GetBus()->Read(eeprom_addr[0], buffer, 1) != 1; k--) ; if (k == 0) return E2P_TIMEOUT; } return E24xx::Write(probe); }
int Device::VerifyData(unsigned char *localbuf) { int rval; int size = GetSize() - GetSplitted(); int base = GetSplitted(); //read current EEPROM content and rval = GetBus()->Read(1, localbuf+base, size ); if ( rval != size ) { if (rval > 0) rval = OP_ABORTED; } else rval = GetBus()->CompareMultiWord(GetBufPtr()+base, localbuf+base, size, 1) == 0 ? OK : 1; return rval; }
//Read Flash program memory int Device::ReadProg() { int retval; int size = GetSplitted(); int base = 0; retval = GetBus()->Read(0, GetBufPtr()+base, size); if (retval != size) { if (retval > 0) retval = OP_ABORTED; } return retval; }
//Write EEprom data memory int Device::WriteData() { int rv; int size = GetSize() - GetSplitted(); int base = GetSplitted(); rv = GetBus()->Write(1, GetBufPtr()+base, size); if ( rv != size ) { if (rv > 0) rv = OP_ABORTED; } return rv; }
//Write Flash program memory int Device::WriteProg() { int rv; int size = GetSplitted(); int base = 0; rv = GetBus()->Write(0, GetBufPtr()+base, size); if ( rv != size ) { if (rv > 0) rv = OP_ABORTED; } return rv; }
int At250xx::Write(int probe, int type) { if (probe || GetNoOfBank() == 0) Probe(); int size = GetNoOfBank() * GetBankSize(); int rv = size; if (type & PROG_TYPE) { rv = GetBus()->Write(0, GetBufPtr(), size); if (rv != size) { if (rv > 0) rv = OP_ABORTED; } } return rv; }
bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) { wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); SCH_SHEET_PIN* label; SCH_TEXT* text; switch( aLayer ) { case LAYER_BUS: if( GetBus( aPosition ) ) return true; label = GetSheetLabel( aPosition ); if( label && IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && IsBusLabel( text->GetText() ) && text->IsConnected( aPosition ) && (text->Type() != SCH_LABEL_T) ) return true; break; case LAYER_NOTES: if( GetLine( aPosition ) ) return true; break; case LAYER_WIRE: if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) ) return true; if( GetPin( aPosition, NULL, true ) ) return true; if( GetWire( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && text->IsConnected( aPosition ) && !IsBusLabel( text->GetText() ) ) return true; label = GetSheetLabel( aPosition ); if( label && label->IsConnected( aPosition ) && !IsBusLabel( label->GetText() ) ) return true; break; default: break; } return false; }