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

Build problem with NRF SDK 12 and EasyDMA

I am a new engineer working with nRF52 and SDK 12 using Makefile project and arm-gcc. I wrote some simple code to try TWI Master and control a i2c slave device. My question is, what Makefile option or other file am I missing to even pull in the support for TWI0_USE_EASY_DMA.

My code and error is copied below. Do I just need to add #define TWI0_USE_EASY_DMA in my Makefile? If yes, why is that not enabled by default? What is a good place to add?

static const nrf_drv_twi_t  m_twi_instance = NRF_DRV_TWI_INSTANCE(0);
nrf_drv_twi_config_t    twi_config = NRF_DRV_TWI_DEFAULT_CONFIG;
twi_config.scl = PIN_SCL;
twi_config.sda = PIN_SDA;
twi_config.frequency = NRF_TWI_FREQ_100K;
twi_config.interrupt_priority = APP_IRQ_PRIORITY_HIGH;

err_code = nrf_drv_twi_init(&m_twi_instance, &twi_config, NULL, NULL);

However, I get a build error as follows:

/nrf-sdk-12/drivers_nrf/twi_master/nrf_drv_twi.h:87:30: error: 'TWI0_USE_EASY_DMA' undeclared here (not in a function)
 .use_easy_dma = CONCAT_3(TWI, id, _USE_EASY_DMA)    \
                          ^
../../../../../lib/nrf-sdk-12//libraries/util/nordic_common.h:77:31: note: in definition of macro 'CONCAT_3_'
#define CONCAT_3_(p1, p2, p3) p1##p2##p3
                           ^
../../../../../lib/nrf-sdk-12//drivers_nrf/twi_master/nrf_drv_twi.h:87:21: note: in expansion of macro 'CONCAT_3'
 .use_easy_dma = CONCAT_3(TWI, id, _USE_EASY_DMA)    \
                 ^
main.c:25:46: note: in expansion of macro 'NRF_DRV_TWI_INSTANCE'
static const nrf_drv_twi_t  m_twi_instance = NRF_DRV_TWI_INSTANCE(0);

And the nrf-sdk-12.mk was modified to add a NRF_FEATURE for TWI as follows:

FEATURE_NRF_TWI_REQUIRES_FEATURES := BASE APP_ERROR DRIVER_COMMON
FEATURE_NRF_TWI_SOURCES := \
   $(NRF_SDK_DIR)/drivers_nrf/twi_master/nrf_drv_twi.c
FEATURE_NRF_TWI_REQUIRES_INCLUDES := \
   $(NRF_SDK_DIR)/drivers_nrf/hal \
   $(NRF_SDK_DIR)/drivers_nrf/twi_master

Thanks a lot to help me get started.

Related