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 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 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)); }
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); }
public static bool Configure_PICkitSerial_For_I2CSlave_Auto_Mode(byte p_slave_addr, byte p_slave_mask, byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str) { byte[] array = new byte[65]; byte[] array2 = new byte[255]; byte[] array3 = new byte[65]; bool result = false; string text = ""; Array.Clear(array, 0, array.Length); Array.Clear(array3, 0, array3.Length); Mode.update_status_packet_data(7, ref array3); array3[23] = 2; array3[29] = p_slave_addr; array3[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array3); USBWrite.Send_Cold_Reset_Cmd(); bool 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]; } USBWrite.Send_Script_To_PICkitS(ref array2); USBWrite.Send_Warm_Reset_Cmd(); if (flag) { 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_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_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]); } return(result); }
public static bool ReadBufferIsReady() { bool flag = false; byte[] array = new byte[300]; byte num = 1; byte[] buffer2 = new byte[1]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = 14; array[3] = 0x81; array[4] = 0x84; array[5] = 2; array[6] = 0x42; array[7] = 0x88; array[8] = 0x83; array[9] = 0x84; array[10] = 1; array[11] = 0x43; array[12] = 0x89; array[13] = num; array[14] = 130; array[15] = 0x1f; array[0x10] = 0x77; array[0x11] = 0; USBRead.Clear_Data_Array(num); USBRead.Clear_Raw_Data_Array(); if ((USBWrite.Send_Script_To_PICkitS(ref array) && Utilities.m_flags.g_data_arrived_event.WaitOne(50, false)) && (USBRead.Retrieve_Data(ref buffer2, num) && (buffer2[0] == 1))) { flag = true; } return(flag); }
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 Read_One_BL_Flash_USB_Packet(ushort p_addr, byte p_byte_count, ref byte[] p_data) { bool result = false; byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 1; array[2] = p_byte_count; array[3] = (byte)p_addr; array[4] = (byte)(p_addr >> 8); array[5] = 0; Utilities.m_flags.g_need_to_copy_bl_data = true; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); if (flag) { bool flag2 = Utilities.m_flags.g_bl_data_arrived_event.WaitOne(1000, false); if (flag2 && Utilities.m_flags.bl_buffer[1] == 1 && Utilities.m_flags.bl_buffer[2] == p_byte_count) { for (int i = 6; i < (int)(6 + p_byte_count); i++) { p_data[i - 6] = Utilities.m_flags.bl_buffer[i]; } result = true; } } return(result); }
public static bool Read_BL_Config_Data(ref byte[] p_data) { byte b = 14; bool result = false; byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 6; array[2] = b; array[3] = 0; array[4] = 0; array[5] = 48; Utilities.m_flags.g_need_to_copy_bl_data = true; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); if (flag) { bool flag2 = Utilities.m_flags.g_bl_data_arrived_event.WaitOne(1000, false); if (flag2 && Utilities.m_flags.bl_buffer[1] == 6 && Utilities.m_flags.bl_buffer[2] == b) { for (int i = 6; i < (int)(6 + b); i++) { p_data[i - 6] = Utilities.m_flags.bl_buffer[i]; } result = true; } } return(result); }
public static bool Write_BL_Config_Bytes(ref byte[] p_config_data, ref bool[] p_config_bool) { bool result = true; byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 7; array[2] = 1; array[3] = 0; array[4] = 0; array[5] = 48; for (int i = 0; i < p_config_data.Length; i++) { if (p_config_bool[i]) { array[3] = (byte)i; array[6] = p_config_data[i]; Utilities.m_flags.g_need_to_copy_bl_data = true; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); if (flag) { bool flag2 = Utilities.m_flags.g_bl_data_arrived_event.WaitOne(1000, false); if (flag2 && (Utilities.m_flags.bl_buffer[1] != 7 || Utilities.m_flags.bl_buffer[2] != 1 || Utilities.m_flags.bl_buffer[3] != (byte)i)) { result = false; break; } } } } return(result); }
public static bool Clear_64_Bytes_of_Flash(ushort p_addr) { bool result = false; byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = 1; array[3] = (byte)p_addr; array[4] = (byte)(p_addr >> 8); array[5] = 0; Utilities.m_flags.g_need_to_copy_bl_data = true; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); if (flag) { bool flag2 = Utilities.m_flags.g_bl_data_arrived_event.WaitOne(1000, false); if (flag2 && Utilities.m_flags.bl_buffer[1] == 3 && Utilities.m_flags.bl_buffer[2] == 1 && Utilities.m_flags.bl_buffer[3] == (byte)p_addr) { result = true; } } return(result); }
public static bool Write_32_Bytes_to_Flash(ushort p_addr, ref byte[] p_data) { bool result = false; byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 2; array[2] = 32; array[3] = (byte)p_addr; array[4] = (byte)(p_addr >> 8); array[5] = 0; for (int i = 0; i < 32; i++) { array[6 + i] = p_data[i]; } Utilities.m_flags.g_need_to_copy_bl_data = true; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); if (flag) { bool flag2 = Utilities.m_flags.g_bl_data_arrived_event.WaitOne(1000, false); if (flag2 && Utilities.m_flags.bl_buffer[1] == 2 && Utilities.m_flags.bl_buffer[2] == 32 && Utilities.m_flags.bl_buffer[3] == (byte)p_addr) { result = true; } } return(result); }
public static bool WriteDefaultSettings() { bool result = false; byte[] array = new byte[300]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = 8; array[3] = 129; array[4] = 132; array[5] = 2; array[6] = 66; array[7] = 146; array[8] = 130; array[9] = 31; array[10] = 119; array[11] = 0; bool flag = USBWrite.Send_Script_To_PICkitS(ref array); if (flag) { result = true; } return(result); }
public static bool Write(byte p_slave_addr, uint p_mem_addr, byte p_num_bytes_to_write, ref byte[] p_data_array) { byte[] array = new byte[300]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = (byte)(12 + p_num_bytes_to_write); array[3] = 129; array[4] = 132; array[5] = (byte)(6 + p_num_bytes_to_write); array[6] = p_slave_addr; array[7] = 2; array[8] = (byte)(p_mem_addr >> 16); array[9] = (byte)(p_mem_addr >> 8); array[10] = (byte)p_mem_addr; array[11] = p_num_bytes_to_write; int i; for (i = 0; i < (int)p_num_bytes_to_write; i++) { array[i + 12] = p_data_array[i]; } array[i + 12] = 130; array[i + 13] = 31; array[i + 14] = 119; array[i + 15] = 0; USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); return(USBWrite.Send_Script_To_PICkitS(ref array)); }
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); } } } }
private static bool there_is_room_in_cbuf1(byte p_num_bytes_to_write) { bool result = false; int num = 0; if (p_num_bytes_to_write > 255) { return(result); } if (p_num_bytes_to_write > USBWrite.m_cbuf1_avail_bytes) { while (p_num_bytes_to_write >= USBWrite.m_cbuf1_avail_bytes) { if (num++ >= 6) { break; } USBWrite.m_cbuf1_avail_bytes_mutex.WaitOne(); USBWrite.m_cbuf1_avail_bytes = USBWrite.this_many_bytes_are_actually_available_in_cbuf1(); USBWrite.m_cbuf1_avail_bytes_mutex.ReleaseMutex(); if (p_num_bytes_to_write < USBWrite.m_cbuf1_avail_bytes) { result = true; break; } Thread.Sleep(100); } } else { result = true; } return(result); }
public static bool WriteTripGuardband(byte p_slave_addr, byte p_index, ushort p_trip, ushort p_guardband) { bool result = false; byte[] array = new byte[300]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = 14; array[3] = 129; array[4] = 132; array[5] = 8; array[6] = p_slave_addr; array[7] = 48; array[8] = p_index; array[9] = 1; array[10] = (byte)(p_trip >> 8); array[11] = (byte)p_trip; array[12] = (byte)(p_guardband >> 8); array[13] = (byte)p_guardband; array[14] = 130; array[15] = 31; array[16] = 119; array[17] = 0; USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); if (USBWrite.Send_Script_To_PICkitS(ref array)) { result = true; } return(result); }
public static bool Send_Data_Packet_To_PICkitS(ref byte[] p_data) { bool result = true; lock (USBWrite.m_priv_write_buffer_lock) { if (USBWrite.m_we_are_in_write_loop && (Utilities.m_flags.HID_DeviceReady != false)) { for (int i = 0; i < Utilities.m_flags.write_buffer.Length; i++) { Utilities.m_flags.write_buffer[i] = p_data[i]; } USBWrite.m_ready_to_write_event.Set(); if (!USBWrite.m_have_written_event.WaitOne(3000, false)) { issue_Tell_Host_PKSA_Needs_Reset(); } if (USBWrite.There_Was_A_Write_Error()) { result = false; } } else { string.Format("Error writing to USB device", new object[0]); result = false; } } return(result); }
public static bool Create_User_Defined_Sensor_Group(byte p_sensor_count, ref byte[] p_sensor_array) { byte[] buffer = new byte[0x41]; buffer[0] = 0; buffer[1] = 0x21; buffer[2] = p_sensor_count; for (int i = 3; i < (p_sensor_count + 3); i++) { buffer[i] = p_sensor_array[i - 3]; } buffer[p_sensor_count + 3] = 0; bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref buffer); byte num2 = 0; byte[] buffer2 = new byte[0x11]; flag = Read_User_Defined_Sensor_Group(ref num2, ref buffer2); if (flag && (num2 == p_sensor_count)) { for (int j = 0; j < p_sensor_count; j++) { if (buffer2[j] != p_sensor_array[j]) { return(false); } } } return(flag); }
public static bool Send_LED_State_Cmd(int p_LED_num, byte p_value) { byte[] array = new byte[65]; Array.Clear(array, 0, array.Length); array[1] = 3; array[2] = 2; switch (p_LED_num) { case 1: array[3] = 18; break; case 2: array[3] = 19; break; default: return(false); } array[4] = p_value; array[5] = 0; bool result = USBWrite.Send_Data_Packet_To_PICkitS(ref array); USBWrite.Update_Status_Packet(); return(result); }
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_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 Send_Bytes(byte p_num_bytes_to_write, ref byte[] p_data_array, ref string p_script_view) { if (p_num_bytes_to_write > 253) { return(false); } byte[] array = new byte[300]; Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = (byte)(4 + p_num_bytes_to_write); array[3] = 193; array[4] = p_num_bytes_to_write; int i; for (i = 0; i < (int)p_num_bytes_to_write; i++) { array[i + 5] = p_data_array[i]; } array[i + 5] = 31; array[i + 6] = 119; array[i + 7] = 0; p_script_view = "[SB]"; string text = string.Format("[{0:X2}]", array[4]); p_script_view += text; for (i = 0; i < (int)p_num_bytes_to_write; i++) { text = string.Format("[{0:X2}]", array[i + 5]); p_script_view += text; } USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); return(USBWrite.Send_Script_To_PICkitS(ref array)); }
public static bool Send_USART_Cmd(byte p_byte_count, ref byte[] p_data, ref string p_script_view) { byte[] array = new byte[255]; int num = 5; p_script_view = ""; if (p_byte_count > 247) { return(false); } Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = (byte)(p_byte_count + 4); array[3] = 130; array[4] = p_byte_count; string text = string.Format("[{0:X2}]", p_byte_count); for (int i = 0; i < (int)p_byte_count; i++) { array[num++] = p_data[i]; text = string.Format("[{0:X2}]", p_data[i]); p_script_view += text; } array[num++] = 31; array[num++] = 119; array[num] = 0; return(USBWrite.Send_Script_To_PICkitS(ref array)); }
public static bool Send_Data(byte p_byte_count, ref byte[] p_data_array, ref string p_script_view) { byte[] array = new byte[310]; int index = 5; int num2 = 0; string str = ""; p_script_view = ""; if (p_byte_count > 0xfb) { return(false); } Array.Clear(array, 0, array.Length); array[0] = 0; array[1] = 3; array[2] = (byte)(p_byte_count + 4); array[3] = 130; array[4] = p_byte_count; str = string.Format("[{0:X2}]", p_byte_count); for (num2 = 0; num2 < p_byte_count; num2++) { array[index++] = p_data_array[num2]; str = string.Format("[{0:X2}]", p_data_array[num2]); p_script_view = p_script_view + str; } array[index++] = 0x1f; array[index++] = 0x77; array[index] = 0; return(USBWrite.Send_Script_To_PICkitS(ref array)); }
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 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)); }
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 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); }