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

porting from SDK 11

I'm trying to port my project from SDK11 to SDK14. I am having troubles understanding how the drivers supposed to be used.

In the files nrf_peripheralXXX_drv.c there is often a state variable m_state, which is changed when the init or stop function of the according peripheral is called. But I can also start or stop peripherals with calls to lower level functions in nrf_peripheralXXX.h. Then the driver module of the peripheral will never know in which state the peripheral is.

I suppose when using a peripheral those functions shouldn't be used in mixed fashion?

Another question why are there ASSERTs now in all the driver functions. This caused me to rewrite so much of my code over again. Because when I was writing a module which supposed to take over in case of an error I just want to disable the peripherals and there interrupts when not used. In this case, I don't want to know whether the "m_state" of the Comparator is NRF_DRV_STATE_INITIALIZED or NRF_DRV_STATE_POWERED_ON I just want to call

nrf_drv_comp_uninit()

That used to work with SDK11 but now in order to keep this logic, I would have to write a peripheral layer myself where I store the current state of the peripheral and provide a function such as my_comp_uninit() and check there in which state the peripheral is.

I'd just like to understand why this has been put in place?

What would help is having functions in the peripheral drivers such as : m_state = nrf_drv_comp_get_state();

cheers Timur

Related