Unable to control GPIOs pin in nrf7002DK

Hello,

For my project I need to control 3 gpios pins. I already found difficult to find gpios that were not already used internally.
I decided to use the gpio0 - 8,9,10 they were used by spi4 but since I don't need it for my project I disabled it 

Here's the overlay : 


&spi4 {
    status = "disabled";
};


&gpio0 {
    status = "okay";
};

&gpio1 {
    status = "okay";
};
/ {

    aliases {
        redpin = &red_pin;
        greenpin = &green_pin;
        bluepin = &blue_pin;
    };

    rgb_leds {
        compatible = "gpio-leds";
        red_pin: red_pin {
            gpios = <&gpio1 3  GPIO_ACTIVE_HIGH>;
            label = "RGB Red Pin";
        };
        green_pin: green_pin {
            gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
            label = "RGB Green Pin";
        };
        blue_pin: blue_pin {
            gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
            label = "RGB Blue Pin";
        };
    };

};

In my code I init these gpios : 

    if (!gpio_is_ready_dt(&red_led)) {
        LOG_ERR("Red LED GPIO device not ready");
        return -ENODEV;
    }

    if (!gpio_is_ready_dt(&green_led)) {
        LOG_ERR("Green LED GPIO device not ready");
        return -ENODEV;
    }

    if (!gpio_is_ready_dt(&blue_led)) {
        LOG_ERR("Blue LED GPIO device not ready");
        return -ENODEV;
    }

    ret = gpio_pin_configure_dt(&red_led, GPIO_OUTPUT);
    if (ret < 0) {
        LOG_ERR("Failed to configure red LED pin: %d", ret);
        return ret;
    }

    ret = gpio_pin_configure_dt(&green_led, GPIO_OUTPUT);
    if (ret < 0) {
        LOG_ERR("Failed to configure green LED pin: %d", ret);
        return ret;
    }

    ret = gpio_pin_configure_dt(&blue_led, GPIO_OUTPUT);
    if (ret < 0) {
        LOG_ERR("Failed to configure blue LED pin: %d", ret);
        return ret;
    }


And here I set the GPIOS : 

    gpio_pin_set_dt(&red_led, 1);
    gpio_pin_set_dt(&green_led, 1);
    gpio_pin_set_dt(&blue_led, 1);
    k_msleep(1);

    int res = gpio_pin_get_dt(&red_led);
    LOG_INF("Red LED pin state when set to 1: %d", res);

    res = gpio_pin_get_dt(&green_led);
    LOG_INF("Green LED pin state when set to 1: %d", res);

    res = gpio_pin_get_dt(&blue_led);
    LOG_INF("Blue LED pin state when set to 1: %d", res);

And the corresponding logs : 

[00:00:17.750,518] <inf> led: Red LED pin state when set to 1: 0
[00:00:17.750,518] <inf> led: Green LED pin state when set to 1: 0
[00:00:17.750,549] <inf> led: Blue LED pin state when set to 1: 0

I really don't understand what im missing, i tried on different gpios and the result is the same, i cannot control it

Thanks in advance for any help

Parents Reply
  • So i shorted the bridges, now i'm doing this : 

        int ret = gpio_pin_set_dt(&red_led, 0);
        if (ret < 0) {
            LOG_ERR("Failed to set red LED: %d", ret);
        }
    
    
        gpio_pin_toggle_dt(&red_led);
        LOG_ERR("First Red led toggle: %d\n", gpio_pin_get_dt(&red_led));
        k_msleep(1000);
        gpio_pin_toggle_dt(&red_led);
        LOG_ERR("Second Red led toggle: %d\n", gpio_pin_get_dt(&red_led));
        k_msleep(1000);

    And i always get 0, I dont understand

Children
Related