Achieved performance goal on DMA

pull/1/head
Steve Lascos 7 years ago
parent 2f5e8e72ee
commit 7c614e6450
  1. 8
      src/AudioEffectAnalogDelay.cpp
  2. 1
      src/AudioEffectAnalogDelay.h
  3. 8
      src/BASpiMemory.cpp

@ -138,7 +138,7 @@ void AudioEffectAnalogDelay::update(void)
if (m_externalMemory && m_memory->getSlot()->isUseDma()) { if (m_externalMemory && m_memory->getSlot()->isUseDma()) {
// Using DMA // Using DMA
unsigned loopCount = 0; unsigned loopCount = 0;
while (m_memory->getSlot()->isReadBusy()) { /*Serial.println(String("RB:") + loopCount); loopCount++; */} while (m_memory->getSlot()->isReadBusy()) {}
} }
// perform the wet/dry mix mix // perform the wet/dry mix mix
@ -148,12 +148,12 @@ void AudioEffectAnalogDelay::update(void)
release(inputAudioBlock); release(inputAudioBlock);
release(m_previousBlock); release(m_previousBlock);
m_previousBlock = blockToOutput; m_previousBlock = blockToOutput;
if (m_externalMemory && m_memory->getSlot()->isUseDma()) { if (m_externalMemory && m_memory->getSlot()->isUseDma()) {
// Using DMA // Using DMA
unsigned loopCount = 0; if (m_blockToRelease) release(m_blockToRelease);
while (m_memory->getSlot()->isWriteBusy()) { /*Serial.println(String("WB:") + loopCount); loopCount++; */} m_blockToRelease = blockToRelease;
} }
if (blockToRelease) release(blockToRelease);
} }
void AudioEffectAnalogDelay::delay(float milliseconds) void AudioEffectAnalogDelay::delay(float milliseconds)

@ -45,6 +45,7 @@ private:
AudioDelay *m_memory = nullptr; AudioDelay *m_memory = nullptr;
size_t m_maxDelaySamples = 0; size_t m_maxDelaySamples = 0;
audio_block_t *m_previousBlock = nullptr; audio_block_t *m_previousBlock = nullptr;
audio_block_t *m_blockToRelease = nullptr;
IirBiQuadFilterHQ *m_iir = nullptr; IirBiQuadFilterHQ *m_iir = nullptr;
// Controls // Controls

@ -372,12 +372,12 @@ void BASpiMemoryDMA::write(size_t address, uint8_t *src, size_t numBytes)
size_t nextAddress = address; size_t nextAddress = address;
while (bytesRemaining > 0) { while (bytesRemaining > 0) {
m_txXferCount = min(bytesRemaining, MAX_DMA_XFER_SIZE); m_txXferCount = min(bytesRemaining, MAX_DMA_XFER_SIZE);
while ( m_txTransfer[1].busy()) {Serial.println("W1");} // wait until not busy while ( m_txTransfer[1].busy()) {} // wait until not busy
m_setSpiCmdAddr(SPI_WRITE_CMD, nextAddress, m_txCommandBuffer); m_setSpiCmdAddr(SPI_WRITE_CMD, nextAddress, m_txCommandBuffer);
m_txTransfer[1] = DmaSpi::Transfer(m_txCommandBuffer, CMD_ADDRESS_SIZE, nullptr, 0, m_cs, TransferType::NO_END_CS); m_txTransfer[1] = DmaSpi::Transfer(m_txCommandBuffer, CMD_ADDRESS_SIZE, nullptr, 0, m_cs, TransferType::NO_END_CS);
m_spiDma->registerTransfer(m_txTransfer[1]); m_spiDma->registerTransfer(m_txTransfer[1]);
while ( m_txTransfer[0].busy()) { Serial.println("W2");} // wait until not busy while ( m_txTransfer[0].busy()) {} // wait until not busy
m_txTransfer[0] = DmaSpi::Transfer(srcPtr, m_txXferCount, nullptr, 0, m_cs, TransferType::NO_START_CS); m_txTransfer[0] = DmaSpi::Transfer(srcPtr, m_txXferCount, nullptr, 0, m_cs, TransferType::NO_START_CS);
m_spiDma->registerTransfer(m_txTransfer[0]); m_spiDma->registerTransfer(m_txTransfer[0]);
bytesRemaining -= m_txXferCount; bytesRemaining -= m_txXferCount;
@ -426,12 +426,12 @@ void BASpiMemoryDMA::read(size_t address, uint8_t *dest, size_t numBytes)
while (bytesRemaining > 0) { while (bytesRemaining > 0) {
m_setSpiCmdAddr(SPI_READ_CMD, nextAddress, m_rxCommandBuffer); m_setSpiCmdAddr(SPI_READ_CMD, nextAddress, m_rxCommandBuffer);
while ( m_rxTransfer[1].busy()) { Serial.println("R1"); } while ( m_rxTransfer[1].busy()) {}
m_rxTransfer[1] = DmaSpi::Transfer(m_rxCommandBuffer, CMD_ADDRESS_SIZE, nullptr, 0, m_cs, TransferType::NO_END_CS); m_rxTransfer[1] = DmaSpi::Transfer(m_rxCommandBuffer, CMD_ADDRESS_SIZE, nullptr, 0, m_cs, TransferType::NO_END_CS);
m_spiDma->registerTransfer(m_rxTransfer[1]); m_spiDma->registerTransfer(m_rxTransfer[1]);
m_rxXferCount = min(bytesRemaining, MAX_DMA_XFER_SIZE); m_rxXferCount = min(bytesRemaining, MAX_DMA_XFER_SIZE);
while ( m_rxTransfer[0].busy()) {Serial.println("R2");} while ( m_rxTransfer[0].busy()) {}
m_rxTransfer[0] = DmaSpi::Transfer(nullptr, m_rxXferCount, destPtr, 0, m_cs, TransferType::NO_START_CS); m_rxTransfer[0] = DmaSpi::Transfer(nullptr, m_rxXferCount, destPtr, 0, m_cs, TransferType::NO_START_CS);
m_spiDma->registerTransfer(m_rxTransfer[0]); m_spiDma->registerTransfer(m_rxTransfer[0]);

Loading…
Cancel
Save