Add GPIO control in overlay

Hi:

   I use NRF9160 and NCS:2.2.0.

  I added IO control in "hello_world" example.

  Add nrf9160dk_nrf9160_ns.overlay

/{
	model = "Nordic nRF9160 DK NRF9160";
	compatible = "nordic,nrf9160-dk-nrf9160";
    GPIOS_CTRL{
        compatible = "gpio-ctrl";
        ctrl1: ctrl_1{
            gpios = < &gpio0 11 0x0 >;
            label = "ctrl 1";
        };         
    };
};

main.c

#define CTRL1_NODE  DT_NODELABEL(ctrl1)
static const struct gpio_dt_spec ctrl1_pin = GPIO_DT_SPEC_GET(CTRL1_NODE, gpios);

void ctrl1_init(void)
{
	int ret;
	if (!device_is_ready(ctrl1_pin.port)) {
		return;
	}
	ret = gpio_pin_configure_dt(&ctrl1_pin, GPIO_OUTPUT_ACTIVE);
	if (ret < 0) {
		return;
	}
	gpio_pin_set_dt(&ctrl1_pin,1);
}
......

But I made an error when build.

Parents Reply Children
No Data
Related