I am using NRF52832.
I met memory allocation issue in nrf_twi_sensor.c.
So, I have question about configuration of TWI Sensor.
Here is my definition for TWI sensor,
#define MAX_PENDING_TRANSACTIONS 33
NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID);
NRF_TWI_SENSOR_DEF(m_nrf_twi_sensor, &m_nrf_twi_mngr, 32);
If MAX_PENDING_TRANSACTION is 33, Is size of buffer in TWI sensor definition should be less or equal to 33? Or Size of buffer in definition of TWI Sensor is not related with that value?
And, If I met "memory is not allocated" issue, Increasing buffer is proper way to solve the issue?
You are correct, the buffer size of the TWI sensor instance must be less than or equal to the TWI manager queue size, i.e the MAX_PENDING_TRANSACTIONS.
Could you post your full code here and the exact error code along with where you get the error, so I can recreate it?
Thanks for clarifying.
I can't post my code here. But, Error is came from code below
In nrf_twi_sensor.c, NRF_ERROR_NO_MEM is returned.
ret_code_t nrf_twi_sensor_read(nrf_twi_sensor_t const * p_instance,
uint8_t * p_data,
ASSERT(p_instance != NULL);
ASSERT(p_data != NULL);
NRF_LOG_INFO("Sensor addr: 0x%02X"
"\r\nRead bytes %d",
nrf_twi_sensor_read_cmd_t * p_cmd =
(nrf_twi_sensor_read_cmd_t *) nrf_balloc_alloc(p_instance->p_pool);
if (p_cmd == NULL)
NRF_LOG_WARNING("Memory not allocated.");