Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. /*----------------------------------------------------------------------------*/
  2. /**
  3. * \file
  4. *
  5. * \brief BMW stub MyDcm_Callbacks.c
  6. *
  7. * This file contains the implementation of the BMW stub MyDcm_Callbacks
  8. * for usage in the BMW AUTOSAR Core Example.
  9. *
  10. * \project BMW AUTOSAR Core
  11. *
  12. * \par To be changed by user:
  13. * [no]
  14. *
  15. * \copyright BMW AG 2015
  16. *
  17. * \remarks
  18. * DISCLAIMER:
  19. * As the program is not fully tested and qualified for series production
  20. * use, the user shall not be entitled to use the program in connection
  21. * with any series production. BMW provides the user with the program only
  22. * as sample application (for testing purposes).
  23. *
  24. */
  25. /*----------------------------------------------------------------------------*/
  26.  
  27.  
  28. #ifndef I_KNOW_THAT_THIS_CODE_IS_NOT_FOR_PRODUCTION
  29. #error "the program must not be used in connection with series production"
  30. #endif
  31.  
  32. #include <MyDcm_Callbacks.h>
  33. #include <Rte_MyDcm.h>
  34. #include "Stubs.h"
  35. #include "Mcu.h"
  36. #include "EcuM.h"
  37. #include "BswM_Callouts.h"
  38.  
  39. #define DCM_START_SEC_CODE
  40. #include <MemMap.h>
  41.  
  42.  
  43. /**********************************************************************************************************************
  44. ******************************* Global Variables *********************************************************************
  45. *********************************************************************************************************************/
  46. uint8 u8_IndicationConfirmation=0;
  47. uint8 u8_ModeReceived;
  48.  
  49. extern uint8 reset_42_condition;
  50. extern uint8 reset_01_condition;
  51.  
  52. extern uint8 Brief_Shutdown_ECU;
  53.  
  54. extern FUNC(Std_ReturnType, RTE_CODE) Rte_Read_LowPowerMode_rDWAInternalStatus_u1DWAState (P2VAR(uint8, AUTOMATIC, RTE_APPL_DATA) data);
  55.  
  56.  
  57. FUNC(Std_ReturnType, RTE_APPL_CODE) MyDcm_Runnable_GEEDS_Temp_Mile_KM(P2VAR(uint8, AUTOMATIC, RTE_APPL_DATA) Data)
  58. {
  59. P2VAR(uint8, AUTOMATIC, RTE_APPL_DATA) LOC_pu8SGMILE_KM_816RValue = pu8SGMILE_KM_816RValue+2;
  60. *Data = (*LOC_pu8SGMILE_KM_816RValue);
  61. Data++;
  62. LOC_pu8SGMILE_KM_816RValue--;
  63. *Data = (*LOC_pu8SGMILE_KM_816RValue);
  64. Data++;
  65. LOC_pu8SGMILE_KM_816RValue--;
  66. *Data = (*LOC_pu8SGMILE_KM_816RValue);
  67. return RTE_E_OK;
  68. }
  69.  
  70. FUNC(Std_ReturnType, RTE_APPL_CODE) MyDcm_Runnable_READ_BN(P2VAR(uint8, AUTOMATIC, RTE_APPL_DATA) Data)
  71. {
  72. *Data = u8BN_DEM;
  73. return RTE_E_OK;
  74. }
  75. FUNC(Std_ReturnType, RTE_APPL_CODE) MyDcm_Runnable_READ_TN(P2VAR(uint8, AUTOMATIC, RTE_APPL_DATA) Data)
  76. {
  77. Data[0] = u8TN_DEM[0];
  78. Data[1] = u8TN_DEM[1];
  79. Data[2] = u8TN_DEM[2];
  80. return RTE_E_OK;
  81. }
  82.  
  83. FUNC(void, DCM_APPL_CODE) MyDcm_vidJumptoBL(void)
  84. {
  85. Srv_BootModeSet(SRV_BOOT_MODE_BOOTLOADER, (Dcm_ProgConditionsType*)&switchToProgrammingSessionNoResponse);
  86. User_ChangeShutdownTarget_To_Reset();
  87. BswM_On_Prep_Shutdown();
  88. }
  89.  
  90.  
  91. FUNC(Std_ReturnType, RTE_APPL_CODE) MyDcm_ManufacturerIndication(uint8 SID, P2CONST(uint8, AUTOMATIC, RTE_APPL_CONST) RequestData, uint16 DataSize, uint8 ReqType, uint16 SourceAddress, P2VAR(MyDcm_DCM_NegativeResponseCodeType, AUTOMATIC, RTE_APPL_DATA) ErrorCode)
  92. {
  93.  
  94. uint8 returnValue = E_OK;
  95.  
  96. uint8 u8DwaArmedState;
  97.  
  98.  
  99. // TS_PARAM_UNUSED(SID);
  100. // TS_PARAM_UNUSED(RequestData);
  101. TS_PARAM_UNUSED(DataSize);
  102. TS_PARAM_UNUSED(ReqType);
  103. TS_PARAM_UNUSED(SourceAddress);
  104.  
  105. Rte_Read_LowPowerMode_rDWAInternalStatus_u1DWAState(&u8DwaArmedState);
  106.  
  107. if ( u8DwaArmedState == (uint8)1)
  108. {
  109. if ((SID != (uint8)0x22) && (SID != (uint8)0x19))
  110. {
  111.  
  112. if((SID == 0x31) && (RequestData[0]==0x01) && (RequestData[1]==0xaa) && (RequestData[2]==0x79))
  113. {
  114. returnValue = E_OK;
  115. }
  116.  
  117. else
  118. {
  119. returnValue=E_NOT_OK;
  120. *ErrorCode=DCM_E_CONDITIONSNOTCORRECT;
  121. }
  122. }
  123. }
  124.  
  125. if ((SID == 0x31) && (RequestData[0]==0x01) && (RequestData[1]==0x0F) && (RequestData[2]==0x0C))
  126. {
  127. if(u8_IndicationConfirmation == 0)
  128. {
  129. u8_IndicationConfirmation = 1;
  130. u8_ModeReceived = RequestData[3];
  131. }
  132.  
  133. }
  134.  
  135.  
  136. return returnValue;
  137. }
  138. FUNC(Std_ReturnType, RTE_APPL_CODE) MyDcm_ManufacturerConfirmation(uint8 SID, uint8 ReqType, uint16 SourceAddress, MyDcm_DCM_ConfirmationStatusType ConfirmationStatus)
  139. {
  140. TS_PARAM_UNUSED(SID);
  141. TS_PARAM_UNUSED(ReqType);
  142. TS_PARAM_UNUSED(ConfirmationStatus);
  143.  
  144. if(Brief_Shutdown_ECU==1)
  145. {
  146. EcuM_AL_SwitchOff();
  147. }
  148.  
  149.  
  150. /* if(reset_42_condition == 1)
  151. {
  152. reset_42_condition=0;
  153. Mcu_PerformReset();
  154. }*/
  155.  
  156. if(reset_01_condition == 1)
  157. {
  158. reset_01_condition=0;
  159. EcuM_SelectShutdownTarget(ECUM_STATE_RESET,ECUM_RESET_WDG);
  160. /*EcuM_SelectShutdownTarget(ECUM_STATE_RESET,ECUM_STATE_OFF);*/
  161.  
  162. BswM_On_Prep_Shutdown();
  163. }
  164.  
  165.  
  166. //Check if routine 0F0C is received and with a positive response
  167. if(u8_IndicationConfirmation == 1 && ConfirmationStatus== 0x00){
  168.  
  169. u8_IndicationConfirmation = 0;
  170. switch(u8_ModeReceived)
  171. {
  172. case 0:
  173. BswM_RequestMode(RP_OMC_OperatingMode,OMC_MODE_ASSEMBLY);
  174. break;
  175. case 1:
  176. BswM_RequestMode(RP_OMC_OperatingMode,OMC_MODE_BMWFLASH);
  177. break;
  178. case 2:
  179. BswM_RequestMode(RP_OMC_OperatingMode,OMC_MODE_NORMAL);
  180. break;
  181. case 3:
  182. BswM_RequestMode(RP_OMC_OperatingMode,OMC_MODE_TRANSPORT);
  183. break;
  184. default:
  185. break;
  186. }
  187. }
  188.  
  189.  
  190.  
  191. return E_OK;
  192. }
  193.  
  194. FUNC(Std_ReturnType, DCM_CODE) Dcm_SetProgConditions
  195. (
  196. P2VAR(Dcm_ProgConditionsType, AUTOMATIC, DCM_APPL_DATA) myProgConditions
  197. )
  198. {
  199. Srv_BootModeSet(SRV_BOOT_MODE_BOOTLOADER, myProgConditions);
  200.  
  201. return E_OK;
  202. }
  203.  
  204. FUNC(Dcm_EcuStartModeType, DCM_CODE) Dcm_GetProgConditions
  205. (
  206. P2VAR(Dcm_ProgConditionsType, AUTOMATIC, DCM_APPL_DATA) myProgConditions
  207. )
  208. {
  209. return DCM_COLD_START;
  210. }
  211.  
  212. FUNC(void, DCM_CALLOUT_CODE) Dcm_Confirmation(Dcm_IdContextType idContext, PduIdType dcmRxPduId, Dcm_ConfirmationStatusType status)
  213. {
  214. }
  215.  
  216. #define DCM_STOP_SEC_CODE
  217. #include <MemMap.h>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement