#include #include #include #include #include #include #include #include #include void app_main (void) { libprocess_self_init (); char commandbuf[32]; memset (commandbuf, 0, sizeof (commandbuf)); if (env_get (process_get_pgid (), "C", (void*)commandbuf, sizeof (commandbuf)) != ST_OK) { mprintf ("ERROR C=???. No command provided\n"); return; } if (strcmp (commandbuf, "poll") == 0) { struct device_info* infos = malloc (sizeof (struct device_info) * 1024); memset (infos, 0, sizeof (struct device_info) * 1024); int device_count = get_device_info (infos, 1024); for (int dev = 0; dev < device_count; dev++) { struct device_info* info = &infos[dev]; if (info->type != DEVICE_TYPE_USB_CTRL) { continue; } mprintf ("Polling device %s\n", info->key); for (;;) { device_do (info->key, XUSBCTRL_POLL_DRIVER, NULL, NULL, NULL, NULL); for (volatile int i = 0; i < 500; i++) sched (); } } } else { mprintf ("ERROR unknown command %s\n", commandbuf); } }