microbit v2 zephyr edge connector and DTS use

Hi

I want to develop something simple for BBC microbit V2 using Zephyr, which can switch on or off an external LED connected to pin 0 on the edge connector. I was able to do this using an old version of Zephyr (v1.14) but I'm now trying to work with v3.3.0 and it looks like a lot has changed, not least with the DTS.

The main dts for the bbc_microbit_v2 board includes this definition:

    edge_connector: connector {
        compatible = "microbit,edge-connector";
        #gpio-cells = <2>;
        gpio-map-mask = <0xffffffff 0xffffffc0>;
        gpio-map-pass-thru = <0 0x3f>;
        gpio-map = <0 0 &gpio0 2 0>,    /* P0 */
               <1 0 &gpio0 3 0>,    /* P1 */
               <2 0 &gpio0 4 0>,    /* P2 */
               <3 0 &gpio0 31 0>,   /* P3 */
               <4 0 &gpio0 28 0>,   /* P4 */
               <5 0 &gpio0 14 0>,   /* P5 */
               <6 0 &gpio1 5 0>,    /* P6 */
               <7 0 &gpio0 11 0>,   /* P7 */
               <8 0 &gpio0 10 0>,   /* P8 */
               <9 0 &gpio0 9 0>,    /* P9 */
               <10 0 &gpio0 30 0>,  /* P10 */
               <11 0 &gpio0 23 0>,  /* P11 */
               <12 0 &gpio0 12 0>,  /* P12 */
               <13 0 &gpio0 17 0>,  /* P13 */
               <14 0 &gpio0 1 0>,   /* P14 */
               <15 0 &gpio0 13 0>,  /* P15 */
               <16 0 &gpio1 2 0>,   /* P16 */
               <19 0 &gpio0 26 0>,  /* P19 */
               <20 0 &gpio1 0 0>;   /* P20 */
    };
What's the recommended way to set up and use GPIO with a specific edge connector pin (e.g. pin 2) from C using Zephyr 3.3.0? A sample app that demonstrates this would be very gratefully received.
Thanks
Parents
  • Nordic, you can close this ticket. I found a solution by looking at the line follower sample, which uses the edge-connector.

    bbc_microbit_v2.overlay

    / {

        zephyr,user {

            led-gpios = <&edge_connector 2 GPIO_ACTIVE_HIGH>;

        };

    };

    edge-connector.yaml

    compatible: "edge-connector"
    main.c
    static const struct gpio_dt_spec p2_gpio =

        GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), led_gpios);

    void main(void)

    {

        if (!device_is_ready(p2_gpio.port)) {

            printk("GPIO controller not ready.\n");

            return;

        }

        printk("Success! Pin 2 at your service!");

    }
Reply
  • Nordic, you can close this ticket. I found a solution by looking at the line follower sample, which uses the edge-connector.

    bbc_microbit_v2.overlay

    / {

        zephyr,user {

            led-gpios = <&edge_connector 2 GPIO_ACTIVE_HIGH>;

        };

    };

    edge-connector.yaml

    compatible: "edge-connector"
    main.c
    static const struct gpio_dt_spec p2_gpio =

        GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), led_gpios);

    void main(void)

    {

        if (!device_is_ready(p2_gpio.port)) {

            printk("GPIO controller not ready.\n");

            return;

        }

        printk("Success! Pin 2 at your service!");

    }
Children
No Data
Related