#include <fx2lafw.h>
#include <gpif-acquisition.h>
-__bit gpif_acquiring;
+enum gpif_status gpif_acquiring = STOPPED;
static void gpif_reset_waveforms(void)
{
gpif_init_flowstates();
/* Reset the status. */
- gpif_acquiring = FALSE;
+ gpif_acquiring = STOPPED;
}
static void gpif_make_delay_state(volatile BYTE *pSTATE, uint8_t delay, uint8_t output)
pSTATE[24] = (6 << 3) | (6 << 0);
}
-bool gpif_acquisition_start(const struct cmd_start_acquisition *cmd)
+bool gpif_acquisition_prepare(const struct cmd_start_acquisition *cmd)
{
int i;
volatile BYTE *pSTATE = &GPIF_WAVE_DATA;
/* Populate S1 - the decision point. */
gpif_make_data_dp_state(pSTATE++);
+ /* Update the status. */
+ gpif_acquiring = PREPARED;
+
+ return true;
+}
+
+void gpif_acquisition_start(void)
+{
/* Execute the whole GPIF waveform once. */
gpif_set_tc16(1);
gpif_fifo_read(GPIF_EP2);
/* Update the status. */
- gpif_acquiring = TRUE;
-
- return true;
+ gpif_acquiring = RUNNING;
}
void gpif_poll(void)
{
/* Detect if acquisition has completed. */
- if (gpif_acquiring && (GPIFTRIG & 0x80)) {
+ if ((gpif_acquiring == RUNNING) && (GPIFTRIG & 0x80)) {
/* Activate NAK-ALL to avoid race conditions. */
FIFORESET = 0x80;
SYNCDELAY();
FIFORESET = 0x00;
SYNCDELAY();
- gpif_acquiring = FALSE;
+ gpif_acquiring = STOPPED;
}
}