/// <summary> /// /// </summary> /// <param name="cMcuFuncInfoBaseParam"></param> public void Init(CMcuFuncAVR8BitsBase cMcuFunc, RichTextBox msg = null) { if (cMcuFunc == null) { return; } //---初始化芯片信息 if (this.defaultCMcuFunc == null) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsBase(); } this.defaultCMcuFunc = cMcuFunc; //---初始化相关控件 this.defaultCMcuFunc.mMcuInfoParam.FormControlInit(this.cCheckedListBoxEx_LowFuseBits, this.cCheckedListBoxEx_HighFuseBits, this.cCheckedListBoxEx_ExternFuseBits, this.cCheckedListBoxEx_LockFuseBits, this.cCheckedListBoxEx_FuseText, this.label_OSCText1, this.label_OSCText2, this.label_OSCText3, this.label_OSCText4, this.textBox_OSCValue1, this.textBox_OSCValue2, this.textBox_OSCValue3, this.textBox_OSCValue4, this.textBox_LowFuseValue, this.textBox_HighFuseValue, this.textBox_ExternFuseValue, this.textBox_LockFuseValue ); //---校验是否已经注册了事件 if (this.defaultRegisterEventState == false) { this.RegisterEventHandler(); this.defaultRegisterEventState = true; } //---消息显示 if (msg != null) { this.defaultRichTextBoxMsg = msg; } }
/// <summary> /// 有参构造函数 /// </summary> public CMcuFormAVR8BitsForm(CCommPort usedCComm, CMcuFuncAVR8BitsBase usedCMcuFunc) { InitializeComponent(); //---限定最小尺寸 this.MinimumSize = this.Size; //---修改自适应宽度的进度条 this.toolStripProgressBar_ChipBar.Width += 30; //28; this.toolStripProgressBar_ChipBar.Tag = this.toolStripProgressBar_ChipBar.Width.ToString(); this.toolStrip_ChipTool.Tag = this.toolStrip_ChipTool.Width.ToString(); //---检查通讯端口 if (this.defaultCComm == usedCComm) { this.defaultCComm = new CCommPort(); } //---通讯接口 this.defaultCComm = usedCComm; //---检查设备函数 if (this.defaultCMcuFunc == null) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsBase(); } //---校验类型 if ((usedCMcuFunc != null) && (usedCMcuFunc.mMcuInfoParam.mTypeMcuInfo != MCU_INFO_TYPE.MCU_AVR8BITS)) { this.defaultCMcuFunc = usedCMcuFunc; } //---窗体事件处理 this.FormEventHandler(); }
/// <summary> /// 有参数构造函数 /// </summary> /// <param name="cCommBase"></param> /// <param name="cMcuFuncInfoBaseParam"></param> public CMcuFormAVR8BitsFuseAndLockControl(CMcuFuncAVR8BitsBase cMcuFunc, RichTextBox msg = null) { InitializeComponent(); //---在内存中先绘制界面,禁止擦除背景 this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); //---双缓冲,防止绘制时抖动 this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); //---双缓存 this.SetStyle(ControlStyles.DoubleBuffer, true); //---限制窗体的大小 this.MinimumSize = this.Size; this.MaximumSize = this.Size; //---初始化芯片信息 if (this.defaultCMcuFunc == null) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsBase(); } this.defaultCMcuFunc = cMcuFunc; //---初始化 this.Init(cMcuFunc, msg); }
/// <summary> /// /// </summary> /// <param name="bt"></param> private void UI_Button_Click(Button bt) { switch (bt.Name) { //---设备接口发生变化 case "button_SetChipInterface": if (!string.IsNullOrEmpty(this.comboBox_ChipInterface.Text)) { switch (this.comboBox_ChipInterface.Text.ToUpper()) { case "ISP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsISP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsISP(this.defaultCMcuFunc); } break; case "JTAG": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsJTAG)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsJTAG(this.defaultCMcuFunc); } break; case "HVPP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsHVPP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsHVPP(this.defaultCMcuFunc); } break; case "HVSP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsHVSP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsHVSP(this.defaultCMcuFunc); } break; default: break; } //---写入配置信息 CIniFile ini = new CIniFile(Application.StartupPath + @"\Config.ini", true); //---记录设备接口 if (ini.CIniFileSectionExists("Interface")) { ini.CIniFileEraseSection("Interface"); } ini.CIniFileWriteInt("Interface", this.comboBox_ChipInterface.Text, this.comboBox_ChipInterface.SelectedIndex); this.cMcuFormAVR8BitsFuseAndLockControl_ChipFuse.mCMcuFunc = this.defaultCMcuFunc; } else { CMessageBoxPlus.Show(this, "???不识别的编程接口", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; //---读取供电电压 case "button_ReadChipPWR": this.defaultCMcuFunc.CMcuFunc_ReadChipPower(this.textBox_ChipPWR, this.cRichTextBoxEx_ChipMsg); break; //---设置供电电压 case "button_SetChipPWR": this.defaultCMcuFunc.CMcuFunc_WriteChipPower(this.textBox_ChipPWR, this.cRichTextBoxEx_ChipMsg, this.checkBox_ChipPWR.Checked); break; //---设置编程时钟 case "button_SetChipClock": this.defaultCMcuFunc.CMcuFunc_SetProgClock((byte)this.trackBar_ChipClock.Value, this.cRichTextBoxEx_ChipMsg); break; //---加载Flash数据 case "button_LoadFlashFile": this.defaultCMcuFunc.CMcuFunc_LoadFlashHexFile(this.cHexBox_Flash, this.label_FlashSize, this.cRichTextBoxEx_ChipMsg); break; //---加载Eeprom case "button_LoadEepromFile": this.defaultCMcuFunc.CMcuFunc_LoadEepromHexFile(this.cHexBox_Eeprom, this.label_EepromSize, this.cRichTextBoxEx_ChipMsg); break; //---保存Flash case "button_SaveFlashFile": this.defaultCMcuFunc.CMcuFunc_SaveFlashHexFile(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg); break; //---保存EEPROM文件 case "button_SaveEepromFile": this.defaultCMcuFunc.CMcuFunc_SaveEepromHexFile(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg); break; //---自动 case "button_AutoChip": case "button_ChipAuto": this.defaultCMcuFunc.CMcuFunc_DoChipTask(this.defaultCMcuFunc.mMcuInfoParam.mChipFuse, Convert.ToByte(this.mLockFuse.Text, 16), this.cHexBox_Flash, this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---擦除 case "button_Erase": case "button_EraseChip": this.defaultCMcuFunc.CMcuFunc_EraseChip(this.mLockFuse, this.cRichTextBoxEx_ChipMsg); break; //---存储器查空操作 case "button_CheckEmpty": this.defaultCMcuFunc.CMcuFunc_CheckChipMemeryEmpty(this.cRichTextBoxEx_ChipMsg, false); break; //---读取识别字 case "button_ReadIDChip": case "button_ReadChipID": this.defaultCMcuFunc.CMcuFunc_ReadChipID(this.cRichTextBoxEx_ChipMsg, this); break; //---读取Flash case "button_ReadChipFlash": this.defaultCMcuFunc.CMcuFunc_ReadChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程Flash case "button_WriteChipFlash": this.defaultCMcuFunc.CMcuFunc_WriteChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, true, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---校验Flash case "button_CheckChipFlash": this.defaultCMcuFunc.CMcuFunc_CheckChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---读取Eeprom case "button_ReadChipEeprom": this.defaultCMcuFunc.CMcuFunc_ReadChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程Eeprom case "button_WriteChipEeprom": this.defaultCMcuFunc.CMcuFunc_WriteChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, true, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---校验Eeprom case "button_CheckChipEeprom": this.defaultCMcuFunc.CMcuFunc_CheckChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程熔丝位 case "button_WriteChipFuse": this.defaultCMcuFunc.CMcuFunc_WriteChipFuse(this.cMcuFormAVR8BitsFuseAndLockControl_ChipFuse.mCMcuFunc.mMcuInfoParam.mChipFuse, this.cRichTextBoxEx_ChipMsg); break; //---编程加密位 case "button_WriteChipLock": this.defaultCMcuFunc.CMcuFunc_WriteChipLock(this.mLockFuse, this.cRichTextBoxEx_ChipMsg); break; //---读取ROM信息 case "button_ReadChipROM": this.defaultCMcuFunc.CMcuFunc_ReadChipRom(this.cHexBox_ROM, this.cRichTextBoxEx_ChipMsg, true); break; default: break; } //---任务空闲 this.defaultTaskIdle = false; }