From: Joel Holdsworth Date: Sun, 11 Mar 2012 20:52:53 +0000 (+0000) Subject: Reset EP2 when GPIF acquisition completes X-Git-Tag: sigrok-firmware-fx2lafw-0.1.0~44 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=293d7e9e38e0a69ab8e51ab9601bfb0bd6c5c9b8;p=sigrok-firmware-fx2lafw.git Reset EP2 when GPIF acquisition completes --- diff --git a/fx2lafw.c b/fx2lafw.c index e6c79e41..d4423633 100644 --- a/fx2lafw.c +++ b/fx2lafw.c @@ -270,4 +270,6 @@ void fx2lafw_poll(void) break; } } + + gpif_poll(); } diff --git a/gpif-acquisition.c b/gpif-acquisition.c index b57bcf68..e2fb3b92 100644 --- a/gpif-acquisition.c +++ b/gpif-acquisition.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include @@ -27,6 +28,8 @@ #include #include +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; + } } diff --git a/include/gpif-acquisition.h b/include/gpif-acquisition.h index 77cf8484..d13273c3 100644 --- a/include/gpif-acquisition.h +++ b/include/gpif-acquisition.h @@ -23,3 +23,5 @@ void gpif_init_la(void); void gpif_acquisition_start(const struct cmd_start_acquisition *cmd); + +void gpif_poll(void);