/*-----------------------------------------------------------------------------------
!
!                              COPYRIGHT 2015 BY
!                            MegaChips Corporation
!
!------------------------------------------------------------------------------------
! These coded instructions, statements, and computer programs include
! intellectual property and know-how belonging to MegaChips
! Corporaiton ("MCC") and its partner companies.
! Therefore, do not use these specifications for any purpose other than
! the purpose
! expressly agreed to by MCCs customer and MCC.  Also, do not duplicate,
! copy,
! or reproduce these specifications, nor reveal these specifications to
! any third party
! without MCCs prior written consent.
!
*/
/*-----------------------------------------------------------------------------------
  FILE        : dma.h
  DESCRIPTION : dma.c header
  Revision    : $Rev: 4 $
  Author      : $Author: shirait $
  Date        : $Date: 2015-09-09 15:19:58 +0900 (豌ｴ, 09 9 2015) $
-----------------------------------------------------------------------------------*/

#ifndef ___DMA_H_INCLUDED___
#define ___DMA_H_INCLUDED___

/********************************************************************************************
include
********************************************************************************************/
#include "dma_reg.h"


/********************************************************************************************
macro
********************************************************************************************/
//
//
// BootCodeサイズを抑えるため、一部マクロ化しています
//
//

/*---------------------------------------------------------------------------
  function  : DMA Stop
  arguments : nonce
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define DMA_Stop()  (DMAR.en = DMAR_EN_STOP)



/*---------------------------------------------------------------------------
  function  : DMA Start
  arguments : direction : I  : Direction
              len       : I  : TransferSize
              cnt       : I  : Block Count
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
//	DMAR.dir = (dir); 
#define DMA_Start(direction, len, cnt) \
	DMAR.dir = (direction); \
	DMAR.tsize = (len); \
	DMAR.tcnt = (cnt)-1; \
	DMAR.en = DMAR_EN_START



/*---------------------------------------------------------------------------
  function  : DMA Start 64ByteGet
  arguments : nonce
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define DMA_CMD60Start()  DMA_Start(DMAR_DIR_E2F, DMAR_SIZE_64Byte, 1)



/*---------------------------------------------------------------------------
  function  : DMA CMD25 Start
  arguments : cnt: I  : Block Count
  return    : void
  detail    : none
--------------------------------------------------------------------------*/
#define DMA_CMD25Start(cnt) DMA_Start(DMAR_DIR_E2F, DMAR_SIZE_512Byte, (cnt))



/********************************************************************************************
prottype
********************************************************************************************/
void DMA_Init(void);

#endif // ___DMA_H_INCLUDED___
