//================================================================================================================
// [mk_flash.h]: 
// -. Version: 1.05
// -. Update Data: 2008/12/11
// -. Created by OYS
// -. Revision history:
//   1 <Ver 1.05>: [2008/12/11] 
//    1) flx_ 함수들 추가.
//================================================================================================================

#ifndef _MICOMMON_FLASH_H_
#define _MICOMMON_FLASH_H_

#include "mk_common.h"

// 공통 함수
t_bool	flsCopySect(t_ui32 nSrcSectIdx, t_ui32 nTargSectIdx, t_i32 nSize); // 함수리턴타입을 t_bool 로 변경했습니다. by johyun, Nov/28/2007
void	flsBootup(void);

#if	(_PLATFORM==PLF_miCUBE || _PLATFORM==PLF_miCUBE_E || _PLATFORM==PLF_EtherIP_2)
t_ui32	flsGetSectBaseAddr(t_i32 nSectIdx);
t_bool	flsCheckReady(void);
int		flsReadDword(t_ui32 dwAddr);
void	flsReadDwordMulti(t_ui32 dwAddr, t_ui32 *plBuffer, t_ui32 nSize);
t_f32	flsReadIeeeFlt(t_ui32 dwAddr);
t_f32	flsReadTmsFlt(t_ui32 dwAddr);
void	flsWriteDword(t_ui32 dwAddr, t_ui32 dwData);
void	flsWriteDwordMulti(t_ui32 dwAddr, t_ui32 *plBuffer, t_ui32 nSize);
void	flsWriteIeeeFlt(t_ui32 dwAddr, t_f32 fTmsValue);
void	flsWriteTmsFlt(t_ui32 dwAddr, t_f32 fTmsValue);
t_bool	flsEraseSector(t_ui16 nSectIdx);

t_ui32	flxGetAddrOfSect(t_ui32 nSectIdx);
t_bool	flxCheckReady(void);
t_byte	flxReadByte(t_ui32 ulByteAddr);
void	flxReadByteMulti(t_ui32 ulByteAddr, t_byte *pbyBuffer, t_ui32 nNumData);
t_ui16	flxReadWord(t_ui32 ulByteAddr);
void	flxReadWordMulti(t_ui32 ulByteAddr, t_ui16 *pwBuffer, t_ui32 nNumData);
t_ui32	flxReadDword(t_ui32 ulByteAddr);
void	flxReadDwordMulti(t_ui32 ulByteAddr, t_ui32 *plBuffer, t_ui32 nNumData);
t_f32	flxReadFlt(t_ui32 ulByteAddr);
void	flxWriteByte(t_ui32 ulByteAddr, t_byte byData);
void	flxWriteByteMulti(t_ui32 ulByteAddr, t_byte *pbyBuffer, t_ui32 nNumData);
void	flxWriteWord(t_ui32 ulByteAddr, t_ui16 wData);
void	flxWriteWordMulti(t_ui32 ulByteAddr, t_ui16 *pwBuffer, t_ui32 nNumData);
void	flxWriteDword(t_ui32 ulByteAddr, t_ui32 dwData);
void	flxWriteDwordMulti(t_ui32 ulByteAddr, t_ui32 *plBuffer, t_ui32 nNumData);
void	flxWriteFlt(t_ui32 ulByteAddr, t_f32 fTmsValue);
t_bool	flxEraseSector(t_ui16 nSectIdx);

#elif (_PLATFORM==PLF_EtherIP_1)
void	flsReadDwordMulti(t_ui16 nSectIdx, t_ui32 dwOffsetAddr, t_ui32 *plBuffer, t_ui32 nSize);
t_bool	flsWriteDwordMulti(t_ui16 nSectIdx, t_ui32 dwOffsetAddr, t_ui32 *plBuffer, t_ui32 nSize);
t_i32	flsSetFwVer(t_i32 ver);
t_i32	flsGetFwVer(t_i32 *pver);
t_i32	flsSetFwUpdateCheckData(t_ui16 nSectIdx, t_i32 sign, t_i32 version, t_bool bEraseSect);
t_i32	flsGetFwUpdateCheckData(t_ui16 nSectIdx, t_i32 *psign, t_i32 *pversion);
t_bool	flsEraseSector(t_ui16 nSectIdx, t_bool bDoReadyToErase); // Sector Index 로만 개별 섹터를 삭제하는 함수.
t_bool 	flsEraseSectorByName(t_ui16 nSectName);	// Sector Group 삭제를 포함하며 섹터 Nickname 으로 하나 이상의 섹터를 삭제하는 함수.
#endif

#endif
