This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to config IRQ pin for SPIS in devicetree

I'm working on NCS 1.6.1.

i plan to use a SPIS with an IRQ pin .

i refered to a sample "hci_spi" in SDK , dts is as follows.

&spi1 {
compatible = "nordic,nrf-spis";
status = "okay";
sck-pin = <0xa>;
mosi-pin = <0xb>;
miso-pin = <0xc>;
csn-pin = <0xd>;
def-char = <0x00>;
spis1: bt-hci@0 {
compatible = "zephyr,bt-hci-spi-slave";
reg = <0>;
irq-gpios = <&gpio0 0xe (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
};
};

and i simply use following gpio_dt_spec to get the pin.

   static const struct gpio_dt_spec irq = GPIO_DT_SPEC_GET(DT_NODELABEL(spis1), irq_gpios);

It basically works,

but if i deleted the "compatible" item or modified the content of the "compatible"("zephyr,bt-hci-spi-slave"), the compiling errors at  the GPIO_DT_SPEC_GET.

so i wonder how to get rid of the "zephyr,bt-hci-spi-slave" since i don't use this spis for HCI.

actually i'm not sure if this is the standard way to config IRQ pin for spis, if there's any standard way, please give me a sample.

Parents
  • i'm not sure how to use interrupts to substitute irq-gpios. i use gpio_pin_set(irq.port,irq.pin,1) to control the pin:

    it needs gpio device and pin, which can be fetched from irq-gpios.

    but how to express &gpio0 in interrupts?

    interrupts = <&gpio0 0xe > ?

  • Hi! My apologies, my previous comment was misleading.

    The interrupt property just sets the IRQ priority. The Button sample in Zephyr demonstrates how to add an interrupt pin. 

    You can add a subnode in your device tree, like the button subnode:

    button2: button_2 {
    	gpios = <&gpio0 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    	label = "Push button 1";

    Then use gpio_pin_interrupt_configure_dt() to configure a GPIO as an interrupt:

    static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw0), gpios,{0});	
    ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
    ret = gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_TO_ACTIVE);

    Then initialize and add a call back:

    gpio_init_callback(&button_cb_data, button_pressed, BIT(button.pin));
    gpio_add_callback(button.port, &button_cb_data);

  • I tried this, however, if the gpios is put in the subnode in &spi, building reports error at the GPIO_DT_SPEC_GET.

    &spi1 {
    compatible = "nordic,nrf-spis";

    spis1: bt-hci@0 {
    reg = <0>;
    gpios = <&gpio0 0xe (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
    };
    };

  • I've found how to add the gpios.

    just need to create a folder dts/bindings in project root folder and create a custom binding yaml file in the folder. 

  • Yes, you can't use any binding. The button node for instance uses gpio-keys. Creating your own binding is a good solution if none of the existing ones (see gpio bindings) fit your application needs.

Reply Children
No Data
Related