Пример #1
0
        public void TickleTickle()
        {
            STDFU.DFU_Status dfuStatus = new STDFU.DFU_Status();
            UInt32           Result    = STDFU.STDFU_SelectCurrentConfiguration(ref hDevice, 0, 0, 0);

            Console.WriteLine("SelectConfig Res: " + Result);
            STDFU.STDFU_GetStatus(ref hDevice, ref dfuStatus);
            STDFU.STDFU_ClrStatus(ref hDevice);
            // Console.WriteLine("DFU iString: " + dfuStatus.iString);
            // Console.WriteLine("DFU State: " + dfuStatus.bState);
            // Console.WriteLine("DFU STATUS: " + dfuStatus.bStatus);
            IntPtr strinng = Marshal.AllocHGlobal(256);

            Result = STDFU.STDFU_GetStringDescriptor(ref hDevice, 1, strinng, 256);
            // Console.WriteLine("StringDesc Res: " + Result);

            STDFU.STDFU_GetStatus(ref hDevice, ref dfuStatus);
            STDFU.STDFU_ClrStatus(ref hDevice);
            // Console.WriteLine("DFU iString: " + dfuStatus.iString);
            //Console.WriteLine("DFU State: " + dfuStatus.bState);
            //Console.WriteLine("DFU STATUS: " + dfuStatus.bStatus);
            byte[] bytes = new byte[256];
            Marshal.Copy(strinng, bytes, 0, 256);
            Marshal.FreeHGlobal(strinng);
            Console.WriteLine(Encoding.ASCII.GetString(bytes));
        }
Пример #2
0
        private void EraseSector(UInt32 address)
        {
            UInt32 result = 0;

            byte[] cmd = { 0x41, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };

            cmd[1] = (byte)(address & 0xFF);
            cmd[2] = (byte)((address >> 8) & 0xFF);
            cmd[3] = (byte)((address >> 16) & 0xFF);
            cmd[4] = (byte)((address >> 24) & 0xFF);

            if ((result = STDFU.STDFU_SelectCurrentConfiguration(ref hDevice, 0, 0, 0)) == STDFU.STDFU_NOERROR)
            {
                WaitUntilIdle();

                STDFU.STDFU_Dnload(ref hDevice, cmd, 5, 0);

                WaitUntilIdle();
            }
        }
Пример #3
0
        public string getDeviceDescriptor(uint index = 1)
        {
            STDFU.DFU_Status dfuStatus = new STDFU.DFU_Status();
            UInt32           Result    = STDFU.STDFU_SelectCurrentConfiguration(ref hDevice, 0, 0, 0);

            STDFU.STDFU_GetStatus(ref hDevice, ref dfuStatus);
            STDFU.STDFU_ClrStatus(ref hDevice);

            IntPtr strinng = Marshal.AllocHGlobal(256);

            STDFU.STDFU_GetStringDescriptor(ref hDevice, index, strinng, 256);

            STDFU.STDFU_GetStatus(ref hDevice, ref dfuStatus);
            STDFU.STDFU_ClrStatus(ref hDevice);

            byte[] bytes = new byte[256];
            Marshal.Copy(strinng, bytes, 0, 256);
            Marshal.FreeHGlobal(strinng);
            return(Encoding.ASCII.GetString(bytes));
        }