This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DeviceTree Macro: #define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)

Hello,

I am trying to get familiar with the DeviceTree macros and started experimenting ...

So, in the light controller example main.c I replaced this macro

#define ADC_DEVICE_NAME DT_LABEL(DT_INST(0, nordic_nrf_saadc))

with this one

#define ADC_DEVICE_NAME DT_LABEL(DT_NODELABEL(adc0))

and added this in the  .overlay file

adc0: adc@4000E000 {
               compatible = "nordic,nrf-saadc"
               label = "ADC_0";
};

I am now getting this build error,

C:/Zypher/v1.3.0/zephyr/include/devicetree.h:169:36: error: 'DT_N_NODELABEL_adc0_P_label' undeclared (first use in this function); did you mean 'DT_N_NODELABEL_sram0_image'?

What am I doing wrong?

Thank you.

Kind regards

Parents
  • I am trying to learn this myself also. I think the below can do the trick, but it doesn't really explain why your implementation doesn't work, maybe there is some limitations to what you can do in the overlay file. I will see if I can get someone experienced to look into it.

    adc0: &adc{
    	compatible = "nordic,nrf-saadc";
    	label = "ADC_0";
    };

  • Thank you Kenneth but the suggested method did not make any difference. The error is still there.

    I think the problem is not the overlay file but the macro itself

    #define ADC_DEVICE_NAME DT_LABEL(DT_NODELABEL(adc0))

    DT_NODE_LABEL(adc0)) which in turn invokes another macro DT_N_NODELABEL_ and it is this last macro that does not seem to be defined anywhere.

  • I am not sure what example you are using here, I simply modified the \empty_app_core example for the nRF5340. I get similar error as you if I don't add what I linked to the overlay file:

    C:/ncs2/v1.3.1/zephyr/include/devicetree.h:169:36: error: 'DT_N_NODELABEL_adc0_P_label' undeclared (first use in this function); did you mean 'DT_N_NODELABEL_sram0_image'?

    If I add what I linked to nrf5340pdk_nrf5340_cpuapp.overlay then there is no error. Maybe the overlay file is not included in your project?

Reply
  • I am not sure what example you are using here, I simply modified the \empty_app_core example for the nRF5340. I get similar error as you if I don't add what I linked to the overlay file:

    C:/ncs2/v1.3.1/zephyr/include/devicetree.h:169:36: error: 'DT_N_NODELABEL_adc0_P_label' undeclared (first use in this function); did you mean 'DT_N_NODELABEL_sram0_image'?

    If I add what I linked to nrf5340pdk_nrf5340_cpuapp.overlay then there is no error. Maybe the overlay file is not included in your project?

Children
Related