I have a hard time to initial a twi ,I reference the example in the SDK11.0,and I used the board is 10040,I copy the example twi sensor code in my project ,but there is an error when i build it: my code is : const nrf_drv_twi_t m_twi_mma_7660 = NRF_DRV_TWI_INSTANCE(0);
void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
ret_code_t err_code;
static uint8_t m_sample;
switch(p_event->type)
{
case NRF_DRV_TWI_EVT_DONE:
if ((p_event->type == NRF_DRV_TWI_EVT_DONE) &&
(p_event->xfer_desc.type == NRF_DRV_TWI_XFER_TX))
{
if(m_set_mode_done != true)
{
m_set_mode_done = true;
return;
}
m_xfer_done = false;
/* Read 4 bytes from the specified address. */
err_code = nrf_drv_twi_rx(&m_twi_mma_7660, 0x00, (uint8_t*)&m_sample, sizeof(m_sample));
APP_ERROR_CHECK(err_code);
}
else
{
// read_data(&m_sample);
// m_xfer_done = true;
}
break;
default:
break;
}
}
void IIC_init(void)
{
uint32_t err_code;
const nrf_drv_twi_config_t twi_mma_7660_config = {
.scl = ARDUINO_SCL_PIN,
.sda = ARDUINO_SDA_PIN,
.frequency = NRF_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_LOW
};
err_code = nrf_drv_twi_init(&m_twi_mma_7660, &twi_mma_7660_config, twi_handler, NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_twi_enable(&m_twi_mma_7660);
}
and when i build ,the error is :
Build target 'nrf52832_xxaa_s132'
compiling nrf_drv_twi.c...
..\..\..\..\..\..\components\drivers_nrf\twi_master\nrf_drv_twi.c(38): error: #35: #error directive: "Wrong configuration."
#error "Wrong configuration."
..\..\..\..\..\..\components\drivers_nrf\twi_master\nrf_drv_twi.c: 0 warnings, 1 error
compiling iic.c...
".\_build\nrf52832_xxaa_s132.axf" - 1 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:03
And when i double click the error,the cursor is on the file nrf_drv_twi.c :
#if (defined(TWIM_IN_USE) && defined(TWI_IN_USE))
// TWIM and TWI combined
#define CODE_FOR_TWIM(code) if (p_instance->use_easy_dma) { code }
#define CODE_FOR_TWI(code) else { code }
#elif (defined(TWIM_IN_USE) && !defined(TWI_IN_USE))
// TWIM only
#define CODE_FOR_TWIM(code) { code }
#define CODE_FOR_TWI(code)
#elif (!defined(TWIM_IN_USE) && defined(TWI_IN_USE))
// TWI only
#define CODE_FOR_TWIM(code)
#define CODE_FOR_TWI(code) { code }
#else
#error "Wrong configuration."
#endif
the wrong configuration.