You are here: Forum Home → ANT Developers Forums → ANT Hardware Products → Thread
NRF_DRV_TWI_EVT_ADDRESS_NACK
#define LIS2DH_SAD_W 0x30UL
#define LIS2DH_CS_PIN 27
#define LIS2DH_SDA_PIN 29
#define LIS2DH_SCL_PIN 30
#define TWI_INSTANCE_ID 0
//...
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
ret_code_t err_code;
const nrf_drv_twi_config_t twi_lis2dh_config = {
.scl = LIS2DH_SCL_PIN,
.sda = LIS2DH_SDA_PIN,
.frequency = (nrf_twi_frequency_t)TWI_DEFAULT_CONFIG_FREQUENCY,
.interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY,
.clear_bus_init = TWI_DEFAULT_CONFIG_CLR_BUS_INIT
};
err_code = nrf_drv_twi_init(&m_twi, &twi;_lis2dh_config, twi_handler, NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_twi_enable(&m_twi);
NRF_DRV_TWI_EVT_ADDRESS_NACK
m_xfer_done = false;
uint8_t reg[2] = {LIS2DH_CTRL_REG1, 0xCB};
err_code = nrf_drv_twi_tx(&m_twi, LIS2DH_SAD_W, reg, sizeof(reg), false);
APP_ERROR_CHECK(err_code);
while (m_xfer_done == false);