Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 usb #189

Merged
merged 2 commits into from Feb 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions libtock/usb.c
@@ -1,15 +1,28 @@
#include "usb.h"

int usb_exists(void) {
return command(DRIVER_NUM_USB, 0, 0, 0) >= 0;
return driver_exists(DRIVER_NUM_USB);
}

int usb_subscribe(subscribe_cb callback, void *ud) {
return subscribe(DRIVER_NUM_USB, 0, callback, ud);
subscribe_return_t sval = subscribe2(DRIVER_NUM_USB, 0, callback, ud);
if (sval.success) {
return 0;
} else {
return tock_error_to_rcode(sval.error);
}
}

int usb_enable_and_attach_async(void) {
return command(DRIVER_NUM_USB, 1, 0, 0);
syscall_return_t com = command2(DRIVER_NUM_USB, 1, 0, 0);
if (com.type == TOCK_SYSCALL_SUCCESS) {
return TOCK_SUCCESS;
} else if (com.type > TOCK_SYSCALL_SUCCESS) {
// Returned an incorrect success code
return TOCK_FAIL;
} else {
return tock_error_to_rcode(com.data[0]);
}
}

struct data {
Expand Down