Files
mop3/usb/usb.c
kamkow1 1ea7b4171e
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 1m26s
Build documentation / build-and-deploy (push) Successful in 1m11s
volumes Move volume management code to a specialized app
2026-04-28 23:21:29 +02:00

45 lines
1021 B
C

#include <cmdline_parser.h>
#include <device_info.h>
#include <devices.h>
#include <malloc.h>
#include <mprintf.h>
#include <process.h>
#include <status.h>
#include <str_status.h>
#include <string.h>
#include <system.h>
#include <volume_info.h>
static bool cmdline_poll = false;
static char cmdline_dev[CMDLINE_OPT_VALUE_MAX];
static struct cmdline_opt cmdline_opts[] = {
CMDLINE_OPT("p", "poll", CMDLINE_OPT_VALUE_BOOL, false, &cmdline_poll),
CMDLINE_OPT("d", "device", CMDLINE_OPT_VALUE_STRING, false, (char*)cmdline_dev),
CMDLINE_END(),
};
static void usb_poll(void) {
for (;;) {
device_do(cmdline_dev, XUSBCTRL_POLL_DRIVER, NULL, NULL, NULL, NULL);
for (volatile int i = 0; i < 1000; i++) {
sched();
#if defined(__x86_64__)
__asm__ volatile("pause" ::: "memory");
#endif
}
}
}
void app_main(void) {
if (cmdline_parse(get_cmdline(), cmdline_opts) < 0) {
mprintf("Failed to parse commandline arguments\n");
return;
}
if (cmdline_poll) {
usb_poll();
}
}