Read data from SPI

Hello,
I’m trying to read data from SPI but I’m not able to do that.
The code is:

[code]#include “FreeRTOS.h”
#include “app_error.h”
#include “app_util_platform.h”
#include “boards.h”
#include “bsp.h”
#include “deca_device_api.h”
#include “deca_param_types.h”
#include “deca_regs.h”
#include “deca_types.h”
#include “nordic_common.h”
#include “nrf.h”
#include “nrf_delay.h”
#include “nrf_drv_clock.h”
#include “nrf_drv_spi.h”
#include “nrf_gpio.h”
#include “nrf_log.h”
#include “nrf_uart.h”
#include “port_platform.h”
#include “sdk_config.h”
#include “task.h”
#include “timers.h”
#include “uart.h”
#include <stdlib.h>
#include <string.h>

//-----------------dw1000----------------------------
/DW1000 config function/
static dwt_config_t config = {
5, /* Channel number. /
DWT_PRF_64M, /
Pulse repetition frequency. /
DWT_PLEN_128, /
Preamble length. Used in TX only. /
DWT_PAC8, /
Preamble acquisition chunk size. Used in RX only. /
10, /
TX preamble code. Used in TX only. /
10, /
RX preamble code. Used in RX only. /
0, /
0 to use standard SFD, 1 to use non-standard SFD. /
DWT_BR_6M8, /
Data rate. /
DWT_PHRMODE_STD, /
PHY header mode. /
(129 + 8 - 8) /
SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
};

/* Inter-frame delay period, in milliseconds. */
#define TX_DELAY_MS 1000

/* Index to access to sequence number of the blink frame in the tx_msg array. */
#define BLINK_FRAME_SN_IDX 1

/* Delay from end of transmission to activation of reception, expressed in UWB microseconds (1 uus is 512/499.2 microseconds). See NOTE 2 below. */
#define TX_TO_RX_DELAY_UUS 60

/* Receive response timeout, expressed in UWB microseconds. See NOTE 3 below. */
#define RX_RESP_TO_UUS 5000

/* Default inter-frame delay period, in milliseconds. /
#define DFLT_TX_DELAY_MS 1000
/
Inter-frame delay period in case of RX timeout, in milliseconds.

  • In case of RX timeout, assume the receiver is not present and lower the rate of blink transmission. /
    #define RX_TO_TX_DELAY_MS 3000
    /
    Inter-frame delay period in case of RX error, in milliseconds.
  • In case of RX error, assume the receiver is present but its response has not been received for any reason and retry blink transmission immediately. /
    #define RX_ERR_TX_DELAY_MS 0
    /
    Current inter-frame delay period.
  • This global static variable is also used as the mechanism to signal events to the background main loop from the interrupt handler callbacks,
  • which set it to positive delay values. */
    static int32 tx_delay_ms = -1;

/* Buffer to store received frame. See NOTE 4 below. */
#define FRAME_LEN_MAX 127
static uint8 rx_buffer[FRAME_LEN_MAX];

/* Buffer to store received frame. See NOTE 1 below. */
#define FRAME_LEN_MAX 127
static uint8 rx_buffer[FRAME_LEN_MAX];

/* Hold copy of status register state here for reference so that it can be examined at a debug breakpoint. */
static uint32 status_reg = 0;

/* Hold copy of frame length of frame received (if good) so that it can be examined at a debug breakpoint. */
static uint16 frame_len = 0;

int main(void) {

/*Initialization UART*/
boUART_Init();

/* Reset DW1000 */
reset_DW1000();

/* Set SPI clock to 2MHz */
port_set_dw1000_slowrate();

/* Init the DW1000 */
if (dwt_initialise(DWT_LOADUCODE) == DWT_ERROR) {
	//Init of DW1000 Failed
	while (1) {
	};
}

// Set SPI to 8MHz clock
//port_set_dw1000_fastrate();

/* Configure DW1000. */
dwt_configure(&config);

/* Enable wanted interrupts (TX confirmation, RX good frames, RX timeouts and RX errors). */
dwt_setinterrupt(DWT_INT_TFRS | DWT_INT_RFCG | DWT_INT_RFTO | DWT_INT_RXPTO | DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFSL | DWT_INT_SFDT, 1);

/* Set delay to turn reception on after transmission of the frame. See NOTE 2 below. */
dwt_setrxaftertxdelay(TX_TO_RX_DELAY_UUS);

/* Set response frame timeout. */
dwt_setrxtimeout(RX_RESP_TO_UUS);


/* Setup some LEDs for debug Green and Blue on DWM1001-DEV */
LEDS_CONFIGURE(BSP_LED_0_MASK | BSP_LED_1_MASK | BSP_LED_2_MASK);
LEDS_ON(BSP_LED_0_MASK | BSP_LED_1_MASK | BSP_LED_2_MASK);

/* Loop forever sending frames periodically. */
while (1) {

	volatile uint8 data_from_spi[20];
	dwt_readfromdevice(0x21, 0, 20, &data_from_spi[0]);


	// SEND data_from_spi
}

}[/code]

Thanks in advance
[hr]

In practice, my goal is explained below:

[attachment=127]