void DMA_RBG_Configure(void)
{
    /* set up DMA channel 0 for the Red LED */
    DMA_ChannelPriority(0,2);
    DMA_ChannelDestination(0,DMA_VirtToPhys(&OC3RS),4);
    DMA_ChannelSource(0,DMA_VirtToPhys(&Red_Duty),4);
    DMA_ChannelTransferSize(0,4);
    DMA_ChannelTransferSource(0,_TIMER_2_IRQ,ON);
    DMA_ChannelAutoEnable(0,ON);
    
    /* set up DMA channel 1 for the Green LED */
    DMA_ChannelPriority(1,1);
    DMA_ChannelDestination(1,DMA_VirtToPhys(&OC2RS),4);
    DMA_ChannelSource(1,DMA_VirtToPhys(&Green_Duty),4);
    DMA_ChannelTransferSize(1,4);
    DMA_ChannelTransferSource(1,_TIMER_2_IRQ,ON);
    DMA_ChannelAutoEnable(1,ON);
    
    /* set up DMA channel 2 for the Blue LED */
    DMA_ChannelPriority(2,0);
    DMA_ChannelDestination(2,DMA_VirtToPhys(&OC1RS),4);
    DMA_ChannelSource(2,DMA_VirtToPhys(&Blue_Duty),4);
    DMA_ChannelTransferSize(2,4);
    DMA_ChannelTransferSource(2,_TIMER_2_IRQ,ON);
    DMA_ChannelAutoEnable(2,ON);
    
    TMR_InterruptTimer2(OFF);
    
    DMA_ChannelEnable(0,ON);
    DMA_ChannelEnable(1,ON);
    DMA_ChannelEnable(2,ON);
}
Пример #2
0
/***************************************************************************//**
 * @brief
 *  Stop an ongoing DMA transfer.
 *
 * @param[in] channelId
 *  The channel Id of the transfer to stop.
 *
 * @return
 *  @ref ECODE_EMDRV_DMADRV_OK on success. On failure an appropriate
 *  DMADRV @ref Ecode_t is returned.
 ******************************************************************************/
Ecode_t DMADRV_StopTransfer( unsigned int channelId )
{
  if ( !initialized )
  {
    return ECODE_EMDRV_DMADRV_NOT_INITIALIZED;
  }

  if ( channelId > EMDRV_DMADRV_DMA_CH_COUNT )
  {
    return ECODE_EMDRV_DMADRV_PARAM_ERROR;
  }

  if ( chTable[ channelId ].allocated == false )
  {
    return ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED;
  }

#if defined( EMDRV_DMADRV_UDMA )
  DMA_ChannelEnable( channelId, false );
#elif defined( EMDRV_DMADRV_LDMA )
  LDMA_StopTransfer( channelId );
#endif

  return ECODE_EMDRV_DMADRV_OK;
}
void DMA_BufferCopy(unsigned long FromAddress, unsigned long ToAddress, unsigned long amount, unsigned char type)
{
    DMA_ChannelDestination(3,DMA_VirtToPhys(ToAddress),amount);
    DMA_ChannelSource(3,DMA_VirtToPhys(FromAddress),amount);
    DMA_ChannelTransferSize(3,amount);
    DMA_TransferType = type;
    DMA_ChannelEnable(3,ON);
    DMA_BufferCopierComplete = FALSE;
    DMA_Force(3); // start the transfer
}