Hello,
The driver is already invoked on startup to enable the LF clock for the Zephyr OS so I don't think it should be neccessary to invoke the driver in the application code. You can use the clock kconfig symbols if you wish to change the LF clock configuration (LFXO is selected by default):
CONFIG_CLOCK_CONTROL_NRF_ACCURACY
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL (=y by default)
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC
You can also use the the following APIs to request and release the HFXO if you have a Bluetooth application:
mpsl_clock_hfclk_release()
But these should only be used if you need a high accuracy HF clock for a particular task. The idle current will stay at ~200 uA if you don't call mpsl_clock_hfclk_release() after you are done with it.
Best regards,
Vidar
Hi,
Thanks for the response!!
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!!
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?