public bool InitializeProgrammer() { int hr; string m_sLastError; Programmer.lib_SetHexFile(SelectedHEXFilePath); Programmer.lib_SetAcquireMode(SelectedAquireMode); Programmer.lib_SetVerification(ValidateAfterProgramming); //is not applicable for PSoC3/5 chips Programmer.lib_SetAutoChipDetection(true); Programmer.lib_SetProtocol(enumInterfaces.SWD); Programmer.lib_SetAutoReset(0x01); Programmer.lib_SetProtocolClock(enumFrequencies.FREQ_03_0); Programmer.lib_SetProtocolConnector(SelectedConnectorType); //0 -> 5-pins; 1 -> 10-pins; Programmer.lib_SetPartialProgram(true); //skips empty flash rows //Setup Power - "3.3V" and internal for reset mode hr = Programmer.SetPowerVoltage(SelectedVoltageSetting.Substring(0, 3), out m_sLastError); if (IsSuccess(hr) == false) { Log.PrintLog(this, "Unable to set acquire mode to Reset.", LogDetailLevel.LogRelevant); return(false); } hr = Programmer.PowerOn(out m_sLastError); if (IsSuccess(hr) == false) { Log.PrintLog(this, "Unable to set programming voltage.", LogDetailLevel.LogRelevant); return(false); } return(true); }
int connected = 0; // DTV private void InitPPCOM(GUI_Settings guiSettings) { int hr; string strVolt; string strError; if (pp != null) { return; //Programmer already started } pp = new PP_ComLib_WrapperClass(); if (!pp.w_IsConnected()) { if (pp.w_ConnectToLatest() == 0) { AppendTextToLog("Detected PSoC Programmer COM object version " + pp.Version()); } else { AppendTextToLog("PSoC Programmer not installed. Please install PSoC Programmer and try again."); //Disconnect from COM-object and unload it pp = null; GC.GetTotalMemory(true); return; } } //Open and Configure MiniProg3 port hr = OpenPort(out strError); if (!SUCCEEDED(hr)) { rtbLog.AppendText("Connect error: " + strError); rtbLog.AppendText("\r\n"); //Disconnect from COM-object and unload it pp = null; GC.GetTotalMemory(true); return; } pp.SetProtocolClock(enumFrequencies.FREQ_03_0, out strError); if (guiSettings.conn == Connector.P10) { pp.SetProtocolConnector(1, out strError); } else { pp.SetProtocolConnector(0, out strError); } pp.SetProtocol(enumInterfaces.SWD_SWV, out strError); if (guiSettings.volt == Voltage.V5_0) { strVolt = "5.0"; } else if (guiSettings.volt == Voltage.V3_3) { strVolt = "3.3"; } else if (guiSettings.volt == Voltage.V2_5) { strVolt = "2.5"; } else if (guiSettings.volt == Voltage.V1_8) { strVolt = "1.8"; } else { strVolt = "EXT"; } if (strVolt != "EXT") { pp.SetPowerVoltage(strVolt, out strError); pp.PowerOn(out strError); } /* Init the event handler for received data */ pp.OnUSB2IIC_DataReceived += new PP_ComLib_Wrapper.PP_ComLib_WrapperClass.DelegateByteArrayParam(pp_USB2IIC_ReceivedData); //object ports; string[] portsStr; hr = pp.GetPorts(out portsStr, out strError); //string[] portsStr = ports as string[]; AppendTextToLog("Connected to '" + portsStr[0] + "' programmer!"); btnConnect.Text = "Disconnect"; // DTV connected = 1; // DTV }