public static bool Set_I2C_Bit_Rate(double p_Bit_Rate) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (p_Bit_Rate < 39.1 || p_Bit_Rate > 5000.0) { return(result); } 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(20000.0 / p_Bit_Rate / 4.0) - 1.0); array2[30] = b; 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 Set_Pullup_State(bool p_enable) { 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); } if (p_enable) { byte[] expr_64_cp_0 = array2; int expr_64_cp_1 = 16; expr_64_cp_0[expr_64_cp_1] |= 16; } else { byte[] expr_7E_cp_0 = array2; int expr_7E_cp_1 = 16; expr_7E_cp_0[expr_7E_cp_1] &= 239; } 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 Configure_PICkitSerial_For_I2CSlave_Default_Mode(byte p_slave_addr, byte p_slave_mask, byte p_read_byte_0_data, byte p_read_bytes_1_N_data) { bool flag = false; if (!Basic.Configure_PICkitSerial(7, 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); } buffer2[0x17] = 0; buffer2[0x1b] = p_read_bytes_1_N_data; buffer2[0x1c] = p_read_byte_0_data; buffer2[0x1d] = p_slave_addr; buffer2[30] = p_slave_mask; 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)); }
private static void Reset_Control_Block_Thread() { m_reset_cb.WaitOne(); string str = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; string str2 = ""; Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); I2CS.reset_buffers(); if (USBWrite.Update_Status_Packet()) { Utilities.m_flags.g_status_packet_mutex.WaitOne(); for (int i = 0; i < array.Length; i++) { array[i] = Constants.STATUS_PACKET_DATA[i]; } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); USBWrite.configure_outbound_control_block_packet(ref buffer2, ref str, ref array); USBWrite.write_and_verify_config_block(ref buffer2, ref str, true, ref str2); } m_reset_cb.ReleaseMutex(); }
public static bool Set_Pullup_State(bool p_enable) { 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_enable) { buffer2[0x10] = (byte)(buffer2[0x10] | 0x10); } else { buffer2[0x10] = (byte)(buffer2[0x10] & 0xef); } 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_I2C_Bit_Rate(double p_Bit_Rate) { bool flag = false; byte num = 0; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if ((p_Bit_Rate < 39.1) || (p_Bit_Rate > 5000.0)) { return(flag); } 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); } num = (byte)(Math.Round((double)((20000.0 / p_Bit_Rate) / 4.0)) - 1.0); buffer2[30] = num; 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)); }
private static void flash_the_busy_led() { byte num = 0xc1; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (Get_Status_Packet(ref buffer2)) { buffer2[7] = (byte)(buffer2[7] | 0x20); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); if (USBWrite.Send_LED_State_Cmd(1, num)) { buffer2[7] = (byte)(buffer2[7] & 0xdf); Thread.Sleep(0x7d0); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); } } } }
public static bool Set_I2CSlave_Address_and_Mask(byte p_slave_addr, byte p_slave_mask) { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } 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[0x1d] = p_slave_addr; buffer2[30] = p_slave_mask; 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 Set_Source_Voltage(double p_voltage) { bool flag = false; int num = 0; 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); } if ((p_voltage < 0.0) || (p_voltage > 5.0)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } 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, false, ref str)); }
public static bool Set_Baud_Rate(ushort p_baud) { 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); } int num = ((int)Math.Round((double)((20000000.0 / ((double)p_baud)) / 4.0))) - 1; buffer2[0x1d] = (byte)num; buffer2[30] = (byte)(num >> 8); 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_I2CSlave_Interactive_Mode(byte p_slave_addr, byte p_slave_mask) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (!Basic.Get_Status_Packet(ref array2)) { return(false); } byte b = array2[28]; byte b2 = array2[27]; if (Basic.Configure_PICkitSerial(7, true) && (Utilities.m_flags.HID_DeviceReady != false)) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } array2[23] = 1; array2[27] = b2; array2[28] = b; array2[29] = p_slave_addr; array2[30] = p_slave_mask; 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 Set_I2CSlave_Address_and_Mask(byte p_slave_addr, byte p_slave_mask) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (!Basic.Get_Status_Packet(ref array2)) { return(false); } 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); } array2[29] = p_slave_addr; array2[30] = p_slave_mask; 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); }
private static void flash_the_busy_led() { byte p_value = 193; 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; } byte[] expr_66_cp_0 = array2; int expr_66_cp_1 = 7; expr_66_cp_0[expr_66_cp_1] |= 32; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); if (USBWrite.Send_LED_State_Cmd(1, p_value)) { byte[] expr_9E_cp_0 = array2; int expr_9E_cp_1 = 7; expr_9E_cp_0[expr_9E_cp_1] &= 223; Thread.Sleep(2000); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } } }
public static bool Configure_PICkitSerial_For_I2CSlave_Default_Mode(byte p_slave_addr, byte p_slave_mask, byte p_read_byte_0_data, byte p_read_bytes_1_N_data) { bool result = false; if (Basic.Configure_PICkitSerial(7, 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); } array2[23] = 0; array2[27] = p_read_bytes_1_N_data; array2[28] = p_read_byte_0_data; array2[29] = p_slave_addr; array2[30] = p_slave_mask; 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 Set_Source_Voltage(double p_voltage) { 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) { 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); } int num = (int)Math.Round((p_voltage * 1000.0 + 43.53) / 21.191); array2[19] = (byte)num; array2[20] = (byte)(num / 4); byte[] expr_BA_cp_0 = array2; int expr_BA_cp_1 = 16; expr_BA_cp_0[expr_BA_cp_1] |= 32; byte[] expr_D2_cp_0 = array2; int expr_D2_cp_1 = 16; expr_D2_cp_0[expr_D2_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, false, ref text); } return(result); }
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_read_handle != IntPtr.Zero) && Basic.Configure_PICkitSerial(10, true)) { 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_chip_select_hi) { buffer2[0x17] = (byte)(buffer2[0x17] | 8); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0xf7); } if (p_receive_enable) { buffer2[0x17] = (byte)(buffer2[0x17] | 0x40); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0xbf); } if (p_autobaud) { 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); flag = USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); if (flag) { Get_LIN_BAUD_Rate(); } } return(flag); }
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 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); } if (p_flush_on_count) { byte[] expr_66_cp_0 = array2; int expr_66_cp_1 = 7; expr_66_cp_0[expr_66_cp_1] |= 64; } else { byte[] expr_7F_cp_0 = array2; int expr_7F_cp_1 = 7; expr_7F_cp_0[expr_7F_cp_1] &= 191; } if (p_flush_on_time) { byte[] expr_9C_cp_0 = array2; int expr_9C_cp_1 = 7; expr_9C_cp_0[expr_9C_cp_1] |= 128; } else { byte[] expr_B8_cp_0 = array2; int expr_B8_cp_1 = 7; expr_B8_cp_0[expr_B8_cp_1] &= 127; } array2[10] = p_flush_byte_count; byte b = (byte)Math.Round(p_flush_interval / 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 Configure_PICkitSerial(int p_mode, bool p_reset) { 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) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); Mode.update_status_packet_data(p_mode, ref buffer2); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); flag = USBWrite.write_and_verify_config_block(ref array, ref str2, p_reset, ref str); } return(flag); }
public static bool Configure_PICkitSerial(int p_mode, bool p_reset) { 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); Mode.update_status_packet_data(p_mode, ref array2); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, p_reset, ref text); } return(result); }
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)); }
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 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 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 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 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 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 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); }
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)); }