]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blobdiff - fx2lafw.c
Update README.
[sigrok-firmware-fx2lafw.git] / fx2lafw.c
index f69955161eb18b88aeda21a5775e7c4658e34a78..2a64b84ae8db8de497fe95de85279ed4c0926456 100644 (file)
--- a/fx2lafw.c
+++ b/fx2lafw.c
 #include <fx2regs.h>
 #include <fx2macros.h>
 #include <delay.h>
-#include <autovector.h>
 #include <setupdat.h>
 #include <eputils.h>
 #include <gpif.h>
+#include <fx2lafw.h>
 
 /* Protocol commands */
 #define CMD_SET_SAMPLERATE     0xb0
@@ -272,7 +272,7 @@ static void setup_endpoints(void)
 #endif
        SYNCDELAY();
 
-       /* Disable all other EPs (EP4 and EP8). */
+       /* Disable all other EPs (EP1, EP4, and EP8). */
        EP1INCFG &= ~bmVALID;
        SYNCDELAY();
        EP1OUTCFG &= ~bmVALID;
@@ -355,14 +355,17 @@ BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc)
        /* (2) Reset data toggles of the EPs in the interface. */
        /* Note: RESETTOGGLE() gets the EP number WITH bit 7 set/cleared. */
        RESETTOGGLE(0x82);
-       RESETTOGGLE(0x76);
+#ifdef DEBUG
+       RESETTOGGLE(0x86);
+#endif
 
        /* (3) Restore EPs to their default conditions. */
        /* Note: RESETFIFO() gets the EP number WITHOUT bit 7 set/cleared. */
        RESETFIFO(0x02);
        /* TODO */
-
+#ifdef DEBUG
        RESETFIFO(0x06);
+#endif
 
        /* (4) Clear the HSNAK bit. Not needed, fx2lib does this. */
 
@@ -404,7 +407,7 @@ void hispeed_isr(void) interrupt HISPEED_ISR
        CLEAR_HISPEED();
 }
 
-void main(void)
+void fx2lafw_init(void)
 {
        /* Set DYN_OUT and ENH_PKT bits, as recommended by the TRM. */
        REVCTL = bmNOAUTOARM | bmSKIPCOMMIT;
@@ -435,11 +438,12 @@ void main(void)
 
        /* Perform the initial GPIF read. */
        gpif_fifo_read(GPIF_EP2);
+}
 
-       while (1) {
-               if (got_sud) {
-                       handle_setupdata();
-                       got_sud = FALSE;
-               }
+void fx2lafw_run(void)
+{
+       if (got_sud) {
+               handle_setupdata();
+               got_sud = FALSE;
        }
 }