Hello Team,
I am using the OT-nRF52840 source and working on the end device. I want to add the I2C(TWI) support in my end application, but as soon as I add any API it shows an error like the undefined reference to `nrfx_twi_init'. However, the TWI's driver is available in the source code. Can someone point me out how can I the driver file to my code? Please check below code snippet for more details:
Downloaded and using the code from https://github.com/openthread/ot-nrf528xx
I am using the file openthread/examples/apps/cli/main.c
#include "../../../../third_party/NordicSemiconductor/nrfx/drivers/include/nrfx_twi.h"
static nrfx_twi_t m_twi;
void twi_handler(nrfx_twi_evt_t const * p_event, void * p_context)
{
}
extern nrfx_err_t nrfx_twi_init(nrfx_twi_t const * p_instance,
nrfx_twi_config_t const * p_config,
nrfx_twi_evt_handler_t event_handler,
void * p_context);
void twi_init()
{
const nrfx_twi_config_t twi_config = {
.scl = 26,
.sda = 27,
.frequency = 100,
.interrupt_priority = 1,
//.clear_bus_init = false
};
m_twi.drv_inst_idx=0;
nrfx_twi_init(&m_twi, &twi_config, twi_handler, NULL);
}
And the error I am getting while compiling:
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: openthread/examples/apps/cli/CMakeFiles/ot-cli-ftd.dir/main.c.obj: in function `twi_init':
main.c:(.text.twi_init+0x26): undefined reference to `nrfx_twi_init'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Thanks,
Hardik