48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
#include <device_info.h>
|
|
#include <devices.h>
|
|
#include <malloc.h>
|
|
#include <mprintf.h>
|
|
#include <process.h>
|
|
#include <process_self.h>
|
|
#include <status.h>
|
|
#include <string.h>
|
|
#include <system.h>
|
|
|
|
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);
|
|
}
|
|
}
|