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

Need help to Initialize the below mentioned API

I need to call the API: clock_control_on( const struct device *dev, clock_control_subsys_t sys)
located at the SDK path ncs\v1.6.1\zephyr\drivers\clock_control.
Can you kindly help me on how i need to initialize the API arguments *dev and sys..?
How can i call this particular API so that my LFCLK/HFCLK is turned ON..?
Parents Reply Children
  • Hi,

    Are you looking to use an existing zephyr driver, or create a new one? Either way, the structure will be populated by the DEVICE_DEFINE()/DEVICE_DT_DEFINE() macro in the driver implementation, and the pointer to this structure is then retrieved by the main application through DEVICE_GET()/DEVICE_DT_GET() or device_get_binding(<device name>).

    As an example, you may take a look at the Zephyr fade_led sample (/zephyr/samples/fade_led) to see how it invokes the nrf52's PWM driver:

    Getting the device object from the main application

    "PWM_0" label in <build dir>/zephyr/zephyr.dts

    Device object definition in /zephyr/drivers/pwm/pwm_nrfx.c

  • Hi,

    Thanks  for the quick response!!

    I need to test an API static inline int clock_control_on(const struct device *dev, clock_control_subsys_t sys)
    Can you kindly inform me in the context of this API, clock_control_on( ), how i can create user handle for device *dev so that this API is successfully executed.?
    That is i need to know what to populate in device *dev for the context of clock_control_on( ).?
  • Hi,

    The following code can be used to retreive the device struct for clock:

    	const struct device *clock;
    	
    	clock = device_get_binding("CLOCK");
    	if (clock == NULL) {
    		printk("Clock device not found\n\r");
    	}

    But like mentioned earlier, the clock control driver is already being invoked by the system on startup, and I'm honestly not sure if it it supports multiple users - that is something I need to look into. Could you let me know what you are trying achieve with this?

Related