示例#1
0
        /*
         * [DllImport("User32.dll")]
         * public static extern int MessageBox(int h, string m, string c, int type);
         *
         * [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
         * public static extern int CreateEvent(ref Utilities.SECURITY_ATTRIBUTES SecurityAttributes, int bManualReset, int bInitialState, string lpName);
         *
         * [DllImport("kernel32.dll", SetLastError = true)]
         * public static extern bool WriteFile(IntPtr hFile, byte[] Buffer, int numBytesToWrite, ref int numBytesWritten, int Overlapped);
         *
         * [DllImport("kernel32", SetLastError = true)]
         * public static extern bool ReadFile(IntPtr hFile, byte[] Buffer, int NumberOfBytesToRead, ref int pNumberOfBytesRead, int Overlapped);
         *
         * [DllImport("kernel32.dll", SetLastError = true)]
         * public static extern int ReadFileEx(IntPtr hFile, byte[] lpBuffer, int nNumberOfBytesToRead, ref Utilities.OVERLAPPED lpOverlapped, int lpCompletionRoutine);
         *
         * [DllImport("kernel32.dll")]
         * public static extern int CloseHandle(IntPtr hObject);
         *
         * [DllImport("kernel32.dll")]
         * public static extern bool TerminateThread(IntPtr hThread, uint dwExitCode);
         *
         * [DllImport("kernel32.dll")]
         * public static extern IntPtr OpenThread(Utilities.ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
         *
         * [DllImport("kernel32.dll")]
         * public static extern int WaitForSingleObject(int hHandle, int dwMilliseconds);
         */

        public static void InitializeParams()
        {
            Utilities.m_flags.HID_write_handle      = IntPtr.Zero;
            Utilities.m_flags.HID_read_handle       = IntPtr.Zero;
            Utilities.m_flags.write_buffer          = new byte[65];
            Utilities.m_flags.read_buffer           = new byte[65];
            Utilities.m_flags.bl_buffer             = new byte[65];
            Utilities.m_flags.orbl                  = 65;
            Utilities.m_flags.irbl                  = 65;
            Utilities.m_flags.g_status_packet_mutex = new Mutex(false);
            Utilities.g_comm_mode        = Utilities.COMM_MODE.IDLE;
            Utilities.g_i2cs_mode        = Utilities.I2CS_MODE.DEFAULT;
            Constants.STATUS_PACKET_DATA = new byte[65];
            Mode.configure_run_mode_arrays();
            Utilities.m_flags.g_status_packet_data_update_event = new AutoResetEvent(false);
            Utilities.m_flags.g_data_arrived_event           = new AutoResetEvent(false);
            Utilities.m_flags.g_bl_data_arrived_event        = new AutoResetEvent(false);
            Utilities.m_flags.g_PKSA_has_completed_script    = new AutoResetEvent(false);
            Utilities.m_flags.g_special_status_request_event = new AutoResetEvent(false);
            USBWrite.Initialize_Write_Objects();
            USBRead.Initialize_Read_Objects();
        }
示例#2
0
        public static void Set_Comm_Mode(byte p_comm_mode, byte p_i2cs_mode)
        {
            switch (p_comm_mode)
            {
            case 0:
                Utilities.g_comm_mode = Utilities.COMM_MODE.IDLE;
                return;

            case 1:
                Utilities.g_comm_mode = Utilities.COMM_MODE.I2C_M;
                return;

            case 2:
                Utilities.g_comm_mode = Utilities.COMM_MODE.SPI_M;
                return;

            case 3:
                Utilities.g_comm_mode = Utilities.COMM_MODE.SPI_S;
                return;

            case 4:
                Utilities.g_comm_mode = Utilities.COMM_MODE.USART_A;
                return;

            case 5:
                Utilities.g_comm_mode = Utilities.COMM_MODE.USART_SM;
                return;

            case 6:
                Utilities.g_comm_mode = Utilities.COMM_MODE.USART_SS;
                return;

            case 7:
                Utilities.g_comm_mode = Utilities.COMM_MODE.I2C_S;
                Utilities.g_i2cs_mode = (Utilities.I2CS_MODE)p_i2cs_mode;
                return;

            case 8:
                Utilities.g_comm_mode = Utilities.COMM_MODE.I2C_BBM;
                return;

            case 9:
                Utilities.g_comm_mode = Utilities.COMM_MODE.I2C_SBBM;
                return;

            case 10:
                Utilities.g_comm_mode = Utilities.COMM_MODE.LIN;
                return;

            case 11:
                Utilities.g_comm_mode = Utilities.COMM_MODE.UWIRE;
                return;

            case 12:
                Utilities.g_comm_mode = Utilities.COMM_MODE.MTOUCH2;
                return;

            default:
                Utilities.g_comm_mode = Utilities.COMM_MODE.CM_ERROR;
                return;
            }
        }