MCUSW
Gpt.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2019 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 (2U)
115 
116 #define GPT_SW_MINOR_VERSION (0U)
117 
118 #define GPT_SW_PATCH_VERSION (0U)
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 
343 typedef enum
344 {
364 
365 
366 /*
367  * Design : MCAL-6221
368  */
370 typedef void (*Gpt_NotifyType)(void);
371 
373 typedef enum
374 {
380 
385 typedef enum
386 {
398 
399 
400 /*
401  * Design : MCAL-6362,MCAL-6332,MCAL-6334
402  */
404 typedef struct
405 {
408  uint32 tickValueMax;
416 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
417  GPT_WAKEUP_FUNCTIONALITY_API)
418  EcuM_WakeupSourceType wakeupSourceRef;
421 #endif
422  uint32 prescale;
425 
429 typedef struct Gpt_ChannelConfigType_PC_s
430 {
434 
435 
436 /*
437  * Design : MCAL-6344
438  */
440 typedef struct Gpt_ConfigType_s
441 {
442  P2CONST(Gpt_ChannelConfigType, AUTOMATIC, GPT_CONST) ChannelCfgPtr;
444  uint32 channelCount;
447 
448 #if (STD_ON == GPT_REGISTER_READBACK_API)
449 
452 typedef struct
453 {
454  /*
455  * GPT related registers
456  */
457  uint32 gptRev;
459  uint32 gptTtgr;
463  uint32 gptTiocpCfg;
465  uint32 gptTclr;
468 
469 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
470 
471 /* @} */
472 
473 /* ========================================================================== */
474 /* Function Declarations */
475 /* ========================================================================== */
476 
477 #if (STD_ON == GPT_VERSION_INFO_API)
478 
497 FUNC(void,
498  GPT_CODE) Gpt_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC,
499  GPT_APPL_DATA) VersionInfoPtr);
500 #endif /*(STD_ON == GPT_VERSION_INFO_API)*/
501 
522 FUNC(void, GPT_CODE) Gpt_Init(P2CONST(Gpt_ConfigType, AUTOMATIC,
523  GPT_CONST) CfgPtr);
524 
525 #if (STD_ON == GPT_DEINIT_API)
526 
547 FUNC(void, GPT_CODE) Gpt_DeInit(void);
548 #endif /*(STD_ON == GPT_DEINIT_API)*/
549 
550 #if (STD_ON == GPT_TIME_ELAPSED_API)
551 
575 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeElapsed(Gpt_ChannelType Channel);
576 #endif /*(STD_ON == GPT_TIME_ELAPSED_API)*/
577 
578 #if (STD_ON == GPT_TIME_REMAINING_API)
579 
604 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeRemaining(Gpt_ChannelType Channel);
605 #endif /*(STD_ON == GPT_CFG_TIME_REMAINING_API)*/
606 
632 FUNC(void, GPT_CODE) Gpt_StartTimer(Gpt_ChannelType Channel,
633  Gpt_ValueType Value);
634 
656 FUNC(void, GPT_CODE) Gpt_StopTimer(Gpt_ChannelType Channel);
657 
658 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
659 
680 FUNC(void, GPT_CODE) Gpt_EnableNotification(Gpt_ChannelType Channel);
681 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
682 
683 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
684 
706 FUNC(void, GPT_CODE) Gpt_DisableNotification(Gpt_ChannelType Channel);
707 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
708 
709 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
710  GPT_WAKEUP_FUNCTIONALITY_API)
711 
737 FUNC(void, GPT_CODE) Gpt_SetMode(Gpt_ModeType Mode);
738 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
739 
740 /*
741  * Design : MCAL-6242
742  */
743 
744 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
745  GPT_WAKEUP_FUNCTIONALITY_API)
746 
766 FUNC(void, GPT_CODE) Gpt_DisableWakeup(Gpt_ChannelType Channel);
767 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
768 
769 /*
770  * Design : MCAL-6242
771  */
772 
773 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
774  GPT_WAKEUP_FUNCTIONALITY_API)
775 
796 FUNC(void, GPT_CODE) Gpt_EnableWakeup(Gpt_ChannelType Channel);
797 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
798 
799 /*
800  * Design : MCAL-6242
801  */
802 
803 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
804  GPT_WAKEUP_FUNCTIONALITY_API)
805 
830 FUNC(void, GPT_CODE) Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource);
831 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
832 
833 #if (STD_ON == GPT_REGISTER_READBACK_API)
834 
863 FUNC(Std_ReturnType, GPT_CODE) Gpt_RegisterReadback(
864  Gpt_ChannelType GptChannel,
865  P2VAR(Gpt_RegisterReadbackType, AUTOMATIC, GPT_APPL_DATA) RegRbPtr);
866 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
867 
868 #ifdef __cplusplus
869 }
870 #endif
871 
872 #endif /* #ifndef GPT_H_ */
873 
874 /* @} */
Definition: Gpt.h:332
void Gpt_SetMode(Gpt_ModeType Mode)
Gpt_SetMode will set the operation mode of the Gpt driver to the given set mode parameter....
Definition: Gpt.h:355
Gpt_PrescaleValueType
List of Prescale values for General purpose timer channels The timer counter is prescaled with the va...
Definition: Gpt.h:343
void Gpt_EnableNotification(Gpt_ChannelType Channel)
Gpt_EnableNotification will enable the interrupt notification for the selected channel....
Definition: Gpt.h:387
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:463
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:377
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:418
Definition: Gpt.h:389
uint32 Gpt_ValueType
Type describing the timeout value.
Definition: Gpt.h:318
Gpt_ChannelType channelId
Definition: Gpt.h:431
Definition: Gpt.h:375
global configuration of the driver
Definition: Gpt.h:440
uint32 channelCount
Definition: Gpt.h:444
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_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:373
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:461
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:345
Definition: Gpt.h:327
Definition: Gpt.h:361
Definition: Gpt.h:359
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....
uint32 gptTtgr
Definition: Gpt.h:459
Gpt_ModeType
List of process modes.
Definition: Gpt.h:325
Definition: Gpt.h:357
SPI sequence config structure parameters Pre-Compile only.
Definition: Gpt.h:429
Definition: Gpt.h:349
Gpt_NotifyType fnPtrNotifyFunction
Definition: Gpt.h:414
Definition: Gpt.h:393
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:370
Gpt_ChannelMode channelMode
Definition: Gpt.h:406
Definition: Gpt.h:329
Definition: Gpt.h:353
This file contains generated pre compile configurations for GPT MCAL driver.
uint32 gptTclr
Definition: Gpt.h:465
const Gpt_ChannelConfigType * ChannelCfgPtr
Definition: Gpt.h:442
Definition: Gpt.h:347
Definition: Gpt.h:391
uint8 enableWakeupFlag
Definition: Gpt.h:412
GPT register readback structure.
Definition: Gpt.h:452
Definition: Gpt.h:351
Definition: Gpt.h:395
uint32 gptRev
Definition: Gpt.h:457
Gpt_ChannelStateType
GPT channel state GPT will be in one of this state during its lifetime.
Definition: Gpt.h:385
uint32 prescale
Definition: Gpt.h:422
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:408
Configuration per channel.
Definition: Gpt.h:404