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(); }
private static void fire_and_forget_write() { I2CS.m_write_mutex.WaitOne(); if (I2CS.Write != null) { I2CS.Write((byte)I2CS.m_last_slave_addr_received, (ushort)I2CS.m_slave_array_index, ref I2CS.m_slave_data_array); } I2CS.m_write_mutex.ReleaseMutex(); }
private static void fire_and_forget_receive() { I2CS.m_receive_mutex.WaitOne(); if (I2CS.Receive != null) { I2CS.Receive((byte)I2CS.m_last_slave_addr_received); } I2CS.m_receive_mutex.ReleaseMutex(); }
public static bool Clear_Comm_Errors() { bool result = false; I2CS.reset_buffers(); if (USBWrite.Send_CommReset_Cmd() && USBWrite.Send_Warm_Reset_Cmd()) { result = true; } return(result); }
internal static void issue_event() { if (Utilities.g_i2cs_mode == Utilities.I2CS_MODE.INTERACTIVE) { if (I2CS.m_last_slave_addr_received == I2CS.m_previous_slave_addr_received + 1 && I2CS.m_master_is_waiting_for_data && !I2CS.m_stop_command_issued) { I2CS.issue_read_command(); } else if (I2CS.m_previous_slave_addr_received == 512 && I2CS.m_last_slave_addr_received % 2 != 0 && I2CS.m_master_is_waiting_for_data && !I2CS.m_stop_command_issued) { I2CS.issue_receive_command(); } else if (I2CS.m_previous_slave_addr_received == 512 && I2CS.m_last_slave_addr_received % 2 == 0 && !I2CS.m_master_is_waiting_for_data && I2CS.m_stop_command_issued) { I2CS.issue_write_command(); } else if (I2CS.m_last_slave_addr_received != I2CS.m_previous_slave_addr_received + 1 && !I2CS.m_master_is_waiting_for_data && I2CS.m_previous_slave_addr_received != 512 && I2CS.m_slave_address_was_just_set && !I2CS.m_stop_command_issued) { I2CS.issue_write_command(); USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); } else if (I2CS.m_previous_slave_addr_received != 512 && I2CS.m_last_slave_addr_received != I2CS.m_previous_slave_addr_received + 1 && I2CS.m_last_slave_addr_received % 2 != 0 && I2CS.m_slave_address_was_just_set && !I2CS.m_stop_command_issued) { I2CS.issue_read_command(); USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); } else if (I2CS.m_previous_slave_addr_received != 512 && I2CS.m_last_slave_addr_received % 2 == 0 && I2CS.m_slave_address_was_just_set && !I2CS.m_stop_command_issued) { I2CS.issue_receive_command(); USBRead.Clear_Data_Array(0u); USBRead.Clear_Raw_Data_Array(); } } }
/* * { * [MethodImpl(32)] * add * { * I2CS.Error = (I2CS.GUINotifierError)Delegate.Combine(I2CS.Error, value); * } * [MethodImpl(32)] * remove * { * I2CS.Error = (I2CS.GUINotifierError)Delegate.Remove(I2CS.Error, value); * } * } */ internal static void issue_error() { Basic.Reset_Control_Block(); I2CS.Error(); }
private static void process_i2c_slave_data(ref bool p_error) { I2CS.m_slave_address_was_just_set = false; I2CS.m_master_is_waiting_for_data = false; I2CS.m_stop_command_issued = false; switch (m_raw_cbuf2_data_array[m_cb2_array_tag_index]) { case 0xc0: case 0xc1: case 0xc2: case 0xc7: if ((m_raw_cbuf2_data_array_index - m_cb2_array_tag_index) < 2) { m_we_need_next_packet_to_continue = true; return; } switch (m_raw_cbuf2_data_array[m_cb2_array_tag_index]) { case 0xc0: I2CS.m_previous_slave_addr_received = I2CS.m_last_slave_addr_received; I2CS.m_last_slave_addr_received = m_raw_cbuf2_data_array[(int)((IntPtr)(m_cb2_array_tag_index + 1))]; I2CS.m_slave_address_was_just_set = true; I2CS.issue_event(); goto Label_0131; case 0xc1: add_data_to_cbuf2_data_array(ref m_raw_cbuf2_data_array, m_cb2_array_tag_index + 1, 1); goto Label_0131; case 0xc7: I2CS.issue_error(); goto Label_0131; } break; case 0xc3: m_cb2_array_tag_index++; return; case 0xc4: m_cb2_array_tag_index++; return; case 0xc6: m_cb2_array_tag_index++; I2CS.m_stop_command_issued = true; I2CS.issue_event(); I2CS.reset_buffers(); return; case 200: m_cb2_array_tag_index++; I2CS.m_master_is_waiting_for_data = true; I2CS.issue_event(); return; case 0xc9: case 0xca: if ((m_raw_cbuf2_data_array_index - m_cb2_array_tag_index) < 3) { m_we_need_next_packet_to_continue = true; return; } switch (m_raw_cbuf2_data_array[m_cb2_array_tag_index]) { } m_cb2_array_tag_index += 3; return; case 0xcb: m_cb2_array_tag_index += (uint)(m_raw_cbuf2_data_array[(int)((IntPtr)(m_cb2_array_tag_index + 3))] + 4); return; default: p_error = true; return; } Label_0131: m_cb2_array_tag_index += 2; }