]> sigrok.org Git - sigrok-firmware-fx2lafw.git/commitdiff
Reset EP2 when GPIF acquisition completes
authorJoel Holdsworth <redacted>
Sun, 11 Mar 2012 20:52:53 +0000 (20:52 +0000)
committerJoel Holdsworth <redacted>
Sun, 11 Mar 2012 20:52:53 +0000 (20:52 +0000)
fx2lafw.c
gpif-acquisition.c
include/gpif-acquisition.h

index e6c79e41a7f7a6db9377376e969866ac699571c7..d4423633a56735166c62cec46cd63909204c1944 100644 (file)
--- a/fx2lafw.c
+++ b/fx2lafw.c
@@ -270,4 +270,6 @@ void fx2lafw_poll(void)
                        break;
                }
        }
+
+       gpif_poll();
 }
index b57bcf684090588710b7f1962679ffacf147c400..e2fb3b9267ec3dfbd982bf27d94633ff337c34e2 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <eputils.h>
 #include <fx2regs.h>
 #include <fx2macros.h>
 #include <delay.h>
@@ -27,6 +28,8 @@
 #include <fx2lafw.h>
 #include <gpif-acquisition.h>
 
+bit gpif_acquiring;
+
 static void gpif_reset_waveforms(void)
 {
        int i;
@@ -125,6 +128,9 @@ void gpif_init_la(void)
 
        /* Initialize flowstate registers (not used by us). */
        gpif_init_flowstates();
+
+       /* Reset the status */
+       gpif_acquiring = FALSE;
 }
 
 void gpif_acquisition_start(const struct cmd_start_acquisition *cmd)
@@ -220,4 +226,36 @@ void gpif_acquisition_start(const struct cmd_start_acquisition *cmd)
 
        /* Perform the initial GPIF read. */
        gpif_fifo_read(GPIF_EP2);
+
+       /* Update the status */
+       gpif_acquiring = TRUE;
+}
+
+void gpif_poll(void)
+{
+       /* Detect if acquisition has completed */
+       if(gpif_acquiring && (GPIFTRIG & 0x80))
+       {
+               /* Activate NAK-ALL to avoid race conditions */
+               FIFORESET = 0x80;
+               SYNCDELAY();
+
+               /* Switch to manual mode */
+               EP2FIFOCFG = 0;
+               SYNCDELAY();
+
+               /* Reset EP2 */
+               FIFORESET = 0x02;
+               SYNCDELAY();
+
+               /* Return to auto mode */
+               EP2FIFOCFG = bmAUTOIN;
+               SYNCDELAY();
+
+               /* Release NAK-ALL */
+               FIFORESET = 0x00;
+               SYNCDELAY();
+
+               gpif_acquiring = FALSE;
+       }
 }
index 77cf8484b15f983e45103ac0aacac420ce957158..d13273c3f7e5838a0b06488444f1351d1345861b 100644 (file)
@@ -23,3 +23,5 @@
 void gpif_init_la(void);
 
 void gpif_acquisition_start(const struct cmd_start_acquisition *cmd);
+
+void gpif_poll(void);