Mcu.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral :
  5. * Dependencies : none
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. /**
  25. * @file Mcu.c
  26. * @implements Mcu.c_Artifact
  27. * @version 1.0.0
  28. *
  29. * @brief AUTOSAR Mcu - Implements the AUTOSAR MCU driver functionality.
  30. * @details Implements the AUTOSAR MCU driver. All the API functions are described by AUTOSAR
  31. *
  32. * @addtogroup MCU_DRIVER Mcu Driver
  33. * @{
  34. */
  35. #ifdef __cplusplus
  36. extern "C"{
  37. #endif
  38. /*==================================================================================================
  39. * INCLUDE FILES
  40. * 1) system and project includes
  41. * 2) needed interfaces from external units
  42. * 3) internal and external interfaces from this unit
  43. ==================================================================================================*/
  44. #include "Mcal.h"
  45. /**
  46. * @brief Mcu.c shall include Mcu.h
  47. */
  48. #include "Mcu.h"
  49. /* Get the prototypes of IPW functions. */
  50. #include "Mcu_IPW.h"
  51. #include "SchM_Mcu.h"
  52. #if (MCU_DEV_ERROR_DETECT == STD_ON)
  53. #include "Det.h"
  54. #endif /* (MCU_DEV_ERROR_DETECT == STD_ON) */
  55. /*==================================================================================================
  56. SOURCE FILE VERSION INFORMATION
  57. ==================================================================================================*/
  58. #define MCU_VENDOR_ID_C 43
  59. #define MCU_AR_RELEASE_MAJOR_VERSION_C 4
  60. #define MCU_AR_RELEASE_MINOR_VERSION_C 4
  61. #define MCU_AR_RELEASE_REVISION_VERSION_C 0
  62. #define MCU_SW_MAJOR_VERSION_C 1
  63. #define MCU_SW_MINOR_VERSION_C 0
  64. #define MCU_SW_PATCH_VERSION_C 0
  65. /*==================================================================================================
  66. * FILE VERSION CHECKS
  67. ==================================================================================================*/
  68. #if (MCU_DEV_ERROR_DETECT == STD_ON)
  69. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  70. /* Check if Mcu.c file and Det.h file are of the same Autosar version */
  71. #if ((MCU_AR_RELEASE_MAJOR_VERSION_C != DET_AR_RELEASE_MAJOR_VERSION) || \
  72. (MCU_AR_RELEASE_MINOR_VERSION_C != DET_AR_RELEASE_MINOR_VERSION))
  73. #error "AutoSar Version Numbers of Mcu.c and Det.h are different"
  74. #endif
  75. #endif
  76. #endif /* (MCU_DEV_ERROR_DETECT == STD_ON) */
  77. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  78. /* Check if Mcu.c file and Mcal.h file are of the same Autosar version */
  79. #if ((MCU_AR_RELEASE_MAJOR_VERSION_C != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  80. (MCU_AR_RELEASE_MINOR_VERSION_C != MCAL_AR_RELEASE_MINOR_VERSION))
  81. #error "AutoSar Version Numbers of Mcu.c and Mcal.h are different"
  82. #endif
  83. /* Check if Mcu.c file and SchM_Mcu.h file are of the same Autosar version */
  84. #if ((MCU_AR_RELEASE_MAJOR_VERSION_C != SCHM_MCU_AR_RELEASE_MAJOR_VERSION) || \
  85. (MCU_AR_RELEASE_MINOR_VERSION_C != SCHM_MCU_AR_RELEASE_MINOR_VERSION))
  86. #error "AutoSar Version Numbers of Mcu.c and SchM_Mcu.h are different"
  87. #endif
  88. #endif
  89. /* Check if Mcu.c file and Mcu.h file are of the same vendor */
  90. #if (MCU_VENDOR_ID_C != MCU_VENDOR_ID)
  91. #error "Mcu.c and Mcu.h have different vendor ids"
  92. #endif
  93. /* Check if Mcu.c file and Mcu.h file are of the same Autosar version */
  94. #if ((MCU_AR_RELEASE_MAJOR_VERSION_C != MCU_AR_RELEASE_MAJOR_VERSION) || \
  95. (MCU_AR_RELEASE_MINOR_VERSION_C != MCU_AR_RELEASE_MINOR_VERSION) || \
  96. (MCU_AR_RELEASE_REVISION_VERSION_C != MCU_AR_RELEASE_REVISION_VERSION) \
  97. )
  98. #error "AutoSar Version Numbers of Mcu.c and Mcu.h are different"
  99. #endif
  100. /* Check if Mcu.c file and Mcu.h file are of the same Software version */
  101. #if ((MCU_SW_MAJOR_VERSION_C != MCU_SW_MAJOR_VERSION) || \
  102. (MCU_SW_MINOR_VERSION_C != MCU_SW_MINOR_VERSION) || \
  103. (MCU_SW_PATCH_VERSION_C != MCU_SW_PATCH_VERSION) \
  104. )
  105. #error "Software Version Numbers of Mcu.c and Mcu.h are different"
  106. #endif
  107. /* Check if Mcu.c file and Mcu_IPW.h file are of the same vendor */
  108. #if (MCU_VENDOR_ID_C != MCU_IPW_VENDOR_ID)
  109. #error "Mcu.c and Mcu_IPW.h have different vendor ids"
  110. #endif
  111. /* Check if Mcu.c file and Mcu_IPW.h file are of the same Autosar version */
  112. #if ((MCU_AR_RELEASE_MAJOR_VERSION_C != MCU_IPW_AR_RELEASE_MAJOR_VERSION) || \
  113. (MCU_AR_RELEASE_MINOR_VERSION_C != MCU_IPW_AR_RELEASE_MINOR_VERSION) || \
  114. (MCU_AR_RELEASE_REVISION_VERSION_C != MCU_IPW_AR_RELEASE_REVISION_VERSION) \
  115. )
  116. #error "AutoSar Version Numbers of Mcu.c and Mcu_IPW.h are different"
  117. #endif
  118. /* Check if Mcu.c file and Mcu_IPW.h file are of the same Software version */
  119. #if ((MCU_SW_MAJOR_VERSION_C != MCU_IPW_SW_MAJOR_VERSION) || \
  120. (MCU_SW_MINOR_VERSION_C != MCU_IPW_SW_MINOR_VERSION) || \
  121. (MCU_SW_PATCH_VERSION_C != MCU_IPW_SW_PATCH_VERSION) \
  122. )
  123. #error "Software Version Numbers of Mcu.c and Mcu_IPW.h are different"
  124. #endif
  125. /*==================================================================================================
  126. LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  127. ==================================================================================================*/
  128. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  129. /**
  130. * @brief This enumerated type contains the Mcu driver's possible states.
  131. */
  132. typedef enum
  133. {
  134. MCU_UNINIT = 0x3U, /**< @brief The Mcu driver is uninitialized. */
  135. MCU_IDLE = 0xCU, /**< @brief = 0xE1 The Mcu driver is currently idle. */
  136. MCU_BUSY = 0xAU /**< @brief = 0xD2 The Mcu driver is currently busy. */
  137. } Mcu_StatusType;
  138. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  139. /*==================================================================================================
  140. * LOCAL MACROS
  141. ==================================================================================================*/
  142. /*==================================================================================================
  143. LOCAL CONSTANTS
  144. ==================================================================================================*/
  145. /*==================================================================================================
  146. LOCAL VARIABLES
  147. ==================================================================================================*/
  148. #define MCU_START_SEC_VAR_CLEARED_8
  149. #include "Mcu_MemMap.h"
  150. #if (MCU_INIT_CLOCK == STD_ON)
  151. /**
  152. * @brief Array for saving the Clock configuration Ids.
  153. */
  154. static uint8 Mcu_au8ClockConfigIds[MCU_MAX_CLKCONFIGS];
  155. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  156. /**
  157. * @brief Array for saving the Mode configuration Ids.
  158. */
  159. static uint8 Mcu_au8ModeConfigIds[MCU_MAX_MODECONFIGS];
  160. #ifndef MCU_MAX_NORAMCONFIGS
  161. /**
  162. * @brief Array for saving the Ram sectors configuration Ids.
  163. * If no RamConfig is defined, remove all usages of this array.
  164. */
  165. static uint8 Mcu_au8RamConfigIds[MCU_MAX_RAMCONFIGS];
  166. #endif /* ( 0 != MCU_MAX_RAMCONFIGS ) */
  167. #define MCU_STOP_SEC_VAR_CLEARED_8
  168. #include "Mcu_MemMap.h"
  169. #define MCU_START_SEC_VAR_INIT_UNSPECIFIED
  170. #include "Mcu_MemMap.h"
  171. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  172. /**
  173. * @brief Variable that indicates the state of the driver.
  174. */
  175. static Mcu_StatusType Mcu_eStatus = MCU_UNINIT;
  176. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  177. #define MCU_STOP_SEC_VAR_INIT_UNSPECIFIED
  178. #include "Mcu_MemMap.h"
  179. #define MCU_START_SEC_VAR_CLEARED_UNSPECIFIED
  180. #include "Mcu_MemMap.h"
  181. /**
  182. * @brief Local copy of the pointer to the configuration data.
  183. */
  184. #if (defined(MCU_CMU_ERROR_ISR_USED) && (MCU_CMU_ERROR_ISR_USED == STD_ON))
  185. const Mcu_ConfigType * Mcu_pConfigPtr;
  186. #else
  187. static const Mcu_ConfigType * Mcu_pConfigPtr;
  188. #endif
  189. #define MCU_STOP_SEC_VAR_CLEARED_UNSPECIFIED
  190. #include "Mcu_MemMap.h"
  191. /*==================================================================================================
  192. GLOBAL CONSTANTS
  193. ==================================================================================================*/
  194. /*==================================================================================================
  195. GLOBAL VARIABLES
  196. ==================================================================================================*/
  197. #define MCU_START_SEC_VAR_CLEARED_UNSPECIFIED
  198. #include "Mcu_MemMap.h"
  199. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  200. const Mcu_DemConfigType * Mcu_pDemCfgPtr;
  201. #endif /* (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
  202. #define MCU_STOP_SEC_VAR_CLEARED_UNSPECIFIED
  203. #include "Mcu_MemMap.h"
  204. /*==================================================================================================
  205. LOCAL FUNCTION PROTOTYPES
  206. ==================================================================================================*/
  207. #define MCU_START_SEC_CODE
  208. #include "Mcu_MemMap.h"
  209. #if (MCU_PARAM_CHECK == STD_ON)
  210. static Std_ReturnType Mcu_CheckInit(const Mcu_ConfigType * pConfigPtr);
  211. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  212. #ifndef MCU_MAX_NORAMCONFIGS
  213. #if (MCU_PARAM_CHECK == STD_ON)
  214. static Std_ReturnType Mcu_CheckInitRamSection(Mcu_RamSectionType RamSection);
  215. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  216. #endif /* ifndef MCU_MAX_NORAMCONFIGS */
  217. #if (MCU_INIT_CLOCK == STD_ON)
  218. #if (MCU_PARAM_CHECK == STD_ON)
  219. static Std_ReturnType Mcu_CheckInitClock(Mcu_ClockType ClockSetting);
  220. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  221. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  222. #if (MCU_PARAM_CHECK == STD_ON)
  223. static Std_ReturnType Mcu_CheckSetMode(Power_Ip_ModeType McuMode);
  224. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  225. #ifdef MCU_GET_MIDR_API
  226. #if ( (MCU_GET_MIDR_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  227. static Std_ReturnType Mcu_CheckGetMidrStructure(const Mcu_MidrReturnType pMidr[MCU_SIUL2_TOTAL_UNITS]);
  228. #endif /* ( (MCU_GET_MIDR_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  229. #endif /* (MCU_GET_MIDR_API == STD_ON) */
  230. #if (MCU_INIT_CLOCK == STD_ON)
  231. #if (MCU_NO_PLL == STD_OFF)
  232. #if ( MCU_PARAM_CHECK == STD_ON )
  233. static Std_ReturnType Mcu_CheckDistributePllClock(void);
  234. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  235. #endif /* (MCU_NO_PLL == STD_OFF) */
  236. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  237. #if ( \
  238. (MCU_PERFORM_RESET_API == STD_ON) && \
  239. (MCU_PARAM_CHECK == STD_ON) \
  240. )
  241. static Std_ReturnType Mcu_CheckPerformReset(void);
  242. #endif
  243. #if (MCU_VERSION_INFO_API == STD_ON)
  244. #if (MCU_PARAM_CHECK == STD_ON)
  245. static Std_ReturnType Mcu_CheckGetVersionInfo(const Std_VersionInfoType * pVersionInfo);
  246. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  247. #endif /* (MCU_VERSION_INFO_API == STD_ON) */
  248. #ifdef MCU_EMIOS_CONFIGURE_GPREN_API
  249. #if ( (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  250. static Std_ReturnType Mcu_CheckConfigureGpren(uint8 u8Module);
  251. #endif /* ( (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  252. #endif /* MCU_EMIOS_CONFIGURE_GPREN_API */
  253. #ifdef MCU_DISABLE_CMU_API
  254. #if ( (MCU_DISABLE_CMU_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  255. static Std_ReturnType Mcu_CheckDisableCMU(Clock_Ip_NameType clockName);
  256. #endif /* ( (MCU_DISABLE_CMU_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  257. #endif /* MCU_DISABLE_CMU_API */
  258. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  259. /* MCU state check, entry point. */
  260. static Std_ReturnType Mcu_HLDChecksEntry(uint8 u8McuServiceID);
  261. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  262. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  263. /* MCU state check, exit point. */
  264. static void Mcu_HLDChecksExit(Std_ReturnType retStatus, uint8 u8McuServiceID);
  265. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  266. /*==================================================================================================
  267. LOCAL FUNCTIONS
  268. ==================================================================================================*/
  269. #if (MCU_PARAM_CHECK == STD_ON)
  270. /**
  271. * @brief Mcu_CheckInit - checks for Mcu_Init
  272. * @implements Mcu_CheckInit_Activity
  273. */
  274. static Std_ReturnType Mcu_CheckInit(const Mcu_ConfigType * pConfigPtr)
  275. {
  276. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  277. #if (MCU_PRECOMPILE_SUPPORT == STD_OFF)
  278. if (NULL_PTR == pConfigPtr)
  279. {
  280. CheckStatus = (Std_ReturnType)E_NOT_OK;
  281. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INIT_ID, MCU_E_INIT_FAILED);
  282. }
  283. #else /* MCU_PRECOMPILE_SUPPORT == STD_ON */
  284. if (NULL_PTR != pConfigPtr)
  285. {
  286. CheckStatus = (Std_ReturnType)E_NOT_OK;
  287. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INIT_ID, MCU_E_INIT_FAILED);
  288. }
  289. #endif /* (MCU_PRECOMPILE_SUPPORT == STD_ON) */
  290. return CheckStatus;
  291. }
  292. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  293. #ifndef MCU_MAX_NORAMCONFIGS
  294. #if (MCU_PARAM_CHECK == STD_ON)
  295. /**
  296. * @brief Mcu_CheckInitRamSection - checks for Mcu_InitRamSection
  297. * @implements Mcu_CheckInitRamSection_Activity
  298. */
  299. static Std_ReturnType Mcu_CheckInitRamSection(Mcu_RamSectionType RamSection)
  300. {
  301. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  302. /* Check if the Ram section's ID is in range. */
  303. if (RamSection >= Mcu_pConfigPtr->Mcu_NoRamConfigs)
  304. {
  305. CheckStatus = (Std_ReturnType)E_NOT_OK;
  306. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INITRAMSECTION_ID, MCU_E_PARAM_RAMSECTION);
  307. }
  308. else
  309. {
  310. /* Check if Ram memory configuration is valid. */
  311. if (NULL_PTR == Mcu_pConfigPtr->Mcu_apRamConfig)
  312. {
  313. CheckStatus = (Std_ReturnType)E_NOT_OK;
  314. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INITRAMSECTION_ID, MCU_E_PARAM_RAMSECTION);
  315. }
  316. /* Check if Ram write size is valid. */
  317. else
  318. {
  319. if (
  320. ( (Mcu_RamWriteSizeType)1U != ((*Mcu_pConfigPtr->Mcu_apRamConfig)[Mcu_au8RamConfigIds[RamSection]]).RamWriteSize ) &&
  321. ( (Mcu_RamWriteSizeType)2U != ((*Mcu_pConfigPtr->Mcu_apRamConfig)[Mcu_au8RamConfigIds[RamSection]]).RamWriteSize ) &&
  322. ( (Mcu_RamWriteSizeType)4U != ((*Mcu_pConfigPtr->Mcu_apRamConfig)[Mcu_au8RamConfigIds[RamSection]]).RamWriteSize ) &&
  323. ( (Mcu_RamWriteSizeType)8U != ((*Mcu_pConfigPtr->Mcu_apRamConfig)[Mcu_au8RamConfigIds[RamSection]]).RamWriteSize )
  324. )
  325. {
  326. CheckStatus = (Std_ReturnType)E_NOT_OK;
  327. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INITRAMSECTION_ID, MCU_E_PARAM_RAMSECTION);
  328. }
  329. }
  330. }
  331. return CheckStatus;
  332. }
  333. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  334. #endif /* ifndef MCU_MAX_NORAMCONFIGS */
  335. #if (MCU_INIT_CLOCK == STD_ON)
  336. #if (MCU_PARAM_CHECK == STD_ON)
  337. /**
  338. * @brief Mcu_CheckInitClock - checks for Mcu_InitClock
  339. * @implements Mcu_CheckInitClock_Activity
  340. */
  341. static Std_ReturnType Mcu_CheckInitClock(Mcu_ClockType ClockSetting)
  342. {
  343. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  344. if (ClockSetting >= Mcu_pConfigPtr->Mcu_NoClkConfigs)
  345. {
  346. CheckStatus = (Std_ReturnType)E_NOT_OK;
  347. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_INITCLOCK_ID, MCU_E_PARAM_CLOCK);
  348. }
  349. return CheckStatus;
  350. }
  351. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  352. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  353. #if (MCU_PARAM_CHECK == STD_ON)
  354. /**
  355. * @brief Mcu_CheckSetMode - checks for Mcu_SetMode
  356. * @implements Mcu_CheckSetMode_Activity
  357. */
  358. static Std_ReturnType Mcu_CheckSetMode(Power_Ip_ModeType McuMode)
  359. {
  360. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  361. if (McuMode >= Mcu_pConfigPtr->Mcu_NoModeConfigs)
  362. {
  363. CheckStatus = (Std_ReturnType)E_NOT_OK;
  364. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_SETMODE_ID, MCU_E_PARAM_MODE);
  365. }
  366. return CheckStatus;
  367. }
  368. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  369. #ifdef MCU_GET_MIDR_API
  370. #if ( (MCU_GET_MIDR_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  371. /**
  372. * @brief Mcu_CheckGetMidrStructure - checks for Mcu_GetMidrStructure
  373. * @implements Mcu_CheckGetMidrStructure_Activity
  374. */
  375. static Std_ReturnType Mcu_CheckGetMidrStructure(const Mcu_MidrReturnType pMidr[MCU_SIUL2_TOTAL_UNITS])
  376. {
  377. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  378. if (NULL_PTR == pMidr)
  379. {
  380. CheckStatus = (Std_ReturnType)E_NOT_OK;
  381. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_GETMIDRSTRUCTURE_ID, MCU_E_PARAM_POINTER);
  382. }
  383. return CheckStatus;
  384. }
  385. #endif /* ( (MCU_GET_MIDR_API == STD_ON) && (MCU_GET_MIDR_API == STD_ON) ) */
  386. #endif /* MCU_GET_MIDR_API */
  387. #if (MCU_INIT_CLOCK == STD_ON)
  388. #if (MCU_NO_PLL == STD_OFF)
  389. #if (MCU_PARAM_CHECK == STD_ON)
  390. /**
  391. * @brief Mcu_CheckDistributePllClock - checks for Mcu_DistributePllClock
  392. * @implements Mcu_CheckDistributePllClock_Activity
  393. */
  394. static Std_ReturnType Mcu_CheckDistributePllClock(void)
  395. {
  396. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  397. if ( MCU_PLL_LOCKED != Mcu_Ipw_GetPllStatus() )
  398. {
  399. CheckStatus = (Std_ReturnType)E_NOT_OK;
  400. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_DISTRIBUTEPLLCLOCK_ID, MCU_E_PLL_NOT_LOCKED);
  401. }
  402. return CheckStatus;
  403. }
  404. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  405. #endif /* (MCU_NO_PLL == STD_OFF) */
  406. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  407. #if ( \
  408. (MCU_PERFORM_RESET_API == STD_ON) && \
  409. (MCU_PARAM_CHECK == STD_ON) \
  410. )
  411. /**
  412. * @brief Mcu_CheckPerformReset - checks for Mcu_PerformReset
  413. * @implements Mcu_PerformReset_Activity
  414. */
  415. static Std_ReturnType Mcu_CheckPerformReset(void)
  416. {
  417. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  418. #ifdef MCU_CHECK_FIRC_STATE
  419. #if (MCU_CHECK_FIRC_STATE == STD_ON)
  420. if ( (Std_ReturnType)E_NOT_OK == Mcu_IPW_GetFircStatus() )
  421. {
  422. CheckStatus = (Std_ReturnType)E_NOT_OK;
  423. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_PERFORMRESET_ID, MCU_E_PERFORM_RESET);
  424. }
  425. #endif /* (MCU_CHECK_FIRC_STATE == STD_ON) */
  426. #endif /* MCU_CHECK_FIRC_STATE */
  427. return CheckStatus;
  428. }
  429. #endif /* ( (MCU_PERFORM_RESET_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  430. #if (MCU_VERSION_INFO_API == STD_ON)
  431. #if (MCU_PARAM_CHECK == STD_ON)
  432. /**
  433. * @brief Mcu_CheckGetVersionInfo - checks for Mcu_GetVersionInfo
  434. * @implements Mcu_GetVersionInfo_Activity
  435. */
  436. static Std_ReturnType Mcu_CheckGetVersionInfo(const Std_VersionInfoType * pVersionInfo)
  437. {
  438. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  439. if (NULL_PTR == pVersionInfo)
  440. {
  441. CheckStatus = (Std_ReturnType)E_NOT_OK;
  442. (void)Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_GETVERSIONINFO_ID, MCU_E_PARAM_POINTER);
  443. }
  444. return CheckStatus;
  445. }
  446. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  447. #endif /* (MCU_VERSION_INFO_API == STD_ON) */
  448. #ifdef MCU_EMIOS_CONFIGURE_GPREN_API
  449. #if ( (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  450. /**
  451. * @brief Mcu_CheckConfigureGpren - checks for Mcu_EmiosConfigureGpren
  452. * @implements Mcu_CheckConfigureGpren_Activity
  453. */
  454. static Std_ReturnType Mcu_CheckConfigureGpren(uint8 u8Module)
  455. {
  456. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  457. #ifdef MCU_CHECK_EMIOS_STATUS
  458. #if (MCU_CHECK_EMIOS_STATUS == STD_ON)
  459. if ( (Std_ReturnType)E_NOT_OK == Mcu_IPW_CheckEmiosStatus(u8Module) )
  460. {
  461. CheckStatus = (Std_ReturnType)E_NOT_OK;
  462. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_EMIOSCONFIGUREGPREN_ID, MCU_E_EMIOS_DEACTIVATED);
  463. }
  464. #endif /* (MCU_CHECK_EMIOS_STATUS == STD_ON) */
  465. #endif /* MCU_CHECK_EMIOS_STATUS */
  466. MCU_PARAM_UNUSED(u8Module);
  467. return CheckStatus;
  468. }
  469. #endif /* ( (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  470. #endif /* MCU_EMIOS_CONFIGURE_GPREN_API */
  471. #ifdef MCU_DISABLE_CMU_API
  472. #if ( (MCU_DISABLE_CMU_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  473. /**
  474. * @brief Mcu_CheckDisableCMU - checks for Mcu_Disable_CMU
  475. */
  476. static Std_ReturnType Mcu_CheckDisableCMU(Clock_Ip_NameType clockName)
  477. {
  478. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  479. if (((uint8)clockName) >= ((uint8)RESERVED_CLK))
  480. {
  481. CheckStatus = (Std_ReturnType)E_NOT_OK;
  482. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, MCU_DISABLECMU_ID, MCU_E_CMU_INDEX_OUT_OF_RANGE);
  483. }
  484. return CheckStatus;
  485. }
  486. #endif /* ( (MCU_DISABLE_CMU_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  487. #endif /* MCU_DISABLE_CMU_API */
  488. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  489. /* MCU state check, entry point. */
  490. /**
  491. * @brief Mcu_HLDChecksEntry - checks for invalid mode transitions.
  492. * @implements Mcu_HLDChecksEntry_Activity
  493. */
  494. static Std_ReturnType Mcu_HLDChecksEntry(uint8 u8McuServiceID)
  495. {
  496. Std_ReturnType CheckStatus = (Std_ReturnType)E_OK;
  497. if (MCU_INIT_ID == u8McuServiceID)
  498. {
  499. if (MCU_UNINIT != Mcu_eStatus) /* If "Mcu_Init" was already called (i.e. driver is initialized). */
  500. {
  501. CheckStatus = (Std_ReturnType)E_NOT_OK;
  502. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, u8McuServiceID, MCU_E_ALREADY_INITIALIZED);
  503. }
  504. }
  505. else
  506. {
  507. if (MCU_UNINIT == Mcu_eStatus) /* If "Mcu_Init" was not called (i.e driver is uninitialized). */
  508. {
  509. CheckStatus = (Std_ReturnType)E_NOT_OK;
  510. (void) Det_ReportError((uint16)MCU_MODULE_ID, MCU_INSTANCE_ID, u8McuServiceID, MCU_E_UNINIT);
  511. }
  512. else
  513. {
  514. Mcu_eStatus = MCU_BUSY;
  515. }
  516. }
  517. return CheckStatus;
  518. }
  519. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  520. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  521. /* MCU state check, exit point. */
  522. /**
  523. * @brief Mcu_HLDChecksExit - checks for invalid mode transitions.
  524. * @implements Mcu_HLDChecksExit_Activity
  525. */
  526. static void Mcu_HLDChecksExit(Std_ReturnType retStatus, uint8 u8McuServiceID)
  527. {
  528. if (MCU_INIT_ID == u8McuServiceID)
  529. {
  530. if ((Std_ReturnType)E_OK == (Std_ReturnType)retStatus)
  531. {
  532. Mcu_eStatus = MCU_IDLE;
  533. }
  534. else
  535. {
  536. Mcu_eStatus = MCU_UNINIT;
  537. }
  538. }
  539. else
  540. {
  541. Mcu_eStatus = MCU_IDLE;
  542. }
  543. }
  544. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  545. /*==================================================================================================
  546. GLOBAL FUNCTIONS
  547. ==================================================================================================*/
  548. /**
  549. * @brief MCU driver initialization function.
  550. * @details This routine initializes the MCU Driver.
  551. * The intention of this function is to make the configuration setting for power
  552. * down, clock and Ram sections visible within the MCU Driver.
  553. *
  554. * @param[in] pConfigPtr Pointer to configuration structure.
  555. *
  556. * @return void
  557. *
  558. * @api
  559. *
  560. * @implements Mcu_Init_Activity
  561. */
  562. void Mcu_Init(const Mcu_ConfigType * pConfigPtr)
  563. {
  564. /* Temporary variable for looping through all the configurations. */
  565. uint32 u32NoConfigs;
  566. #if ( (MCU_VALIDATE_GLOBAL_CALL == STD_ON) || (MCU_PARAM_CHECK == STD_ON) )
  567. Std_ReturnType checkStatus;
  568. #endif /* ( (MCU_VALIDATE_GLOBAL_CALL == STD_ON) || (MCU_PARAM_CHECK == STD_ON) ) */
  569. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  570. checkStatus = (Std_ReturnType) Mcu_HLDChecksEntry(MCU_INIT_ID);
  571. if( (Std_ReturnType)E_OK == checkStatus )
  572. {
  573. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  574. /* Get a local copy of the driver initalization structure. */
  575. #if (MCU_PARAM_CHECK == STD_ON)
  576. /* When PostBuild is used and #(Variants) > 1, the input parameter 'pConfigPtr' is mandatory
  577. * to be different than NULL_PTR. */
  578. /* Check the config. In case of error, return immediately. The "Mcu_CheckInit" function will report DET errors. */
  579. checkStatus = Mcu_CheckInit(pConfigPtr);
  580. if ((Std_ReturnType)E_OK == checkStatus)
  581. {
  582. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  583. #if (MCU_PRECOMPILE_SUPPORT == STD_ON)
  584. Mcu_pConfigPtr = &Mcu_PreCompileConfig;
  585. MCU_PARAM_UNUSED(pConfigPtr);
  586. #else
  587. Mcu_pConfigPtr = pConfigPtr;
  588. #endif /* (MCU_PRECOMPILE_SUPPORT == STD_ON) */
  589. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  590. /* Get a local copy of the DEM error reporting structure. */
  591. Mcu_pDemCfgPtr = Mcu_pConfigPtr->Mcu_pDemConfig;
  592. #endif /* (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
  593. /* Save the Mcu Mode IDs configurations. */
  594. for(u32NoConfigs = (uint32)0U; u32NoConfigs < Mcu_pConfigPtr->Mcu_NoModeConfigs; u32NoConfigs++)
  595. {
  596. Mcu_au8ModeConfigIds[(*Mcu_pConfigPtr->Mcu_apModeConfig)[u32NoConfigs].Power_Ip_ModeConfigId] = (uint8)u32NoConfigs;
  597. }
  598. #if (MCU_INIT_CLOCK == STD_ON)
  599. /* Save the Mcu Clock IDs configurations. */
  600. for(u32NoConfigs = (uint32)0U; u32NoConfigs < Mcu_pConfigPtr->Mcu_NoClkConfigs; u32NoConfigs++)
  601. {
  602. Mcu_au8ClockConfigIds[(*Mcu_pConfigPtr->Mcu_apClockConfig)[u32NoConfigs].ClkConfigId] = (uint8)u32NoConfigs;
  603. }
  604. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  605. #ifndef MCU_MAX_NORAMCONFIGS
  606. /* Save the Mcu Ram Sector IDs configurations. */
  607. for(u32NoConfigs = (uint32)0U; u32NoConfigs < Mcu_pConfigPtr->Mcu_NoRamConfigs; u32NoConfigs++)
  608. {
  609. Mcu_au8RamConfigIds[(*Mcu_pConfigPtr->Mcu_apRamConfig)[u32NoConfigs].RamSectorId] = (uint8)u32NoConfigs;
  610. }
  611. #endif /* (0 != MCU_MAX_RAMCONFIGS) */
  612. Mcu_Ipw_Init(Mcu_pConfigPtr->Mcu_pHwIPsConfig);
  613. #if (MCU_PARAM_CHECK == STD_ON)
  614. }
  615. else
  616. {
  617. /* Clean the init pointer in case of an error. */
  618. Mcu_pConfigPtr = NULL_PTR;
  619. }
  620. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  621. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  622. /* The driver is now initialized. Set the proper status. */
  623. Mcu_HLDChecksExit(checkStatus, MCU_INIT_ID);
  624. }
  625. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  626. }
  627. /**
  628. * @brief MCU driver initialization of Ram sections.
  629. * @details Function initializes the ram section selected by RamSection parameter.
  630. * The section base address, size and value to be written are provided from
  631. * the configuration structure.
  632. * The function will write the value specified in the configuration structure
  633. * indexed by RamSection.
  634. * After the write it will read back the RAM to verify that the requested value was
  635. * written.
  636. *
  637. * @param[in] RamSection Index of ram section from configuration structure to be initialized.
  638. *
  639. * @return Command has or has not been accepted.
  640. * @retval E_OK Valid parameter, the driver state allowed execution and the RAM
  641. * check was successful
  642. * @retval E_NOT_OK Invalid parameter, the driver state did not allowed execution or
  643. * the RAM check was not successful
  644. *
  645. * @api
  646. *
  647. * @implements Mcu_InitRamSection_Activity
  648. *
  649. */
  650. Std_ReturnType Mcu_InitRamSection(Mcu_RamSectionType RamSection)
  651. {
  652. /* Result of the operation. */
  653. Std_ReturnType RamStatus = (Std_ReturnType)E_NOT_OK;
  654. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  655. /* Check if the driver is initialized. */
  656. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_INITRAMSECTION_ID) )
  657. {
  658. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  659. #ifndef MCU_MAX_NORAMCONFIGS
  660. #if (MCU_PARAM_CHECK == STD_ON)
  661. /* Check if Ram memory configuration is valid. */
  662. /* If no ramConfig is defined, the function will return immediately. */
  663. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckInitRamSection(RamSection) )
  664. {
  665. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  666. /* Get Ram settings from the configuration structure. */
  667. RamStatus = Mcu_Ipw_InitRamSection(&(*Mcu_pConfigPtr->Mcu_apRamConfig)[Mcu_au8RamConfigIds[RamSection]]);
  668. #if (MCU_PARAM_CHECK == STD_ON)
  669. }
  670. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  671. #else
  672. /* To avoid compiler warning. */
  673. MCU_PARAM_UNUSED(RamSection);
  674. #endif /* #ifndef MCU_MAX_NORAMCONFIGS */
  675. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  676. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_INITRAMSECTION_ID);
  677. }
  678. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  679. return RamStatus;
  680. }
  681. #if (MCU_INIT_CLOCK == STD_ON)
  682. /**
  683. * @brief MCU driver clock initialization function.
  684. * @details This function intializes the PLL and MCU specific clock options. The clock
  685. * setting is provided from the configuration structure.
  686. *
  687. * @param[in] ClockSetting Clock setting ID from config structure to be used.
  688. *
  689. * @return Command has or has not been accepted.
  690. * @retval E_OK The driver state allowed the execution of the function and the
  691. * provided parameter was in range
  692. * @retval E_NOT_OK The driver state did not allowed execution or the parameter was
  693. * invalid
  694. *
  695. * @api
  696. *
  697. * @implements Mcu_InitClock_Activity
  698. */
  699. Std_ReturnType Mcu_InitClock(Mcu_ClockType ClockSetting)
  700. {
  701. /* Return the success of the clock initalization operation. */
  702. #if ( (MCU_VALIDATE_GLOBAL_CALL == STD_ON) || (MCU_PARAM_CHECK == STD_ON) )
  703. Std_ReturnType ClockStatus = (Std_ReturnType)E_NOT_OK;
  704. #else
  705. Std_ReturnType ClockStatus;
  706. #endif
  707. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  708. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_INITCLOCK_ID) )
  709. {
  710. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  711. /* Check if Clock configuration is valid. */
  712. #if (MCU_PARAM_CHECK == STD_ON)
  713. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckInitClock(ClockSetting) )
  714. {
  715. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  716. Mcu_Ipw_InitClock(&(*Mcu_pConfigPtr->Mcu_apClockConfig)[Mcu_au8ClockConfigIds[ClockSetting]]);
  717. /* Command has been accepted. */
  718. ClockStatus = (Std_ReturnType)E_OK;
  719. #if (MCU_PARAM_CHECK == STD_ON)
  720. }
  721. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  722. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  723. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_INITCLOCK_ID);
  724. }
  725. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  726. return ClockStatus;
  727. }
  728. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  729. /**
  730. * @brief This function sets the MCU power mode.
  731. * @details This function activates MCU power mode from config structure selected by McuMode
  732. * parameter.
  733. * If the driver state is invalid or McuMode is not in range the function will skip
  734. * changing the mcu mode.
  735. *
  736. * @param[in] McuMode MCU mode setting ID from config structure to be set.
  737. *
  738. * @return void
  739. *
  740. * @api
  741. *
  742. * @implements Mcu_SetMode_Activity
  743. */
  744. void Mcu_SetMode(Mcu_ModeType McuMode)
  745. {
  746. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  747. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_SETMODE_ID) )
  748. {
  749. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  750. #if (MCU_PARAM_CHECK == STD_ON)
  751. /* Check if Mode configuration is valid. */
  752. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckSetMode(McuMode) )
  753. {
  754. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  755. /* ASR 4.3.1: "Mcu_SetMode" has to be "concurrency-safe" */
  756. SchM_Enter_Mcu_MCU_EXCLUSIVE_AREA_00();
  757. Mcu_Ipw_SetMode( &(*Mcu_pConfigPtr->Mcu_apModeConfig)[Mcu_au8ModeConfigIds[McuMode]] );
  758. SchM_Exit_Mcu_MCU_EXCLUSIVE_AREA_00();
  759. #if (MCU_PARAM_CHECK == STD_ON)
  760. }
  761. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  762. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  763. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_SETMODE_ID);
  764. }
  765. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  766. }
  767. #if (MCU_INIT_CLOCK == STD_ON)
  768. #if (MCU_NO_PLL == STD_OFF)
  769. /**
  770. * @brief This function activates the PLL clock to the MCU clock distribution.
  771. * @details Function completes the PLL configuration and then activates the PLL clock to
  772. * MCU. If the MCU_NO_PLL is TRUE the Mcu_DistributePllClock has to be
  773. * disabled.
  774. * The function will not distribute the PLL clock if the driver state does not
  775. * allow it, or the PLL is not stable.
  776. *
  777. * @return Std_ReturnType
  778. * @retval E_OK Command has been accepted.
  779. * @retval E_NOT_OK Command has not been accepted.
  780. *
  781. * @api
  782. *
  783. * @implements Mcu_DistributePllClock_Activity
  784. *
  785. */
  786. Std_ReturnType Mcu_DistributePllClock(void)
  787. {
  788. /* Return variable */
  789. Std_ReturnType PllStatus = (Std_ReturnType)E_NOT_OK;
  790. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  791. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_DISTRIBUTEPLLCLOCK_ID) )
  792. {
  793. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  794. #if (MCU_PARAM_CHECK == STD_ON)
  795. /* Check if the PLL is locked. */
  796. if( (Std_ReturnType)E_OK == (Std_ReturnType)Mcu_CheckDistributePllClock() )
  797. {
  798. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  799. /* Set the PLL as System Clock if it is locked and enabled by the current mode.
  800. If the PLL0 is already selected as system clock, then this function will return without
  801. doing anything. */
  802. Mcu_Ipw_DistributePllClock();
  803. PllStatus = (Std_ReturnType)E_OK;
  804. #if (MCU_PARAM_CHECK == STD_ON)
  805. }
  806. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  807. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  808. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_DISTRIBUTEPLLCLOCK_ID);
  809. }
  810. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  811. return PllStatus;
  812. }
  813. #endif /* (MCU_NO_PLL == STD_OFF) */
  814. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  815. /**
  816. * @brief This function returns the lock status of the PLL.
  817. * @details The user takes care that the PLL is locked by executing Mcu_GetPllStatus.
  818. * If the MCU_NO_PLL is TRUE the MCU_GetPllStatus has to return
  819. * MCU_PLL_STATUS_UNDEFINED.
  820. * It will also return MCU_PLL_STATUS_UNDEFINED if the driver state was invalid
  821. *
  822. * @return Provides the lock status of the PLL.
  823. * @retval MCU_PLL_STATUS_UNDEFINED PLL Status is unknown.
  824. * @retval MCU_PLL_LOCKED PLL is locked.
  825. * @retval MCU_PLL_UNLOCKED PLL is unlocked.
  826. *
  827. * @api
  828. *
  829. * @implements Mcu_GetPllStatus_Activity
  830. *
  831. *
  832. */
  833. Mcu_PllStatusType Mcu_GetPllStatus(void)
  834. {
  835. /* Return variable. */
  836. #if ( (MCU_VALIDATE_GLOBAL_CALL == STD_ON) || (MCU_NO_PLL == STD_ON) )
  837. Mcu_PllStatusType ePllStatus = MCU_PLL_STATUS_UNDEFINED;
  838. #else
  839. Mcu_PllStatusType ePllStatus;
  840. #endif
  841. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  842. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETPLLSTATUS_ID) )
  843. {
  844. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  845. /* If the PLL is not used in the configuration, return MCU_PLL_STATUS_UNDEFINED. */
  846. #if (MCU_NO_PLL == STD_OFF)
  847. /* Get status of the PLL (if enabled in current mode).
  848. At this point, the return value can be only MCU_PLL_LOCKED or MCU_PLL_UNLOCKED. */
  849. ePllStatus = Mcu_Ipw_GetPllStatus();
  850. #endif /* (MCU_NO_PLL == STD_OFF) */
  851. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  852. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETPLLSTATUS_ID);
  853. }
  854. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  855. return ePllStatus;
  856. }
  857. /**
  858. * @brief This function returns the Reset reason.
  859. * @details This routine returns the Reset reason that is read from the hardware.
  860. *
  861. *
  862. * @return Reason of the Reset event.
  863. *
  864. * @api
  865. *
  866. * @implements Mcu_GetResetReason_Activity
  867. */
  868. Mcu_ResetType Mcu_GetResetReason(void)
  869. {
  870. /* Return value of the function. */
  871. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  872. Mcu_ResetType eResetReason = MCU_RESET_UNDEFINED;
  873. #else
  874. Mcu_ResetType eResetReason;
  875. #endif
  876. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  877. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETRESETREASON_ID) )
  878. {
  879. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  880. /* Get the reset reason. */
  881. eResetReason = Mcu_Ipw_GetResetReason();
  882. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  883. Mcu_HLDChecksExit( (Std_ReturnType)E_OK, MCU_GETRESETREASON_ID);
  884. }
  885. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  886. return eResetReason;
  887. }
  888. /**
  889. * @brief This function returns the Raw Reset value.
  890. * @details This routine returns the Raw Reset value that is read from the hardware.
  891. *
  892. * @return Description of the returned value.
  893. * @retval uint32 Code of the Raw reset value.
  894. *
  895. * @api
  896. *
  897. * @implements Mcu_GetResetRawValue_Activity
  898. *
  899. */
  900. Mcu_RawResetType Mcu_GetResetRawValue(void)
  901. {
  902. /* Return value of the function. */
  903. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  904. Mcu_RawResetType RawResetValue = MCU_RAW_RESET_DEFAULT;
  905. #else
  906. Mcu_RawResetType RawResetValue;
  907. #endif
  908. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  909. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETRESETRAWVALUE_ID) )
  910. {
  911. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  912. RawResetValue = (Mcu_RawResetType) Mcu_Ipw_GetResetRawValue();
  913. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  914. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETRESETRAWVALUE_ID);
  915. }
  916. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  917. return RawResetValue;
  918. }
  919. #if (MCU_PERFORM_RESET_API == STD_ON)
  920. /**
  921. * @brief This function performs a microcontroller reset.
  922. * @details This function performs a microcontroller reset by using the hardware feature of
  923. * the microcontroller. In case the function returns, the user must reset the
  924. * platform using an alternate reset mechanism
  925. *
  926. * @return void
  927. *
  928. * @api
  929. *
  930. * @implements Mcu_PerformReset_Activity
  931. */
  932. void Mcu_PerformReset(void)
  933. {
  934. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  935. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_PERFORMRESET_ID) )
  936. {
  937. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  938. #if (MCU_PARAM_CHECK == STD_ON)
  939. if ( (Std_ReturnType)E_OK == (Std_ReturnType)Mcu_CheckPerformReset() )
  940. {
  941. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  942. #if (MCU_RESET_CALLOUT_USED == STD_ON)
  943. /* User callout. */
  944. MCU_RESET_CALLOUT();
  945. #endif /* (MCU_RESET_CALLOUT_USED == STD_ON) */
  946. Mcu_Ipw_PerformReset(Mcu_pConfigPtr->Mcu_pHwIPsConfig);
  947. /* we should not get here */
  948. /* it's the app. responsability to detect if the reset failled */
  949. #if (MCU_PARAM_CHECK == STD_ON)
  950. }
  951. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  952. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  953. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_PERFORMRESET_ID);
  954. }
  955. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  956. }
  957. #endif /* (MCU_PERFORM_RESET_API == STD_ON) */
  958. #if (MCU_VERSION_INFO_API == STD_ON)
  959. /**
  960. * @brief This function returns the Version Information for the MCU module.
  961. * @details This function returns the vendor id, module id, major, minor and patch version.
  962. *
  963. * @param[in,out] pVersionInfo A pointer to a variable to store version info.
  964. *
  965. * @return void
  966. *
  967. * @api
  968. *
  969. * @implements Mcu_GetVersionInfo_Activity
  970. */
  971. void Mcu_GetVersionInfo(Std_VersionInfoType * pVersionInfo)
  972. {
  973. #if (MCU_PARAM_CHECK == STD_ON)
  974. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckGetVersionInfo(pVersionInfo) )
  975. {
  976. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  977. (pVersionInfo)->vendorID = (uint16)MCU_VENDOR_ID;
  978. (pVersionInfo)->moduleID = (uint8)MCU_MODULE_ID;
  979. (pVersionInfo)->sw_major_version = (uint8)MCU_SW_MAJOR_VERSION;
  980. (pVersionInfo)->sw_minor_version = (uint8)MCU_SW_MINOR_VERSION;
  981. (pVersionInfo)->sw_patch_version = (uint8)MCU_SW_PATCH_VERSION;
  982. #if (MCU_PARAM_CHECK == STD_ON)
  983. }
  984. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  985. }
  986. #endif /* (MCU_VERSION_INFO_API == STD_ON) */
  987. #ifdef MCU_GET_MIDR_API
  988. #if (MCU_GET_MIDR_API == STD_ON)
  989. /**
  990. * @brief This function returns the value of the MIDR registers.
  991. * @details This function returns the platform dependent Mcu_MidrReturnType structure witch
  992. * contains the MIDRn registers.
  993. *
  994. * @param[in,out] pMidr A pointer to a variable to store the Mcu_MidrReturnType structure.
  995. *
  996. * @return void
  997. *
  998. * @api
  999. *
  1000. * @implements Mcu_GetMidrStructure_Activity
  1001. *
  1002. */
  1003. void Mcu_GetMidrStructure(Mcu_MidrReturnType pMidr[MCU_SIUL2_TOTAL_UNITS])
  1004. {
  1005. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1006. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETMIDRSTRUCTURE_ID) )
  1007. {
  1008. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1009. #ifdef MCU_GET_MIDR_API
  1010. #if ( (MCU_GET_MIDR_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) )
  1011. /* Check if Mode configuration is valid. */
  1012. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckGetMidrStructure(pMidr) )
  1013. {
  1014. #endif /* ( (MCU_GET_MIDR_API == STD_ON) && (MCU_PARAM_CHECK == STD_ON) ) */
  1015. #endif /* MCU_GET_MIDR_API */
  1016. Mcu_Ipw_GetMidrStructure( pMidr );
  1017. #if (MCU_PARAM_CHECK == STD_ON)
  1018. }
  1019. #endif /* ( MCU_PARAM_CHECK == STD_ON) */
  1020. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1021. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETMIDRSTRUCTURE_ID);
  1022. }
  1023. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1024. }
  1025. #endif /* (MCU_GET_MIDR_API == STD_ON) */
  1026. #endif /* MCU_GET_MIDR_API */
  1027. #if (MCU_GET_RAM_STATE_API == STD_ON)
  1028. /**
  1029. * @brief This function returns the actual state of the RAM.
  1030. * @details This function returns if the Ram Status is valid after a reset.
  1031. * The report is get from STCU as a result of MBIST (Memory Built-In Self Tests).
  1032. *
  1033. * @return Status of the Ram Content.
  1034. *
  1035. * @retval MCU_RAMSTATE_INVALID Ram state is not valid or unknown (default),
  1036. * or the driver state does not allow this call.
  1037. * @retval MCU_RAMSTATE_VALID Ram state is valid.
  1038. *
  1039. * @api
  1040. *
  1041. * @implements Mcu_GetRamState_Activity
  1042. *
  1043. */
  1044. Mcu_RamStateType Mcu_GetRamState(void)
  1045. {
  1046. /* Return value of this function. */
  1047. Mcu_RamStateType eRamState = MCU_RAMSTATE_INVALID;
  1048. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1049. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETRAMSTATE_ID) )
  1050. {
  1051. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1052. eRamState = Mcu_Ipw_GetRamState();
  1053. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1054. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETRAMSTATE_ID);
  1055. }
  1056. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1057. return eRamState;
  1058. }
  1059. #endif /* (MCU_GET_RAM_STATE_API == STD_ON) */
  1060. #if (MCU_GET_PERIPH_STATE_API == STD_ON)
  1061. /**
  1062. * @brief This function returns the peripheral clock state.
  1063. * @details This function returns one peripheral is frozen or active from MC_ME hw IP.
  1064. *
  1065. * @param[in] McuPeriphId Peripheral ID based ME_PSx registers.
  1066. *
  1067. * @return Status of the peripheral clock.
  1068. * @retval E_OK Peripheral is active (clocked).
  1069. * @retval E_NOT_OK Peripheral is not active (not clocked) or the driver state did not
  1070. * allow the call.
  1071. *
  1072. * @api
  1073. *
  1074. */
  1075. Std_ReturnType Mcu_GetPeripheralState(Mcu_PeripheralIdType McuPeriphId)
  1076. {
  1077. /* Result of the operation. */
  1078. Std_ReturnType PeripheralStatus = (Std_ReturnType)E_NOT_OK;
  1079. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1080. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETPERIPHERALSTATE_ID) )
  1081. {
  1082. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1083. PeripheralStatus = (Std_ReturnType) Mcu_Ipw_GetPeripheralState(McuPeriphId);
  1084. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1085. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETPERIPHERALSTATE_ID);
  1086. }
  1087. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1088. return PeripheralStatus;
  1089. }
  1090. #endif /* (MCU_GET_PERIPH_STATE_API == STD_ON) */
  1091. #ifdef MCU_GET_SYSTEM_STATE_API
  1092. #if (MCU_GET_SYSTEM_STATE_API == STD_ON)
  1093. /**
  1094. * @brief This function returns the System Status and Configuration Module information.
  1095. * @details This function returns information about execution mode, security, vle, jtag id.
  1096. *
  1097. * @return Status read from SSCM module - STATUS and MEMCONFIG registers.
  1098. * @retval uint32 Platform register specific.
  1099. *
  1100. * @api
  1101. *
  1102. */
  1103. Mcu_SSCM_SystemStateType Mcu_GetSystemState(void)
  1104. {
  1105. Mcu_SSCM_SystemStateType SystemStatus = (Mcu_SSCM_SystemStateType)0U;
  1106. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1107. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETSYSTEMSTATE_ID) )
  1108. {
  1109. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1110. SystemStatus = Mcu_Ipw_GetSystemState();
  1111. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1112. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETSYSTEMSTATE_ID);
  1113. }
  1114. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1115. return SystemStatus;
  1116. }
  1117. #endif /* (MCU_GET_SYSTEM_STATE_API == STD_ON) */
  1118. #endif /* MCU_GET_SYSTEM_STATE_API */
  1119. #ifdef MCU_GET_MEM_CONFIG_API
  1120. #if (MCU_GET_MEM_CONFIG_API == STD_ON)
  1121. /**
  1122. * @brief This function returns the System Memory and ID register from SSCM.
  1123. * @details This function returns the value of the SSCM_MEMCONFIG register.
  1124. *
  1125. * @return Value read from SSCM_MEMCONFIG register.
  1126. * @retval Mcu_SSCM_MemConfigType Platform register specific.
  1127. *
  1128. * @api
  1129. *
  1130. * @implements Mcu_SscmGetMemConfig_Activity
  1131. *
  1132. */
  1133. Mcu_SSCM_MemConfigType Mcu_SscmGetMemConfig(void)
  1134. {
  1135. Mcu_SSCM_MemConfigType MemConfig = (Mcu_SSCM_MemConfigType)0U;
  1136. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1137. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETMEMCONFIG_ID) )
  1138. {
  1139. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1140. MemConfig = Mcu_Ipw_SscmGetMemConfig();
  1141. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1142. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETMEMCONFIG_ID);
  1143. }
  1144. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1145. return MemConfig;
  1146. }
  1147. #endif /* (MCU_GET_MEM_CONFIG_API == STD_ON) */
  1148. #endif /* MCU_GET_MEM_CONFIG_API */
  1149. #ifdef MCU_SSCM_GET_STATUS_API
  1150. #if (MCU_SSCM_GET_STATUS_API == STD_ON)
  1151. /**
  1152. * @brief This function returns the value of the SSCM_STATUS register..
  1153. * @details Return information about execution mode, security, vle.
  1154. *
  1155. * @return Value read from SSCM_STATUS register.
  1156. * @retval Mcu_SSCM_StatusType Platform register specific.
  1157. *
  1158. * @api
  1159. *
  1160. * @implements Mcu_SscmGetStatus_Activity
  1161. *
  1162. */
  1163. Mcu_SSCM_StatusType Mcu_SscmGetStatus(void)
  1164. {
  1165. Mcu_SSCM_StatusType Status = (Mcu_SSCM_StatusType)0U;
  1166. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1167. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_SSCMGETSTATUS_ID) )
  1168. {
  1169. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1170. Status = Mcu_Ipw_SscmGetStatus();
  1171. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1172. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_SSCMGETSTATUS_ID);
  1173. }
  1174. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1175. return Status;
  1176. }
  1177. #endif /* (MCU_SSCM_GET_STATUS_API == STD_ON) */
  1178. #endif /* MCU_SSCM_GET_STATUS_API */
  1179. #ifdef MCU_SSCM_GET_UOPT_API
  1180. #if (MCU_SSCM_GET_UOPT_API == STD_ON)
  1181. /**
  1182. * @brief This function returns the value of the SSCM_UOPT register.
  1183. * @details Return information about User Option Bits, HSM Boot Configuration.
  1184. *
  1185. * @return Value read from SSCM_UOPT register.
  1186. * @retval Mcu_SSCM_UoptType Platform register specific.
  1187. *
  1188. * @api
  1189. *
  1190. * @implements Mcu_SscmGetUopt_Activity
  1191. *
  1192. */
  1193. Mcu_SSCM_UoptType Mcu_SscmGetUopt(void)
  1194. {
  1195. Mcu_SSCM_UoptType Status = (Mcu_SSCM_UoptType)0U;
  1196. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1197. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_SSCMGETUOPT_ID) )
  1198. {
  1199. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1200. Status = Mcu_Ipw_SscmGetUopt();
  1201. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1202. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_SSCMGETUOPT_ID);
  1203. }
  1204. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1205. return Status;
  1206. }
  1207. #endif /* (MCU_SSCM_GET_UOPT_API == STD_ON) */
  1208. #endif /* MCU_SSCM_GET_UOPT_API */
  1209. #if (MCU_POWERMODE_STATE_API == STD_ON)
  1210. /**
  1211. * @brief This function returns the System Status (power mode, clock settings)
  1212. * @details The return value is the content register read from hardware. The return
  1213. * value shall evidentiate the current running mode.
  1214. *
  1215. * @return Get the state of the power mode.
  1216. * @retval uint32 Content of register.
  1217. *
  1218. * @api
  1219. *
  1220. */
  1221. Mcu_PowerModeStateType Mcu_GetPowerModeState(void)
  1222. {
  1223. /* Return value of this function. */
  1224. Mcu_PowerModeStateType PowerModeState = (Mcu_PowerModeStateType)0U;
  1225. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1226. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETPOWERMODESTATE_ID) )
  1227. {
  1228. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1229. PowerModeState = (Mcu_PowerModeStateType) Mcu_Ipw_GetPowerModeState();
  1230. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1231. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETPOWERMODESTATE_ID);
  1232. }
  1233. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1234. return PowerModeState;
  1235. }
  1236. #endif /* (MCU_POWERMODE_STATE_API == STD_ON) */
  1237. #if (MCU_GET_POWER_DOMAIN_API == STD_ON)
  1238. /**
  1239. * @brief This function returns the power status of all available power domains.
  1240. * @details This function returns if power domain is operable or inoperable form MC_PCU hw
  1241. * IP.
  1242. *
  1243. * @return Get the state of Power Control Unit
  1244. * @retval E_OK Power domain is operable.
  1245. * @retval E_NOT_OK Power domain is inoperable or the driver state did not alloed the
  1246. * functionc all.
  1247. *
  1248. * @api
  1249. *
  1250. */
  1251. Std_ReturnType Mcu_GetPowerDomainState(void)
  1252. {
  1253. /* Result of the operation. */
  1254. Std_ReturnType PowerStatus = (Std_ReturnType)E_NOT_OK;
  1255. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1256. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETPOWERDOMAIN_ID) )
  1257. {
  1258. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1259. PowerStatus = (Std_ReturnType) Mcu_Ipw_GetPowerDomainState();
  1260. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1261. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETPOWERDOMAIN_ID);
  1262. }
  1263. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1264. return PowerStatus;
  1265. }
  1266. #endif /* (MCU_GET_POWER_DOMAIN_API == STD_ON) */
  1267. #ifdef MCU_EMIOS_CONFIGURE_GPREN_API
  1268. #if (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON)
  1269. /**
  1270. * @brief eMios Global Prescaler Enable.
  1271. * @details This function enables or disables the GPREN bit of the EMIOSMCR register of an
  1272. * addressed eMIOS instance.
  1273. * @pre Function requires an execution of Mcu_Init() before it can be used,
  1274. *otherwise it reports error to DET.
  1275. *
  1276. * @param[in] u8Module MCU_EMIOS_MODULE_0 --> Select eMios 0
  1277. * MCU_EMIOS_MODULE_1 --> Select eMios 1
  1278. * MCU_EMIOS_MODULE_2 --> Select eMios 2
  1279. *
  1280. * @param[in] u8Value MCU_EMIOS_GPREN_BIT_ENABLE --> Global Prescaler Enabled
  1281. * MCU_EMIOS_GPREN_BIT_DISABLE --> Global Prescaler Disabled
  1282. *
  1283. * @return void
  1284. *
  1285. * @api
  1286. * @implements Mcu_EmiosConfigureGpren_Activity
  1287. */
  1288. void Mcu_EmiosConfigureGpren(uint8 u8Module, uint8 u8Value)
  1289. {
  1290. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1291. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_EMIOSCONFIGUREGPREN_ID) )
  1292. {
  1293. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1294. #if (MCU_PARAM_CHECK == STD_ON)
  1295. if ( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckConfigureGpren(u8Module) )
  1296. {
  1297. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  1298. Mcu_Ipw_EmiosConfigureGpren(u8Module, u8Value);
  1299. #if (MCU_PARAM_CHECK == STD_ON)
  1300. }
  1301. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  1302. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1303. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_EMIOSCONFIGUREGPREN_ID);
  1304. }
  1305. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1306. }
  1307. #endif /* (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) */
  1308. #endif /* MCU_EMIOS_CONFIGURE_GPREN_API */
  1309. #ifdef MCU_DISABLE_CMU_API
  1310. #if (MCU_DISABLE_CMU_API == STD_ON)
  1311. /**
  1312. * @brief Disable clock monitoring unit.
  1313. * @details This function disables the selected clock monitoring unit.
  1314. * @pre Function requires an execution of Mcu_Init() before it can be used.
  1315. *
  1316. * @param[in] clockName Name of the monitor clock for which CMU must be disabled.
  1317. *
  1318. * @return void
  1319. *
  1320. * @api
  1321. * @implements Mcu_DisableCmu_Activity
  1322. */
  1323. void Mcu_DisableCmu(Clock_Ip_NameType clockName)
  1324. {
  1325. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1326. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_DISABLECMU_ID) )
  1327. {
  1328. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1329. #if (MCU_PARAM_CHECK == STD_ON)
  1330. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_CheckDisableCMU(clockName) )
  1331. {
  1332. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  1333. Mcu_Ipw_DisableCmu(clockName);
  1334. #if (MCU_PARAM_CHECK == STD_ON)
  1335. }
  1336. #endif /* (MCU_PARAM_CHECK == STD_ON) */
  1337. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1338. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_DISABLECMU_ID);
  1339. }
  1340. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1341. }
  1342. #endif /* (MCU_DISABLE_CMU_API == STD_ON) */
  1343. #endif /* MCU_DISABLE_CMU_API */
  1344. #ifdef MCU_GET_CLOCK_FREQUENCY_API
  1345. #if (MCU_GET_CLOCK_FREQUENCY_API == STD_ON)
  1346. /**
  1347. * @brief Return the frequency of a given clock.
  1348. * @details This function returns the frequency of a given clock which is request by user.
  1349. * @pre Function requires an execution of Mcu_Init() before it can be used,
  1350. *
  1351. * @param[in] clockName Name of the monitor clock for which CMU must be disabled.
  1352. *
  1353. * @return uint32
  1354. *
  1355. * @api
  1356. *
  1357. */
  1358. uint32 Mcu_GetClockFrequency(Clock_Ip_NameType clockName)
  1359. {
  1360. uint32 u32Frequency = 0U;
  1361. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1362. if( (Std_ReturnType)E_OK == (Std_ReturnType) Mcu_HLDChecksEntry(MCU_GETCLOCKFREQUENCY_ID) )
  1363. {
  1364. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1365. u32Frequency = MCU_Ipw_GetClockFrequency(clockName);
  1366. #if (MCU_VALIDATE_GLOBAL_CALL == STD_ON)
  1367. Mcu_HLDChecksExit((Std_ReturnType)E_OK, MCU_GETCLOCKFREQUENCY_ID);
  1368. }
  1369. #endif /* (MCU_VALIDATE_GLOBAL_CALL == STD_ON) */
  1370. return u32Frequency;
  1371. }
  1372. #endif /* (MCU_GET_CLOCK_FREQUENCY_API == STD_ON) */
  1373. #endif /* MCU_GET_CLOCK_FREQUENCY_API */
  1374. #ifdef MCU_SLEEPONEXIT_SUPPORT
  1375. #if (MCU_SLEEPONEXIT_SUPPORT == STD_ON)
  1376. /**
  1377. * @brief This function disable/enable SleepOnExit.
  1378. * @details Disable/enable Sleep on exit when returning from Handler mode to Thread mode.
  1379. *
  1380. * @param[in] Mcu_SleepOnExitType The value will be configured to SLEEPONEXIT bits.
  1381. * MCU_SLEEP_ON_EXIT_DISABLED - Disable SLEEPONEXIT bit.
  1382. * MCU_SLEEP_ON_EXIT_ENABLED - Enable SLEEPONEXIT bit.
  1383. * @return void
  1384. *
  1385. * @api
  1386. *
  1387. * @implements Mcu_SleepOnExit_Activity
  1388. *
  1389. */
  1390. void Mcu_SleepOnExit(Mcu_SleepOnExitType SleepOnExit)
  1391. {
  1392. #if ( MCU_VALIDATE_GLOBAL_CALL == STD_ON )
  1393. if((Std_ReturnType)E_OK == (Std_ReturnType)Mcu_HLDChecksEntry(MCU_SLEEPONEXIT_ID))
  1394. {
  1395. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  1396. Mcu_Ipw_SleepOnExit(SleepOnExit);
  1397. #if ( MCU_VALIDATE_GLOBAL_CALL == STD_ON )
  1398. Mcu_HLDChecksExit( (Std_ReturnType)E_OK ,MCU_SLEEPONEXIT_ID);
  1399. }
  1400. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  1401. }
  1402. #endif
  1403. #endif
  1404. #ifdef MCU_SRAM_RETEN_CONFIG_API
  1405. #if (MCU_SRAM_RETEN_CONFIG_API == STD_ON)
  1406. /**
  1407. * @brief Configuration for SRAM retention.
  1408. * @details This function configure for both SRAML_RETEN and SRAMU_RETEN bits.
  1409. * @pre Function requires an execution of Mcu_Init() before it can be used.
  1410. *
  1411. * @param[in] eSRAMRetenConfig The value will be configured to SRAML_RETEN and SRAMU_RETEN bits.
  1412. * MCU_SRAML_RETEN - SRAML will be retain only.
  1413. * MCU_SRAMU_RETEN - SRAMU will be retain only.
  1414. * MCU_SRAMLU_RETEN - Both SRAML and SRAMU will be retain.
  1415. * MCU_NO_SRAMLU_RETEN - Both SRAML and SRAMU will not be retain.
  1416. *
  1417. * @return void
  1418. *
  1419. * @api
  1420. */
  1421. void Mcu_SRAMRetentionConfig(Mcu_SRAMRetenConfigType eSRAMRetenConfig)
  1422. {
  1423. #if ( MCU_VALIDATE_GLOBAL_CALL == STD_ON )
  1424. if((Std_ReturnType)E_OK == (Std_ReturnType)Mcu_HLDChecksEntry(MCU_SRAMRETENCONFIG_ID))
  1425. {
  1426. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  1427. Mcu_Ipw_SRAMRetentionConfig(eSRAMRetenConfig);
  1428. #if ( MCU_VALIDATE_GLOBAL_CALL == STD_ON )
  1429. Mcu_HLDChecksExit( (Std_ReturnType)E_OK ,MCU_SRAMRETENCONFIG_ID);
  1430. }
  1431. #endif /*( MCU_VALIDATE_GLOBAL_CALL == STD_ON )*/
  1432. }
  1433. #endif
  1434. #endif
  1435. #define MCU_STOP_SEC_CODE
  1436. #include "Mcu_MemMap.h"
  1437. #ifdef __cplusplus
  1438. }
  1439. #endif
  1440. /** @} */