MCUSW
Mcu.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2023 Texas Instruments Incorporated
4 *
5 * All rights reserved not granted herein.
6 *
7 * Limited License.
8 *
9 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10 * license under copyrights and patents it now or hereafter owns or controls to make,
11 * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12 * terms herein. With respect to the foregoing patent license, such license is granted
13 * solely to the extent that any such patent is necessary to Utilize the software alone.
14 * The patent license shall not apply to any combinations which include this software,
15 * other than combinations with devices manufactured by or for TI ("TI Devices").
16 * No hardware patent is licensed hereunder.
17 *
18 * Redistributions must preserve existing copyright notices and reproduce this license
19 * (including the above copyright notice and the disclaimer and (if applicable) source
20 * code license limitations below) in the documentation and/or other materials provided
21 * with the distribution
22 *
23 * Redistribution and use in binary form, without modification, are permitted provided
24 * that the following conditions are met:
25 *
26 * * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 *
29 * * any redistribution and use are licensed by TI for use only with TI Devices.
30 *
31 * * Nothing shall obligate TI to provide you with source code for the software
32 * licensed and provided to you in object code.
33 *
34 * If software source code is provided to you, modification and redistribution of the
35 * source code are permitted provided that the following conditions are met:
36 *
37 * * any redistribution and use of the source code, including any resulting derivative
38 * works, are licensed by TI for use only with TI Devices.
39 *
40 * * any redistribution and use of any object code compiled from the source code
41 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42 *
43 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44 *
45 * may be used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * DISCLAIMER.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 */
62 
77 #ifndef MCU_H_
78 #define MCU_H_
79 
80 /* ========================================================================== */
81 /* Include Files */
82 /* ========================================================================== */
83 
84 #include "Std_Types.h"
85 #include "Mcu_Cfg.h"
86 #include "EcuM.h"
87 
88 
89 #ifdef __cplusplus
90 extern "C"
91 {
92 #endif
93 
94 /* ========================================================================== */
95 /* Macros & Typedefs */
96 /* ========================================================================== */
97 
98 #define ARRAYSIZE(array) ((sizeof (array) / \
99  sizeof ((array)[0])))
100 
101 
109 #define MCU_SW_MAJOR_VERSION (9U)
110 
111 #define MCU_SW_MINOR_VERSION (1U)
112 
113 #define MCU_SW_PATCH_VERSION (0U)
114 /* @} */
115 
123 #define MCU_AR_RELEASE_MAJOR_VERSION (4U)
124 
125 #define MCU_AR_RELEASE_MINOR_VERSION (3U)
126 
127 #define MCU_AR_RELEASE_REVISION_VERSION (1U)
128 /* @} */
129 
135 #define MCU_VENDOR_ID ((uint16) 44U)
136 
137 #define MCU_MODULE_ID ((uint16) 101U)
138 
139 #define MCU_INSTANCE_ID ((uint8) 0U)
140 /* @} */
141 
150 #define MCU_TEST_CFG_ID_1 (0x01U)
151 
152 #define MCU_TEST_CFG_ID_2 (0x02U)
153 
154 #define MCU_TEST_CFG_ID_3 (0x04U)
155 
156 #define MCU_TEST_CFG_ID_4 (0x08U)
157 
165  /*
166  * Design: MCAL-8507,MCAL-8489
167  */
168  #ifndef MCU_E_PARAM_CONFIG
169 
170  #define MCU_E_PARAM_CONFIG (0x0AU)
171  #endif
172 
173 
174  /*
175  * Design: MCAL-8507
176  */
177 
178 #ifndef MCU_E_PARAM_CLOCK
179 
180 #define MCU_E_PARAM_CLOCK (0x0BU)
181 #endif
182 
183 /*
184  * Design: MCAL-8507
185  */
186 #ifndef MCU_E_PARAM_MODE
187 
188 #define MCU_E_PARAM_MODE (0x0CU)
189 #endif
190 
191 /*
192  * Design: MCAL-8507
193  */
194 #ifndef MCU_E_PARAM_RAMSECTION
195 
196 #define MCU_E_PARAM_RAMSECTION (0x0DU)
197 #endif
198 
199 /*
200  * Design: MCAL-8507
201  */
202 #ifndef MCU_E_PLL_NOT_LOCKED
203 
204 #define MCU_E_PLL_NOT_LOCKED (0x0EU)
205 #endif
206 
207 /*
208  * Design: MCAL-8507
209  */
210 #ifndef MCU_E_UNINIT
211 
212 #define MCU_E_UNINIT (0x0FU)
213 #endif
214 
215 /*
216  * Design: MCAL-8507
217  */
218 #ifndef MCU_E_PARAM_POINTER
219 
220 #define MCU_E_PARAM_POINTER (0x10U)
221 #endif
222 
223 /*
224  * Design: MCAL-8507
225  */
226 #ifndef MCU_E_INIT_FAILED
227 
228 #define MCU_E_INIT_FAILED (0x11U)
229 #endif
230 
237  /*
238  * Design: MCAL-8507
239  */
241 #define MCU_STATUS_UNINIT ((uint8)(0U))
242 
243 #define MCU_STATUS_INIT ((uint8)(1U))
244 
254 #define MCU_SID_INIT (0x00U)
255 
256 #define MCU_SID_INIT_RAM_SECTION (0x01U)
257 
258 #define MCU_SID_INIT_CLOCK (0x02U)
259 
260 #define MCU_SID_DISTRIBUTE_PLL_CLOCK (0x03U)
261 
262 #define MCU_SID_GET_PLL_STATUS (0x04U)
263 
264 #define MCU_SID_GET_RESET_REASON (0x05U)
265 
266 #define MCU_SID_GET_RESET_RAW_VALUE (0x06U)
267 
268 #define MCU_SID_PERFORM_RESET (0x07U)
269 
270 #define MCU_SID_SETMODE (0x08U)
271 
272 #define MCU_SID_GET_VERSION_INFO (0x09U)
273 
274 #define MCU_SID_GET_RAM_STATE (0x0AU)
275 /* @} */
276 
277 #if defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_J721S2) || defined (SOC_J784S4)
278 
285 #define MCU_PERFORM_RESET_MODE_COLD ((uint8) 0U)
286 #endif
287 
288 #define MCU_PERFORM_RESET_MODE_WARM ((uint8) 1U)
289 /* @} */
290 #define MCU_E_MODE_FAILURE 0U
291 
292 
293 
294 
295 /*
296  * Design: MCAL-8487,MCAL-8492
297  */
302 typedef uint8 Mcu_ClockType;
303 
304 /*
305  * Design: MCAL-8491,MCAL-8471
306  */
311 typedef uint32 Mcu_RawResetType;
312 
313 /*
314  * Design: MCAL-8406,MCAL-8421
315  */
320 typedef uint8 Mcu_RamSectionType;
321 
322 /*
323  * Design: MCAL-8490,MCAL-8418
324  */
329 typedef uint8 Mcu_ModeType;
330 
331 /* ========================================================================== */
332 /* Structures and Enums */
333 /* ========================================================================== */
334 
335 /*
336  * Design: MCAL-8438
337  */
341  typedef struct
342  {
351  boolean Mcu_InitCfg;
356 
357 
358 
362 typedef P2CONST (Mcu_ClockConfigType, AUTOMATIC, MCU_PBCFG)
364 
365 /*
366 * Design: MCAL-8439,MCAL-8424,MCAL-8405,MCAL-8438,MCAL-8457
367 */
372  typedef struct Mcu_ConfigType_s
373  {
384  } Mcu_ConfigType;
385 
386 
388 extern const struct Mcu_ConfigType_s McuModuleConfiguration_0;
389 
390 
391 
392 
393 /* @} */
394 
395 /* ========================================================================== */
396 /* Function Declarations */
397 /* ========================================================================== */
398 
415 FUNC(void, MCU_CODE) Mcu_Init(
416  P2CONST(Mcu_ConfigType, AUTOMATIC, MCU_PBCFG) ConfigPtr);
417 
418 FUNC(Std_ReturnType, MCU_CODE) Mcu_ClockSetSource(
419  Mcu_ClkModuleIdType moduleId,
420  Mcu_ClkSourceIdType clkSrcId,
421  uint8 clkParentId);
422 
423 #if (STD_ON == MCU_INIT_CLOCK_API)
424 
444 FUNC(Std_ReturnType, MCU_CODE) Mcu_InitClock(Mcu_ClockType ClockSetting);
445 #endif /* MCU_INIT_CLOCK_API */
446 
464 #if(STD_OFF == MCU_NO_PLL)
465 FUNC(Std_ReturnType, MCU_CODE) Mcu_DistributePllClock(void);
466 
467 #endif /* STD_OFF == MCU_NO_PLL */
468 
469 #if (STD_ON == MCU_PERFORM_RESET_API)
470 
486 FUNC(void, MCU_CODE) Mcu_PerformReset(void);
487 
488 #endif /* MCU_PERFORM_RESET_API */
489 
490 #if (STD_ON == MCU_INIT_RAM_API)
491 
512 FUNC(Std_ReturnType, MCU_CODE) Mcu_InitRamSection(
513  Mcu_RamSectionType RamSection);
514 #endif /* MCU_INIT_RAM_API */
515 
516 
517 /* Design: MCAL-8391 */
518 
519 /* This is a Dummy API */
520 
537 FUNC(Mcu_PllStatusType, MCU_CODE) Mcu_GetPllStatus(void);
538 
556 FUNC(Mcu_ResetType, MCU_CODE) Mcu_GetResetReason(void);
557 
576 FUNC(Mcu_RawResetType, MCU_CODE) Mcu_GetResetRawValue(void);
577 
578 #if defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_J721S2) || defined (SOC_J784S4)
579 
596 FUNC(void, MCU_CODE) Mcu_ClearResetReason(void);
597 #endif
598 
599 #if (STD_ON == MCU_GET_RAM_STATE_API)
600 
601 /* This is a Dummy API
602 */
621 FUNC(Mcu_RamStateType, MCU_CODE) Mcu_GetRamState(void);
622 #endif /* MCU_GET_RAM_STATE_API */
623 
624 #if (STD_ON == MCU_GET_VERSION_INFO_API)
625 
648 FUNC(void, MCU_CODE) Mcu_GetVersionInfo(
649  P2VAR(Std_VersionInfoType, AUTOMATIC, MCU_APPL_DATA) versioninfo);
650 #endif /* MCU_GET_VERSION_INFO_API */
651 
652 
653 
671 FUNC(void, MCU_CODE) Mcu_SetMode(P2CONST(Mcu_ModeType, AUTOMATIC, MCU_APPL_DATA) McuMode);
672 
673 
674 
675 
676 #ifdef __cplusplus
677 }
678 #endif
679 
680 #endif /* #ifndef MCU_H_ */
681 
682 /* @} */
Mcu_ClkSourceIdType
This is the type of the clock source in clock tree that is selectable for peripheral. Please see TRM to map clock source to module.
Definition: Mcu_Cfg.h:414
Mcu_ClkModuleIdType
Clock source config modules id enum.
Definition: Mcu_Cfg.h:313
MCU CONFIG ROOT structure.
Definition: Mcu.h:372
void Mcu_SetMode(const Mcu_ModeType *McuMode)
This service activates the MCU power modes.
Mcu_RawResetType Mcu_GetResetRawValue(void)
The service reads the reset type from the hardware register, if supported.
Mcu_ResetType
This is the type of the reset enumerator containing the subset of reset types. It is not required t...
Definition: Mcu_Cfg.h:257
Mcu_ModuleName
Definition: Mcu_Cfg.h:282
Mcu_ClkSourceIdType Mcu_ClockSourceId
Definition: Mcu.h:345
This file contains generated pre compile configuration file for MCU MCAL driver.
uint8 Mcu_NumberOfClockConfig
Definition: Mcu.h:380
Std_ReturnType(* Mcu_CBKFunctionPtrType)(uint32 moduleId, uint32 clkId, uint64 ParentId)
Pointer to Callback function.
Definition: Mcu_Cfg.h:516
uint8 Mcu_ResetMode
Definition: Mcu.h:376
uint8 Mcu_ClockType
This type specifies the identification (ID) for a ClockType status used by Mcu_InitClock() ...
Definition: Mcu.h:302
Mcu_RamStateType
Enumeration of ranstate queried by Mcu_GetRamState()
Definition: Mcu_Cfg.h:470
uint8 Mcu_ModeType
This type specifies the identification (ID) for a MCU mode used in Mcu_SetMode()
Definition: Mcu.h:329
Structure for module clock setting.
Definition: Mcu.h:341
Mcu_DomainType
Definition: Mcu_Cfg.h:271
Mcu_RamStateType Mcu_GetRamState(void)
This service provides the actual status of the microcontroller Ram. (if supported) ...
Mcu_ClkModuleIdType Mcu_ClockModuleId
Definition: Mcu.h:343
Std_ReturnType Mcu_InitClock(Mcu_ClockType ClockSetting)
This service initializes the PLL and other MCU specific clock options.
Mcu_PllStatusType Mcu_GetPllStatus(void)
This service provides the lock status of the PLL.
const struct Mcu_ConfigType_s McuModuleConfiguration_0
MCU Configuration struct declaration.
uint64 Mcu_ClockFrequency
Definition: Mcu.h:353
void Mcu_Init(const Mcu_ConfigType *ConfigPtr)
This service initializes the MCU driver.
Mcu_CBKFunctionPtrType Mcu_CBK_Function
Definition: Mcu.h:382
void Mcu_ClearResetReason(void)
Clear the Mcu Reset reason by clearing the reset reason register.
uint8 Mcu_RamSectionType
This type specifies the identification (ID) for a RAM section used in Mcu_InitRamSection() ...
Definition: Mcu.h:320
Mcu_DomainType Domain
Definition: Mcu.h:349
void Mcu_GetVersionInfo(Std_VersionInfoType *versioninfo)
This service returns the version information of this module.
boolean Mcu_InitCfg
Definition: Mcu.h:351
void Mcu_PerformReset(void)
The service performs a microcontroller reset.
Std_ReturnType Mcu_DistributePllClock(void)
This service activates the PLL clock to the MCU clock distribution.
Mcu_ModeType Mcu_Mode
Definition: Mcu.h:374
Mcu_PllStatusType
This is a status value returned by the function Mcu_GetPllStatus() of the MCU module.
Definition: Mcu_Cfg.h:432
Std_ReturnType Mcu_InitRamSection(Mcu_RamSectionType RamSection)
This service initializes the RAM section wise.
uint32 Mcu_RawResetType
This type specifies the identification (ID) for a RAW MCU reset status returned by Mcu_GetResetRawVal...
Definition: Mcu.h:311
Mcu_ClockConfigPtrType Mcu_ClockConfig
Definition: Mcu.h:378
Std_ReturnType Mcu_ClockSetSource(Mcu_ClkModuleIdType moduleId, Mcu_ClkSourceIdType clkSrcId, uint8 clkParentId)
Mcu_ResetType Mcu_GetResetReason(void)
The service reads the reset type from the hardware, if supported.
Mcu_ModuleName ModuleName
Definition: Mcu.h:347