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

How to get accelerometer value of Thingy:91?

I want to tranceive data to ADXL362 through SPI and refer to this program.

https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi

However, I can't get data.

I only modified tx_buffer value.

void spi_test_send(void)
{
	int err;
	u8_t tx_buffer[1] = {0x00}; // Modified here
	u8_t rx_buffer[1];

	const struct spi_buf tx_buf = {
		.buf = tx_buffer,
		.len = sizeof(tx_buffer)
	};
	const struct spi_buf_set tx = {
		.buffers = &tx_buf,
		.count = 1
	};

	struct spi_buf rx_buf = {
		.buf = rx_buffer,
		.len = sizeof(rx_buffer),
	};
	const struct spi_buf_set rx = {
		.buffers = &rx_buf,
		.count = 1
	};

	err = spi_transceive(accel_spi_dev, &spi_cfg, &tx, &rx);
	if (err) {
		printk("SPI error: %d\n", err);
	} else {
		/* Connect MISO to MOSI for loopback */
		printk("TX sent: 0x%02x\n", tx_buffer[0]);
		printk("RX recv: 0x%02x\n", rx_buffer[0]);
//		tx_buffer[0]++;
	}	
}

Also, I added nrf9160_pca20035_v0_3_0.overlay file.

Any tip?

Related