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

SDK 16.0.0, nrf_drv_twi.h, something wrong in the code

sdk 16.0.0, nrf_drv_twi.h, line 477:

#if (NRFX_CHECK(TWI0_ENABLED) && NRFX_CHECK(TWI0_USE_EASY_DMA)) || \
(NRFX_CHECK(TWI1_ENABLED) && NRFX_CHECK(TWI1_USE_EASY_DMA))
#define NRF_DRV_TWI_WITH_TWIM
#endif
#if (NRFX_CHECK(TWI0_ENABLED) && !NRFX_CHECK(TWI0_USE_EASY_DMA)) || \
(NRFX_CHECK(TWI1_ENABLED) && !NRFX_CHECK(TWI1_USE_EASY_DMA))
#define NRF_DRV_TWI_WITH_TWI
#endif

It used the same condition to check if its NRF_DRV_TWI_WITH_TWIM or NRF_DRV_TWI_WITH_TWI. Shouldn't the NRF_DRV_TWI_WITH_TWIM use NRFX_TWIM0_ENABLED to check? 

Thanks,

Parents
  • TWI and TWIM are the same peripheral only with or without DMA. The check is for whether the physical peripheral is enabled and if DMA is enabled or not. 

    The NRFX layer is written to be an HW interface for higher abstraction layers, f.ex. RTOS'es, where it is not common to distinguish between TWI_0 and TWIM_0, but rather use a single entity with different configurations, ie. TWI_0 with/without DMA, as is the case for Zephyr. 

    The check you've posted works perfectly fine, it will distinguish between TWI and TWIM, ofc you have to KNOW that you will need to set TWI0_ENABLED event though you use TWIM. The NRFX layer will be a bit strange when it's used out of context. 

Reply
  • TWI and TWIM are the same peripheral only with or without DMA. The check is for whether the physical peripheral is enabled and if DMA is enabled or not. 

    The NRFX layer is written to be an HW interface for higher abstraction layers, f.ex. RTOS'es, where it is not common to distinguish between TWI_0 and TWIM_0, but rather use a single entity with different configurations, ie. TWI_0 with/without DMA, as is the case for Zephyr. 

    The check you've posted works perfectly fine, it will distinguish between TWI and TWIM, ofc you have to KNOW that you will need to set TWI0_ENABLED event though you use TWIM. The NRFX layer will be a bit strange when it's used out of context. 

Children
No Data
Related