Пример #1
0
        private void BwErase(object sender, DoWorkEventArgs e)
        {
            e.Result = -1;
            var worker = new XNAND();

            if (!worker.IsOk)
            {
                return;
            }
            e.Result = -2;
            if (!BwInit(ref worker))
            {
                return;
            }
            e.Result = -3;
            BwArgs args;

            if (e.Argument is BwArgs)
            {
                args = e.Argument as BwArgs;
            }
            else
            {
                return;
            }
            var nandopt = BwFixArgs(ref args, ref worker);

            progressbar.Maximum = (int)(args.StartBlock + args.BlockCount);
            SetInfo(args.StartBlock, args.BlockCount, (int)(args.StartBlock + args.BlockCount - 1));
            XNAND.Erase((int)args.StartBlock, (int)(args.StartBlock + args.BlockCount - 1), ref nandopt);
            e.Result = 0;
        }
Пример #2
0
        bool BwInit(ref XNAND worker)
        {
            var config = XNAND.FlashDataInit();

            if (config > 0)
            {
                flashconfigbox.Text = string.Format("0x{0:X8}", config);
                XNAND.SetConfig(config);
                return(true);
            }
            flashconfigbox.Text = "";
            return(false);
        }
Пример #3
0
        static XNANDSettings BwFixArgs(ref BwArgs args, ref XNAND worker)
        {
            var nandopt = XNAND.GetSettings();

            if (nandopt == null)
            {
                return(null);
            }
            if (args.BlockCount > nandopt.SizeBlocks - 1)
            {
                args.BlockCount = 0;
            }
            if (args.BlockCount == 0 || args.StartBlock + args.BlockCount > nandopt.SizeBlocks - 1)
            {
                args.BlockCount = nandopt.SizeBlocks - args.StartBlock;
            }
            if (args.Pages == 0)
            {
                args.Pages = nandopt.PagesInBlock * nandopt.SizeBlocks;
            }
            return(nandopt);
        }
Пример #4
0
 bool BwInit(ref XNAND worker) {
     var config = XNAND.FlashDataInit();
     if (config > 0) {
         flashconfigbox.Text = string.Format("0x{0:X8}", config);
         XNAND.SetConfig(config);
         return true;
     }
     flashconfigbox.Text = "";
     return false;
 }
Пример #5
0
 private void BwErase(object sender, DoWorkEventArgs e)
 {
     e.Result = -1;
     var worker = new XNAND();
     if (!worker.IsOk)
         return;
     e.Result = -2;
     if (!BwInit(ref worker))
         return;
     e.Result = -3;
     BwArgs args;
     if (e.Argument is BwArgs)
         args = e.Argument as BwArgs;
     else
         return;
     var nandopt = BwFixArgs(ref args, ref worker);
     progressbar.Maximum = (int)(args.StartBlock + args.BlockCount);
     SetInfo(args.StartBlock, args.BlockCount, (int)(args.StartBlock + args.BlockCount - 1));
     XNAND.Erase((int)args.StartBlock, (int)(args.StartBlock + args.BlockCount - 1), ref nandopt);
     e.Result = 0;
 }
Пример #6
0
 private void BwRead(object sender, DoWorkEventArgs e)
 {
     e.Result = -1;
     var worker = new XNAND();
     if (!worker.IsOk)
         return;
     e.Result = -2;
     if (!BwInit(ref worker))
         return;
     e.Result = -3;
     BwArgs args;
     if (e.Argument is BwArgs)
         args = e.Argument as BwArgs;
     else
         return;
     var nandopt = BwFixArgs(ref args, ref worker);
     SetInfo(args.StartBlock, args.BlockCount, (int) (args.StartBlock + args.BlockCount - 1));
     XNAND.Read(args.Filename, (int) args.StartBlock, (int) (args.StartBlock + args.BlockCount - 1), args.Mode, ref nandopt);
     e.Result = 0;
 }
Пример #7
0
 static XNANDSettings BwFixArgs(ref BwArgs args, ref XNAND worker)
 {
     var nandopt = XNAND.GetSettings();
     if (nandopt == null)
         return null;
     if (args.BlockCount > nandopt.SizeBlocks - 1)
         args.BlockCount = 0;
     if (args.BlockCount == 0 || args.StartBlock + args.BlockCount > nandopt.SizeBlocks - 1)
         args.BlockCount = nandopt.SizeBlocks - args.StartBlock;
     if (args.Pages == 0)
         args.Pages = nandopt.PagesInBlock * nandopt.SizeBlocks;
     return nandopt;
 }