[Help] Enabling Full duplex Transfer mode for SPI

Placeholder Anubhav Rawal
2023-10-20T23:18:22Z

I am trying to turn on the full duplex mode using the udma driver. I took a reference from the [repo found here](https://github.com/openhwgroup/core-v-mcu-demo/blob/main/demo/drivers/source/udma_qspi_driver.c) and the SPI register information from [here](https://docs.openhwgroup.org/projects/core-v-mcu/doc-src/ip-blocks/udma_qspim.html) Can you please share the sequence in which the registers expect to enable the full duplex mode, I have currently setup my code to work as below for an attempt to full duplex R/W,

```
#define WORD_PER_TRANSFER 4 // 1, 2 or 4 is only supported
#define WORD_SIZE 8
.
.
*pcmd++ = kSPIm_Cfg | clk_divisor;
*pcmd++ = ( uint32_t ) kSPIm_SOT | chipSelect; // cs 0
*pcmd++ = kSPIm_TxData | ( ( WORD_PER_TRANSFER << 20 ) |
( ( WORD_SIZE - 1 ) << 16 ) |
( xBytes - 1 ) ); // user size to transfer
*pcmd++ = kSPIm_RxData | ( ( WORD_PER_TRANSFER << 20 ) |
( ( WORD_SIZE - 1 ) << 16 ) |
( xBytes - 1 ) ); // user size recieved
*pcmd++ = ( uint32_t ) kSPIm_FDX | ( xBytes - 1 );
*pcmd++ = ( uint32_t ) kSPIm_EOT | 1; // generate event

iot_spi_handler->udma->tx_saddr = ( uintptr_t ) pdataWrite;
iot_spi_handler->udma->tx_size = xBytes - 1;
iot_spi_handler->udma->tx_cfg_b.datasize = 2;
iot_spi_handler->udma->tx_cfg_b.en = 1;

iot_spi_handler->udma->rx_saddr = ( uintptr_t ) pdataRead;
iot_spi_handler->udma->rx_size = xBytes;
iot_spi_handler->udma->rx_cfg_b.en = 1;

iot_spi_handler->udma->cmd_saddr = ( uintptr_t ) auccmd_tx_write;
iot_spi_handler->udma->cmd_size = ( uint32_t ) ( pcmd -
auccmd_tx_write ) *
sizeof( *pcmd );
iot_spi_handler->udma->cmd_cfg_b.en = 1; // initiate the transfer
.
.
```
I took a reference from the working half duplex example and try to extend it for full duplex example, However, the drive does not work as expected of a full duplex driver.