Skip to content
Merged
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
36 changes: 17 additions & 19 deletions tests/boards/intel_s1000_crb/src/gpio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,13 @@ void setup_gpio(struct device *gpio_dev)
int ret;

/* Setup GPIO output */
ret = gpio_pin_configure(gpio_dev, GPIO_OUT_PIN, (GPIO_DIR_OUT));
ret = gpio_pin_configure(gpio_dev, GPIO_OUT_PIN, GPIO_OUTPUT_LOW);
if (ret) {
printk("Error configuring " GPIO_NAME "%d!\n", GPIO_OUT_PIN);
}

/* Setup GPIO input, and triggers on rising edge. */
ret = gpio_pin_configure(gpio_dev, GPIO_INT_PIN,
(GPIO_DIR_IN | GPIO_INT |
GPIO_INT_EDGE | GPIO_INT_ACTIVE_HIGH |
GPIO_INT_DEBOUNCE));
ret = gpio_pin_configure(gpio_dev, GPIO_INT_PIN, GPIO_INPUT);
if (ret) {
printk("Error configuring " GPIO_NAME "%d!\n", GPIO_INT_PIN);
}
Expand All @@ -83,9 +80,11 @@ void setup_gpio(struct device *gpio_dev)
printk("Cannot setup callback!\n");
}

ret = gpio_pin_enable_callback(gpio_dev, GPIO_INT_PIN);
ret = gpio_pin_interrupt_configure(gpio_dev, GPIO_INT_PIN,
GPIO_INT_EDGE_RISING);
if (ret) {
printk("Error enabling callback!\n");
printk("Error configuring interrupt on " GPIO_NAME "%d!\n",
GPIO_INT_PIN);
}

/* Disable the GPIO interrupt. It is enabled by default */
Expand All @@ -97,8 +96,6 @@ void gpio_thread(void *dummy1, void *dummy2, void *dummy3)
{
struct device *gpio_dev;
int ret;
int toggle = 1;
u32_t read_val = 0U;

ARG_UNUSED(dummy1);
ARG_UNUSED(dummy2);
Expand All @@ -116,19 +113,20 @@ void gpio_thread(void *dummy1, void *dummy2, void *dummy3)
/* take semaphore */
k_sem_take(&thread_sem, K_FOREVER);

if (toggle) {
toggle = 0;
} else {
toggle = 1;
}

ret = gpio_pin_write(gpio_dev, GPIO_OUT_PIN, toggle);
ret = gpio_pin_toggle(gpio_dev, GPIO_OUT_PIN);
if (ret) {
printk("Error set " GPIO_NAME "%d!\n", GPIO_OUT_PIN);
printk("Cannot toggle " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
}

gpio_pin_read(gpio_dev, GPIO_INT_PIN, &read_val);
printk("Reading "GPIO_NAME"%d = %d\n", GPIO_INT_PIN, read_val);
ret = gpio_pin_get(gpio_dev, GPIO_INT_PIN);
if (ret < 0) {
Copy link
Member

@mnkp mnkp Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this testcase is dedicated to the specific SoC and we know that gpio_pin_get function implemented by gpio_dw driver always returns 0 (as most of the drivers which control on chip GPIO hardware module) from my perspective it would be OK not to do error handling.

printk("Error getting " GPIO_NAME "%d!\n",
GPIO_OUT_PIN);
} else {
printk("Reading "GPIO_NAME"%d = %d\n", GPIO_INT_PIN,
ret);
}

/* let other threads have a turn */
k_sem_give(&thread_sem);
Expand Down