コード例 #1
0
        private void clickSet(object sender, EventArgs e)
        {
            string editText;

            try
            {
                if (textBoxOSCCAL.Text.Substring(0, 2) == "0x")
                {
                    editText = textBoxOSCCAL.Text;
                }
                else if (textBoxOSCCAL.Text.Substring(0, 1) == "x")
                {
                    editText = "0" + textBoxOSCCAL.Text;
                }
                else
                {
                    editText = "0x" + textBoxOSCCAL.Text;
                }
                int value = UTIL.Convert_Value_To_Int(editText);

                Pk2.DeviceBuffers.OSCCAL   = (uint)value;
                FormPICkit2.setOSCCALValue = true;
                this.Close();
            }
            catch
            {
                textBoxOSCCAL.Text = string.Format("{0:X4}", Pk2.DeviceBuffers.OSCCAL);
            }
        }
コード例 #2
0
        private void baselineConfigEdit()
        {
            string editText = "0x" + textBoxBaselineConfig.Text;
            int    value    = UTIL.Convert_Value_To_Int(editText);

            Pk2.DeviceBuffers.ConfigWords[0] = (uint)value;
            UpdateTestMemoryGrid();
            UpdateMainFormGUI();
        }
コード例 #3
0
        private void dataGridTestMemory_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int    row            = e.RowIndex;
            int    col            = e.ColumnIndex;
            string editText       = "0x" + dataGridTestMemory[col, row].FormattedValue.ToString();
            int    value          = UTIL.Convert_Value_To_Int(editText);
            int    numColumns     = dataGridTestMemory.ColumnCount - 1;
            int    testMemAddress = (row * numColumns) + col - 1;
            int    testMemStart   = getTestMemAddress() * Pk2.DevFile.Families[Pk2.GetActiveFamily()].ProgMemHexBytes;
            int    userIDAddr     = (int)Pk2.DevFile.PartsList[Pk2.ActivePart].UserIDAddr;

            if (Pk2.GetActiveFamily() == 2)
            { // baseline
                userIDAddr = testMemStart;
            }

            TestMemory[testMemAddress] =
                (uint)(value & Pk2.DevFile.Families[Pk2.GetActiveFamily()].BlankValue);

            if ((Pk2.DevFile.PartsList[Pk2.ActivePart].UserIDWords > 0) &&
                (userIDAddr >= testMemStart) && (userIDAddr < (testMemStart + FormPICkit2.TestMemoryWords)))
            { // if user IDs are in test memory
                int userIDIndex = (int)(userIDAddr - testMemStart)
                                  / Pk2.DevFile.Families[Pk2.GetActiveFamily()].BytesPerLocation;
                if ((testMemAddress >= userIDIndex) && (testMemAddress < (userIDIndex + Pk2.DevFile.PartsList[Pk2.ActivePart].UserIDWords)))
                {
                    Pk2.DeviceBuffers.UserIDs[testMemAddress - userIDIndex] =
                        (uint)(value & Pk2.DevFile.Families[Pk2.GetActiveFamily()].BlankValue);
                    if (Pk2.GetActiveFamily() == 3)
                    { // 18F
                        Pk2.DeviceBuffers.UserIDs[testMemAddress - userIDIndex] &= 0xFF;
                    }
                }
            }

            if ((Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigWords > 0) &&
                (Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigAddr >= testMemStart) &&
                (Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigAddr < (testMemStart + FormPICkit2.TestMemoryWords)))
            { // if config words are in test memory
                int cfgWordsIndex = (int)(Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigAddr - testMemStart)
                                    / Pk2.DevFile.Families[Pk2.GetActiveFamily()].BytesPerLocation;
                if ((testMemAddress >= cfgWordsIndex) && (testMemAddress < (cfgWordsIndex + Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigWords)))
                {
                    Pk2.DeviceBuffers.ConfigWords[testMemAddress - cfgWordsIndex] =
                        (uint)(value & Pk2.DevFile.PartsList[Pk2.ActivePart].ConfigMasks[testMemAddress - cfgWordsIndex]);
                }
            }

            testMemJustEdited = true;
            UpdateMainFormGUI();
        }
