/* ... */
volatile bit got_sud;
+BYTE vendor_command;
static void setup_endpoints(void)
{
/* EP2: Reset the FIFOs. */
/* Note: RESETFIFO() gets the EP number WITHOUT bit 7 set/cleared. */
RESETFIFO(0x02)
+
#ifdef DEBUG
/* Reset the FIFOs of EP6 when in debug mode. */
RESETFIFO(0x06)
#endif
/* EP2: Enable AUTOIN mode. Set FIFO width to 8bits. */
- EP2FIFOCFG = bmAUTOIN | ~bmWORDWIDE;
+ EP2FIFOCFG = bmAUTOIN;
SYNCDELAY();
/* EP2: Auto-commit 512 (0x200) byte packets (due to AUTOIN = 1). */
BOOL handle_vendorcommand(BYTE cmd)
{
/* Protocol implementation */
-
switch (cmd) {
case CMD_START:
- gpif_acquisition_start();
- return TRUE;
- case CMD_STOP:
- GPIFABORT = 0xff;
- /* TODO */
- return TRUE;
- break;
+ /* There is data to receive - arm EP0 */
+ EP0BCL = 0;
case CMD_GET_FW_VERSION:
- /* TODO */
- break;
+ vendor_command = cmd;
+ return TRUE;
default:
/* Unimplemented command. */
break;
REVCTL = bmNOAUTOARM | bmSKIPCOMMIT;
got_sud = FALSE;
+ vendor_command = 0;
/* Renumerate. */
RENUMERATE_UNCOND();
gpif_init_la();
}
-void fx2lafw_run(void)
+void fx2lafw_poll(void)
{
if (got_sud) {
handle_setupdata();
got_sud = FALSE;
}
+
+ if (vendor_command) {
+ switch (vendor_command) {
+ case CMD_GET_FW_VERSION:
+ /* TODO */
+
+ /* Acknowledge the vendor command. */
+ vendor_command = 0;
+ break;
+
+ case CMD_START:
+ if((EP0CS & bmEPBUSY) != 0)
+ break;
+
+ if(EP0BCL == 2) {
+ gpif_acquisition_start(
+ (const struct cmd_start_acquisition*)EP0BUF);
+ }
+
+ /* Acknowledge the vendor command. */
+ vendor_command = 0;
+ break;
+
+ default:
+ /* Unimplemented command. */
+ vendor_command = 0;
+ break;
+ }
+ }
}