Mcu_IPW.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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_IPW.c
  26. * @version 1.0.0
  27. *
  28. * @brief AUTOSAR Mcu - Mcu driver header file.
  29. * @details AUTOSAR specific Mcu driver header file.
  30. * @addtogroup MCU_DRIVER Mcu Driver
  31. * @{
  32. */
  33. #ifdef __cplusplus
  34. extern "C"{
  35. #endif
  36. /*==================================================================================================
  37. * INCLUDE FILES
  38. * 1) system and project includes
  39. * 2) needed interfaces from external units
  40. * 3) internal and external interfaces from this unit
  41. ==================================================================================================*/
  42. /* Header file with prototype functions defines in this layer. */
  43. #include "Mcu_IPW.h"
  44. #include "Clock_Ip.h"
  45. #include "Power_Ip.h"
  46. #include "Ram_Ip.h"
  47. #include "Mcu.h"
  48. #if (MCU_DEV_ERROR_DETECT == STD_ON)
  49. #include "Det.h"
  50. #endif
  51. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  52. #include "Mcu_Dem_Wrapper.h"
  53. #endif
  54. /*==================================================================================================
  55. SOURCE FILE VERSION INFORMATION
  56. ==================================================================================================*/
  57. #define MCU_IPW_VENDOR_ID_C 43
  58. #define MCU_IPW_AR_RELEASE_MAJOR_VERSION_C 4
  59. #define MCU_IPW_AR_RELEASE_MINOR_VERSION_C 4
  60. #define MCU_IPW_AR_RELEASE_REVISION_VERSION_C 0
  61. #define MCU_IPW_SW_MAJOR_VERSION_C 1
  62. #define MCU_IPW_SW_MINOR_VERSION_C 0
  63. #define MCU_IPW_SW_PATCH_VERSION_C 0
  64. /*==================================================================================================
  65. * FILE VERSION CHECKS
  66. ==================================================================================================*/
  67. /* Check if Mcu_IPW.c file and Mcu_IPW.h file are of the same vendor */
  68. #if (MCU_IPW_VENDOR_ID_C != MCU_IPW_VENDOR_ID)
  69. #error "Mcu_IPW.c and Mcu_IPW.h have different vendor ids"
  70. #endif
  71. /* Check if Mcu_IPW.c file and Mcu_IPW.h file are of the same Autosar version */
  72. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != MCU_IPW_AR_RELEASE_MAJOR_VERSION) || \
  73. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != MCU_IPW_AR_RELEASE_MINOR_VERSION) || \
  74. (MCU_IPW_AR_RELEASE_REVISION_VERSION_C != MCU_IPW_AR_RELEASE_REVISION_VERSION) \
  75. )
  76. #error "AutoSar Version Numbers of Mcu_IPW.c and Mcu_IPW.h are different"
  77. #endif
  78. /* Check if Mcu_IPW.c file and Mcu_IPW.h file are of the same Software version */
  79. #if ((MCU_IPW_SW_MAJOR_VERSION_C != MCU_IPW_SW_MAJOR_VERSION) || \
  80. (MCU_IPW_SW_MINOR_VERSION_C != MCU_IPW_SW_MINOR_VERSION) || \
  81. (MCU_IPW_SW_PATCH_VERSION_C != MCU_IPW_SW_PATCH_VERSION) \
  82. )
  83. #error "Software Version Numbers of Mcu_IPW.c and Mcu_IPW.h are different"
  84. #endif
  85. /* Check if Mcu_IPW.c file and Power_Ip.h file are of the same vendor */
  86. #if (MCU_IPW_VENDOR_ID_C != POWER_IP_VENDOR_ID)
  87. #error "Mcu_IPW.c and Power_Ip.h have different vendor ids"
  88. #endif
  89. /* Check if Mcu_IPW.c file and Power_Ip.h file are of the same Autosar version */
  90. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != POWER_IP_AR_RELEASE_MAJOR_VERSION) || \
  91. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != POWER_IP_AR_RELEASE_MINOR_VERSION) || \
  92. (MCU_IPW_AR_RELEASE_REVISION_VERSION_C != POWER_IP_AR_RELEASE_REVISION_VERSION) \
  93. )
  94. #error "AutoSar Version Numbers of Mcu_IPW.c and Power_Ip.h are different"
  95. #endif
  96. /* Check if Mcu_IPW.c file and Power_Ip.h file are of the same Software version */
  97. #if ((MCU_IPW_SW_MAJOR_VERSION_C != POWER_IP_SW_MAJOR_VERSION) || \
  98. (MCU_IPW_SW_MINOR_VERSION_C != POWER_IP_SW_MINOR_VERSION) || \
  99. (MCU_IPW_SW_PATCH_VERSION_C != POWER_IP_SW_PATCH_VERSION) \
  100. )
  101. #error "Software Version Numbers of Mcu_IPW.c and Power_Ip.h are different"
  102. #endif
  103. /* Check if Mcu_IPW.c file and Clock_Ip.h file are of the same vendor */
  104. #if (MCU_IPW_VENDOR_ID_C != CLOCK_IP_VENDOR_ID)
  105. #error "Mcu_IPW.c and Clock_Ip.h have different vendor ids"
  106. #endif
  107. /* Check if Mcu_IPW.c file and Clock_Ip.h file are of the same Autosar version */
  108. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != CLOCK_IP_AR_RELEASE_MAJOR_VERSION) || \
  109. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != CLOCK_IP_AR_RELEASE_MINOR_VERSION) || \
  110. (MCU_IPW_AR_RELEASE_REVISION_VERSION_C != CLOCK_IP_AR_RELEASE_REVISION_VERSION) \
  111. )
  112. #error "AutoSar Version Numbers of Mcu_IPW.c and Clock_Ip.h are different"
  113. #endif
  114. /* Check if Mcu_IPW.c file and Clock_Ip.h file are of the same Software version */
  115. #if ((MCU_IPW_SW_MAJOR_VERSION_C != CLOCK_IP_SW_MAJOR_VERSION) || \
  116. (MCU_IPW_SW_MINOR_VERSION_C != CLOCK_IP_SW_MINOR_VERSION) || \
  117. (MCU_IPW_SW_PATCH_VERSION_C != CLOCK_IP_SW_PATCH_VERSION) \
  118. )
  119. #error "Software Version Numbers of Mcu_IPW.c and Clock_Ip.h are different"
  120. #endif
  121. /* Check if Mcu_IPW.c file and Ram_Ip.h file are of the same vendor */
  122. #if (MCU_IPW_VENDOR_ID_C != RAM_IP_VENDOR_ID)
  123. #error "Mcu_IPW.c and Ram_Ip.h have different vendor ids"
  124. #endif
  125. /* Check if Mcu_IPW.c file and Ram_Ip.h file are of the same Autosar version */
  126. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != RAM_IP_AR_RELEASE_MAJOR_VERSION) || \
  127. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != RAM_IP_AR_RELEASE_MINOR_VERSION) || \
  128. (MCU_IPW_AR_RELEASE_REVISION_VERSION_C != RAM_IP_AR_RELEASE_REVISION_VERSION) \
  129. )
  130. #error "AutoSar Version Numbers of Mcu_IPW.c and Ram_Ip.h are different"
  131. #endif
  132. /* Check if Mcu_IPW.c file and Ram_Ip.h file are of the same Software version */
  133. #if ((MCU_IPW_SW_MAJOR_VERSION_C != RAM_IP_SW_MAJOR_VERSION) || \
  134. (MCU_IPW_SW_MINOR_VERSION_C != RAM_IP_SW_MINOR_VERSION) || \
  135. (MCU_IPW_SW_PATCH_VERSION_C != RAM_IP_SW_PATCH_VERSION) \
  136. )
  137. #error "Software Version Numbers of Mcu_IPW.c and Ram_Ip.h are different"
  138. #endif
  139. /* Check if Mcu_IPW.c file and Mcu.h file are of the same vendor */
  140. #if (MCU_IPW_VENDOR_ID_C != MCU_VENDOR_ID)
  141. #error "Mcu_IPW.c and Mcu.h have different vendor ids"
  142. #endif
  143. /* Check if Mcu_IPW.c file and Mcu.h file are of the same Autosar version */
  144. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != MCU_AR_RELEASE_MAJOR_VERSION) || \
  145. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != MCU_AR_RELEASE_MINOR_VERSION) || \
  146. (MCU_IPW_AR_RELEASE_REVISION_VERSION_C != MCU_AR_RELEASE_REVISION_VERSION) \
  147. )
  148. #error "AutoSar Version Numbers of Mcu_IPW.c and Mcu.h are different"
  149. #endif
  150. /* Check if Mcu_IPW.c file and Mcu.h file are of the same Software version */
  151. #if ((MCU_IPW_SW_MAJOR_VERSION_C != MCU_SW_MAJOR_VERSION) || \
  152. (MCU_IPW_SW_MINOR_VERSION_C != MCU_SW_MINOR_VERSION) || \
  153. (MCU_IPW_SW_PATCH_VERSION_C != MCU_SW_PATCH_VERSION) \
  154. )
  155. #error "Software Version Numbers of Mcu_IPW.c and Mcu.h are different"
  156. #endif
  157. #if (MCU_DEV_ERROR_DETECT == STD_ON)
  158. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  159. /* Check if Mcu_IPW.c file and Det.h file are of the same Autosar version */
  160. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION_C != DET_AR_RELEASE_MAJOR_VERSION) || \
  161. (MCU_IPW_AR_RELEASE_MINOR_VERSION_C != DET_AR_RELEASE_MINOR_VERSION))
  162. #error "AutoSar Version Numbers of Mcu_IPW.c and Det.h are different"
  163. #endif
  164. #endif
  165. #endif /* (MCU_DEV_ERROR_DETECT == STD_ON) */
  166. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  167. /* Check if Mcu_IPW.c file and Mcu_Dem_Wrapper.h file are of the same vendor */
  168. #if (MCU_IPW_VENDOR_ID != MCU_DEM_WRAPPER_VENDOR_ID)
  169. #error "Mcu_IPW.c and Mcu_Dem_Wrapper.h have different vendor ids"
  170. #endif
  171. /* Check if Mcu_IPW.c file and Mcu_Dem_Wrapper.h file are of the same Autosar version */
  172. #if ((MCU_IPW_AR_RELEASE_MAJOR_VERSION != MCU_DEM_WRAPPER_AR_RELEASE_MAJOR_VERSION) || \
  173. (MCU_IPW_AR_RELEASE_MINOR_VERSION != MCU_DEM_WRAPPER_AR_RELEASE_MINOR_VERSION) || \
  174. (MCU_IPW_AR_RELEASE_REVISION_VERSION != MCU_DEM_WRAPPER_AR_RELEASE_REVISION_VERSION) \
  175. )
  176. #error "AutoSar Version Numbers of Mcu_IPW.c and Mcu_Dem_Wrapper.h are different"
  177. #endif
  178. /* Check if Mcu_IPW.c file and Mcu_Dem_Wrapper.h file are of the same Software version */
  179. #if ((MCU_IPW_SW_MAJOR_VERSION != MCU_DEM_WRAPPER_SW_MAJOR_VERSION) || \
  180. (MCU_IPW_SW_MINOR_VERSION != MCU_DEM_WRAPPER_SW_MINOR_VERSION) || \
  181. (MCU_IPW_SW_PATCH_VERSION != MCU_DEM_WRAPPER_SW_PATCH_VERSION) \
  182. )
  183. #error "Software Version Numbers of Mcu_IPW.c and Mcu_Dem_Wrapper.h are different"
  184. #endif
  185. #endif /* (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
  186. /*==================================================================================================
  187. LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  188. ==================================================================================================*/
  189. /*==================================================================================================
  190. LOCAL MACROS
  191. ==================================================================================================*/
  192. /*==================================================================================================
  193. LOCAL CONSTANTS
  194. ==================================================================================================*/
  195. /*==================================================================================================
  196. LOCAL VARIABLES
  197. ==================================================================================================*/
  198. /*==================================================================================================
  199. GLOBAL CONSTANTS
  200. ==================================================================================================*/
  201. /*==================================================================================================
  202. GLOBAL VARIABLES
  203. ==================================================================================================*/
  204. /*==================================================================================================
  205. LOCAL FUNCTION PROTOTYPES
  206. ==================================================================================================*/
  207. #define MCU_START_SEC_CODE
  208. #include "Mcu_MemMap.h"
  209. #if (CLOCK_IP_ENABLE_NOTIFICATIONS == STD_ON)
  210. static void ClockNotificationsCallback(Clock_Ip_ClockNotificationType notification, Clock_Ip_NameType clockName);
  211. #endif
  212. #if (POWER_IP_ENABLE_NOTIFICATIONS == STD_ON)
  213. static void ReportPowerErrorsCallback(Power_Ip_PowerReportErrorType error, uint8 u8ErrorCode);
  214. #endif
  215. /*==================================================================================================
  216. LOCAL FUNCTIONS
  217. ==================================================================================================*/
  218. #if (CLOCK_IP_ENABLE_NOTIFICATIONS == STD_ON)
  219. static void ClockNotificationsCallback(Clock_Ip_ClockNotificationType notification, Clock_Ip_NameType clockName)
  220. {
  221. (void)clockName;
  222. switch(notification)
  223. {
  224. case CLOCK_IP_CMU_NOTIFICATION:
  225. {
  226. #if (defined(MCU_CMU_ERROR_ISR_USED) && (MCU_CMU_ERROR_ISR_USED == STD_ON))
  227. if ( (NULL_PTR != Mcu_pConfigPtr) && (Mcu_pConfigPtr->Mcu_ClkSrcFailureNotification == MCU_CLK_NOTIF_EN))
  228. {
  229. #if defined(MCU_CMU_FCCU_NOTIFICATION)
  230. /* CMU clock out of bounds notification. */
  231. MCU_CMU_FCCU_NOTIFICATION(clockName);
  232. #endif
  233. #ifdef MCU_ERROR_ISR_NOTIFICATION
  234. MCU_ERROR_ISR_NOTIFICATION(MCU_E_ISR_CLOCK_FAILURE);
  235. #endif
  236. }
  237. #endif /* (MCU_CMU_ERROR_ISR_USED == STD_ON) */
  238. }
  239. break;
  240. case CLOCK_IP_REPORT_TIMEOUT_ERROR:
  241. {
  242. #if (defined(MCU_DISABLE_DEM_REPORT_ERROR_STATUS) && (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF))
  243. Mcu_Macro_ReportDemTimeoutError();
  244. }
  245. break;
  246. case CLOCK_IP_REPORT_FXOSC_CONFIGURATION_ERROR:
  247. {
  248. Mcu_Macro_ReportDemFxoscConfigurationError();
  249. }
  250. break;
  251. case CLOCK_IP_REPORT_CLOCK_MUX_SWITCH_ERROR:
  252. {
  253. Mcu_Macro_ReportDemClockMuxSwitchError();
  254. #endif /* (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
  255. }
  256. break;
  257. case CLOCK_IP_RAM_MEMORY_CONFIG_ENTRY_POINT:
  258. {
  259. #if (defined(MCU_DISABLE_RAM_CONFIG) && (MCU_DISABLE_RAM_CONFIG == STD_OFF))
  260. #ifdef MCU_PREPARE_MEMORY_CONFIG
  261. /* The exit point of the FLASH and RAM controllers configuration. */
  262. MCU_PREPARE_MEMORY_CONFIG(MCU_RAM_MEMORY_CONFIG_ENTRY_POINT);
  263. #endif
  264. }
  265. break;
  266. case CLOCK_IP_RAM_MEMORY_CONFIG_EXIT_POINT:
  267. {
  268. #ifdef MCU_PREPARE_MEMORY_CONFIG
  269. /* The exit point of the FLASH and RAM controllers configuration. */
  270. MCU_PREPARE_MEMORY_CONFIG(MCU_RAM_MEMORY_CONFIG_EXIT_POINT);
  271. #endif
  272. #endif /* (MCU_DISABLE_RAM_CONFIG == STD_OFF) */
  273. }
  274. break;
  275. case CLOCK_IP_FLASH_MEMORY_CONFIG_ENTRY_POINT:
  276. {
  277. #if (defined(MCU_DISABLE_FLASH_CONFIG) && (MCU_DISABLE_FLASH_CONFIG == STD_OFF))
  278. #ifdef MCU_PREPARE_MEMORY_CONFIG
  279. /* The entry point of the FLASH and RAM controllers configuration. */
  280. MCU_PREPARE_MEMORY_CONFIG(MCU_FLASH_MEMORY_CONFIG_ENTRY_POINT);
  281. #endif
  282. }
  283. break;
  284. case CLOCK_IP_FLASH_MEMORY_CONFIG_EXIT_POINT:
  285. {
  286. #ifdef MCU_PREPARE_MEMORY_CONFIG
  287. /* The exit point of the FLASH and RAM controllers configuration. */
  288. MCU_PREPARE_MEMORY_CONFIG(MCU_FLASH_MEMORY_CONFIG_EXIT_POINT);
  289. #endif
  290. #endif /* (MCU_DISABLE_FLASH_CONFIG == STD_OFF) */
  291. }
  292. break;
  293. default:
  294. {
  295. /* Notification is not consumed HLD layer (it's not enabled from MCU component) */
  296. }
  297. break;
  298. }
  299. }
  300. #endif /* (CLOCK_IP_ENABLE_NOTIFICATIONS == STD_ON) */
  301. #if (POWER_IP_ENABLE_NOTIFICATIONS == STD_ON)
  302. static void ReportPowerErrorsCallback(Power_Ip_PowerReportErrorType error, uint8 u8ErrorCode)
  303. {
  304. switch(error)
  305. {
  306. case POWER_IP_REPORT_TIMEOUT_ERROR:
  307. {
  308. (void)u8ErrorCode;
  309. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  310. Mcu_Macro_ReportDemTimeoutError();
  311. #endif
  312. }
  313. break;
  314. case POWER_IP_REPORT_SWITCH_MODE_ERROR:
  315. {
  316. (void)u8ErrorCode;
  317. #if (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF)
  318. Mcu_Macro_ReportDemSwitchModeError();
  319. #endif
  320. }
  321. break;
  322. case POWER_IP_ERROR_ISR_NOTIFICATION:
  323. {
  324. #ifdef MCU_ERROR_ISR_NOTIFICATION
  325. MCU_ERROR_ISR_NOTIFICATION(u8ErrorCode);
  326. #endif
  327. }
  328. break;
  329. case POWER_IP_PMC_NOTIFICATION:
  330. {
  331. #ifdef MCU_PMC_NOTIFICATION
  332. MCU_PMC_NOTIFICATION(u8ErrorCode);
  333. #endif
  334. }
  335. break;
  336. case POWER_IP_REPORT_VLPSA_NOTIFICATION:
  337. {
  338. (void)u8ErrorCode;
  339. #ifdef MCU_VLPSA_NOTIFICATION
  340. MCU_VLPSA_NOTIFICATION();
  341. #endif
  342. }
  343. break;
  344. default:
  345. {
  346. /* Reporting errors mechanism */
  347. }
  348. break;
  349. }
  350. }
  351. #endif /* (MCU_DISABLE_DEM_REPORT_ERROR_STATUS == STD_OFF) */
  352. /*==================================================================================================
  353. GLOBAL FUNCTIONS
  354. ==================================================================================================*/
  355. /**
  356. * @brief This function initializes the MCU module on the common (main) platform.
  357. * @details The function initializes the CGM, ME, RGM, and PMC modules.
  358. * Called by:
  359. * - Mcu_Init() from HLD.
  360. *
  361. * @param[in] Mcu_pHwIPsConfigPtr Pointer to IPW configuration structure.
  362. *
  363. * @return void
  364. *
  365. */
  366. void Mcu_Ipw_Init(const Mcu_HwIPsConfigType * Mcu_pHwIPsConfigPtr)
  367. {
  368. #if (MCU_INIT_CLOCK == STD_ON)
  369. #if (CLOCK_IP_ENABLE_NOTIFICATIONS == STD_ON)
  370. Clock_Ip_InstallNotificationsCallback(ClockNotificationsCallback);
  371. #endif
  372. #endif
  373. #if (POWER_IP_ENABLE_NOTIFICATIONS == STD_ON)
  374. Power_Ip_InstallNotificationsCallback(ReportPowerErrorsCallback);
  375. #endif
  376. #if (defined(MCU_DISABLE_RCM_INIT) && (STD_OFF == MCU_DISABLE_RCM_INIT))
  377. /* Init Reset Control Module */
  378. Power_Ip_InitReset(Mcu_pHwIPsConfigPtr);
  379. #endif
  380. #if ((defined(MCU_DISABLE_PMC_INIT) && (STD_OFF == MCU_DISABLE_PMC_INIT)) || \
  381. (defined(MCU_DISABLE_SMC_INIT) && (STD_OFF == MCU_DISABLE_SMC_INIT)))
  382. /* Init Power Management Controller digital interface */
  383. Power_Ip_InitPower(Mcu_pHwIPsConfigPtr);
  384. #endif
  385. (void)Mcu_pHwIPsConfigPtr; /* Fix warning compiler: unused variable Mcu_pHwIPsConfigPtr */
  386. }
  387. #ifndef MCU_MAX_NORAMCONFIGS
  388. /**
  389. * @brief This function initializes a given RAM section of the MCU on the common (main) platform.
  390. * @details Function initializes the RAM section specified by the pointer to the "Mcu_RamConfigType" parameter.
  391. * The section's base address, size, value to be written, and write-at-once-size are provided by
  392. * the configuration structure.
  393. * The function will write the value specified in the configuration structure.
  394. * After the write it will read back the RAM to verify that the requested value was
  395. * written.
  396. * Called by:
  397. * - Mcu_InitRamSection() from HLD.
  398. *
  399. * @param[in] Mcu_pRamConfigPtr Pointer to RAM section configuration structure
  400. * (member of 'Mcu_ConfigType' struct).
  401. *
  402. * @return Status signaling if the given RAM section has or has not been successfully initialized.
  403. * @retval E_OK The RAM section check was successful.
  404. * @retval E_NOT_OK The RAM section check was not successful.
  405. *
  406. */
  407. Std_ReturnType Mcu_Ipw_InitRamSection(const Mcu_RamConfigType * Mcu_pRamConfigPtr)
  408. {
  409. /* Ram status variable. */
  410. Std_ReturnType eRamStatus;
  411. switch(Ram_Ip_InitRamSection(Mcu_pRamConfigPtr))
  412. {
  413. case RAM_IP_STATUS_OK:
  414. {
  415. eRamStatus = E_OK;
  416. }
  417. break;
  418. case RAM_IP_STATUS_NOT_OK:
  419. /* pass-through */
  420. default:
  421. {
  422. eRamStatus = E_NOT_OK;
  423. }
  424. break;
  425. }
  426. /* Return the RAM state. */
  427. return eRamStatus;
  428. }
  429. #endif /* ifndef MCU_MAX_NORAMCONFIGS */
  430. #if (MCU_INIT_CLOCK == STD_ON)
  431. /**
  432. * @brief This function initializes the clock structure on the common (main) platform.
  433. * @details This function initializes the clock structure by configuring the CGM module.
  434. * Called by:
  435. * - Mcu_InitClock() from HLD.
  436. *
  437. * @param[in] Mcu_pClockConfigPtr Pointer to clock configuration structure
  438. * (member of 'Mcu_ConfigType' struct).
  439. *
  440. * @return void
  441. *
  442. */
  443. void Mcu_Ipw_InitClock(const Mcu_ClockConfigType * Mcu_pClockConfigPtr)
  444. {
  445. Clock_Ip_InitClock(Mcu_pClockConfigPtr);
  446. }
  447. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  448. #if (MCU_INIT_CLOCK == STD_ON)
  449. #if (MCU_NO_PLL == STD_OFF)
  450. /**
  451. * @brief This function activates the main PLL as the system clock source.
  452. * @details This function sets the PLL as the system clock and also enables monitoring.
  453. * Called by:
  454. * - Mcu_DistributePllClock() from HLD.
  455. *
  456. * @return void
  457. *
  458. */
  459. void Mcu_Ipw_DistributePllClock(void)
  460. {
  461. Clock_Ip_DistributePll();
  462. }
  463. #endif /* (MCU_NO_PLL == STD_OFF) */
  464. #endif /* (MCU_INIT_CLOCK == STD_ON) */
  465. #if (MCU_NO_PLL == STD_OFF)
  466. /**
  467. * @brief This function returns the lock status of the PLL.
  468. * @details The user takes care that the PLL is locked by executing Mcu_GetPllStatus.
  469. * If the MCU_NO_PLL is TRUE the MCU_GetPllStatus has to return
  470. * MCU_PLL_STATUS_UNDEFINED.
  471. * Called by:
  472. * - Mcu_GetPllStatus() from HLD.
  473. *
  474. * @return Provides the lock status of the PLL.
  475. * @retval MCU_PLL_STATUS_UNDEFINED PLL Status is unknown.
  476. * @retval MCU_PLL_LOCKED PLL is locked.
  477. * @retval MCU_PLL_UNLOCKED PLL is unlocked.
  478. *
  479. */
  480. Mcu_PllStatusType Mcu_Ipw_GetPllStatus(void)
  481. {
  482. /* PLL status variable. */
  483. Mcu_PllStatusType ePllStatus;
  484. switch(Clock_Ip_GetPllStatus())
  485. {
  486. case CLOCK_IP_PLL_LOCKED:
  487. {
  488. ePllStatus = MCU_PLL_LOCKED;
  489. }
  490. break;
  491. case CLOCK_IP_PLL_UNLOCKED:
  492. {
  493. ePllStatus = MCU_PLL_UNLOCKED;
  494. }
  495. break;
  496. case CLOCK_IP_PLL_STATUS_UNDEFINED:
  497. default:
  498. {
  499. ePllStatus = MCU_PLL_STATUS_UNDEFINED;
  500. }
  501. break;
  502. }
  503. /* Return the PLL status. */
  504. return ePllStatus;
  505. }
  506. #endif /* (MCU_NO_PLL == STD_OFF) */
  507. #ifdef MCU_GET_CLOCK_FREQUENCY_API
  508. #if (MCU_GET_CLOCK_FREQUENCY_API == STD_ON)
  509. /**
  510. * @brief This function returns the frequency of a given clock.
  511. * @details The function returns the frequency of a given clock which is request by user.
  512. * Called by:
  513. * - Mcu_GetClockFrequency() from HLD.
  514. *
  515. * @param[in] clockName Name of the clock source for which need to get frequency.
  516. *
  517. * @return Provides the frequency value of a source clock.
  518. *
  519. */
  520. uint32 MCU_Ipw_GetClockFrequency(Clock_Ip_NameType clockName)
  521. {
  522. return Clock_Ip_GetClockFrequency(clockName);
  523. }
  524. #endif /* (MCU_GET_CLOCK_FREQUENCY_API == STD_ON) */
  525. #endif /* MCU_GET_CLOCK_FREQUENCY_API */
  526. /**
  527. * @brief This function initializes the mode structure.
  528. * @details This function initializes the mode structure by configuring the MC_ME module.
  529. * Called by:
  530. * - Mcu_SetMode() from HLD.
  531. *
  532. * @param[in] Mcu_pModeConfigPtr Pointer to mode configuration structure.
  533. *
  534. * @return void
  535. *
  536. */
  537. void Mcu_Ipw_SetMode(const Mcu_ModeConfigType * Mcu_pModeConfigPtr)
  538. {
  539. Power_Ip_SetMode(Mcu_pModeConfigPtr);
  540. }
  541. #if (MCU_PERFORM_RESET_API == STD_ON)
  542. /**
  543. * @brief This function performs a microcontroller reset.
  544. * @details This function performs a microcontroller reset by using the hardware feature of
  545. * the microcontroller.
  546. * Called by:
  547. * - Mcu_PerformReset() from HLD.
  548. *
  549. * @param[in] Mcu_pHwIPsConfigPtr Pointer to LLD configuration structure (member of
  550. * 'Mcu_ConfigType' struct).
  551. *
  552. * @return void
  553. *
  554. */
  555. void Mcu_Ipw_PerformReset(const Mcu_HwIPsConfigType * Mcu_pHwIPsConfigPtr)
  556. {
  557. /*
  558. * Performs a microcontroller reset.
  559. * A RESET mode requested via the ME_MCTL register is passed to the MC_RGM, which generates a
  560. * global system reset and initiates the reset sequence.
  561. */
  562. Power_Ip_PerformReset(Mcu_pHwIPsConfigPtr);
  563. }
  564. #endif /* (MCU_PERFORM_RESET_API == STD_ON) */
  565. /**
  566. * @brief This function returns the reset reason.
  567. * @details This routine returns the Reset reason that is read from the hardware.
  568. * Called by:
  569. * - Mcu_GetResetReason() from HLD.
  570. *
  571. * @param[in] None
  572. *
  573. * @return void
  574. *
  575. */
  576. Mcu_ResetType Mcu_Ipw_GetResetReason(void)
  577. {
  578. return (Mcu_ResetType)Power_Ip_GetResetReason();
  579. }
  580. /**
  581. * @brief This function returns the reset reason.
  582. * @details This routine returns the Reset reason that is read from the hardware.
  583. * Called by:
  584. * - Mcu_GetResetReason() from HLD.
  585. *
  586. * @param[in] None
  587. *
  588. * @return void
  589. *
  590. */
  591. Mcu_RawResetType Mcu_Ipw_GetResetRawValue(void)
  592. {
  593. return (Mcu_RawResetType)Power_Ip_GetResetRawValue();
  594. }
  595. #if (MCU_GET_RAM_STATE_API == STD_ON)
  596. Mcu_RamStateType Mcu_Ipw_GetRamState(void)
  597. {
  598. /* Ram state variable. */
  599. Mcu_RamStateType eRamState;
  600. switch(Ram_Ip_GetRamState())
  601. {
  602. case RAM_IP_RAMSTATE_VALID:
  603. {
  604. eRamState = MCU_RAMSTATE_VALID;
  605. }
  606. break;
  607. case RAM_IP_RAMSTATE_INVALID:
  608. /* pass-through */
  609. default:
  610. {
  611. eRamState = MCU_RAMSTATE_INVALID;
  612. }
  613. break;
  614. }
  615. /* Return the RAM state. */
  616. return eRamState;
  617. }
  618. #endif /* (MCU_GET_RAM_STATE_API == STD_ON) */
  619. #if (MCU_POWERMODE_STATE_API == STD_ON)
  620. /**
  621. * @brief This function return current power mode.
  622. *
  623. * @details This function return current power mode.
  624. *
  625. * @param[in] None
  626. *
  627. * @return Power_Ip_PowerModeStateType
  628. */
  629. Mcu_PowerModeStateType Mcu_Ipw_GetPowerModeState(void)
  630. {
  631. Mcu_PowerModeStateType State ;
  632. State = Power_Ip_GetPowerModeState();
  633. return State;
  634. }
  635. #endif /*(MCU_POWERMODE_STATE_API == STD_ON)*/
  636. #if (MCU_GET_POWER_DOMAIN_API == STD_ON)
  637. Std_ReturnType Mcu_Ipw_GetPowerDomainState(void)
  638. {
  639. Std_ReturnType State ;
  640. State = Mcu_MC_PCU_Get_PcuState();
  641. return State;
  642. }
  643. #endif /*(MCU_GET_POWER_DOMAIN_API == STD_ON)*/
  644. #ifdef MCU_GET_MIDR_API
  645. #if (MCU_GET_MIDR_API == STD_ON)
  646. void Mcu_Ipw_GetMidrStructure(Mcu_MidrReturnType * pMidr)
  647. {
  648. uint8 u8Index;
  649. SIUL2_Type * u32Siul2BasePtrs[SIUL2_INSTANCE_COUNT] = SIUL2_BASE_PTRS;
  650. for (u8Index = 0U; u8Index < SIUL2_INSTANCE_COUNT; ++u8Index)
  651. {
  652. pMidr[u8Index].u32Midr1 = u32Siul2BasePtrs[u8Index]->MIDR1;
  653. pMidr[u8Index].u32Midr2 = u32Siul2BasePtrs[u8Index]->MIDR2;
  654. }
  655. }
  656. #endif /* (MCU_GET_MIDR_API == STD_ON) */
  657. #endif /* MCU_GET_MIDR_API */
  658. #ifdef MCU_DISABLE_CMU_API
  659. #if (MCU_DISABLE_CMU_API == STD_ON)
  660. void Mcu_Ipw_DisableCmu(Clock_Ip_NameType clockName)
  661. {
  662. Clock_Ip_DisableClockMonitor(clockName);
  663. }
  664. #endif /* (MCU_DISABLE_CMU_API == STD_ON) */
  665. #endif /* MCU_DISABLE_CMU_API */
  666. #ifdef MCU_ERROR_ISR_NOTIFICATION
  667. #if (MCU_CMU_CLEAR_CLOCK_IRQ_FLAG == STD_ON)
  668. void Mcu_Ipw_CmuClearClockFailIrqFlags(Clock_Ip_NameType clockName)
  669. {
  670. Clock_Ip_ClearClockMonitorStatus(clockName);
  671. }
  672. #endif /* MCU_CMU_CLEAR_CLOCK_IRQ_FLAG == STD_ON */
  673. #endif /* MCU_ERROR_ISR_NOTIFICATION */
  674. #ifdef MCU_EMIOS_CONFIGURE_GPREN_API
  675. #if (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON)
  676. void Mcu_Ipw_EmiosConfigureGpren(uint8 u8Module, uint8 u8Value)
  677. {
  678. eMIOS_Type *u32EmiosBasePtrs[eMIOS_INSTANCE_COUNT] = eMIOS_BASE_PTRS;
  679. if (u8Value == MCU_EMIOS_GPREN_BIT_ENABLE)
  680. {
  681. u32EmiosBasePtrs[u8Module]->MCR |= MCU_EMIOS_MCR_GPREN_MASK32;
  682. }
  683. else
  684. {
  685. u32EmiosBasePtrs[u8Module]->MCR &= (~MCU_EMIOS_MCR_GPREN_MASK32);
  686. }
  687. }
  688. #endif /* (MCU_EMIOS_CONFIGURE_GPREN_API == STD_ON) */
  689. #endif /* MCU_EMIOS_CONFIGURE_GPREN_API */
  690. #ifdef MCU_SLEEPONEXIT_SUPPORT
  691. #if (MCU_SLEEPONEXIT_SUPPORT == STD_ON)
  692. /**
  693. * @brief This function disable/enable SleepOnExit.
  694. * @details Disable/enable Sleep on exit when returning from Handler mode to Thread mode.
  695. * Called by:
  696. * - Mcu_CM4_SleepOnExit() from HLD.
  697. *
  698. * @param[in] None
  699. *
  700. * @return void
  701. *
  702. */
  703. void Mcu_Ipw_SleepOnExit(Mcu_SleepOnExitType SleepOnExit)
  704. {
  705. if(MCU_SLEEP_ON_EXIT_DISABLED == (Mcu_SleepOnExitType)SleepOnExit)
  706. {
  707. Power_Ip_DisableSleepOnExit();
  708. }
  709. else
  710. {
  711. Power_Ip_EnableSleepOnExit();
  712. }
  713. }
  714. #endif
  715. #endif
  716. #ifdef MCU_SRAM_RETEN_CONFIG_API
  717. #if (MCU_SRAM_RETEN_CONFIG_API == STD_ON)
  718. /**
  719. * @brief Configuration for SRAM retention.
  720. *
  721. * @details This function configure for both SRAML_RETEN and SRAMU_RETEN bits.
  722. *
  723. * @return void
  724. */
  725. void Mcu_Ipw_SRAMRetentionConfig(Mcu_SRAMRetenConfigType eSRAMRetenConfig)
  726. {
  727. Power_Ip_SRAMRetentionConfig(eSRAMRetenConfig);
  728. }
  729. #endif
  730. #endif
  731. #define MCU_STOP_SEC_CODE
  732. #include "Mcu_MemMap.h"
  733. #ifdef __cplusplus
  734. }
  735. #endif
  736. /** @} */