public void ProgramAVR(IntelHex program, statusUpdate target) { //program each non-bootloader section of Flash sequentially for(ushort addr = 0; addr < AVR.HW.FlashSize - AVR.HW.BootloadSize; addr += AVR.HW.PageSize) { //Write the page to the AVR. device.WriteAVRPage(addr, program.GetPage(addr)); //If a delegate has been provided to accept status updates, inform it of the update. if(target != null) target((float) addr / (float)(AVR.HW.FlashSize - AVR.HW.BootloadSize)); } //and then reset the microprocessor device.ResetAVR(true); //indicate completion if(target!=null) target(1); }
public void ProgramAVR(IntelHex program, statusUpdate target) { //program each non-bootloader section of Flash sequentially for (int i = 0; i < CurrentLabKit.WriteableFlash / CurrentLabKit.PageSize; ++i) { //Write the page to the AVR. device.WriteAVRPage(i*128, program.GetPage(i)); //If a delegate has been provided to accept status updates, inform it of the update. if(target != null) target((i * 128.0f) / (float)(CurrentLabKit.WriteableFlash)); } //and then reset the microprocessor device.ResetAVR(true); //indicate completion if(target!=null) target(1); }
/// <summary> /// Compares one IntelHex record to another to determine equivalence. /// </summary> /// <param name="a"> /// The IntelHex record to compare with this one. /// </param> /// <returns> /// True iff the two records are identical. /// </returns> public bool Equals(IntelHex a) { //This item cannot equal null. if(a==null) return false; //To compare to IntelHex records, compare their memory maps. byte[] memoryA = a.GetPage(0, a.MemoryLength); byte[] memoryB = this.GetPage(0, this.MemoryLength); //Array with nonequal length cannot be equivalent if(memoryA.Length != memoryB.Length) return false; //Search for any inequalities in the two arrays. for(int i=0; i < memoryA.Length; ++i) if(memoryA[i] != memoryB[i]) return false; //Otherwise, they must be equal. return true; }