📄 cdax7eep.c
字号:
/* == IDENTIFICATION ========================================================== * * Copyright (C) 2003, TCMC Nuernberg - Philips Semiconductors * * System : VegaFamily * Component : all * Module : DAX * Unit : EEPROM Functions * * @(#) %filespec: cdax7eep.c-10 % *//* == HISTORY ================================================================= * * Name Date Ver Action * ---------------------------------------------------------------------------- * tcmc_asb 12-May-2004 10 compile issue with DAFEATURES==0x10030 * tcmc_asb 7-Apr-2004 9 renamings, move FDR_ATSUBST to cda10cfg.h * tcmc_asb 29-Apr-2003 8 manage diff prog buf sizes (and IF layout) * tcmc_asb 28-Mar-2003 7 CR227: EepWr by byte * tcmc_asb 11-Mar-2003 6 PR223: EepRd, num odd > pg, off even>0, buf even * tcmc_asb 30-Jan-2003 5 rework after code review (add comments) * tcmc_asb 21-Jan-2003 4 PR214: EepRd, straddling dies, even num+off+buf * tcmc_asb 18-Nov-2002 3 PR194: preemptive DAX (do not reenter DAX1_START) * tcmc_asb 14-Oct-2002 1 creation *//*MPM========================================================================== * * ABSTRACT: * * state machines for EEPROM read & write * * * Global functions to be called by other modules: * ----------------------------------------------- * - None * * Module functions to be called by other units: * --------------------------------------------- * - p_dax7_DoEepRd * - p_dax7_DoEepWr * * Unit functions to be called only by this unit: * ---------------------------------------------- * - p_dax7_CalcRemOnPage * - p_dax7_CmpEepReq * - p_dax7_DoEepWrReadPage * - p_dax7_ErEepReq * - p_dax7_RdEepReq * - p_dax7_WrEepReq * *//* == dESIGN ================================================================== * */#define cdax7eep_c#include <cdax0api.h>#if DAX_EE#include <cfdr0fla.h>#include <cdax1fpg.h>/* == GLOBAL DECLARATIONS ======================================= *//* == DEFINITION OF LOCAL CONSTANTS ======================================== *//* == DEFINITION OF LOCAL MACROS =========================================== *//* == DEFINITION OF LOCAL ENUMERATIONS ===================================== *//* == DECLARATION OF LOCAL TYPES =========================================== *//* == DECLARATION OF LOCAL DATA =========================================== *//* == DECLARATION OF LOCAL FUNCTION PROTOTYPES ============================= *//* FUNCTIONAL DESCRIPTION: * * Local function to calculate the remaining bytes on the current page * * GLOBALS * DAX1EEP_PGSZ(fh) r/- size of EEPROM page * DAX1EEP_PGOFF(fh) r/- first relevant byte on page * DAX1EEP_LEN(fh) r/w total remaining num of bytes * * * PARAMETERS * pst_FH i/- pointer fh to file handle structure for EEPROM * return -/o 1..DAX1EEP_PGSZ, byte following last byte to write * * INTERFACE DECLARATION: */u32 p_dax7_CalcRemOnPage (t_dax1_EeHandle *pst_FH){ u32 res; res= DAX1EEP_PGSZ(pst_FH) - DAX1EEP_PGOFF(pst_FH); if (res > DAX1EEP_LEN(pst_FH)){ res= DAX1EEP_LEN(pst_FH); } return res;}/* FUNCTIONAL DESCRIPTION: * * Local function to initiate an FDR (EEPROM) page compare request according * to globals stored for DAX1FH_EEP * * * GLOBALS * DAX1FH_FH(fh) r/- index in array of file handle structures * DAX1FH_SH(fh) -/w sequence handle returned from FDR * DAX1EEP_PAGE(fh) r/- EEPROM page (compare operand) * DAX1EEP_PGSZ(fh) r/- size of EEPROM page * DAX1EEP_EEBUF(fh) r/- data buffer (compare operand) * DAX1EEP_CMP(fh) -/w variable to receive result of comparison * * PARAMETERS * fh=pst_FH i/- pointer fh to file handle structure for EEPROM * * INTERFACE DECLARATION: */void p_dax7_CmpEepReq(t_dax1_EeHandle *pst_FH){ u32 page; page= DAX1EEP_PAGE(pst_FH) + FDR_EE_PGNUM_MIN; DAX1FH_SH(pst_FH)= p_fdr_Register(DAX1FH_FH(pst_FH), page); p_fdr_CheckPageReq(DAX1FH_SH(pst_FH), DAX1EEP_EEBUF(pst_FH) , DAX1EEP_PGSZ(pst_FH), &DAX1EEP_CMP(pst_FH));}/* FUNCTIONAL DESCRIPTION: * * Local function to initiate an FDR (EEPROM) write request according * to globals stored for DAX1FH_EEP * * GLOBALS * DAX1FH_FH(fh) r/- index in array of file handle structures * DAX1FH_SH(fh) -/w sequence handle returned from FDR * DAX1EEP_PAGE(fh) r/- EEPROM page to write to * DAX1EEP_PGSZ(fh) r/- size of EEPROM page * DAX1EEP_EEBUF(fh) r/- data to write * * PARAMETERS * fh=pst_FH i/- pointer fh to file handle structure for EEPROM * off i/- offset within page, * len i/- number of bytes * * INTERFACE DECLARATION: */void p_dax7_WrEepReq(t_dax1_EeHandle *pst_FH, u32 off, u32 len){ u32 page; DAX_VERIFY(off+len <= DAX1EEP_PGSZ(pst_FH), DAXEV_FATAL_DoEepWr, 0); page= DAX1EEP_PAGE(pst_FH) + FDR_EE_PGNUM_MIN; DAX1FH_SH(pst_FH)= p_fdr_Register(DAX1FH_FH(pst_FH), page); p_fdr_WriteS (DAX1FH_SH(pst_FH), off, len, page); p_fdr_WriteReq(DAX1FH_SH(pst_FH), DAX1EEP_EEBUF(pst_FH) + off, len); }/* FUNCTIONAL DESCRIPTION: * * Local function to initiate an FDR (EEPROM) page read request * * GLOBALS * DAX1FH_FH(fh) r/- index in array of file handle structures * DAX1FH_SH(fh) -/w sequence handle returned from FDR * DAX1EEP_PGSZ(fh) r/- size of EEPROM page * * * PARAMETERS * fh=pst_FH i/- pointer fh to file handle structure for EEPROM * offNpage i/- bit 0..15: EEPROM page to read from * bit16..31: offset rel. page to start reading * length i/- number of bytes to read * buf i/o buffer to receive the data * * INTERFACE DECLARATION: */void p_dax7_RdEepReq(t_dax1_EeHandle *pst_FH, u32 offNpage,u32 length,void *buf){ u32 page= offNpage & 0xFFFF; page+= FDR_EE_PGNUM_MIN; DAX1FH_SH(pst_FH)= p_fdr_Register(DAX1FH_FH(pst_FH), page); p_fdr_ReadS (DAX1FH_SH(pst_FH), offNpage>>16, length); p_fdr_ReadReq (DAX1FH_SH(pst_FH), buf, length);}/* FUNCTIONAL DESCRIPTION: * * Local function to initiate an FDR (EEPROM) page erase request according * to parameters stored for DAX1FH_EEP * * * GLOBALS * fh=DAX1FH_EEP r/- pointer to file handle structure for EEPROM * DAX1FH_FH(fh) r/- index in array of file handle structures * DAX1FH_SH(fh) -/w sequence handle returned from FDR * DAX1EEP_PAGE(fh) r/- EEPROM page to erase * * PARAMETERS * fh=pst_FH i/- pointer fh to file handle structure for EEPROM * * INTERFACE DECLARATION: */void p_dax7_ErEepReq(t_dax1_EeHandle *pst_FH){ u32 page; page= DAX1EEP_PAGE(pst_FH) + FDR_EE_PGNUM_MIN; DAX1FH_SH(pst_FH)= p_fdr_Register(DAX1FH_FH(pst_FH), page); p_fdr_EraseReq (DAX1FH_SH(pst_FH), FDREM_SINGLE);}/* FUNCTIONAL DESCRIPTION: * * Local function to initiate an FDR (EEPROM) page read request for * the p_dax7_DoEepWr state machine * * GLOBALS * DAX1EEP_PAGE(fh) r/w EEPROM page to read * DAX1EEP_PGSZ(fh) r/- size of EEPROM page * DAX1EEP_LEN(fh) r/w remaining num of bytes to write * DAX1EEP_UBUF(fh) r/w pointer to user data, moved with DAX1EEP_LEN(fh) * DAX1EEP_EEBUF(fh) -/w EEPROM page buffer to receive the page content * DAX1EEP_EVCBK(fh) r/- return value if done * * * PARAMETERS * fh=pst_FH i/- pointer fh to file handle structure for EEPROM * inc i/- 0/1 to read first/next page * return -/o DAX1EEWR_DOPAGE next state if more to write * DAX1EEP_EVCBK(fh) otherwise * * INTERFACE DECLARATION: */s32 p_dax7_DoEepWrReadPage (t_dax1_EeHandle *pst_FH, u32 inc){ u32 length, page; DAX1EEP_STAT(pst_FH)= 0; // no change for new page page= DAX1EEP_PAGE(pst_FH); if (inc) { // switch to next page, check if end reached page+=inc; DAX1EEP_PAGE(pst_FH)= page; length= p_dax7_CalcRemOnPage(pst_FH); DAX1EEP_PGOFF(pst_FH)= 0; DAX1EEP_UBUF(pst_FH) += length; DAX1EEP_LEN(pst_FH) -= length; if (DAX1EEP_LEN(pst_FH)==0){ return DAX1EEP_EVCBK(pst_FH); // DAX1_DONE or DAXEV_EEP_VERIFY_ERR // --------------------------------------- ready -------> } } p_dax7_RdEepReq(pst_FH, page, DAX1EEP_PGSZ(pst_FH), DAX1EEP_EEBUF(pst_FH)); return DAX1EEWR_DOPAGE; }/* FUNCTIONAL DESCRIPTION: * * This function is the state machine for p_dax_EepReadReq. * * The read is performed in a single FDR operation, if possible. * A split into several FDR reads becomes necessary, if the area to read * is not aligned wrt. odd byte offsets, odd user buffer address, odd length, * or if more than 1 die is involved. * For unaligned parts first the page in question is read into the internal * DAX1EEP_EEBUF(fh) from which the unaligned copy to the user buffer * is performed. * * * GLOBALS * DAX1G_DEVTYPES r/- check if EEPROM is accessible * DAX1EEP_PAGE(fh) r/w EEPROM page to read
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -