Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_DRV_TWI_INSTANCE error

hi,

       i test my project for i2c sensor module, the debug found have error what there are the following error tips.

..\..\..\swct_application\i2c_sensor_driver.c(14): error:  #20: identifier "NRF_DRV_TWI_INSTANCE_0" is undefined

please tell me set this macro definition where is it ? in sdk_config.h ?

and i have include nrf_drv_twi.c and #include "nrf_drv_twi.h"

my code :

/* TWI instance ID. */
#define TWI_INSTANCE_ID     0

/* Common addresses definition for temperature sensor. */
#define SENSOR_ADDR          (0x78U >> 1)


/* Indicates if operation on TWI has ended. */
static volatile bool m_xfer_done = false;

/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);

Parents
  • Hi,

    It is hard to tell without more information.

    What SDK version is this, and what SoC? (SDK 14.2? nRf52832?)

    Is your application based on an example, if so which example?

    Can you share the full build log?

    Can you share i2c_sensor_driver.c?

    Regards,
    Terje

  • i am using the SDK 15.0.0 , using the i2c_sensor_driver.c,NRF_DRV_TWI_INSTANCE error problem has been resolved.but i  found a question, as follows:

    //twi:

    m_xfer_done = false;
    err_code = nrf_drv_twi_tx(&m_twi, SENSOR_ADDR, reg, sizeof(reg), false);
     APP_ERROR_CHECK(err_code);
     while (m_xfer_done == false);

    //spi:

    KX123_spi_activate_cs();/*no delay*/
     spi_xfer_done = false;  
      APP_ERROR_CHECK(nrf_drv_spi_transfer(&kx123_spi_instance, tx_data, 2, NULL, 0));
      while(!spi_xfer_done);  
       KX123_spi_deactivate_cs();

    i also need to wait for complete flag every time? this way will cause system halted.

Reply
  • i am using the SDK 15.0.0 , using the i2c_sensor_driver.c,NRF_DRV_TWI_INSTANCE error problem has been resolved.but i  found a question, as follows:

    //twi:

    m_xfer_done = false;
    err_code = nrf_drv_twi_tx(&m_twi, SENSOR_ADDR, reg, sizeof(reg), false);
     APP_ERROR_CHECK(err_code);
     while (m_xfer_done == false);

    //spi:

    KX123_spi_activate_cs();/*no delay*/
     spi_xfer_done = false;  
      APP_ERROR_CHECK(nrf_drv_spi_transfer(&kx123_spi_instance, tx_data, 2, NULL, 0));
      while(!spi_xfer_done);  
       KX123_spi_deactivate_cs();

    i also need to wait for complete flag every time? this way will cause system halted.

Children
No Data
Related