Slexy.org is shutting down and stopped accepting new Pastes on May 4th, 2021.
Existing Pastes will stop being available on or after May 10th, 2021.
Author: Not specified Language: c
Description: Not specified Timestamp: 2017-08-01 13:25:15 +0000
View raw paste Reply
/*
  DCM Callouts for VAG SLP 3 FBL. FBL process data is stored with WrapNV API
  Author: viskjs
*/


/* #define USE_FBL_WRAPNV */

#include "Dcm.h"
#if defined ( USE_FBL_WRAPNV )
# include "WrapNv_cfg.h"
#endif

/* Values of response after reset flag */
#define RESET_RESPONSE_NOT_REQUIRED          0x00u
#define RESET_RESPONSE_SDS_REQUIRED          0x01u
#define RESET_RESPONSE_ECURESET_REQUIRED     0x02u
/* Values of reprogramming flag */
#define FBL_REPROGRAM                        0xB5u

#if !defined ( USE_FBL_WRAPNV )
/* Macros for accessing Dummy EEP directly */
# define DUMMYEEP_PROGREQFLAG                0x70105f00ul /* TODO: change to address of prog request flag */
# define DUMMYEEP_RESETRESPFLAG              0x70105f02ul /* TODO: change to address of reset response flag */
 
# define ApplFblNvWriteProgReqFlag(idx, buf)       {(*((volatile uint8 *)DUMMYEEP_PROGREQFLAG)) = *buf;}
# define ApplFblNvReadResetResponseFlag(idx, buf)  {*buf = (*((volatile uint8 *)DUMMYEEP_RESETRESPFLAG));}
# define ApplFblNvWriteResetResponseFlag(idx, buf) {(*((volatile uint8 *)DUMMYEEP_RESETRESPFLAG)) = *buf;}
#endif

/* Called to set programming request flag before descending to FBL */
FUNC(Std_ReturnType, DCM_CALLOUT_CODE) Dcm_SetProgConditions(Dcm_ProgConditionsPtrType progConditions)
{
   uint8 buffer;
   
   /* Set Programming request flag */
   if (progConditions->ReprogrammingRequest == 1u)
   {
      buffer = FBL_REPROGRAM;
      ApplFblNvWriteProgReqFlag(&buffer);
      progConditions->ReprogrammingRequest = 0u;
   }
   
   /* Make sure that reset response flag is not set */
   ApplFblNvReadResetResponseFlag(&buffer);
   if ((buffer == RESET_RESPONSE_ECURESET_REQUIRED) || \
       (buffer == RESET_RESPONSE_SDS_REQUIRED))
   {
      buffer = RESET_RESPONSE_NOT_REQUIRED;
      ApplFblNvWriteResetResponseFlag(&buffer);
   }
   
   return DCM_E_OK;
}

/* Called by DCM after starting application; Determines if final response have to be sent */
FUNC(Dcm_EcuStartModeType, DCM_CALLOUT_CODE) Dcm_GetProgConditions(Dcm_ProgConditionsPtrType progConditions)
{
   uint8 buffer;

   ApplFblNvReadResetResponseFlag(&buffer);

   /* Set members of progConditions according to state of reset response flag */
   if ((buffer == RESET_RESPONSE_ECURESET_REQUIRED) || \
       (buffer == RESET_RESPONSE_SDS_REQUIRED))
   {
      /* Set parameters for Reset Response after Reset*/
      if(buffer == RESET_RESPONSE_ECURESET_REQUIRED)
      {
         progConditions->Sid = 0x11u;
      }
      else
      {
         progConditions->Sid = 0x10u;
      }
     
      progConditions->ApplUpdated = FALSE;
      progConditions->ResponseRequired = TRUE;
      progConditions->SubFuncId = 0x01u;
      progConditions->TesterSourceAddr = 0x0u;
     
      return DCM_WARM_START;
   }
   else
   {
      return DCM_COLD_START;
   }
}
 
View raw paste Reply