Raspberry Pi Pico-W - SDK C/C++ not working - GPIO

180 views Asked by At

I use the Pico W. Other than the mainboard LED (which is routed via Wifi Module) I cannot get any GPIO to work. They are always low.

Also, where is the implementation?
pico-sdk/src/host/hardware_gpio/gpio.c is a bunch of empty functions.

  1. Why? Where is the implementation?
  2. Even if commented out it links correctly, against what? Likely a static lib, which one, where?

This is the code:

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <hardware/gpio.h>

int main() 
{
    const uint ledwifi = 0;
    const uint led1 = 17;
    const uint led2 = 19;
    const uint led3 = 20;
 
    stdio_init_all();
    if(cyw43_arch_init()) 
    {
        printf("Wi-Fi init failed");
        return -1;
    }

    gpio_init(led1);
    gpio_init(led2);
    gpio_init(led3);

    gpio_set_dir(led1, GPIO_OUT);
    gpio_set_dir(led2, GPIO_OUT);
    gpio_set_dir(led3, GPIO_OUT);

    gpio_set_drive_strength(led1, GPIO_DRIVE_STRENGTH_12MA);
    gpio_set_drive_strength(led2, GPIO_DRIVE_STRENGTH_12MA);
    gpio_set_drive_strength(led3, GPIO_DRIVE_STRENGTH_12MA);

    check_gpio_param(led1);
    check_gpio_param(led2);
    check_gpio_param(led3);

    enum gpio_function f1 = gpio_get_function(led1);
    enum gpio_function f2 = gpio_get_function(led2);
    enum gpio_function f3 = gpio_get_function(led3);
    enum gpio_drive_strength ds1 = gpio_get_drive_strength(led1);
    enum gpio_drive_strength ds2 = gpio_get_drive_strength(led2);
    enum gpio_drive_strength ds3 = gpio_get_drive_strength(led3);

    int counter = 0;
    uint state = 0;

    for(;;) 
    {
        counter++;

        cyw43_arch_gpio_put(ledwifi, 1);
        gpio_put(led1, 1); //gpio_set_dir(led1, GPIO_IN); state = gpio_get(led1); gpio_set_dir(led1, GPIO_OUT);
        gpio_put(led2, 1);
        gpio_put(led3, 1);
        // gpio_put_all(1);
        sleep_ms(500);
        printf("High : %d - %u\n", counter, state);

        cyw43_arch_gpio_put(ledwifi, 0);
        gpio_put(led1, 0); //gpio_set_dir(led1, GPIO_IN); state = gpio_get(led1); gpio_set_dir(led1, GPIO_OUT);
        gpio_put(led2, 0);
        gpio_put(led3, 0);
        // gpio_put_all(1);
        sleep_ms(500);
        printf("Low  : %d - %u\n", counter, state);

        printf("1: func: %d drive: %d\n", f1, ds1);
        printf("2: func: %d drive: %d\n", f2, ds2);
        printf("3: func: %d drive: %d\n", f3, ds3);
    }
}

GPIO_FUNC_SIO / GPIO_DRIVE_STRENGTH_12MA
1: func: 5 drive: 3
2: func: 5 drive: 3
3: func: 5 drive: 3 
0

There are 0 answers