Fee

1、    上电初始化过程

1.1、   假设

假设FLASH之前没有写过任何数据,也即两个Sector都处于擦除状态,也即意味着从FLASH中读出来的数据全为0xFFu;

假设总共配置了165个BLOCK(包括FEE模块默认的两个BLOCK);

假设每个BLOCK的配置内容中:

number of datasets: 1

instances exponent: 1

immediate data:      FALSE

critical data:                FALSE

1.2、   初始化函数

FUNC(void, FEE_API_CODE) Fee_Init(P2CONST(Fee_ConfigType, AUTOMATIC, FEE_APPL_CONFIG) ConfigPtr)  /* PRQA S 1503 */ /* MD_MSR_14.1 */
{
  /* Check data buffer parameter for being valid address. */
#if (STD_ON == FEE_CFG_CHK_PARAM_NULL_POINTER)

    /* Is pointer to a data buffer valid? */
    if (NULL_PTR == ConfigPtr)
    {
        /* Report development error. */
        Fee_Errorhook(FEE_SID_INIT, FEE_E_PARAM_DATABUFFERPTR);      /* PRQA S 3200 */ /* MISRA-C:2004 Rule 16.10 According to a component requirement the return values of that function is right and has to be ignored. */

        /* stay unitialized / explicitly unitialize */
#       if (STD_ON == FEE_CFG_CHK_STATUS_UNINIT)
            Fee_ModuleStatus_t = MEMIF_UNINIT;
#       endif

        return;
    }
#endif

  /* set the config pointer */
  Fee_Globals_t.Config_ptloc = ConfigPtr;

  /****************************************************************************
   * Initialize global variables
   ***************************************************************************/
  Fee_Globals_t.FlsJobResult_t = MEMIF_JOB_OK;
  Fee_Globals_t.FeeModuleStatus_t = MEMIF_BUSY_INTERNAL;
  Fee_Globals_t.FeeJobResult_t = MEMIF_JOB_OK;
  Fee_Globals_t.FeeLocalJobResult_t = FEE_LOCAL_JOB_RESULT_OK;
  Fee_Globals_t.InternalFlags_t = 0u;
  Fee_Globals_t.ApiFlags_t = 0u;
  Fee_Globals_t.SectorSwitchFlags.Request_t = 0;
  
  Fee_Globals_t.SectorSwitchFlags.Prio_t = FEE_SS_SECTOR_FORMAT; /* must not be 0!! */
  Fee_Globals_t.SectorSwitchFlags.Mask_t = 0;

  Fee_Globals_t.SectorSwitchBlockNumber_u16 = 0;
  Fee_Globals_t.CurrentSector_pt = 
      Fee_Globals_t.OperatingSector_pt = &Fee_SectorConfig_at[0];

  Fee_Globals_t.WritesSuspended_bl = FALSE;

  /* set the FlsSectorEraseIndex to FEE_SECTOR_ERASE_FINISHED, which represents a successfully finished Fls erase */
  Fee_Globals_t.FlsSectorEraseIndex_u16 = 0;

  /* Start Fls job to read the lower sector header.
   * Reading only 4 bytes of the lower sector header where the Sector ID is located, because the sector ID is
   * utilized to evaluate a valid sector[用于评估sector的有效性].
   */
  Fee_InternalPrepareSectorHeaderRead(FEE_LOWER_SECTOR_NUMBER);

  /****************************************************************************
   * Initialize the FSM stack and start the state machine
   *   only the first two levels of the FSM stack must be initialized, because all 
   *   other will be initialized before increasing the stack pointer
   ***************************************************************************/
  Fee_Globals_t.FsmStack_t.TopOfStack_u8 = 1u;
  Fee_Globals_t.FsmStack_t.Stack_at[0] = FEE_STATE_MAIN_STARTUP;
  Fee_Globals_t.FsmStack_t.Stack_at[1] = FEE_STATE_STARTUP_READ_SECTOR_HEADER_LOWER;

#ifdef FEE_TESTING_LOG_TRANSITIONS
    TsxFee_LogFsmCompleteReinitialization(FEE_STATE_MAIN_STARTUP);
    TsxFee_LogFsmInitalization(FEE_STATE_STARTUP_READ_SECTOR_HEADER_LOWER);
#endif
  /****************************************************************************
   * Initialize the component
   ***************************************************************************/
#if (STD_ON == FEE_CFG_CHK_STATUS_UNINIT)
    Fee_ModuleStatus_t = MEMIF_IDLE;
#endif /* (STD_ON == FEE_CFG_CHK_STATUS_UNINIT) */
} /* End of Fee_Init() */       /* PRQA S 2006 */ /* MD_MSR_14.7 */







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值