/* upload a binary image to uC */ private async Task UploadFile(string portName, uint baudRate, byte[] bin, uint address, uint jumpAddress) { /* get page size */ //uint psize = uint.Parse(cbPSize.SelectedItem as string); uint psize = pageSize; /* create new programming interface object */ using (var uc = new STBoot()) { /* open device */ uc.Open(portName, baudRate); ///* initialize communication */ //await uc.Initialize(); ///* update the status */ //UpdateStatus(false, string.Format("Connected: Ver: {0}, PID: 0x{1:X4}", // uc.Version, uc.ProductID)); ///* give some chance see the message */ //await Task.Delay(500); /* apply new message */ UpdateStatus(false, "Erasing..."); await uc.EraseAll(); /* apply new message */ UpdateStatus(false, "Programming..."); /* progress reporter */ var p = new Progress <STBootProgress>(UpdateProgress); /* write memory */ await uc.WriteMemory(address, bin, 0, bin.Length, p, CancellationToken.None, pageSize); /* update the status */ UpdateStatus(false, string.Format("Success: {0} bytes written", bin.Length)); ///* go! */ //await uc.Jump(jumpAddress); /* end communication */ uc.Close(); } }