/*---------------------------------------------------------------------------*
  Project:  NitroSDK - MI
  File:     mi_dma_card.c

  Copyright 2003-2004 Nintendo.  All rights reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law.  They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Log: mi_dma_card.c,v $
  Revision 1.2  2004/10/12 02:03:46  yosizaki
  change ~0 to MIi_DMA_TIMING_ANY.

  Revision 1.1  2004/10/11 23:49:01  yosizaki
  (none)

  $NoKeywords: $
 *---------------------------------------------------------------------------*/

#include <nitro.h>
#include "../include/mi_dma.h"


/*---------------------------------------------------------------------------*
  Name:         MIi_CardDmaCopy32

  Description:  CARD DMA copy.
                32bit, sync version.
                (this sets only DMA-control. CARD register must be set after)

  Arguments:    dmaNo   : DMA channel No.
                src     : source address
                dest    : destination address
                size    : transfer size (byte)

  Returns:      None
 *---------------------------------------------------------------------------*/
void MIi_CardDmaCopy32( u32 dmaNo, const void* src, void* dest, u32 size )
{
  vu32* dmaCntp;

  MIi_ASSERT_DMANO( dmaNo );
  MIi_ASSERT_DEST_ALIGN4( dest );
  /* The size is not used in this function, but it is specified for the decision */
  MIi_ASSERT_SRC_ALIGN512( size );
  MIi_WARNING_ADDRINTCM( dest, size );
  (void)size;

#ifdef SDK_ARM9
  /*
   * In CARD, unlike other DMAs, it is not possible to "Arrange the same types in a line".
   * Unified management is done on the call-side CARD library, but since we've taken the
   * trouble to put in a check feature, MIi_DMA_TIMING_ANY is configured to detect the same types.
   */
  MIi_CheckAnotherAutoDMA( dmaNo, MIi_DMA_TIMING_ANY );
#endif
  if ( size == 0 ){ return; }

  MIi_Wait_BeforeDMA( dmaCntp, dmaNo );
  MIi_DmaSetParams( dmaNo, (u32)src, (u32)dest,
    (u32)(MI_CNT_CARDRECV32(4) | MI_DMA_CONTINUOUS_ON) );
  /*
   * Here, the automatic startup only turns ON.
   * It will start up for the first time when commands are configured in the CARD register.
   */
}
