Hello!
I have the following component in my device tree:
pwmdevs {
compatible = "pwm-leds";
pwmTest0: pwm_device_test_0 {
pwms = < &pwm1 0x14 >;
label = "PWM Test";
};
};
aliases {
myDev-pwm = &pwmTest0;
};
I would like to retrieve the PWM device and the associated pin number (pwm1 and 0x14). I tried:
#define NODE DT_LABEL(myDev_pwm) #define PIN DT_GPIO_PIN(NODE, gpios)
Which looks like the code I am using to retrieve a GPIO. But I get an error during compile time.
Currently, I am using the definition in the devicetree.h but it is not ideal:
#define PWM_NODE DT_N_S_soc_S_peripheral_40000000_S_pwm_21000_P_label #define PIN DT_N_S_pwmdevs_S_<alias>_P_pwms_IDX_0_VAL_channelThis gives me the node name "PWM1" and pin number 0x14 as expected and I can use them in my code in order to retrieve the device structure (device_get_binding) and set the PWM pin (pwm_pin_set_cycles)
How can I use the Device Tree macros to retrieve the PWM and associated pin?
Thanks!