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

libtock: update breaking driver existence check changes #349

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/tests/adc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main(void) {
printf("[Tock] ADC Test\n");

// check if ADC driver exists
if (!adc_is_present()) {
if (!adc_exists()) {
printf("No ADC driver!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/adc_continuous/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main(void) {
printf("[Tock] ADC Continuous Test\n");

// check if ADC driver exists
if (!adc_is_present()) {
if (!adc_exists()) {
printf("No ADC driver!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/adc_single_samples/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(void) {
printf("[Tock] ADC Sample All Channels Test\n");

// check if ADC driver exists
if (!adc_is_present()) {
if (!adc_exists()) {
printf("No ADC driver!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/udp/udp_rx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(void) {
}
;

if (ieee802154_driver_is_present()) {
if (ieee802154_driver_exists()) {
ieee802154_set_address(49138); // Corresponds to the dst mac addr set in kernel
ieee802154_set_pan(0xABCD);
ieee802154_config_commit();
Expand Down
2 changes: 1 addition & 1 deletion libtock/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int adc_set_double_buffer(uint16_t* buffer, uint32_t len) {
return tock_allow_rw_return_to_returncode(rw);
}

bool adc_is_present(void) {
bool adc_exists(void) {
return driver_exists(DRIVER_NUM_ADC);
}

Expand Down
2 changes: 1 addition & 1 deletion libtock/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int adc_set_buffer(uint16_t* buffer, uint32_t length);
int adc_set_double_buffer(uint16_t* buffer, uint32_t length);

// query whether the ADC driver is present
bool adc_is_present(void);
bool adc_exists(void);

// query how many channels are available in the ADC driver
int adc_channel_count(int* count);
Expand Down
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
1 change: 1 addition & 0 deletions libtock/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef enum {
// Returns the number of GPIO pins configured on the board.
int gpio_count(int* count);

bool gpio_exists(void);
int gpio_enable_output(GPIO_Pin_t pin);
int gpio_set(GPIO_Pin_t pin);
int gpio_clear(GPIO_Pin_t pin);
Expand Down
2 changes: 1 addition & 1 deletion libtock/ieee802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const int COMMAND_SEND = 26;
// parameters / return codes are not enough te contain the required data.
unsigned char BUF_CFG[27];

bool ieee802154_driver_is_present(void) {
bool ieee802154_driver_exists(void) {
return driver_exists(RADIO_DRIVER);
}

Expand Down
2 changes: 1 addition & 1 deletion libtock/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
#endif

// Check for presence of the driver
bool ieee802154_driver_is_present(void);
bool ieee802154_driver_exists(void);

// Synchronously enable the 802.15.4 radio. Returns once the radio is fully
// initialized.
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
2 changes: 2 additions & 0 deletions libtock/read_only_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern "C" {
// |-------------------------|
#define READ_ONLY_STATEBUFFER_LEN (4 * 4 + 4 * 4 + 8 * 4)

bool read_only_state_exists(void);

// Get the latest version of the read only state supported by the kernel.
int read_only_state_get_version(void);

Expand Down