1 /*
2  * Copyright 2021-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef STM_IP_TYPES_H
8 #define STM_IP_TYPES_H
9 
10 /**
11 *   @file       Stm_Ip_Types.h
12 *
13 *   @addtogroup stm_ip Stm IPL
14 *
15 *   @{
16 */
17 
18 #ifdef __cplusplus
19 extern "C"{
20 #endif
21 
22 /*==================================================================================================
23 *                                        INCLUDE FILES
24 * 1) system and project includes
25 * 2) needed interfaces from external units
26 * 3) internal and external interfaces from this unit
27 ==================================================================================================*/
28 #include "Stm_Ip_Cfg_Defines.h"
29 
30 /*==================================================================================================
31 *                               SOURCE FILE VERSION INFORMATION
32 ==================================================================================================*/
33 /**
34 * @internal
35 * @brief Defines used for file version checks
36 */
37 #define STM_IP_TYPES_VENDOR_ID                       43
38 #define STM_IP_TYPES_AR_RELEASE_MAJOR_VERSION        4
39 #define STM_IP_TYPES_AR_RELEASE_MINOR_VERSION        7
40 #define STM_IP_TYPES_AR_RELEASE_REVISION_VERSION     0
41 #define STM_IP_TYPES_SW_MAJOR_VERSION                1
42 #define STM_IP_TYPES_SW_MINOR_VERSION                0
43 #define STM_IP_TYPES_SW_PATCH_VERSION                0
44 
45 /*==================================================================================================
46 *                                      FILE VERSION CHECKS
47 ==================================================================================================*/
48 #if (STM_IP_TYPES_VENDOR_ID != STM_IP_DEFINES_VENDOR_ID_CFG)
49     #error "Stm_Ip_Types.h and Stm_Ip_Cfg_Defines.h have different vendor ids"
50 #endif
51 /* Check if header file and Gpt header file are of the same Autosar version */
52 #if ((STM_IP_TYPES_AR_RELEASE_MAJOR_VERSION != STM_IP_DEFINES_AR_RELEASE_MAJOR_VERSION_CFG) || \
53      (STM_IP_TYPES_AR_RELEASE_MINOR_VERSION != STM_IP_DEFINES_AR_RELEASE_MINOR_VERSION_CFG) || \
54      (STM_IP_TYPES_AR_RELEASE_REVISION_VERSION != STM_IP_DEFINES_AR_RELEASE_REVISION_VERSION_CFG) \
55     )
56     #error "AutoSar Version Numbers of Stm_Ip_Types.h and Stm_Ip_Cfg_Defines.h are different"
57 #endif
58 /* Check if source file and GPT header file are of the same Software version */
59 #if ((STM_IP_TYPES_SW_MAJOR_VERSION != STM_IP_DEFINES_SW_MAJOR_VERSION_CFG) || \
60      (STM_IP_TYPES_SW_MINOR_VERSION != STM_IP_DEFINES_SW_MINOR_VERSION_CFG) || \
61      (STM_IP_TYPES_SW_PATCH_VERSION != STM_IP_DEFINES_SW_PATCH_VERSION_CFG) \
62     )
63     #error "Software Version Numbers of Stm_Ip_Types.h and Stm_Ip_Cfg_Defines.h are different"
64 #endif
65 /*==================================================================================================
66 *                                      CONSTANT-LIKE DEFINES
67 ==================================================================================================*/
68 
69 /*==================================================================================================
70 *                                      FUNCTION-LIKE DEFINES(MACROS)
71 ==================================================================================================*/
72 #if (STM_IP_USED == STD_ON)
73 
74 /**
75 * @internal
76 * @brief STM Channels defines
77 *
78 */
79 #define PREDEF                ((uint8)0)
80 
81 #endif /*STM_IP_USED == STD_ON */
82 /*==================================================================================================
83 *                                             ENUMS
84 ==================================================================================================*/
85 #if (STM_IP_SET_CLOCK_MODE == STD_ON)
86 /**
87 * @brief    Prescaler type. Indicates of whether the clock channel mode is "NORMAL" or "ALTERNATE".
88 * @details  This enumeration specifies the possible types of prescalers used to configure base-clock timers
89 */
90 typedef enum
91 {
92     STM_IP_CLOCKMODE_NORMAL    = 0x0U,  /**< @brief Selected value is the NORMAL configured prescaler    */
93     STM_IP_CLOCKMODE_ALTERNATE = 0x1U   /**< @brief Selected value is the ALTERNATE configured prescaler */
94 } Stm_Ip_ClockModeType;
95 #endif /* STM_IP_SET_CLOCK_MODE */
96 
97 
98 /**
99 * @brief    Channel mode type. Indicates of whether the channel mode is "CONTINUOUS" or "ONE SHOT".
100 * @details  ChannelModeType of channel.
101 */
102 typedef enum
103 {
104     STM_IP_CH_MODE_CONTINUOUS = 0U,      /**< @brief channel mode -  continuous mode */
105     STM_IP_CH_MODE_ONESHOT    = 1U       /**< @brief channel mode -  one-shot mode.  */
106 } Stm_Ip_ChannelModeType;
107 /*==================================================================================================
108 *                                 STRUCTURES AND OTHER TYPEDEFS
109 ==================================================================================================*/
110 /**
111 * @internal
112 * @brief    Callback type for each channel
113 * @details  Stm_Ip_CallbackType
114 *
115 */
116 typedef void (*Stm_Ip_CallbackType)(uint8 callbackParam);
117 
118 /**
119 * @internal
120 * @brief       Structure to configure the STM
121 * @details     This structure holds the configuration settings Stm_Ip_InstanceConfigType
122 *
123 */
124 typedef struct
125 {
126     boolean stopInDebugMode;                /**< @brief Allows the timer counter to be stopped in debug mode */
127 #if(STM_IP_SET_CLOCK_MODE == STD_ON)
128     uint8 clockAlternatePrescaler;          /**< @brief Clock divide value for the AlternatePrescaler        */
129 #endif
130     uint8 clockPrescaler;                   /**< @brief Clock divide value for the clockPrescaler            */
131 } Stm_Ip_InstanceConfigType;
132 
133 /**
134 * @internal
135 * @brief       Structure to configure the STM
136 * @details     This structure holds the configuration settings for the ChannelConfigType
137 *
138 */
139 typedef struct
140 {
141     uint8 hwChannel;                                /**< @brief Timer channel number */
142     Stm_Ip_CallbackType        callback;            /**< @brief callback             */
143     uint8                      callbackParam;       /**< @brief callbackParam        */
144     Stm_Ip_ChannelModeType     channelMode;         /**< @brief channelMode          */
145 } Stm_Ip_ChannelConfigType;
146 
147 /**
148 * @internal
149 * @brief       internal context structure
150 * @details     This structure is used by the IPL driver for internal logic.
151 *              The content is populated on InitChannel
152 *
153 */
154 typedef struct
155 {
156     boolean                    chInit;          /**< @brief chInit           */
157     Stm_Ip_CallbackType        callback;        /**< @brief callback         */
158     uint8                      callbackParam;   /**< @brief callbackParam    */
159     Stm_Ip_ChannelModeType     channelMode;         /**< @brief channelMode  */
160 } Stm_Ip_ChState;
161 
162 /**
163 * @internal
164 * @brief       internal context structure
165 * @details     This structure is used by the IPL driver for internal logic.
166 *              The content is populated on Init
167 *
168 */
169 typedef struct
170 {
171     uint8       clockPrescaler;                /**< @brief Clock divide value for the NormalPrescaler    */
172     uint8       clockAlternatePrescaler;       /**< @brief Clock divide value for the AlternatePrescaler */
173 } Stm_Ip_InstanceState;
174 /*==================================================================================================
175 *                                 GLOBAL VARIABLE DECLARATIONS
176 ==================================================================================================*/
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 /** @} */
183 #endif/*STM_IP_TYPES_H*/
184