I cant assign DMA to SPI.
Interresting code spippet looks like below:
Code: Select all
// Configure command phase
SPIDEVICE.user.usr_command = (trans->command_bits) ? 1 : 0;
SPIDEVICE.user2.usr_command_bitlen = trans->command_bits - 1;
SPIDEVICE.user2.usr_command_value = trans->command; // todo: czy przesuwac
// Configure address phase
SPIDEVICE.user.usr_addr = (trans->address_bits) ? 1 : 0;
SPIDEVICE.user1.usr_addr_bitlen = trans->address_bits - 1;
SPIDEVICE.addr = trans->address << (32 - trans->address_bits);
// TX Phase
lldesc_setup_link(dmadesc_tx, trans->tx_buffer, trans->tx_bits, false);
SPIDEVICE.dma_out_link.addr = (int)(&dmadesc_tx[0]) & 0xFFFFF;
SPIDEVICE.dma_out_link.start = 1;
SPIDEVICE.user.usr_mosi_highpart = 0;
// RX Phase
lldesc_setup_link(dmadesc_rx, trans->rx_buffer, trans->rx_bits, true);
SPIDEVICE.dma_in_link.addr = (int)(&dmadesc_rx[0]) & 0xFFFFF;
SPIDEVICE.dma_in_link.start = 1;
SPIDEVICE.user.usr_miso_highpart = 0;
// Configure tx/rx phase
SPIDEVICE.mosi_dlen.usr_mosi_dbitlen = trans->tx_bits-1;
SPIDEVICE.miso_dlen.usr_miso_dbitlen = trans->rx_bits-1;
SPIDEVICE.user.usr_mosi = (trans->tx_buffer == NULL)?0:1;
SPIDEVICE.user.usr_miso = (trans->rx_buffer == NULL)?0:1;
SPIDEVICE.user.doutdin is set to zero (half duplex mode). When I change it to 1 (full duplex) a dead transmission loop occurs (CS low, CLK is ticking, MOSI is zero).
What should I do for starting this DMA?