MCUSW
Gpt.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 
82 #ifndef GPT_H_
83 #define GPT_H_
84 
85 /* ========================================================================== */
86 /* Include Files */
87 /* ========================================================================== */
88 
89 #include "Std_Types.h"
90 #include "Gpt_Cfg.h"
91 #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
92  /* included for Wakeup handling */
93  #include "EcuM_Cbk.h"
94 #endif
95 
96 #ifdef __cplusplus
97 extern "C"
98 {
99 #endif
100 
101 /* ========================================================================== */
102 /* Macros & Typedefs */
103 /* ========================================================================== */
104 /*
105  * Design : MCAL-6324
106  */
114 #define GPT_SW_MAJOR_VERSION (9U)
115 
116 #define GPT_SW_MINOR_VERSION (0U)
117 
118 #define GPT_SW_PATCH_VERSION (1U)
119 /* @} */
120 
128 #define GPT_AR_RELEASE_MAJOR_VERSION (4U)
129 
130 #define GPT_AR_RELEASE_MINOR_VERSION (3U)
131 
132 #define GPT_AR_RELEASE_REVISION_VERSION (1U)
133 /* @} */
134 
140 #define GPT_VENDOR_ID ((uint16) 44U)
141 
142 #define GPT_MODULE_ID ((uint16) 100U)
143 
144 #define GPT_INSTANCE_ID ((uint8) 0U)
145 /* @} */
146 
147 /*
148  * GPT channel notification/wakeup function index.
149  * This is used store function index into ISR array.
150  */
152 #define GPT_CH_ISR_MODE_CONTINUOUS (0U)
153 
154 #define GPT_CH_ISR_MODE_ONESHOT (1U)
155 
156 #define GPT_CH_ISR_MODE_CONT_WAKEUP (2U)
157 
158 #define GPT_CH_ISR_MODE_ONESHOT_WAKEUP (3U)
159 
167 /*
168  * Design : MCAL-6255,MCAL-6197,MCAL-6193
169  */
170 
171 #ifndef GPT_E_UNINIT
172 
173 #define GPT_E_UNINIT (0x0AU)
174 #endif
175 
176 /*
177  * Design : MCAL-6318
178  */
179 #ifndef GPT_E_BUSY
180 
184 #define GPT_E_BUSY (0x0BU)
185 #endif
186 
187 /*
188  * Design : MCAL-2514
189  */
190 #ifndef GPT_E_MODE
191 
195 #define GPT_E_MODE (0x0CU)
196 #endif
197 
198 /*
199  * Design : MCAL-6255
200  */
201 #ifndef GPT_E_ALREADY_INITIALIZED
202 
203 #define GPT_E_ALREADY_INITIALIZED (0x0DU)
204 #endif
205 
206 /*
207  * Design : MCAL-6243
208  */
209 #ifndef GPT_E_INIT_FAILED
210 
211 #define GPT_E_INIT_FAILED (0x0EU)
212 #endif
213 
214 /*
215  * Design : MCAL-6232
216  */
217 #ifndef GPT_E_PARAM_CHANNEL
218 
219 #define GPT_E_PARAM_CHANNEL (0x14U)
220 #endif
221 
222 /*
223  * Design : MCAL-6285
224  */
225 #ifndef GPT_E_PARAM_VALUE
226 
227 #define GPT_E_PARAM_VALUE (0x15U)
228 #endif
229 
230 /*
231  * Design : MCAL-6313
232  */
233 #ifndef GPT_E_PARAM_POINTER
234 
235 #define GPT_E_PARAM_POINTER (0x16U)
236 #endif
237 #ifndef GPT_E_PARAM_PREDEF_TIMER
238 
240 #define GPT_E_PARAM_PREDEF_TIMER (0x17U)
241 #endif
242 
243 /*
244  * Design : MCAL-6258
245  */
246 #ifndef GPT_E_PARAM_MODE
247 
248 #define GPT_E_PARAM_MODE (0x1FU)
249 #endif
250 #ifndef GPT_E_INVALID_ISR
251 
252 #define GPT_E_INVALID_ISR (0x80U)
253 #endif
254 /* @} */
255 
264 #define GPT_SID_GET_VERSION_INFO (0x00U)
265 
266 #define GPT_SID_INIT (0x01U)
267 
268 #define GPT_SID_DEINIT (0x02U)
269 
270 #define GPT_SID_GET_TIME_ELAPSED (0x03U)
271 
272 #define GPT_SID_GET_TIME_REMAINING (0x04U)
273 
274 #define GPT_SID_START_TIMER (0x05U)
275 
276 #define GPT_SID_STOP_TIMER (0x06U)
277 
278 #define GPT_SID_ENABLE_NOTIFY (0x07U)
279 
280 #define GPT_SID_DISABLE_NOTIFY (0x08U)
281 
282 #define GPT_SID_SET_MODE (0x09U)
283 
284 #define GPT_SID_DISABLE_WAKEUP (0x0AU)
285 
286 #define GPT_SID_ENABLE_WAKEUP (0x0BU)
287 
288 #define GPT_SID_CHECK_WAKEUP (0x0CU)
289 
290 #define GPT_SID_GET_PREDEFTIMERVALUE (0x0DU)
291 
292 #define GPT_SID_GET_GETHWUNITOBJ (0x0EU)
293 
294 #define GPT_SID_REGISTER_READBACK (0x0FU)
295 /* @} */
296 
297 /* ========================================================================== */
298 /* Structures and Enums */
299 /* ========================================================================== */
300 
307 /*
308  * Design : MCAL-6368
309  */
311 typedef uint32 Gpt_ChannelType;
312 
313 
314 /*
315  * Design : MCAL-6282
316  */
318 typedef uint32 Gpt_ValueType;
319 
320 
321 /*
322  * Design : MCAL-6349
323  */
325 typedef enum
326 {
334 } Gpt_ModeType;
335 
336 
338 typedef enum
339 {
349 
350 
358 typedef enum
359 {
379 
380 
381 /*
382  * Design : MCAL-6221
383  */
385 typedef void (*Gpt_NotifyType)(void);
386 
388 typedef enum
389 {
395 
400 typedef enum
401 {
413 
414 
415 /*
416  * Design : MCAL-6362,MCAL-6332,MCAL-6334
417  */
419 typedef struct
420 {
423  uint32 tickValueMax;
431 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
432  GPT_WAKEUP_FUNCTIONALITY_API)
433  EcuM_WakeupSourceType wakeupSourceRef;
436 #endif
437  uint32 prescale;
440 
444 typedef struct Gpt_ChannelConfigType_PC_s
445 {
449 
450 
451 /*
452  * Design : MCAL-6344
453  */
455 typedef struct Gpt_ConfigType_s
456 {
457  P2CONST(Gpt_ChannelConfigType, AUTOMATIC, GPT_CONST) ChannelCfgPtr;
459  uint32 channelCount;
462 
463 #if (STD_ON == GPT_REGISTER_READBACK_API)
464 
467 typedef struct
468 {
469  /*
470  * GPT related registers
471  */
472  uint32 gptRev;
474  uint32 gptTtgr;
478  uint32 gptTiocpCfg;
480  uint32 gptTclr;
483 
484 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
485 
486 /* @} */
487 
488 /* ========================================================================== */
489 /* Function Declarations */
490 /* ========================================================================== */
491 
492 #if (STD_ON == GPT_VERSION_INFO_API)
493 
512 FUNC(void,
513  GPT_CODE) Gpt_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC,
514  GPT_APPL_DATA) VersionInfoPtr);
515 #endif /*(STD_ON == GPT_VERSION_INFO_API)*/
516 
537 FUNC(void, GPT_CODE) Gpt_Init(P2CONST(Gpt_ConfigType, AUTOMATIC,
538  GPT_CONST) CfgPtr);
539 
540 #if (STD_ON == GPT_DEINIT_API)
541 
562 FUNC(void, GPT_CODE) Gpt_DeInit(void);
563 #endif /*(STD_ON == GPT_DEINIT_API)*/
564 
565 #if (STD_ON == GPT_TIME_ELAPSED_API)
566 
590 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeElapsed(Gpt_ChannelType Channel);
591 #endif /*(STD_ON == GPT_TIME_ELAPSED_API)*/
592 
593 #if (STD_ON == GPT_TIME_REMAINING_API)
594 
619 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeRemaining(Gpt_ChannelType Channel);
620 #endif /*(STD_ON == GPT_CFG_TIME_REMAINING_API)*/
621 
647 FUNC(void, GPT_CODE) Gpt_StartTimer(Gpt_ChannelType Channel,
648  Gpt_ValueType Value);
649 
671 FUNC(void, GPT_CODE) Gpt_StopTimer(Gpt_ChannelType Channel);
672 
673 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
674 
695 FUNC(void, GPT_CODE) Gpt_EnableNotification(Gpt_ChannelType Channel);
696 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
697 
698 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
699 
721 FUNC(void, GPT_CODE) Gpt_DisableNotification(Gpt_ChannelType Channel);
722 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
723 
724 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
725  GPT_WAKEUP_FUNCTIONALITY_API)
726 
752 FUNC(void, GPT_CODE) Gpt_SetMode(Gpt_ModeType Mode);
753 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
754 
755 /*
756  * Design : MCAL-6242
757  */
758 
759 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
760  GPT_WAKEUP_FUNCTIONALITY_API)
761 
781 FUNC(void, GPT_CODE) Gpt_DisableWakeup(Gpt_ChannelType Channel);
782 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
783 
784 /*
785  * Design : MCAL-6242
786  */
787 
788 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
789  GPT_WAKEUP_FUNCTIONALITY_API)
790 
811 FUNC(void, GPT_CODE) Gpt_EnableWakeup(Gpt_ChannelType Channel);
812 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
813 
814 /*
815  * Design : MCAL-6242
816  */
817 
818 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
819  GPT_WAKEUP_FUNCTIONALITY_API)
820 
845 FUNC(void, GPT_CODE) Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource);
846 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
847 
848 #if (STD_ON == GPT_REGISTER_READBACK_API)
849 
878 FUNC(Std_ReturnType, GPT_CODE) Gpt_RegisterReadback(
879  Gpt_ChannelType GptChannel,
880  P2VAR(Gpt_RegisterReadbackType, AUTOMATIC, GPT_APPL_DATA) RegRbPtr);
881 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
882 
883 #if (GPT_PREDEF_TIMER_DISABLED == GPT_PREDEF_TIMER_TYPE)
884 /* Function not implemented due to hardware limitation
885  Dummy Function*/
886 FUNC(Std_ReturnType, GPT_CODE) Gpt_GetPredefTimerValue (
887  Gpt_PredefTimerType PredefTimer,uint32* TimeValuePtr);
888 #endif
889 
890 #ifdef __cplusplus
891 }
892 #endif
893 
894 #endif /* #ifndef GPT_H_ */
895 
896 /* @} */
Definition: Gpt.h:332
Std_ReturnType Gpt_GetPredefTimerValue(Gpt_PredefTimerType PredefTimer, uint32 *TimeValuePtr)
Definition: Gpt.h:344
void Gpt_SetMode(Gpt_ModeType Mode)
Gpt_SetMode will set the operation mode of the Gpt driver to the given set mode parameter. If the parameter mode = Normal, then the function will enable the interrupt notifications for all the channels which are configured for notification and notification is enabled. If the Mode = Sleep, the function will enable the wakeup interrupts for all channels which are configured for wakeup and disable all other channels. All the timer channels which are running will be stopped in this mode.
Definition: Gpt.h:370
Gpt_PrescaleValueType
List of Prescale values for General purpose timer channels The timer counter is prescaled with the va...
Definition: Gpt.h:358
void Gpt_EnableNotification(Gpt_ChannelType Channel)
Gpt_EnableNotification will enable the interrupt notification for the selected channel. The SETINT bit in RTI Set interrupt register will be Set to enable the Compare interrupt. The interrupt is triggered when Free running counter value matches with compare register value.
Definition: Gpt.h:402
void Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource)
Gpt_CheckWakeup will check if wakeup capable timer channel is source for a wakeup event and call EcuM...
Gpt_ValueType Gpt_GetTimeRemaining(Gpt_ChannelType Channel)
Gpt_GetTimeRemaining will return the timer value remaining until the target time will be reached next...
uint32 gptTiocpCfg
Definition: Gpt.h:478
void Gpt_StopTimer(Gpt_ChannelType Channel)
Gpt_StopTimer will stop the selected timer channel.This will clear all the registers corresponding to...
Definition: Gpt.h:340
Definition: Gpt.h:392
void Gpt_DisableWakeup(Gpt_ChannelType Channel)
Gpt_DisableWakeup will disable the wakeup interrupt of the referenced channel. The function will save...
EcuM_WakeupSourceType wakeupSourceRef
Definition: Gpt.h:433
Definition: Gpt.h:404
uint32 Gpt_ValueType
Type describing the timeout value.
Definition: Gpt.h:318
Gpt_ChannelType channelId
Definition: Gpt.h:446
Definition: Gpt.h:390
global configuration of the driver
Definition: Gpt.h:455
uint32 channelCount
Definition: Gpt.h:459
void Gpt_StartTimer(Gpt_ChannelType Channel, Gpt_ValueType Value)
Gpt_StartTimer will start the selected timer channel with defined target time. If the timer channel i...
Gpt_PredefTimerType
Type for GPT Predef Timers.
Definition: Gpt.h:338
Gpt_ValueType Gpt_GetTimeElapsed(Gpt_ChannelType Channel)
Gpt_GetTimeElapsed will return the time elapsed for channel which is referenced. The user can configu...
Gpt_ChannelMode
GPT channel mode macros.
Definition: Gpt.h:388
void Gpt_GetVersionInfo(Std_VersionInfoType *VersionInfoPtr)
This service returns the version information of this module.
uint32 Gpt_ChannelType
Type describing the Gpt channel.
Definition: Gpt.h:311
uint32 gptTimerSynCtrl
Definition: Gpt.h:476
Std_ReturnType Gpt_RegisterReadback(Gpt_ChannelType GptChannel, Gpt_RegisterReadbackType *RegRbPtr)
This function reads the important registers of the hardware unit and returns the value in the structu...
Definition: Gpt.h:360
Definition: Gpt.h:327
Definition: Gpt.h:376
Definition: Gpt.h:374
void Gpt_DisableNotification(Gpt_ChannelType Channel)
Gpt_DisableNotification will disable the compare interrupt notification for the selected channel...
void Gpt_DeInit(void)
This service deinitializes the RTI used by Gpt driver to the power on reset state. The Gpt driver state is changed to "Uninitialized" state". All the channel registers are cleared to stop the timer channels. API will disable all interrupt notifications, wakeup interrupts.
uint32 gptTtgr
Definition: Gpt.h:474
Gpt_ModeType
List of process modes.
Definition: Gpt.h:325
Definition: Gpt.h:372
SPI sequence config structure parameters Pre-Compile only.
Definition: Gpt.h:444
Definition: Gpt.h:364
Gpt_NotifyType fnPtrNotifyFunction
Definition: Gpt.h:429
Definition: Gpt.h:408
void Gpt_Init(const Gpt_ConfigType *CfgPtr)
This service initializes all the configured Gpt channels. This will set the state of the each channel...
void(* Gpt_NotifyType)(void)
Notification callback function pointer.
Definition: Gpt.h:385
Gpt_ChannelMode channelMode
Definition: Gpt.h:421
Definition: Gpt.h:329
Definition: Gpt.h:368
This file contains generated pre compile configurations for GPT MCAL driver.
uint32 gptTclr
Definition: Gpt.h:480
const Gpt_ChannelConfigType * ChannelCfgPtr
Definition: Gpt.h:457
Definition: Gpt.h:362
Definition: Gpt.h:406
uint8 enableWakeupFlag
Definition: Gpt.h:427
Definition: Gpt.h:346
GPT register readback structure.
Definition: Gpt.h:467
Definition: Gpt.h:366
Definition: Gpt.h:410
uint32 gptRev
Definition: Gpt.h:472
Definition: Gpt.h:342
Gpt_ChannelStateType
GPT channel state GPT will be in one of this state during its lifetime.
Definition: Gpt.h:400
uint32 prescale
Definition: Gpt.h:437
void Gpt_EnableWakeup(Gpt_ChannelType Channel)
Gpt_EnableWakeup will enable the wakeup interrupt of the referenced channel. The function will save t...
uint32 tickValueMax
Definition: Gpt.h:423
Configuration per channel.
Definition: Gpt.h:419