public static bool Get_Aux_Status(ref bool p_aux1_state, ref bool p_aux2_state, ref bool p_aux1_dir, ref bool p_aux2_dir) { byte[] array = new byte[0x41]; bool flag = false; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { p_aux1_state = (array[0x30] & 1) > 0; p_aux2_state = (array[0x30] & 2) > 0; p_aux1_dir = (array[0x30] & 4) > 0; p_aux2_dir = (array[0x30] & 8) > 0; flag = true; } } return(flag); }
public static bool Get_Aux_Status(ref bool p_aux1_state, ref bool p_aux2_state, ref bool p_aux1_dir, ref bool p_aux2_dir) { byte[] array = new byte[65]; bool result = false; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { p_aux1_state = ((array[48] & 1) > 0); p_aux2_state = ((array[48] & 2) > 0); p_aux1_dir = ((array[48] & 4) > 0); p_aux2_dir = ((array[48] & 8) > 0); result = true; } } return(result); }
private static bool Toggle_AutoBaud_Set(bool p_turn_autobaudset_on, ref ushort p_baud, ref string p_error_detail) { bool flag = false; int num = 0; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; p_error_detail = ""; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { p_error_detail = "Could not poll PKSA for status."; return(false); } p_baud = LIN.calculate_baud_rate((ushort)((int)array2[29] + ((int)array2[30] << 8))); if (p_turn_autobaudset_on) { byte[] expr_8F_cp_0 = array2; int expr_8F_cp_1 = 23; expr_8F_cp_0[expr_8F_cp_1] |= 128; } else { byte[] expr_AC_cp_0 = array2; int expr_AC_cp_1 = 23; expr_AC_cp_0[expr_AC_cp_1] &= 127; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); while (!flag && num < 3) { num++; flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref text2, false, ref text); p_error_detail += text2; } } return(flag); }
public static double Get_SPI_Bit_Rate() { byte[] array = new byte[0x41]; double num = 0.0; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(num); } Array.Clear(array, 0, array.Length); if (!Basic.Get_Status_Packet(ref array)) { return(num); } double num2 = 0.0; double num3 = 0.0; switch (array[50]) { case 0: num2 = 8.0; break; case 1: num2 = 32.0; break; case 2: num2 = 128.0; break; default: num2 = 0.0; break; } num3 = array[0x33] + 1; if (num2 == 0.0) { return(0.0); } return(((20.0 / num2) / num3) * 1000.0); }
public static double Get_SPI_Bit_Rate() { byte[] array = new byte[65]; double result = 0.0; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { double num; switch (array[50]) { case 0: num = 8.0; break; case 1: num = 32.0; break; case 2: num = 128.0; break; default: num = 0.0; break; } double num2 = (double)(array[51] + 1); if (num == 0.0) { result = 0.0; } else { result = 20.0 / num / num2 * 1000.0; } } } return(result); }
public static double Get_Buffer_Flush_Time() { double num = 9999.0; byte[] array = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (!Basic.Get_Status_Packet(ref array)) { return(9999.0); } num = (double)array[11] * 0.409; if (num == 0.0) { num = 0.409; } } return(num); }
public static bool Set_Buffer_Flush_Parameters(bool p_flush_on_count, bool p_flush_on_time, byte p_flush_byte_count, double p_flush_interval) { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } if (p_flush_on_count) { buffer2[7] = (byte)(buffer2[7] | 0x40); } else { buffer2[7] = (byte)(buffer2[7] & 0xbf); } if (p_flush_on_time) { buffer2[7] = (byte)(buffer2[7] | 0x80); } else { buffer2[7] = (byte)(buffer2[7] & 0x7f); } buffer2[10] = p_flush_byte_count; byte num = (byte)Math.Round((double)(p_flush_interval / 0.409)); buffer2[11] = num; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
public static bool Tell_PKSA_To_Use_External_Voltage_Source() { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } buffer2[0x10] = (byte)(buffer2[0x10] & 0xdf); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
private static bool Toggle_AutoBaud_Set(bool p_turn_autobaudset_on, ref ushort p_baud, ref string p_error_detail) { bool flag = false; int num = 0; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; p_error_detail = ""; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { p_error_detail = "Could not poll PKSA for status."; return(false); } p_baud = calculate_baud_rate((ushort)(buffer2[0x1d] + (buffer2[30] << 8))); if (p_turn_autobaudset_on) { buffer2[0x17] = (byte)(buffer2[0x17] | 0x80); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0x7f); } USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); while (!flag && (num < 3)) { num++; flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref str2, false, ref str); p_error_detail = p_error_detail + str2; } } return(flag); }
public static bool Get_SPI_Status(ref bool p_sample_phase, ref bool p_clock_edge_select, ref bool p_clock_polarity, ref bool p_auto_output_disable, ref bool p_SDI_state, ref bool p_SDO_state, ref bool p_SCK_state, ref bool p_chip_select_state) { byte[] array = new byte[0x41]; bool flag = false; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { p_sample_phase = (array[0x2d] & 1) > 0; p_clock_edge_select = (array[0x2d] & 2) > 0; p_clock_polarity = (array[0x2d] & 4) > 0; p_auto_output_disable = (array[0x2d] & 8) > 0; p_SDI_state = (array[0x2e] & 1) > 0; p_SDO_state = (array[0x2e] & 2) > 0; p_SCK_state = (array[0x2e] & 4) > 0; p_chip_select_state = (array[0x2e] & 8) > 0; flag = true; } } return(flag); }
public static bool Get_SPI_Status(ref bool p_sample_phase, ref bool p_clock_edge_select, ref bool p_clock_polarity, ref bool p_auto_output_disable, ref bool p_SDI_state, ref bool p_SDO_state, ref bool p_SCK_state, ref bool p_chip_select_state) { byte[] array = new byte[65]; bool result = false; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { p_sample_phase = ((array[45] & 1) > 0); p_clock_edge_select = ((array[45] & 2) > 0); p_clock_polarity = ((array[45] & 4) > 0); p_auto_output_disable = ((array[45] & 8) > 0); p_SDI_state = ((array[46] & 1) > 0); p_SDO_state = ((array[46] & 2) > 0); p_SCK_state = ((array[46] & 4) > 0); p_chip_select_state = ((array[46] & 8) > 0); result = true; } } return(result); }
public static bool Get_Buffer_Flush_Parameters(ref bool p_flush_on_count, ref bool p_flush_on_time, ref byte p_flush_byte_count, ref double p_flush_interval) { bool result = false; byte[] array = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); if (Basic.Get_Status_Packet(ref array)) { p_flush_on_count = ((array[7] & 64) > 0); p_flush_on_time = ((array[7] & 128) > 0); p_flush_byte_count = array[10]; p_flush_interval = (double)array[11] * 0.409; if (p_flush_interval == 0.0) { p_flush_interval = 0.409; } result = true; } } return(result); }
public static bool Set_Buffer_Flush_Time(double p_time) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } byte b = (byte)Math.Round(p_time / 0.409); array2[11] = b; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Tell_PKSA_To_Power_My_Device() { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } byte[] expr_61_cp_0 = array2; int expr_61_cp_1 = 16; expr_61_cp_0[expr_61_cp_1] |= 32; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Get_Buffer_Flush_Parameters(ref bool p_flush_on_count, ref bool p_flush_on_time, ref byte p_flush_byte_count, ref double p_flush_interval) { bool flag = false; byte[] array = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); if (!Basic.Get_Status_Packet(ref array)) { return(flag); } p_flush_on_count = (array[7] & 0x40) > 0; p_flush_on_time = (array[7] & 0x80) > 0; p_flush_byte_count = array[10]; p_flush_interval = array[11] * 0.409; if (p_flush_interval == 0.0) { p_flush_interval = 0.409; } return(true); }
public static bool Set_Buffer_Flush_Time(double p_time) { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } byte num = (byte)Math.Round((double)(p_time / 0.409)); buffer2[11] = num; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
public static bool Set_Baud_Rate(ushort p_baud) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } int num = (int)Math.Round(20000000.0 / (double)p_baud / 4.0) - 1; array2[29] = (byte)num; array2[30] = (byte)(num >> 8); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } return(result); }
public static bool Add_LIN_Slave_Profile_To_PKS(byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str, ref int p_error_code) { bool flag = false; byte[] array = new byte[65]; byte[] array2 = new byte[255]; byte[] array3 = new byte[65]; bool result = false; byte b = 0; byte b2 = 0; string text = ""; p_error_code = 0; Array.Clear(array, 0, array.Length); Array.Clear(array3, 0, array3.Length); byte b3 = LIN.Number_Of_Bytes_In_CBUF3(ref b, ref b2); if (p_array_byte_count > b3) { p_result_str = string.Format("Byte count of {0} greater than allowed value of {1}.", p_array_byte_count, b3); p_error_code = 1; return(flag); } USBWrite.Clear_CBUF(3); if (!Basic.Get_Status_Packet(ref array3)) { p_result_str = string.Format("Error reading status packet.", new object[0]); p_error_code = 2; return(false); } byte[] expr_A6_cp_0 = array3; int expr_A6_cp_1 = 23; expr_A6_cp_0[expr_A6_cp_1] |= 32; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array3); flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); Array.Clear(array2, 0, array2.Length); array2[0] = 0; array2[1] = 5; array2[2] = p_array_byte_count; for (int i = 3; i < (int)(p_array_byte_count + 3); i++) { array2[i] = p_profile_array[i - 3]; } bool flag2 = USBWrite.Send_Script_To_PICkitS(ref array2); if (flag & flag2) { if (USBWrite.Update_Status_Packet()) { Utilities.m_flags.g_status_packet_mutex.WaitOne(); int j; for (j = 7; j < 31; j++) { if (Constants.STATUS_PACKET_DATA[j] != array[j - 5]) { p_error_code = 3; p_result_str = string.Format("Byte {0} failed verification in config block write.\n Value reads {1:X2}, but should be {2:X2}.", j - 7, Constants.STATUS_PACKET_DATA[j], array[j - 5]); break; } } if (j == 31) { result = true; p_result_str = string.Format("PICkit Serial Analyzer correctly updated.", new object[0]); } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); } else { p_result_str = string.Format("Error requesting config verification - Config Block may not be updated correctly", new object[0]); } } else { p_error_code = 2; p_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]); } return(result); }
public static bool Configure_PICkitSerial_For_MicrowireMaster(bool p_sample_phase, bool p_clock_edge_select, bool p_clock_polarity, bool p_auto_output_disable, bool p_chip_sel_polarity, bool p_supply_5V) { bool flag = false; if (!Basic.Configure_PICkitSerial(11, true)) { return(flag); } string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } if (p_sample_phase) { buffer2[0x18] = (byte)(buffer2[0x18] | 1); } else { buffer2[0x18] = (byte)(buffer2[0x18] & 0xfe); } if (p_clock_edge_select) { buffer2[0x18] = (byte)(buffer2[0x18] | 2); } else { buffer2[0x18] = (byte)(buffer2[0x18] & 0xfd); } if (p_clock_polarity) { buffer2[0x18] = (byte)(buffer2[0x18] | 4); } else { buffer2[0x18] = (byte)(buffer2[0x18] & 0xfb); } if (p_auto_output_disable) { buffer2[0x18] = (byte)(buffer2[0x18] | 8); } else { buffer2[0x18] = (byte)(buffer2[0x18] & 0xf7); } if (p_chip_sel_polarity) { buffer2[0x18] = (byte)(buffer2[0x18] | 0x80); } else { buffer2[0x18] = (byte)(buffer2[0x18] & 0x7f); } if (p_supply_5V) { buffer2[0x10] = (byte)(buffer2[0x10] | 0x20); } else { buffer2[0x10] = (byte)(buffer2[0x10] & 0xdf); } USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
public static bool Configure_PICkitSerial_For_USARTAsync(bool p_aux1_def, bool p_aux2_def, bool p_aux1_dir, bool p_aux2_dir, bool p_rcv_dis, double p_voltage) { bool result = false; if (Basic.Configure_PICkitSerial(4, true)) { string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { if (p_voltage < 0.0 || p_voltage > 5.0) { return(result); } Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } if (p_aux1_def) { byte[] expr_94_cp_0 = array2; int expr_94_cp_1 = 28; expr_94_cp_0[expr_94_cp_1] |= 1; } else { byte[] expr_AD_cp_0 = array2; int expr_AD_cp_1 = 28; expr_AD_cp_0[expr_AD_cp_1] &= 254; } if (p_aux2_def) { byte[] expr_CB_cp_0 = array2; int expr_CB_cp_1 = 28; expr_CB_cp_0[expr_CB_cp_1] |= 2; } else { byte[] expr_E4_cp_0 = array2; int expr_E4_cp_1 = 28; expr_E4_cp_0[expr_E4_cp_1] &= 253; } if (p_aux1_dir) { byte[] expr_102_cp_0 = array2; int expr_102_cp_1 = 28; expr_102_cp_0[expr_102_cp_1] |= 4; } else { byte[] expr_11B_cp_0 = array2; int expr_11B_cp_1 = 28; expr_11B_cp_0[expr_11B_cp_1] &= 251; } if (p_aux2_dir) { byte[] expr_139_cp_0 = array2; int expr_139_cp_1 = 28; expr_139_cp_0[expr_139_cp_1] |= 8; } else { byte[] expr_152_cp_0 = array2; int expr_152_cp_1 = 28; expr_152_cp_0[expr_152_cp_1] &= 247; } if (p_rcv_dis) { byte[] expr_171_cp_0 = array2; int expr_171_cp_1 = 24; expr_171_cp_0[expr_171_cp_1] |= 4; } else { byte[] expr_18A_cp_0 = array2; int expr_18A_cp_1 = 24; expr_18A_cp_0[expr_18A_cp_1] &= 251; } int num = (int)Math.Round((p_voltage * 1000.0 + 43.53) / 21.191); array2[19] = (byte)num; array2[20] = (byte)(num / 4); byte[] expr_1DD_cp_0 = array2; int expr_1DD_cp_1 = 16; expr_1DD_cp_0[expr_1DD_cp_1] |= 32; byte[] expr_1F5_cp_0 = array2; int expr_1F5_cp_1 = 16; expr_1F5_cp_0[expr_1F5_cp_1] |= 64; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } } return(result); }
public static bool Add_LIN_Slave_Profile_To_PKS(byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str, ref int p_error_code) { bool flag = false; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0xff]; byte[] buffer3 = new byte[0x41]; bool flag2 = false; byte num = 0; byte num2 = 0; string str = ""; int index = 0; p_error_code = 0; Array.Clear(array, 0, array.Length); Array.Clear(buffer3, 0, buffer3.Length); byte num4 = Number_Of_Bytes_In_CBUF3(ref num, ref num2); if (p_array_byte_count > num4) { p_result_str = string.Format("Byte count of {0} greater than allowed value of {1}.", p_array_byte_count, num4); p_error_code = 1; return(flag); } USBWrite.Clear_CBUF(3); if (!Basic.Get_Status_Packet(ref buffer3)) { p_result_str = string.Format("Error reading status packet.", new object[0]); p_error_code = 2; return(false); } buffer3[0x17] = (byte)(buffer3[0x17] | 0x20); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer3); flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); Array.Clear(buffer2, 0, buffer2.Length); buffer2[0] = 0; buffer2[1] = 5; buffer2[2] = p_array_byte_count; for (int i = 3; i < (p_array_byte_count + 3); i++) { buffer2[i] = p_profile_array[i - 3]; } bool flag3 = USBWrite.Send_Script_To_PICkitS(ref buffer2); if (!(flag & flag3)) { p_error_code = 2; p_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]); return(flag2); } if (!USBWrite.Update_Status_Packet()) { p_result_str = string.Format("Error requesting config verification - Config Block may not be updated correctly", new object[0]); return(flag2); } Utilities.m_flags.g_status_packet_mutex.WaitOne(); index = 7; while (index < 0x1f) { if (Constants.STATUS_PACKET_DATA[index] != array[index - 5]) { p_error_code = 3; p_result_str = string.Format("Byte {0} failed verification in config block write.\n Value reads {1:X2}, but should be {2:X2}.", index - 7, Constants.STATUS_PACKET_DATA[index], array[index - 5]); break; } index++; } if (index == 0x1f) { flag2 = true; p_result_str = string.Format("PICkit Serial Analyzer correctly updated.", new object[0]); } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); return(flag2); }
public static bool Configure_PICkitSerial_For_SPIMaster(bool p_sample_phase, bool p_clock_edge_select, bool p_clock_polarity, bool p_auto_output_disable, bool p_chip_sel_polarity, bool p_supply_5V) { bool result = false; if (Basic.Configure_PICkitSerial(2, true)) { string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } if (p_sample_phase) { byte[] expr_73_cp_0 = array2; int expr_73_cp_1 = 24; expr_73_cp_0[expr_73_cp_1] |= 1; } else { byte[] expr_8C_cp_0 = array2; int expr_8C_cp_1 = 24; expr_8C_cp_0[expr_8C_cp_1] &= 254; } if (p_clock_edge_select) { byte[] expr_AA_cp_0 = array2; int expr_AA_cp_1 = 24; expr_AA_cp_0[expr_AA_cp_1] |= 2; } else { byte[] expr_C3_cp_0 = array2; int expr_C3_cp_1 = 24; expr_C3_cp_0[expr_C3_cp_1] &= 253; } if (p_clock_polarity) { byte[] expr_E1_cp_0 = array2; int expr_E1_cp_1 = 24; expr_E1_cp_0[expr_E1_cp_1] |= 4; } else { byte[] expr_FA_cp_0 = array2; int expr_FA_cp_1 = 24; expr_FA_cp_0[expr_FA_cp_1] &= 251; } if (p_auto_output_disable) { byte[] expr_118_cp_0 = array2; int expr_118_cp_1 = 24; expr_118_cp_0[expr_118_cp_1] |= 8; } else { byte[] expr_131_cp_0 = array2; int expr_131_cp_1 = 24; expr_131_cp_0[expr_131_cp_1] &= 247; } if (p_chip_sel_polarity) { byte[] expr_150_cp_0 = array2; int expr_150_cp_1 = 24; expr_150_cp_0[expr_150_cp_1] |= 128; } else { byte[] expr_16D_cp_0 = array2; int expr_16D_cp_1 = 24; expr_16D_cp_0[expr_16D_cp_1] &= 127; } if (p_supply_5V) { byte[] expr_189_cp_0 = array2; int expr_189_cp_1 = 16; expr_189_cp_0[expr_189_cp_1] |= 32; } else { byte[] expr_1A3_cp_0 = array2; int expr_1A3_cp_1 = 16; expr_1A3_cp_0[expr_1A3_cp_1] &= 223; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } } return(result); }
public static bool Get_Status_Packet(ref byte[] p_status_packet) { return(Basic.Get_Status_Packet(ref p_status_packet)); }
public static bool Configure_PICkitSerial_For_I2CMaster(bool p_aux1_def, bool p_aux2_def, bool p_aux1_dir, bool p_aux2_dir, bool p_enable_pu, double p_voltage) { bool flag = false; int num = 0; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } if ((p_voltage < 0.0) || (p_voltage > 5.0)) { return(flag); } if (!Basic.Configure_PICkitSerial(1, true)) { return(flag); } string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } if (p_aux1_def) { buffer2[0x1c] = (byte)(buffer2[0x1c] | 1); } else { buffer2[0x1c] = (byte)(buffer2[0x1c] & 0xfe); } if (p_aux2_def) { buffer2[0x1c] = (byte)(buffer2[0x1c] | 2); } else { buffer2[0x1c] = (byte)(buffer2[0x1c] & 0xfd); } if (p_aux1_dir) { buffer2[0x1c] = (byte)(buffer2[0x1c] | 4); } else { buffer2[0x1c] = (byte)(buffer2[0x1c] & 0xfb); } if (p_aux2_dir) { buffer2[0x1c] = (byte)(buffer2[0x1c] | 8); } else { buffer2[0x1c] = (byte)(buffer2[0x1c] & 0xf7); } if (p_enable_pu) { buffer2[0x10] = (byte)(buffer2[0x10] | 0x10); } else { buffer2[0x10] = (byte)(buffer2[0x10] & 0xef); } num = (int)Math.Round((double)(((p_voltage * 1000.0) + 43.53) / 21.191)); buffer2[0x13] = (byte)num; buffer2[20] = (byte)(num / 4); buffer2[0x10] = (byte)(buffer2[0x10] | 0x20); buffer2[0x10] = (byte)(buffer2[0x10] | 0x40); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
public static bool Configure_PICkitSerial_For_LIN(bool p_chip_select_hi, bool p_receive_enable, bool p_autobaud) { bool flag = false; if ((Utilities.m_flags.HID_DeviceReady != false) && Basic.Configure_PICkitSerial(10, true)) { string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } if (p_chip_select_hi) { byte[] expr_8D_cp_0 = array2; int expr_8D_cp_1 = 23; expr_8D_cp_0[expr_8D_cp_1] |= 8; } else { byte[] expr_A6_cp_0 = array2; int expr_A6_cp_1 = 23; expr_A6_cp_0[expr_A6_cp_1] &= 247; } if (p_receive_enable) { byte[] expr_C4_cp_0 = array2; int expr_C4_cp_1 = 23; expr_C4_cp_0[expr_C4_cp_1] |= 64; } else { byte[] expr_DE_cp_0 = array2; int expr_DE_cp_1 = 23; expr_DE_cp_0[expr_DE_cp_1] &= 191; } if (p_autobaud) { byte[] expr_FC_cp_0 = array2; int expr_FC_cp_1 = 23; expr_FC_cp_0[expr_FC_cp_1] |= 128; } else { byte[] expr_119_cp_0 = array2; int expr_119_cp_1 = 23; expr_119_cp_0[expr_119_cp_1] &= 127; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); flag = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); if (flag) { LIN.Get_LIN_BAUD_Rate(); } } } return(flag); }