/**************************************************************************//**
 * @brief
 *   Callback function called when the DMA finishes a transfer.
 * @param channel
 *   The DMA channel that finished.
 * @param primary
 *   Primary or Alternate DMA descriptor
 * @param user
 *   User defined pointer (Not used in this example.)
 *****************************************************************************/
void PingPongTransferCompleteRX(unsigned int channel, bool primary, void *user)
{
  (void) channel;              /* Unused parameter */
  (void) user;                 /* Unused parameter */

//  FillBufferFromSDcard((bool) wavHeader.channels, primary);

  /* Stop DMA if bytecounter is equal to datasize or larger */
  bool stop = false;
  int8_t * buffer;

  /* Set buffer pointer correct ram buffer */
  if (primary)
  {
    buffer = ramBufferDacData0Stereo;
  }
  else /* Alternate */
  {
    buffer = ramBufferDacData1Stereo;
  }
  USB_Transmit((uint8_t *)buffer, 256);
  rxPackets++;
  /* Refresh the DMA control structure */
  DMA_RefreshPingPong(1,
                      primary,
                      false,
                      NULL,
                      NULL,
                      (2 * BUFFERSIZE) - 1,
                      stop);
}
/***************************************************************************//**
* @brief
*   Callback invoked from DMA interrupt handler when DMA transfer has filled
*   an audio in buffer. (I.e. received from ADC.)
*******************************************************************************/
static void guitarDMAInCb(unsigned int channel, bool primary, void *user)
{
  (void) user; /* Unused parameter */
  
  uint16_t *inBuf;
  
  inBuf = primary ? guitarAudioInBuffer1 : guitarAudioInBuffer2;
  
  /* Copy the recieved samples unless we are currently processing */
  if (!processingFFT)
  {
    /* Two channels, and each sample is 2 bytes */
    memcpy(audioToFFTBuffer, inBuf, GUITAR_AUDIO_BUFFER_SAMPLES * 2 * 2);
    dataReadyForFFT = true;
  }
  
  /* Refresh DMA for using this buffer. DMA ping-pong will */
  /* halt if buffer not refreshed in time. */
  DMA_RefreshPingPong(channel,
                      primary,
                      false,
                      NULL,
                      NULL,
                      (GUITAR_AUDIO_BUFFER_SAMPLES * 2) - 1,
                      false);

  guitarMonInCount++;
}
示例#3
0
/***************************************************************************//**
* @brief
*   Callback invoked from DMA interrupt handler when DMA transfer has used
*   an audio out buffer. (I.e. transferred to DAC.)
*******************************************************************************/
static void preampDMAOutCb(unsigned int channel, bool primary, void *user)
{
  (void) user; /* Unused parameter */

  /* Refresh DMA for using this buffer. DMA ping-pong will */
  /* halt if buffer not refreshed in time. */
  DMA_RefreshPingPong(channel,
                      primary,
                      false,
                      NULL,
                      NULL,
                      PREAMP_AUDIO_BUFFER_SIZE - 1,
                      false);

  preampMonOutCount++;
}
/**************************************************************************//**
 * @brief
 *   Callback function called when the DMA finishes a transfer.
 * @param channel
 *   The DMA channel that finished.
 * @param primary
 *   Primary or Alternate DMA descriptor
 * @param user
 *   User defined pointer (Not used in this example.)
 *****************************************************************************/
void PingPongTransferCompleteTX(unsigned int channel, bool primary, void *user)
{
  (void) channel;              /* Unused parameter */
  (void) user;                 /* Unused parameter */

  /* Stop DMA if bytecounter is equal to datasize or larger */
  bool stop = false;

  /* Refresh the DMA control structure */
  DMA_RefreshPingPong(0,
                      primary,
                      false,
                      NULL,
                      NULL,
                              (2 * BUFFERSIZE) - 1,
                      stop);
}
示例#5
0
/***************************************************************************//**
 * @brief
 *  Callback function for UDMA ping-pong transfers.
 ******************************************************************************/
static void DmaPingPongCallback( unsigned int channel, bool primary, void *user )
{
  bool stop = true;
  ChTable_t *ch = &chTable[ channel ];

  (void)user;

  if ( ch->callback != NULL )
  {
    ch->callbackCount++;
    stop = !ch->callback( channel, ch->callbackCount, ch->userParam );
  }

  DMA_RefreshPingPong(  0,
                        primary,
                        false,
                        NULL,
                        NULL,
                        ch->length - 1,
                        stop );
}
示例#6
0
/***************************************************************************//**
* @brief
*   Callback invoked from DMA interrupt handler when DMA transfer has filled
*   an audio in buffer. (I.e. received from ADC.)
*******************************************************************************/
static void preampDMAInCb(unsigned int channel, bool primary, void *user)
{
  (void) user; /* Unused parameter */

  /* Refresh DMA for using this buffer. DMA ping-pong will */
  /* halt if buffer not refreshed in time. */
  DMA_RefreshPingPong(channel,
                      primary,
                      false,
                      NULL,
                      NULL,
                      (PREAMP_AUDIO_BUFFER_SIZE * 2) - 1,
                      false);

  preampMonInCount++;

  /* Indicate buffer to be processed next */
  preampProcessPrimary = primary;

  /* Trigger lower priority interrupt which will process data */
  SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
}
示例#7
0
文件: memmem.c 项目: havardh/bitless
static void dacCb(unsigned int channel, bool primary, void *user)
{
	(void) user;
	DMA_RefreshPingPong(channel, primary, false, NULL, NULL, N-1, false);
}
示例#8
0
文件: memmem.c 项目: havardh/bitless
void transferOutRightComplete(unsigned int channel, bool primary, void *user)
{
	(void) user;
	DMA_RefreshPingPong(channel, primary, false, NULL, NULL, N-1, false);
}