Skip to content

Commit

Permalink
Update inconsistent driver existence checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir-Rashid committed Oct 3, 2023
1 parent b57f2fc commit 492ddc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 5 additions & 5 deletions libtock/analog_comparator.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ bool analog_comparator_exists(void) {
return driver_exists(DRIVER_NUM_ANALOG_COMPARATOR);
}

int analog_comparator_count(int* count) {
syscall_return_t com = command(DRIVER_NUM_ANALOG_COMPARATOR, 0, 0, 0);
return tock_command_return_u32_to_returncode(com, (uint32_t*) count);
}

int analog_comparator_comparison(uint8_t channel, bool* comparison) {
syscall_return_t com = command(DRIVER_NUM_ANALOG_COMPARATOR, 1, channel, 0);
return tock_command_return_u32_to_returncode(com, (uint32_t*) comparison);
Expand All @@ -25,6 +20,11 @@ int analog_comparator_stop_comparing(uint8_t channel) {
return tock_command_return_novalue_to_returncode(com);
}

int analog_comparator_count(int* count) {
syscall_return_t com = command(DRIVER_NUM_ANALOG_COMPARATOR, 4, 0, 0);
return tock_command_return_u32_to_returncode(com, (uint32_t*) count);
}

int analog_comparator_interrupt_callback(subscribe_upcall callback, void* callback_args) {
subscribe_return_t sub = subscribe(DRIVER_NUM_ANALOG_COMPARATOR, 0, callback, callback_args);
return tock_subscribe_return_to_returncode(sub);
Expand Down
10 changes: 7 additions & 3 deletions libtock/gpio.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "gpio.h"

int gpio_count(int* count) {
syscall_return_t rval = command(GPIO_DRIVER_NUM, 0, 0, 0);
return tock_command_return_u32_to_returncode(rval, (uint32_t*) count);
bool gpio_exists(void) {
return driver_exists(GPIO_DRIVER_NUM);
}

int gpio_enable_output(GPIO_Pin_t pin) {
Expand Down Expand Up @@ -50,6 +49,11 @@ int gpio_disable(GPIO_Pin_t pin) {
return tock_command_return_novalue_to_returncode(rval);
}

int gpio_count(int* count) {
syscall_return_t rval = command(GPIO_DRIVER_NUM, 10, 0, 0);
return tock_command_return_u32_to_returncode(rval, (uint32_t*) count);
}

int gpio_interrupt_callback(subscribe_upcall callback, void* callback_args) {
subscribe_return_t sval = subscribe(GPIO_DRIVER_NUM, 0, callback, callback_args);
return tock_subscribe_return_to_returncode(sval);
Expand Down
6 changes: 5 additions & 1 deletion libtock/read_only_state.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "read_only_state.h"

bool read_only_state_exists(void) {
return driver_exists(READ_ONLY_STATEDRIVER_NUM);
}

int read_only_state_get_version(void) {
syscall_return_t res = command(READ_ONLY_STATEDRIVER_NUM, 0, 0, 0);
syscall_return_t res = command(READ_ONLY_STATEDRIVER_NUM, 1, 0, 0);

if (res.type != TOCK_SYSCALL_SUCCESS_U32) {
return RETURNCODE_ENOSUPPORT;
Expand Down

0 comments on commit 492ddc1

Please sign in to comment.