I'm trying to operate the ''twi_sensor" example of SDK 15.30, using Kielu5, but the compiler is issuing errors for the syntax of the TWI libraries. From my side I only changed the main source file from c to c++.
The following image shows how I changed the source file from c to c++.
The following errors are the displayed errors once compiled:
compiling nrf_drv_twi.c...
compiling main.c...
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(588): error: #29: expected an expression
.type = (nrfx_twim_xfer_type_t)p_xfer_desc->type,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(589): error: #29: expected an expression
.address = p_xfer_desc->address,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(590): error: #29: expected an expression
.primary_length = p_xfer_desc->primary_length,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(591): error: #29: expected an expression
.secondary_length = p_xfer_desc->secondary_length,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(592): error: #29: expected an expression
.p_primary_buf = p_xfer_desc->p_primary_buf,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(593): error: #29: expected an expression
.p_secondary_buf = p_xfer_desc->p_secondary_buf,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(603): error: #29: expected an expression
.type = (nrfx_twi_xfer_type_t)p_xfer_desc->type,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(604): error: #29: expected an expression
.address = p_xfer_desc->address,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(605): error: #29: expected an expression
.primary_length = p_xfer_desc->primary_length,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(606): error: #29: expected an expression
.secondary_length = p_xfer_desc->secondary_length,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(607): error: #29: expected an expression
.p_primary_buf = p_xfer_desc->p_primary_buf,
..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_twi.h(608): error: #29: expected an expression
.p_secondary_buf = p_xfer_desc->p_secondary_buf,
The above errors are indicating errors in the following lines of the nrf_drv_twi.h, and are pointing to the lines of code in the image below:
ret_code_t result = 0;
if (NRF_DRV_TWI_USE_TWIM)
{
#ifdef TWIM_PRESENT
nrfx_twim_xfer_desc_t const twim_xfer_desc =
{
.type = (nrfx_twim_xfer_type_t)p_xfer_desc->type,
.address = p_xfer_desc->address,
.primary_length = p_xfer_desc->primary_length,
.secondary_length = p_xfer_desc->secondary_length,
.p_primary_buf = p_xfer_desc->p_primary_buf,
.p_secondary_buf = p_xfer_desc->p_secondary_buf,
};
result = nrfx_twim_xfer(&p_instance->u.twim, &twim_xfer_desc, flags);
#endif
}
else if (NRF_DRV_TWI_USE_TWI)
{
#ifdef TWI_PRESENT
nrfx_twi_xfer_desc_t const twi_xfer_desc =
{
.type = (nrfx_twi_xfer_type_t)p_xfer_desc->type,
.address = p_xfer_desc->address,
.primary_length = p_xfer_desc->primary_length,
.secondary_length = p_xfer_desc->secondary_length,
.p_primary_buf = p_xfer_desc->p_primary_buf,
.p_secondary_buf = p_xfer_desc->p_secondary_buf,
};
result = nrfx_twi_xfer(&p_instance->u.twi, &twi_xfer_desc, flags);
#endif
Is there a step by step procedure to use the provided code from the SDK's to be used in C++ compilers ? and how can i rectify the issue I am dealing with?
Thanks