/*---------------------------------------------------------------------------*
  Project:  NitroSDK - CARD - include
  File:     flash.h

  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: flash.h,v $
  Revision 1.3  2004/11/02 10:07:39  yosizaki
  fix comment.

  Revision 1.2  2004/08/23 10:39:07  yosizaki
  add write-command.
  delete erase-command. (FLASH)

  Revision 1.1  2004/08/18 13:40:54  yosizaki
  (none)

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


#if	!defined(NITRO_CARD_FLASH_H_)
#define NITRO_CARD_FLASH_H_


#include <nitro/types.h>
#include <nitro/card/common.h>
#include <nitro/card/backup.h>


#if	defined(__cplusplus)
extern "C" {
#endif


/* Determines whether or not the currently configured device is EEPROM */
static inline BOOL	CARD_IsBackupFlash(void)
{
	const CARDBackupType	t = CARD_GetCurrentBackupType();
	return	(((t >> CARD_BACKUP_TYPE_DEVICE_SHIFT) &
		CARD_BACKUP_TYPE_DEVICE_MASK) == CARD_BACKUP_TYPE_DEVICE_FLASH);
}

/* Data Read */
static inline BOOL	CARD_ReadFlash(u32 src, void *dst, u32 len)
{
	return	CARD_ReadBackup(src, dst, len);
}
static inline void	CARD_ReadFlashAsync(
	u32 src, void *dst, u32 len, MIDmaCallback callback, void *arg)
{
	CARD_ReadBackupAsync(src, dst, len, callback, arg);
}

/* Data  Write  */
static inline BOOL	CARD_WriteFlash(u32 dst, const void *src, u32 len)
{
	return	CARD_WriteBackup(dst, src, len);
}
static inline void	CARD_WriteFlashAsync(
	u32 dst, const void *src, u32 len, MIDmaCallback callback, void *arg)
{
	CARD_WriteBackupAsync(dst, src, len, callback, arg);
}

/* Data Verify */
static inline BOOL	CARD_VerifyFlash(u32 dst, const void *src, u32 len)
{
	return	CARD_VerifyBackup(dst, src, len);
}
static inline void	CARD_VerifyFlashAsync(
	u32 dst, const void *src, u32 len, MIDmaCallback callback, void *arg)
{
	CARD_VerifyBackupAsync(dst, src, len, callback, arg);
}

/* Data  Write  + Verify */
static inline BOOL	CARD_WriteAndVerifyFlash(u32 dst, const void *src, u32 len)
{
	return	CARD_WriteAndVerifyBackup(dst, src, len);
}
static inline void	CARD_WriteAndVerifyFlashAsync(
	u32 dst, const void *src, u32 len, MIDmaCallback callback, void *arg)
{
	CARD_WriteAndVerifyBackupAsync(dst, src, len, callback, arg);
}


#if	defined(__cplusplus)
} /* extern "C" */
#endif


#endif	/* NITRO_CARD_EEPROM_H_ */
