MCUSW
Loading...
Searching...
No Matches
Gpt.h
Go to the documentation of this file.
1/*
2*
3* Copyright (c) 2024 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
97extern "C"
98{
99#endif
100
101/* ========================================================================== */
102/* Macros & Typedefs */
103/* ========================================================================== */
104/*
105 * Design : MCAL-6324
106 */
114#define GPT_SW_MAJOR_VERSION (9U)
116#define GPT_SW_MINOR_VERSION (2U)
118#define GPT_SW_PATCH_VERSION (0U)
119/* @} */
120
128#define GPT_AR_RELEASE_MAJOR_VERSION (4U)
130#define GPT_AR_RELEASE_MINOR_VERSION (3U)
132#define GPT_AR_RELEASE_REVISION_VERSION (1U)
133/* @} */
134
140#define GPT_VENDOR_ID ((uint16) 44U)
142#define GPT_MODULE_ID ((uint16) 100U)
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)
154#define GPT_CH_ISR_MODE_ONESHOT (1U)
156#define GPT_CH_ISR_MODE_CONT_WAKEUP (2U)
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
173#define GPT_E_UNINIT (0x0AU)
174#endif
175
176/*
177 * Design : MCAL-6318
178 */
179#ifndef GPT_E_BUSY
184#define GPT_E_BUSY (0x0BU)
185#endif
186
187/*
188 * Design : MCAL-2514
189 */
190#ifndef GPT_E_MODE
195#define GPT_E_MODE (0x0CU)
196#endif
197
198/*
199 * Design : MCAL-6255
200 */
201#ifndef GPT_E_ALREADY_INITIALIZED
203#define GPT_E_ALREADY_INITIALIZED (0x0DU)
204#endif
205
206/*
207 * Design : MCAL-6243
208 */
209#ifndef GPT_E_INIT_FAILED
211#define GPT_E_INIT_FAILED (0x0EU)
212#endif
213
214/*
215 * Design : MCAL-6232
216 */
217#ifndef GPT_E_PARAM_CHANNEL
219#define GPT_E_PARAM_CHANNEL (0x14U)
220#endif
221
222/*
223 * Design : MCAL-6285
224 */
225#ifndef GPT_E_PARAM_VALUE
227#define GPT_E_PARAM_VALUE (0x15U)
228#endif
229
230/*
231 * Design : MCAL-6313
232 */
233#ifndef GPT_E_PARAM_POINTER
235#define GPT_E_PARAM_POINTER (0x16U)
236#endif
237#ifndef GPT_E_PARAM_PREDEF_TIMER
240#define GPT_E_PARAM_PREDEF_TIMER (0x17U)
241#endif
242
243/*
244 * Design : MCAL-6258
245 */
246#ifndef GPT_E_PARAM_MODE
248#define GPT_E_PARAM_MODE (0x1FU)
249#endif
250#ifndef GPT_E_INVALID_ISR
252#define GPT_E_INVALID_ISR (0x80U)
253#endif
254/* @} */
255
264#define GPT_SID_GET_VERSION_INFO (0x00U)
266#define GPT_SID_INIT (0x01U)
268#define GPT_SID_DEINIT (0x02U)
270#define GPT_SID_GET_TIME_ELAPSED (0x03U)
272#define GPT_SID_GET_TIME_REMAINING (0x04U)
274#define GPT_SID_START_TIMER (0x05U)
276#define GPT_SID_STOP_TIMER (0x06U)
278#define GPT_SID_ENABLE_NOTIFY (0x07U)
280#define GPT_SID_DISABLE_NOTIFY (0x08U)
282#define GPT_SID_SET_MODE (0x09U)
284#define GPT_SID_DISABLE_WAKEUP (0x0AU)
286#define GPT_SID_ENABLE_WAKEUP (0x0BU)
288#define GPT_SID_CHECK_WAKEUP (0x0CU)
290#define GPT_SID_GET_PREDEFTIMERVALUE (0x0DU)
292#define GPT_SID_GET_GETHWUNITOBJ (0x0EU)
294#define GPT_SID_REGISTER_READBACK (0x0FU)
295/* @} */
296
297/* ========================================================================== */
298/* Structures and Enums */
299/* ========================================================================== */
300
307/*
308 * Design : MCAL-6368
309 */
311typedef uint32 Gpt_ChannelType;
312
313
314/*
315 * Design : MCAL-6282
316 */
318typedef uint32 Gpt_ValueType;
319
320
321/*
322 * Design : MCAL-6349
323 */
325typedef enum
326{
327 GPT_MODE_NORMAL = 0U,
329 GPT_MODE_SLEEP = 1U,
332 GPT_MODE_INVALID = 0xFFU
335
336
349
350
379
380
381/*
382 * Design : MCAL-6221
383 */
385typedef void (*Gpt_NotifyType)(void);
386
395
413
414
415/*
416 * Design : MCAL-6362,MCAL-6332,MCAL-6334
417 */
419typedef struct
420{
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
444typedef struct Gpt_ChannelConfigType_PC_s
445{
449
450
451/*
452 * Design : MCAL-6344
453 */
455typedef struct Gpt_ConfigType_s
456{
457 P2CONST(Gpt_ChannelConfigType, AUTOMATIC, GPT_CONST) ChannelCfgPtr;
462
463#if (STD_ON == GPT_REGISTER_READBACK_API)
467typedef struct
468{
469 /*
470 * GPT related registers
471 */
472 uint32 gptRev;
474 uint32 gptTtgr;
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)
512FUNC(void,
513 GPT_CODE) Gpt_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC,
514 GPT_APPL_DATA) VersionInfoPtr);
515#endif /*(STD_ON == GPT_VERSION_INFO_API)*/
516
537FUNC(void, GPT_CODE) Gpt_Init(P2CONST(Gpt_ConfigType, AUTOMATIC,
538 GPT_CONST) CfgPtr);
539
540#if (STD_ON == GPT_DEINIT_API)
562FUNC(void, GPT_CODE) Gpt_DeInit(void);
563#endif /*(STD_ON == GPT_DEINIT_API)*/
564
565#if (STD_ON == GPT_TIME_ELAPSED_API)
591#endif /*(STD_ON == GPT_TIME_ELAPSED_API)*/
592
593#if (STD_ON == GPT_TIME_REMAINING_API)
620#endif /*(STD_ON == GPT_CFG_TIME_REMAINING_API)*/
621
647FUNC(void, GPT_CODE) Gpt_StartTimer(Gpt_ChannelType Channel,
648 Gpt_ValueType Value);
649
671FUNC(void, GPT_CODE) Gpt_StopTimer(Gpt_ChannelType Channel);
672
673#if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
695FUNC(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)
721FUNC(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)
752FUNC(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)
781FUNC(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)
811FUNC(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)
845FUNC(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)
878FUNC(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*/
886FUNC(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/* @} */
This file contains generated pre compile configurations for GPT MCAL driver.
Gpt_ChannelMode
GPT channel mode macros.
Definition Gpt.h:389
void Gpt_StopTimer(Gpt_ChannelType Channel)
Gpt_StopTimer will stop the selected timer channel.This will clear all the registers corresponding to...
void Gpt_EnableWakeup(Gpt_ChannelType Channel)
Gpt_EnableWakeup will enable the wakeup interrupt of the referenced channel. The function will save t...
Gpt_ValueType Gpt_GetTimeElapsed(Gpt_ChannelType Channel)
Gpt_GetTimeElapsed will return the time elapsed for channel which is referenced. The user can configu...
void Gpt_DisableNotification(Gpt_ChannelType Channel)
Gpt_DisableNotification will disable the compare interrupt notification for the selected channel....
void Gpt_DisableWakeup(Gpt_ChannelType Channel)
Gpt_DisableWakeup will disable the wakeup interrupt of the referenced channel. The function will save...
void Gpt_EnableNotification(Gpt_ChannelType Channel)
Gpt_EnableNotification will enable the interrupt notification for the selected channel....
void(* Gpt_NotifyType)(void)
Notification callback function pointer
Definition Gpt.h:385
Gpt_ModeType
List of process modes
Definition Gpt.h:326
void Gpt_GetVersionInfo(Std_VersionInfoType *VersionInfoPtr)
This service returns the version information of this module.
Std_ReturnType Gpt_GetPredefTimerValue(Gpt_PredefTimerType PredefTimer, uint32 *TimeValuePtr)
void Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource)
Gpt_CheckWakeup will check if wakeup capable timer channel is source for a wakeup event and call EcuM...
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:339
uint32 Gpt_ChannelType
Type describing the Gpt channel.
Definition Gpt.h:311
Gpt_PrescaleValueType
List of Prescale values for General purpose timer channels The timer counter is prescaled with the va...
Definition Gpt.h:359
void Gpt_DeInit(void)
This service deinitializes the RTI used by Gpt driver to the power on reset state....
void Gpt_Init(const Gpt_ConfigType *CfgPtr)
This service initializes all the configured Gpt channels. This will set the state of the each channel...
uint32 Gpt_ValueType
Type describing the timeout value
Definition Gpt.h:318
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...
Gpt_ValueType Gpt_GetTimeRemaining(Gpt_ChannelType Channel)
Gpt_GetTimeRemaining will return the timer value remaining until the target time will be reached next...
Gpt_ChannelStateType
GPT channel state GPT will be in one of this state during its lifetime.
Definition Gpt.h:401
void Gpt_SetMode(Gpt_ModeType Mode)
Gpt_SetMode will set the operation mode of the Gpt driver to the given set mode parameter....
uint32 gptRev
Definition Gpt.h:472
uint32 gptTiocpCfg
Definition Gpt.h:478
EcuM_WakeupSourceType wakeupSourceRef
Definition Gpt.h:433
Gpt_ChannelMode channelMode
Definition Gpt.h:421
uint32 gptTtgr
Definition Gpt.h:474
uint8 enableWakeupFlag
Definition Gpt.h:427
uint32 channelCount
Definition Gpt.h:459
uint32 gptTclr
Definition Gpt.h:480
Gpt_NotifyType fnPtrNotifyFunction
Definition Gpt.h:429
uint32 tickValueMax
Definition Gpt.h:423
uint32 gptTimerSynCtrl
Definition Gpt.h:476
const Gpt_ChannelConfigType * ChannelCfgPtr
Definition Gpt.h:457
Gpt_ChannelType channelId
Definition Gpt.h:446
uint32 prescale
Definition Gpt.h:437
@ GPT_CH_MODE_ONESHOT
Definition Gpt.h:392
@ GPT_CH_MODE_CONTINUOUS
Definition Gpt.h:390
@ GPT_MODE_SLEEP
Definition Gpt.h:329
@ GPT_MODE_INVALID
Definition Gpt.h:332
@ GPT_MODE_NORMAL
Definition Gpt.h:327
@ GPT_PREDEF_TIMER_1US_16BIT
Definition Gpt.h:340
@ GPT_PREDEF_TIMER_1US_24BIT
Definition Gpt.h:342
@ GPT_PREDEF_TIMER_1US_32BIT
Definition Gpt.h:344
@ GPT_PREDEF_TIMER_100US_32BIT
Definition Gpt.h:346
@ GPT_PRESCALER_NO_PRESCALE
Definition Gpt.h:376
@ GPT_PRESCALER_CLK_DIV_BY_4
Definition Gpt.h:362
@ GPT_PRESCALER_CLK_DIV_BY_256
Definition Gpt.h:374
@ GPT_PRESCALER_CLK_DIV_BY_2
Definition Gpt.h:360
@ GPT_PRESCALER_CLK_DIV_BY_128
Definition Gpt.h:372
@ GPT_PRESCALER_CLK_DIV_BY_64
Definition Gpt.h:370
@ GPT_PRESCALER_CLK_DIV_BY_32
Definition Gpt.h:368
@ GPT_PRESCALER_CLK_DIV_BY_16
Definition Gpt.h:366
@ GPT_PRESCALER_CLK_DIV_BY_8
Definition Gpt.h:364
@ GPT_UNINITIALIZED
Definition Gpt.h:402
@ GPT_STOPPED
Definition Gpt.h:408
@ GPT_EXPIRED
Definition Gpt.h:410
@ GPT_RUNNING
Definition Gpt.h:406
@ GPT_INITIALIZED
Definition Gpt.h:404
SPI sequence config structure parameters Pre-Compile only.
Definition Gpt.h:445
Configuration per channel.
Definition Gpt.h:420
global configuration of the driver
Definition Gpt.h:456
GPT register readback structure.
Definition Gpt.h:468