@@ -623,6 +623,22 @@ static int32_t executeCommand(struct mtd_k64f_data *context)
623
623
}
624
624
625
625
#if ASYNC_OPS
626
+ static inline void launchCommandFromIRQ (const struct mtd_k64f_data * context )
627
+ {
628
+ launchCommand ();
629
+
630
+ while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
631
+ if (failedWithAccessError () || failedWithProtectionError ()) {
632
+ clearErrorStatusBits ();
633
+ if (context -> commandCompletionCallback ) {
634
+ context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , context -> currentCommand );
635
+ }
636
+ return ;
637
+ }
638
+
639
+ enableCommandCompletionInterrupt ();
640
+ }
641
+
626
642
static void ftfe_ccie_irq_handler (void )
627
643
{
628
644
disbleCommandCompletionInterrupt ();
@@ -654,18 +670,7 @@ static void ftfe_ccie_irq_handler(void)
654
670
655
671
/* start the successive program operation */
656
672
setupNextProgramData (context );
657
- launchCommand ();
658
-
659
- while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
660
- if (failedWithAccessError () || failedWithProtectionError ()) {
661
- clearErrorStatusBits ();
662
- if (context -> commandCompletionCallback ) {
663
- context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , ARM_STORAGE_OPERATION_PROGRAM_DATA );
664
- }
665
- return ;
666
- }
667
-
668
- enableCommandCompletionInterrupt ();
673
+ launchCommandFromIRQ (context );
669
674
break ;
670
675
671
676
case ARM_STORAGE_OPERATION_ERASE :
@@ -677,18 +682,7 @@ static void ftfe_ccie_irq_handler(void)
677
682
}
678
683
679
684
setupNextErase (context );
680
- launchCommand ();
681
-
682
- while (!controllerCurrentlyBusy () && !failedWithAccessError () && !failedWithProtectionError ());
683
- if (failedWithAccessError () || failedWithProtectionError ()) {
684
- clearErrorStatusBits ();
685
- if (context -> commandCompletionCallback ) {
686
- context -> commandCompletionCallback (ARM_DRIVER_ERROR_PARAMETER , ARM_STORAGE_OPERATION_ERASE );
687
- }
688
- return ;
689
- }
690
-
691
- enableCommandCompletionInterrupt ();
685
+ launchCommandFromIRQ (context );
692
686
break ;
693
687
694
688
default :
0 commit comments