Spi2 on a esp32c3 dont send data

can someone help me? why doesn't my spi2 interface send any data? what is configured incorrectly?

/* spi2_enable
*
* return 0: enable_ok
* return 1: enable_error
*
*/
uint8_t spi2_enable()
{
  REG_CLR_BIT( SYSTEM_PERIP_RST_EN0_REG, 1<<6 ); // spi2 rst disable
  REG_SET_BIT( SYSTEM_PERIP_CLK_EN0_REG, 1<<6 ); // spi2 clk enable

  return REG_READ( SPI_DATE_REG ) == 0 ? 1 : 0;
}

uint8_t spi2_disable()
{
  REG_SET_BIT( SYSTEM_PERIP_RST_EN0_REG, 1<<6 ); // spi2 rst enable
  REG_CLR_BIT( SYSTEM_PERIP_CLK_EN0_REG, 1<<6 ); // spi2 clk enable
}

uint8_t spi_write_buffer( uint32_t *uiData, uint8_t uiLength )
{
  if ( uiLength > 16 )
  {
    return 1; // error
  }

  for ( uint8_t x = 0; x < uiLength ; x++ )
  {
    REG_WRITE( SPI_Wn_REG(x), *uiData++ );
  }

  return 0; // all_ok
}

void spi_write_cmd( uint16_t uiCmd, uint8_t uiBitLen )
{
  // set uiCmd and 7 = bitleng
  REG_WRITE( SPI_USER2_REG, ( uiCmd ) | ( ( uiBitLen & 0x0F ) << 28 ) );
}

void spi_enable_cmd()
{
  REG_SET_BIT( SPI_USER_REG, 1 << 31 ); // set this bit to enable the command (CMD) state of an operation
}

void spi_write_addr(uint32_t uiAddr, uint8_t uiBitLen )
{
  REG_WRITE( SPI_ADDR_REG, uiAddr );
  REG_WRITE( SPI_USER1_REG, ( uiBitLen & 0x1F ) << 27 );
}

void spi_enable_addr()
{
  REG_SET_BIT( SPI_USER_REG, 1 << 30 );
}

void spi_enable_dout()
{
  REG_SET_BIT( SPI_USER_REG, 1 << 27 );
}

void spi_set_data_bit_len( uint32_t uiBitLen )
{
  REG_WRITE( SPI_MS_DLEN_REG, uiBitLen & 0x3FFFF );
}

void spi_set_dummy_cycle_len( uint8_t uiCycleLen )
{
  REG_SET_BIT( SPI_USER1_REG, uiCycleLen );
}

void spi_enable_dummy()
{
  REG_SET_BIT( SPI_USER_REG, SPI_USR_DUMMY_bm );
}

void spi_start()
{
  REG_SET_BIT( SPI_CMD_REG, SPI_USR_bm );
}

void spi_set_master_mode()
{
  REG_CLR_BIT( SPI_SLAVE_REG, SPI_SLAVE_MODE_bm );
}

void spi_reset_buffer()
{
  REG_SET_BIT( SPI_DMA_CONF_REG, ( SPI_DMA_AFIFO_RST_bm | SPI_BUF_AFIFO_RST_bm | SPI_RX_AFIFO_RST_bm ) );
}

void spi_set_half_duplex_com()
{
  REG_CLR_BIT( SPI_USER_REG, SPI_DOUTDIN_bm );
}

uint32_t fill[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};

void setup()
{    
  Serial.begin(115200);
  
  spi2_enable();

  spi_write_buffer( fill, 16 );

  REG_CLR_BIT( SPI_USER_REG, SPI_USR_MOSI_HIGHPART_bm ); // use buffer from 0 to 15
  
  spi_set_half_duplex_com();
  spi_set_master_mode();

  spi_write_cmd( 0x01, 7 ); //Transfer Type: Wr_BUF, CMD STATE = 1bit mode, ADDR STATE= 1bit mode, DATA STATE= 1bit mode 
  spi_enable_cmd();

  spi_write_addr( 0x05, 7 );
  spi_enable_addr();

  spi_set_dummy_cycle_len( 7 );
  spi_enable_dummy();

  spi_set_data_bit_len( 7 );

  spi_reset_buffer();

  spi_start();

}

void loop()
{
  
  Serial.println("SPI_BUFFER_0~15: ");

  for ( uint8_t x = 0 ; x < 16 ; x++ )
  {
    Serial.print(REG_READ(SPI_Wn_REG(x)) );
     x < 15 ? Serial.print( ", " ) : Serial.print( "" ) ;
  }
  Serial.println("");

  Serial.println("SPI_CMD_REG (operation active?): ");
  Serial.println( (REG_READ( SPI_CMD_REG  ) & SPI_USR_bm ) >> SPI_USR_bp );

  delay(1000);
}

Is there a reason why you are not using the standard Arduino SPI commands?

yes.. i want to learn how it works :wink:

Sorry, I only know how to use the Arduino and Espressif IDF APIs.
Maybe you should examine the Expressif SPI APIs.

Anyway, thank you for your answer