This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_twi_schedule with Soft Device returning error

I'm hoping this is just something silly that I've overlooked, but I'm running into an issue: Whenever I try to prompt the scheduling of a TWI transaction an error occurs

What I'm trying to do is initialise the transaction when a certain value is sent to the characteristic. What I'm seeing in the debugger though is an NRF_ERROR_BUSY being generated when doing the app_twi_schedule in the function below (called when the write is made), located within my service file:

void rh_read(void)
{
	//printf("rh read...  ");
	
	static app_twi_transfer_t transfers[] = 
	{
		SHT21_RH_READ(&m_sht21_buffer[0])
	};
	static app_twi_transaction_t const transaction =
	{
	.callback            = rh_read_callback,
	.p_user_data         = NULL,
	.p_transfers         = transfers,
	.number_of_transfers = sizeof(transfers) / sizeof(transfers[0])
	};
	
	APP_ERROR_CHECK(app_twi_schedule(&m_app_twi, &transaction));

}

The documentation says that this error is thrown when the queue is full, but no other twi transactions would have been scheduled at this point. When the slave device is set up it's set up with app_twi_perform, and I see them complete on with my scope.

Here's my TWI setup function:

static void twi_init(void)
{
	ret_code_t err_code;
	
	nrf_drv_twi_config_t const config = {
		.scl						= I2C_SCL,
		.sda						= I2C_SDA,
		.frequency					= NRF_TWI_FREQ_100K,
		.interrupt_priority			= APP_IRQ_PRIORITY_HIGH
	};
	
	APP_TWI_INIT(&m_app_twi, &config, MAX_PENDING_TRANSACTIONS, err_code);
	APP_ERROR_CHECK(err_code);
}

Any idea what's happening here?

Parents Reply Children
No Data
Related