I'm using SDK 15.2 and I'm stuck with trying to use the spi transaction manager to perform a transaction with a variable transmit buffer. Is this possible? It seems like it requires the use of constants for the tx_buffer, tx_length, rx_buffer, and rx_length. While this is certainly doable for sensors and similar SPI devices, it doesn't seem feasible for something like SPI flash or SPI devices with wireless communication where the data needed to be written may not be known before compile time. Below is the code I'm trying to execute, however it gives me an error that initializer elements are not constant. I also tried declaring p_out_data and p_in_data as buffers with global file scope. This worked to eliminate 2 of the 4 initializer element is not constant errors, but it still complained about the length variables. Since the length is variable, I'm not sure how to make that constant.
NRF_SPI_MNGR_DEF(g_spi0_manager, 5, 0);
static nrf_drv_spi_config_t g_spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
// set g_spi_config to appropriate values for the hardware configuration
nrf_spi_mngr_init(&g_spi0_manager, &g_spi_config);
// Here is the function I'm writing that is causing issues due to NRF_SPI_MNGR_TRANSFER "initializer element is not constant"
int32_t spi_hal_manager_read_write(spi_hal_t *p_spi, void *p_out_data, uint8_t out_length, void *p_in_data, uint8_t in_length) { static nrf_spi_mngr_transfer_t const spi_transfer[] = { NRF_SPI_MNGR_TRANSFER(p_out_data, out_length, p_in_data, in_length) };
nrf_spi_mngr_perform(&g_spi0_manager, &g_spi_config, spi_transfer, 1, NULL);
}