I am attempting to do a simple read from the FEM on the nrf21540-DK board. I should be able to use the zephyr driver with spi3 (or fem_spi) to do a simple read/write from the fem chip correct?
I seem to be able to get the device -
but the gpio don't seem to show up (the following is just done for validation):
There is no other FEM libraries used at this point (that I am aware of )
The project file is essentially
CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_ASYNC=y
Any quick ideas what I am doing wrong ?
This code in its sort of simplest form is the following.
static uint8_t tx_buffer[2];
static uint8_t rx_buffer[2];
static struct spi_config spi_cfg = {
.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB ,
.frequency = 4000000,
.slave = 0,
.cs = {.gpio = MY_SPI_MASTER_CS_DT_SPEC, .delay = 0},
};
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
};
// Reset signal
k_poll_signal_reset(&spi_done_sig);
// Start transaction
int error = spi_transceive_signal(spi_dev, &spi_cfg, &tx, &rx, &spi_done_sig);
if(error != 0){
printk("SPI transceive error: %i\n", error);
return error;
}
// Wait for the done signal to be raised and log the rx buffer
int spi_signaled, spi_result;
do{
k_poll_signal_check(&spi_done_sig, &spi_signaled, &spi_result);
} while(spi_signaled == 0);