void spi_read_write(0x1E,0x00) ==> output 0x10 as return value of register read.
Here I want to send value 0x90 as register value in the argument of spi_read_write(0x1E, 0x90) function, after sending this it is retaining 0x10 as a rx_data buffer. Here is my code
static spi_rx_data[2] = {0x00,0x00};
void init(void)
{
spi_read_write(ACCEL_WHO_M_I,0x00); //this is working perfectly
spi_read_write(ACCEL_REG_CTRL0,0x00); //return value spi_rx_data = 0xff,0x10
spi_read_write(ACCEL_REG_CTRL0,0x90); //return value spi_rx_data = 0xff,0x10 also returning 0x10 previous value instead of 0x90
}
void spi_read_write(uint8_t register_pointer, uint8_t register_value)
{
ret_code_t err_code;
uint8_t data[2] ={0};
uint8_t rx_buf;
memset(spi_rx_data,0x00,sizeof(spi_rx_data));
register_pointer |= 0x80;
data[0] = register_pointer;
data[1] = register_value;
err_code = nrf_drv_spi_transfer(&spi, data,sizeof(data), spi_rx_data,sizeof(spi_rx_data));
NRF_LOG_HEXDUMP_INFO(spi_rx_data,sizeof(spi_rx_data));
APP_ERROR_CHECK(err_code);
}