warning: Macro is deprecated when using gpio_pin_interrupt_configure or gpio_pin_interrupt_configure_dt

Hello, I update the nRF Connect SDK to 2.2.0 on Windows 10 Pro recently. 

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include <zephyr/kernel.h>
#include "common/led.h"
#include "common/colors.h"
#include "door/door.h"
#include <zephyr/logging/log.h>
#include <zephyr/drivers/gpio.h>

#define SLEEP_TIME_MS   3*60*1000


LOG_MODULE_REGISTER(sensor, LOG_LEVEL_DBG);

#define SW0_NODE	DT_ALIAS(sw0)
static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET(SW0_NODE, gpios);


static struct gpio_callback button_cb_data;

int main()
{
	led l;
	
	l.toString();
	if(IS_ENABLED(CONFIG_ENABLE_DOOR_SENSOR_MODULE))
	{
		door d;
		d.toString();
	}
	
	auto ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
	if (ret < 0) {
		LOG_ERR("Button configuration failed");
		return 0;
	}
	ret = gpio_pin_interrupt_configure(button.port, button.pin, GPIO_INT_EDGE_TO_ACTIVE | GPIO_INT_DEBOUNCE);
	if (ret < 0) {
		LOG_ERR("Button interrupt configuration is failed");
		return 0;
	}
	...
}

On line 40, I have a warning:

d:\projects\Nordic\2.2.0\Sensors\Sensors\src\main.cpp:40:20: warning: Macro is deprecated
   40 |         ret = gpio_pin_interrupt_configure(button.port, button.pin, GPIO_INT_EDGE_TO_ACTIVE | GPIO_INT_DEBOUNCE);
      |                    ^~~~~~~~~~~~~~~~~~~~~

I also tried to use gpio_pin_interrupt_configure() and got the same warning. But I checked the Zephyr 3.2.99, https://docs.zephyrproject.org/latest/hardware/peripherals/gpio.html#c.gpio_pin_interrupt_configure it does not mention the function is deprecated I also checked the function declaration, no annotation/comment saying the function is deprecated.

Any suggestion on how to get rid of the warning? Cheers

Parents
  • Hi Rong,

    I just checked a zephyr example in nCS 2.2.0. Indeed, it is showing the "Macro is deprecated" when I use the macro as you are using, that is "gpio_pin_interrupt_configure".

    However, when I use "gpio_pin_interrupt_configure_dt" macro, as is used in the basic zephyr example, there is no warning.

    Snapshot of using both macros, and hence with and without warning, are attached for reference.

    (I commented the line 58 and enabled other macro on line 59)

    image1: with warning 

    image2: without warning

    Hope it helps,

    Regards,

    Naeem

  • Thanks for your reply Naeem :)

    That is very interesting, I tried the function `gpio_pin_interrupt_configure_dt` and then did a `Pristine Build`. The compiler yields the same warning. However, I enabled C++ for the application, here is my prj.conf

    CONFIG_CPLUSPLUS=y
    CONFIG_STD_CPP20=y
    
    CONFIG_BT=y
    CONFIG_CONSOLE_SUBSYS=y
    CONFIG_DEBUG_THREAD_INFO=y
    CONFIG_DEBUG_OPTIMIZATIONS=y
    
    # Logs
    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=y
    # Project specific configurations
    CONFIG_ENABLE_DOOR_SENSOR_MODULE=y

    Is the C++ configuration have anything to do with the macro warning?

  • Hi Rong,

    I don't think so. I have tested with your prj.conf as well (snapshot below). There was no problem related to CPP or the pin interrupt macro. 

Reply Children
Related