polpla, thanks for the code. I have tested block read performance with a simple sketch using card.readBlock() at various SPI speeds and compared with non-DMA with mapleSDfat library. SD block is 512 bytes.
SPI speed DMA non-DMA
1.225MHz 0.8mbs 0.7mbs
4.5MHz 3.3mbs 1.3mbs
9MHz 6.0mbs 1.6mbs
18MHz 8.2mbs 1.6mbs
I don't think you need DMA_CIRC_MODE, and you can get by with just a one byte ack[] array if you disable DMA_MINC_MODE. I tested the library with both of these modifications, and DMA reads still seemed to work.
I also tried simple card.writeBlock() tests which worked with the mapleSDfat library, but I got errors when doing write using the polpla library?? I'm still trying to figure out what's different, as I was going to try to add DMA for writes ??
Here is what I was going to add to Sd2Card::writeData()
#ifdef DO_DMA_WRITE
dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, (uint8_t *)src,
DMA_SIZE_8BITS,
(DMA_MINC_MODE | DMA_FROM_MEM | DMA_TRNS_CMPLT | DMA_TRNS_ERR));
dma_attach_interrupt(DMA1, DMA_CH3, DMAEvent);
dma_set_priority(DMA1, DMA_CH3, DMA_PRIORITY_VERY_HIGH);
dma_set_num_transfers(DMA1, DMA_CH3, 512);
dmaActive = true;
dma_enable(DMA1, DMA_CH3);
while(dmaActive) delayMicroseconds(1);
dma_disable(DMA1, DMA_CH3);
#else
for (uint16_t i = 0; i < 512; i++) {
spiSend(src[i]);
}
#endif