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

how to use device_get_binding()

device_get_binding() this function has many parameters ,very Incomprehensible to use, in the nordic samples i use debug step by step to find what port what pin to be used ,but cannot find

Parents
  • Hi! 

    I'm not sure what you mean because device_get_binding() only has one parameter:

    const struct device *device_get_binding(const char *name).

    The parameter is the device name you want to get the binding for. 

    However, there are multiple macros that will return the device name, for instance DT_LABEL(node_id), DT_PROP(node_id prop). 

    There are also a lot of macros that return the node identifier. DT_NODELABEL(label) takes the node label as a parameter to return the node_id. DT_ALIAS(alias) uses the alias, DT_PATH(...) uses the node path, and DT_INST(inst, compact) returns the node identified for an instance of a compatible. 

    Is this what you were looking for?

    Best regards,

    Heidi

Reply
  • Hi! 

    I'm not sure what you mean because device_get_binding() only has one parameter:

    const struct device *device_get_binding(const char *name).

    The parameter is the device name you want to get the binding for. 

    However, there are multiple macros that will return the device name, for instance DT_LABEL(node_id), DT_PROP(node_id prop). 

    There are also a lot of macros that return the node identifier. DT_NODELABEL(label) takes the node label as a parameter to return the node_id. DT_ALIAS(alias) uses the alias, DT_PATH(...) uses the node path, and DT_INST(inst, compact) returns the node identified for an instance of a compatible. 

    Is this what you were looking for?

    Best regards,

    Heidi

Children
Related