コード例 #4
0
        private void progMemEdit(object sender, DataGridViewCellEventArgs e)
        {
            int    row      = e.RowIndex;
            int    col      = e.ColumnIndex;
            string editText = "0x" + dataGridProgramMemory[col, row].FormattedValue.ToString();
            int    value    = 0;

            try
            {
                value = UTIL.Convert_Value_To_Int(editText);
            }
            catch
            {
                value = 0;
            }
            int numColumns = dataGridProgramMemory.ColumnCount - 1;

            if (comboBoxProgMemView.SelectedIndex >= 1) // ascii view
            {
                numColumns /= 2;
            }

            int index = ((row * numColumns) + col - 1);

            if (Pk2.FamilyIsPIC32())
            {
                int progMemP32 = (int)Pk2.DevFile.PartsList[Pk2.ActivePart].ProgramMem;
                int bootMemP32 = (int)Pk2.DevFile.PartsList[Pk2.ActivePart].BootFlash;
                progMemP32 -= bootMemP32; // boot flash at upper end of prog mem.

                index -= numColumns;      // first row has "Program Flash" text

                if (index > progMemP32)
                {
                    index -= numColumns; // subtract row with "Boot Flash" text
                }
            }

            Pk2.DeviceBuffers.ProgramMemory[index] =
                (uint)(value & Pk2.DevFile.Families[Pk2.GetActiveFamily()].BlankValue);

            TellMainFormProgMemEdited();

            progMemJustEdited = true;
            TellMainFormUpdateGUI();
        }
コード例 #5
0
        private void progMemEdit(object sender, DataGridViewCellEventArgs e)
        {
            int    row      = e.RowIndex;
            int    col      = e.ColumnIndex;
            string editText = "0x" + dataGridProgramMemory[col, row].FormattedValue.ToString();
            int    value    = 0;

            try
            {
                value = UTIL.Convert_Value_To_Int(editText);
            }
            catch
            {
                value = 0;
            }
            int numColumns = dataGridProgramMemory.ColumnCount - 1;

            if (comboBoxProgMemView.SelectedIndex >= 1) // ascii view
            {
                numColumns /= 2;
            }

            uint blankValue = 0xFF;

            if (Pk2.DevFile.Families[Pk2.GetActiveFamily()].BlankValue > 0xFFFF)
            {
                blankValue = 0xFFFF; // dsPIC
            }
            else if (Pk2.DevFile.Families[Pk2.GetActiveFamily()].BlankValue == 0xFFF)
            {
                blankValue = 0xFFF; // BL dataflash
            }

            Pk2.DeviceBuffers.EEPromMemory[((row * numColumns) + col - 1)] =
                (uint)(value & blankValue);

            TellMainFormProgMemEdited();

            progMemJustEdited = true;
            TellMainFormUpdateGUI();
        }
コード例 #6
0
 private void memSizeEdit()
 {
     labelTestMemSize8.Visible = false;
     try
     {
         string editText = textBoxTestMemSize.Text;
         if (textBoxTestMemSize.Text.Length > 1)
         {
             if (textBoxTestMemSize.Text.Substring(0, 2) == "0x")
             {
                 editText = textBoxTestMemSize.Text;
             }
             else if (textBoxTestMemSize.Text.Substring(0, 1) == "x")
             {
                 editText = "0" + textBoxTestMemSize.Text;
             }
         }
         FormPICkit2.TestMemoryWords = UTIL.Convert_Value_To_Int(editText);
         if (FormPICkit2.TestMemoryWords > 1024)
         {
             FormPICkit2.TestMemoryWords = 1024;
         }
         else if (FormPICkit2.TestMemoryWords < 16)
         {
             FormPICkit2.TestMemoryWords = 16;
         }
         else if ((FormPICkit2.TestMemoryWords % 16) != 0)
         { // must be multiple of 16 - otherwise grid view handling & hex exporting gets complicated
             FormPICkit2.TestMemoryWords = ((FormPICkit2.TestMemoryWords / 16) + 1) * 16;
             labelTestMemSize8.Visible   = true;
         }
     }
     catch
     {   // don't do anything
     }
     UpdateTestMemForm();
     UpdateTestMemoryGrid();
 }