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 /* Design : DES_GPT_001 */
105 /* Requirements : MCAL-2123, MCAL-981 */
106 
114 #define GPT_SW_MAJOR_VERSION (1U)
115 
116 #define GPT_SW_MINOR_VERSION (2U)
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 
160 #if defined (SOC_AM65XX)
161 
162 #define GPT_CH_GPTIMER_MAX (16U)
163 #endif /* SOC_AM65XX */
164 
165 #if defined (SOC_J721E)
166 
167 #define GPT_CH_GPTIMER_MAX (30U)
168 #endif /* SOC_J721E */
169 
170 /*
171  * GPT channels available for user
172  */
174 #define GPT_CH_GPTIMER1 (0U)
175 
176 #define GPT_CH_GPTIMER2 (1U)
177 
178 #define GPT_CH_GPTIMER3 (2U)
179 
180 #define GPT_CH_GPTIMER4 (3U)
181 
182 #define GPT_CH_GPTIMER5 (4U)
183 
184 #define GPT_CH_GPTIMER6 (5U)
185 
186 #define GPT_CH_GPTIMER7 (6U)
187 
188 #define GPT_CH_GPTIMER8 (7U)
189 
190 #define GPT_CH_GPTIMER9 (8U)
191 
192 #define GPT_CH_GPTIMER10 (9U)
193 
194 #define GPT_CH_GPTIMER11 (10U)
195 
196 #define GPT_CH_GPTIMER12 (11U)
197 
198 #define GPT_CH_GPTIMER13 (12U)
199 
200 #define GPT_CH_GPTIMER14 (13U)
201 
202 #define GPT_CH_GPTIMER15 (14U)
203 
204 #define GPT_CH_GPTIMER16 (15U)
205 
206 #if defined (SOC_J721E)
207 
208 #define GPT_CH_GPTIMER17 (16U)
209 
210 #define GPT_CH_GPTIMER18 (17U)
211 
212 #define GPT_CH_GPTIMER19 (18U)
213 
214 #define GPT_CH_GPTIMER20 (19U)
215 
216 #define GPT_CH_GPTIMER21 (20U)
217 
218 #define GPT_CH_GPTIMER22 (21U)
219 
220 #define GPT_CH_GPTIMER23 (22U)
221 
222 #define GPT_CH_GPTIMER24 (23U)
223 
224 #define GPT_CH_GPTIMER25 (24U)
225 
226 #define GPT_CH_GPTIMER26 (25U)
227 
228 #define GPT_CH_GPTIMER27 (26U)
229 
230 #define GPT_CH_GPTIMER28 (27U)
231 
232 #define GPT_CH_GPTIMER29 (28U)
233 
234 #define GPT_CH_GPTIMER30 (29U)
235 
236 #endif /* SOC_J721E */
237 
244 /* Design : DES_GPT_037 */
245 /* Requirements : MCAL-2512, MCAL-4176, MCAL-4177 */
246 
247 #ifndef GPT_E_UNINIT
248 
249 #define GPT_E_UNINIT (0x0AU)
250 #endif
251 /* Design : DES_GPT_037 */
252 /* Requirements : MCAL-2513 */
253 #ifndef GPT_E_BUSY
254 
258 #define GPT_E_BUSY (0x0BU)
259 #endif
260 /* Design : DES_GPT_037 */
261 /* Requirements : MCAL-2514 */
262 #ifndef GPT_E_MODE
263 
267 #define GPT_E_MODE (0x0CU)
268 #endif
269 /* Design : DES_GPT_037 */
270 /* Requirements : MCAL-2515 */
271 #ifndef GPT_E_ALREADY_INITIALIZED
272 
273 #define GPT_E_ALREADY_INITIALIZED (0x0DU)
274 #endif
275 /* Design : DES_GPT_037 */
276 /* Requirements : MCAL-2516 */
277 #ifndef GPT_E_INIT_FAILED
278 
279 #define GPT_E_INIT_FAILED (0x0EU)
280 #endif
281 /* Design : DES_GPT_037 */
282 /* Requirements : MCAL-2517 */
283 #ifndef GPT_E_PARAM_CHANNEL
284 
285 #define GPT_E_PARAM_CHANNEL (0x14U)
286 #endif
287 /* Design : DES_GPT_037 */
288 /* Requirements : MCAL-2518 */
289 #ifndef GPT_E_PARAM_VALUE
290 
291 #define GPT_E_PARAM_VALUE (0x15U)
292 #endif
293 /* Design : DES_GPT_037 */
294 /* Requirements : MCAL-2519 */
295 #ifndef GPT_E_PARAM_POINTER
296 
297 #define GPT_E_PARAM_POINTER (0x16U)
298 #endif
299 #ifndef GPT_E_PARAM_PREDEF_TIMER
300 
302 #define GPT_E_PARAM_PREDEF_TIMER (0x17U)
303 #endif
304 /* Design : DES_GPT_037 */
305 /* Requirements : MCAL-2520 */
306 #ifndef GPT_E_PARAM_MODE
307 
308 #define GPT_E_PARAM_MODE (0x1FU)
309 #endif
310 #ifndef GPT_E_INVALID_ISR
311 
312 #define GPT_E_INVALID_ISR (0x80U)
313 #endif
314 /* @} */
315 
324 #define GPT_SID_GET_VERSION_INFO (0x00U)
325 
326 #define GPT_SID_INIT (0x01U)
327 
328 #define GPT_SID_DEINIT (0x02U)
329 
330 #define GPT_SID_GET_TIME_ELAPSED (0x03U)
331 
332 #define GPT_SID_GET_TIME_REMAINING (0x04U)
333 
334 #define GPT_SID_START_TIMER (0x05U)
335 
336 #define GPT_SID_STOP_TIMER (0x06U)
337 
338 #define GPT_SID_ENABLE_NOTIFY (0x07U)
339 
340 #define GPT_SID_DISABLE_NOTIFY (0x08U)
341 
342 #define GPT_SID_SET_MODE (0x09U)
343 
344 #define GPT_SID_DISABLE_WAKEUP (0x0AU)
345 
346 #define GPT_SID_ENABLE_WAKEUP (0x0BU)
347 
348 #define GPT_SID_CHECK_WAKEUP (0x0CU)
349 
350 #define GPT_SID_GET_PREDEFTIMERVALUE (0x0DU)
351 
352 #define GPT_SID_GET_GETHWUNITOBJ (0x0EU)
353 
354 #define GPT_SID_REGISTER_READBACK (0x0FU)
355 /* @} */
356 
357 /* ========================================================================== */
358 /* Structures and Enums */
359 /* ========================================================================== */
360 
366 /* Design : DES_GPT_018 */
367 /* Requirements : MCAL-1988 */
369 typedef uint32 Gpt_ChannelType;
370 
371 /* Design : DES_GPT_018 */
372 /* Requirements : MCAL-1989 */
374 typedef uint32 Gpt_ValueType;
375 
376 /* Design : DES_GPT_018 */
377 /* Requirements : MCAL-1990 */
379 typedef enum
380 {
388 } Gpt_ModeType;
389 
397 typedef enum
398 {
418 
419 /* Design : DES_GPT_034 */
420 /* Requirements : MCAL-2113 */
422 typedef void (*Gpt_NotifyType)(void);
423 
425 typedef enum
426 {
432 
437 typedef enum
438 {
450 
451 /* Design : DES_GPT_018, DES_GPT_034 */
452 /* Requirements : MCAL-2119, MCAL-2114, MCAL-2115 */
454 typedef struct
455 {
456  Gpt_ChannelMode channelMode;
458  uint32 tickValueMax;
466 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
467  GPT_WAKEUP_FUNCTIONALITY_API)
468  EcuM_WakeupSourceType wakeupSourceRef;
471 #endif
472  uint32 prescale;
475 
479 typedef struct Gpt_ChannelConfigType_PC_s
480 {
481  Gpt_ChannelType channelId;
484 
485 /* Design : DES_GPT_019 */
486 /* Requirements : MCAL-1987 */
488 typedef struct Gpt_ConfigType_s
489 {
490  P2CONST(Gpt_ChannelConfigType, AUTOMATIC, GPT_CONST) ChannelCfgPtr;
492  uint32 channelCount;
495 
496 #if (STD_ON == GPT_REGISTER_READBACK_API)
497 
500 typedef struct
501 {
502  /*
503  * GPT related registers
504  */
505  uint32 gptRev;
507  uint32 gptTtgr;
512 
513 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
514 
515 /* @} */
516 
517 /* ========================================================================== */
518 /* Function Declarations */
519 /* ========================================================================== */
520 
521 #if (STD_ON == GPT_VERSION_INFO_API)
522 
540 FUNC(void,
541  GPT_CODE) Gpt_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC,
542  GPT_APPL_DATA) VersionInfoPtr);
543 #endif /*(STD_ON == GPT_VERSION_INFO_API)*/
544 
564 FUNC(void, GPT_CODE) Gpt_Init(P2CONST(Gpt_ConfigType, AUTOMATIC,
565  GPT_CONST) CfgPtr);
566 
567 #if (STD_ON == GPT_DEINIT_API)
568 
588 FUNC(void, GPT_CODE) Gpt_DeInit(void);
589 #endif /*(STD_ON == GPT_DEINIT_API)*/
590 
591 #if (STD_ON == GPT_TIME_ELAPSED_API)
592 
615 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeElapsed(Gpt_ChannelType Channel);
616 #endif /*(STD_ON == GPT_TIME_ELAPSED_API)*/
617 
618 #if (STD_ON == GPT_TIME_REMAINING_API)
619 
643 FUNC(Gpt_ValueType, GPT_CODE) Gpt_GetTimeRemaining(Gpt_ChannelType Channel);
644 #endif /*(STD_ON == GPT_CFG_TIME_REMAINING_API)*/
645 
670 FUNC(void, GPT_CODE) Gpt_StartTimer(Gpt_ChannelType Channel,
671  Gpt_ValueType Value);
672 
693 FUNC(void, GPT_CODE) Gpt_StopTimer(Gpt_ChannelType Channel);
694 
695 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
696 
716 FUNC(void, GPT_CODE) Gpt_EnableNotification(Gpt_ChannelType Channel);
717 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
718 
719 #if (STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)
720 
741 FUNC(void, GPT_CODE) Gpt_DisableNotification(Gpt_ChannelType Channel);
742 #endif /*(STD_ON == GPT_ENABLE_DISABLE_NOTIFICATION_API)*/
743 
744 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
745  GPT_WAKEUP_FUNCTIONALITY_API)
746 
771 FUNC(void, GPT_CODE) Gpt_SetMode(Gpt_ModeType Mode);
772 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
773 
774 /*
775  * Requirements : MCAL-1969
776  */
777 /*
778  * Design : DES_GPT_030
779  */
780 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
781  GPT_WAKEUP_FUNCTIONALITY_API)
782 
801 FUNC(void, GPT_CODE) Gpt_DisableWakeup(Gpt_ChannelType Channel);
802 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
803 
804 /*
805  * Requirements : MCAL-1969
806  */
807 /*
808  * Design : DES_GPT_031
809  */
810 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
811  GPT_WAKEUP_FUNCTIONALITY_API)
812 
832 FUNC(void, GPT_CODE) Gpt_EnableWakeup(Gpt_ChannelType Channel);
833 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
834 
835 /*
836  * Requirements : MCAL-1969
837  */
838 /*
839  * Design : DES_GPT_032
840  */
841 #if (STD_ON == GPT_REPORT_WAKEUP_SOURCE) && (STD_ON == \
842  GPT_WAKEUP_FUNCTIONALITY_API)
843 
867 FUNC(void, GPT_CODE) Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource);
868 #endif /*(STD_ON == GPT_WAKEUP_FUNCTIONALITY_API)*/
869 
870 #if (STD_ON == GPT_REGISTER_READBACK_API)
871 
899 FUNC(Std_ReturnType, GPT_CODE) Gpt_RegisterReadback(
900  Gpt_ChannelType GptChannel,
901  P2VAR(Gpt_RegisterReadbackType, AUTOMATIC, GPT_APPL_DATA) RegRbPtr);
902 #endif /* #if (STD_ON == GPT_REGISTER_READBACK_API) */
903 
904 #ifdef __cplusplus
905 }
906 #endif
907 
908 #endif /* #ifndef GPT_H_ */
909 
910 /* @} */
Definition: Gpt.h:386
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:409
Gpt_PrescaleValueType
List of Prescale values for General purpose timer channels The timer counter is prescaled with the va...
Definition: Gpt.h:397
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:439
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...
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:429
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:468
Definition: Gpt.h:441
uint32 Gpt_ValueType
Type describing the timeout value.
Definition: Gpt.h:374
Gpt_ChannelType channelId
Definition: Gpt.h:481
Definition: Gpt.h:427
global configuration of the driver
Definition: Gpt.h:488
uint32 channelCount
Definition: Gpt.h:492
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:425
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:369
uint32 gptTimerSynCtrl
Definition: Gpt.h:509
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:399
Definition: Gpt.h:381
Definition: Gpt.h:415
Definition: Gpt.h:413
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:507
Gpt_ModeType
List of process modes.
Definition: Gpt.h:379
Definition: Gpt.h:411
SPI sequence config structure parameters Pre-Compile only.
Definition: Gpt.h:479
Definition: Gpt.h:403
Gpt_NotifyType fnPtrNotifyFunction
Definition: Gpt.h:464
Definition: Gpt.h:445
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:422
Gpt_ChannelMode channelMode
Definition: Gpt.h:456
Definition: Gpt.h:383
Definition: Gpt.h:407
This file contains generated pre compile configurations for GPT MCAL driver.
const Gpt_ChannelConfigType * ChannelCfgPtr
Definition: Gpt.h:490
Definition: Gpt.h:401
Definition: Gpt.h:443
uint8 enableWakeupFlag
Definition: Gpt.h:462
GPT register readback structure.
Definition: Gpt.h:500
Definition: Gpt.h:405
Definition: Gpt.h:447
uint32 gptRev
Definition: Gpt.h:505
Gpt_ChannelStateType
GPT channel state GPT will be in one of this state during its lifetime.
Definition: Gpt.h:437
uint32 prescale
Definition: Gpt.h:472
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:458
Configuration per channel.
Definition: Gpt.h:454