5.3. GPT

5.3.1. Types

Base type

Type Name

Brief

enum

Gpt_PredefTimerType

Type for GPT Predef Timers.

enum

Gpt_ChannelModeType

GPT channel mode macro.

enum

Gpt_SimStatusType

GPT Simulation enabled/disabled.

enum

Gpt_SimModeType

GPT Simulation Behaviour Hard/Soft stop upon GPT simulation enabled.

enum

Gpt_ModeType

GPT Operation Mode.

enum

Gpt_NotificationStateType

GPT channel notification enable/disable status. This indicates if the notification of GPT channel is enabled or disabled.

enum

Gpt_ChannelStateType

GPT channel state. GPT will be in one of this state during its lifetime.

typedef uint8

Gpt_ChannelType

Numeric ID of a GPT channel.

typedef uint32

Gpt_ChannelBaseAddrType

Base address of a GPT channel.

typedef uint32

Gpt_ValueType

Type for reading and setting the timer values(in number of ticks).

typedef uint16

Gpt_PrescaleValueType

Prescale value for General purpose timer channels.

typedef void(*)(void)

Gpt_NotifyType

Notification callback function pointer.

5.3.1.1. enum Gpt_PredefTimerType

Enumerator

Value

Description

GPT_PREDEF_TIMER_1US_16BIT

0U

GPT Predef Timer with tick duration 1µs and range 16bit.

GPT_PREDEF_TIMER_1US_24BIT

1U

GPT Predef Timer with tick duration 1µs and range 24bit.

GPT_PREDEF_TIMER_1US_32BIT

2U

GPT Predef Timer with tick duration 1µs and range 32bit.

GPT_PREDEF_TIMER_100US_32BIT

3U

GPT Predef Timer with tick duration 100µs and range 32bit.

Brief: Type for GPT Predef Timers.

5.3.1.2. enum Gpt_ChannelModeType

Enumerator

Value

Description

GPT_CH_MODE_CONTINUOUS

Timer will continue to running with the specified time period when target time reached.

GPT_CH_MODE_ONESHOT

Timer will stop after running once when target time reached.

Brief: GPT channel mode macro.

5.3.1.3. enum Gpt_SimStatusType

Enumerator

Value

Description

GPT_SIM_DISABLE

Timer is free-running.

GPT_SIM_ENABLE

Timer is not free-running. Gpt_SimMode decides mode of operation.

Brief: GPT Simulation enabled/disabled.

5.3.1.4. enum Gpt_SimModeType

Enumerator

Value

Description

GPT_SIM_STOP_TIMER_AT_NEXT_COUNTER_DEC

Timer stops at next decrement (HARD STOP)

GPT_SIM_STOP_TIMER_AT_NEXT_TIMER_ELAPSE

Timer stops at the next timer elapsed (SOFT STOP)

Brief: GPT Simulation Behaviour Hard/Soft stop upon GPT simulation enabled.

5.3.1.5. enum Gpt_ModeType

Enumerator

Value

Description

GPT_MODE_NORMAL

0x0U

Normal Mode.

GPT_MODE_SLEEP

0x1U

Sleep Mode.

Brief: GPT Operation Mode.

5.3.1.6. enum Gpt_NotificationStateType

Enumerator

Value

Description

GPT_NOTIF_ENABLED

GPT notification is enabled.

GPT_NOTIF_DISABLED

GPT notification is disabled.

Brief: GPT channel notification enable/disable status. This indicates if the notification of GPT channel is enabled or disabled.

5.3.1.7. enum Gpt_ChannelStateType

Enumerator

Value

Description

GPT_CH_UNINITIALIZED

GPT channel is uninitialized.

GPT_CH_INITIALIZED

GPT channel is initialized.

GPT_CH_RUNNING

GPT channel is running.

GPT_CH_STOPPED

GPT channel is stopped.

GPT_CH_EXPIRED

GPT channel is expired.

Brief: GPT channel state. GPT will be in one of this state during its lifetime.

5.3.2. Structures

Name

Brief

Gpt_ChannelConfigType

Configuration per channel.

Gpt_ConfigType

global configuration of the driver.

Gpt_DriverObjType

GPT driver object structure.

5.3.3. Defines

Name

Brief

GPT_SW_MAJOR_VERSION

Driver Implementation Major Version.

GPT_SW_MINOR_VERSION

Driver Implementation Minor Version.

GPT_SW_PATCH_VERSION

Driver Implementation Patch Version.

GPT_AR_RELEASE_MAJOR_VERSION

AUTOSAR major version specification implemented by GPT Driver.

GPT_AR_RELEASE_MINOR_VERSION

AUTOSAR minor version specification implemented by GPT Driver.

GPT_AR_RELEASE_PATCH_VERSION

AUTOSAR patch version specification implemented by GPT Driver.

GPT_VENDOR_ID

Texas Instruments Vendor ID.

GPT_MODULE_ID

GPT Driver Module ID.

GPT_E_UNINIT

API service called without module initialization.

GPT_E_BUSY

API service called when timer channel is still busy (running).

GPT_E_MODE

API service called when driver is in wrong mode.

GPT_E_ALREADY_INITIALIZED

API service for initialization called when already initialized.

GPT_E_INIT_FAILED

API error return code: Init function failed.

GPT_E_PARAM_CHANNEL

API parameter checking: invalid channel.

GPT_E_PARAM_VALUE

API parameter checking: invalid value.

GPT_E_PARAM_POINTER

API parameter checking: invalid pointer.

GPT_E_PARAM_PREDEF_TIMER

API parameter checking: invalid pointer.

GPT_E_PARAM_MODE

API parameter checking: invalid mode.

GPT_SID_GET_VERSION_INFO

Gpt_GetVersionInfo().

GPT_SID_INIT

Gpt_Init().

GPT_SID_DEINIT

Gpt_DeInit().

GPT_SID_GET_TIME_ELAPSED

Gpt_GetTimeElapsed().

GPT_SID_GET_TIME_REMAINING

Gpt_GetTimeRemaining().

GPT_SID_START_TIMER

Gpt_StartTimer().

GPT_SID_STOP_TIMER

Gpt_StopTimer().

GPT_SID_ENABLE_NOTIFY

Gpt_EnableNotification().

GPT_SID_DISABLE_NOTIFY

Gpt_DisableNotification().

GPT_SID_SET_MODE

Gpt_SetMode().

GPT_SID_DISABLE_WAKEUP

Gpt_DisableWakeup().

GPT_SID_ENABLE_WAKEUP

Gpt_EnableWakeup().

GPT_SID_CHECK_WAKEUP

Gpt_CheckWakeup().

GPT_SID_GET_TIME_PREDEF

Gpt_GetPredefTimerValue().

GPT_MAX_32BIT_VAL

Max. 32bit value.

5.3.4. Functions

Return type

Function Name

Brief

void

Gpt_GetVersionInfo(Std_VersionInfoType * VersionInfoPtr)

Gpt_GetVersionInfo : Returns the Gpt Version Info.

void

Gpt_Init(const Gpt_ConfigType * ConfigPtr)

Gpt_Init : Initializes the Gpt module.

void

Gpt_DeInit(void )

Gpt_DeInit : De-initializes the GPT module.

Gpt_ValueType

Gpt_GetTimeElapsed(Gpt_ChannelType Channel)

Gpt_GetTimeElapsed : Returns the time elapsed for a given channel.

Gpt_ValueType

Gpt_GetTimeRemaining(Gpt_ChannelType Channel)

Gpt_GetTimeRemaining : Returns the time remaining for a given channel.

void

Gpt_StartTimer(Gpt_ChannelType Channel, Gpt_ValueType Value)

Gpt_StartTimer : Starts a timer channel.

void

Gpt_StopTimer(Gpt_ChannelType Channel)

Gpt_StopTimer : Stops a timer channel.

void

Gpt_SetMode(Gpt_ModeType Mode)

Gpt_SetMode : Sets the operation mode of the GPT.

void

Gpt_DisableWakeup(Gpt_ChannelType Channel)

Gpt_DisableWakeup : Disables the wakeup interrupt of a channel (relevant in sleep mode).

void

Gpt_EnableWakeup(Gpt_ChannelType Channel)

Gpt_EnableWakeup : Enables the wakeup interrupt of a channel (relevant in sleep mode).

void

Gpt_CheckWakeup(EcuM_WakeupSourceType WakeupSource)

Gpt_CheckWakeup : Checks if a wakeup capable GPT channel is the source for a wakeup event and calls the ECU state manager service EcuM_SetWakeupEvent in case of a valid GPT channel wakeup event.

void

Gpt_SetDriverObjPtr(Gpt_DriverObjType * Set_DrvObj)

Set the Gpt driver object into global pointer.

void

Gpt_DeInitPriv(const Gpt_ChannelConfigType * ChannelObj)

Deinitializes the timer hardware to reset state.

void

Gpt_InitPriv(const Gpt_ChannelConfigType * ChannelObj)

Initialize the timer instance.

uint32

Gpt_GetCurCountPriv(const Gpt_ChannelConfigType * ChannelObj)

Get the current timer count.

uint32

Gpt_GetPrdCountPriv(const Gpt_ChannelConfigType * ChannelObj)

Get the timer period count.

void

Gpt_StartTimerPriv(const Gpt_ChannelConfigType * ChannelObj, uint32 count)

Start the timer.

void

Gpt_StopTimerPriv(const Gpt_ChannelConfigType * ChannelObj)

Stop the timer.

void

Gpt_ClrOvfFlagPriv(const Gpt_ChannelConfigType * ChannelObj)

Clear the Timer Overflow flag.

void

Gpt_EnableIntPriv(const Gpt_ChannelConfigType * ChannelObj)

Enable the timer interrupt.

void

Gpt_DisableIntPriv(const Gpt_ChannelConfigType * ChannelObj)

Disable the timer interrupt.

void

Gpt_GetChIdxPriv(const Gpt_DriverObjType * GptDrvObj, Gpt_ChannelType Channel, uint32 * ChannelIndex)

Get the array index of a channel from configuration array/vector.

Std_ReturnType

Gpt_GetPredefTimerValue(Gpt_PredefTimerType PredefTimer, uint32 * TimeValuePtr)

Gpt_GetPredefTimerValue : Delivers the current value of the desired GPT Predef Timer.

void

Gpt_IsrNotifyFunction(Gpt_ChannelType Channel)

Gpt_IsrNotifyFunction: Invoked by the respective timer channel ISR.

5.3.4.1. function Gpt_GetVersionInfo

void Gpt_GetVersionInfo(
    Std_VersionInfoType * VersionInfoPtr
)

Brief: Gpt_GetVersionInfo : Returns the Gpt Version Info.

This service returns the version information of this module.

Parameters:

  • VersionInfoPtr

  • VersionInfoPtr Pointer to where to store the version information of this module.

Returns:

  • None

Return: None

Precondition: VersionInfoPtr should not be NULL

Postcondition: None

5.3.4.2. function Gpt_Init

void Gpt_Init(
    const Gpt_ConfigType * ConfigPtr
)

Brief: Gpt_Init : Initializes the Gpt module.

This service initializes all the configured Gpt channels. This will set the state of the each channel to “Initialized”.

Parameters:

  • ConfigPtr

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.3. function Gpt_DeInit

void Gpt_DeInit(
    void 
)

Brief: Gpt_DeInit : De-initializes the GPT module.

This service deinitializes the Gpt driver to the power on reset state. The Gpt driver state is changed to “Uninitialized” state”. All the configuration registers are cleared to stop the timer channels. API will disable all interrupts.

Returns:

  • None

Return: None

Precondition: Gpt_Init should be called first before calling this service.

Postcondition: None

5.3.4.4. function Gpt_GetTimeElapsed

Gpt_ValueType Gpt_GetTimeElapsed(
    Gpt_ChannelType Channel
)

Brief: Gpt_GetTimeElapsed : Returns the time elapsed for a given channel.

This service will return the time elapsed for the referenced channel. The user can configure the channel in two modes, One-shot and Continuous mode. In one shot mode, if the timer is in stopped state, the function will return time value at the moment of stopping. If the timer is expired, the function will return the target time configured for the channel. If the timer has not expired/stopped in one shot mode, it will return the value of time elapsed, relative to the time of starting. In Continuous Mode - The elapsed time value will be the value relative to last occurrence of start/restart, that is for current iteration only.

Parameters:

  • Channel Numeric identifier of the GPT channel.

Returns:

  • Value of the type Gpt_ValueType

Return: Returns the time already elapsed.

Precondition: Gpt Driver must be initialized.

Postcondition: None

5.3.4.5. function Gpt_GetTimeRemaining

Gpt_ValueType Gpt_GetTimeRemaining(
    Gpt_ChannelType Channel
)

Brief: Gpt_GetTimeRemaining : Returns the time remaining for a given channel.

Gpt_GetTimeRemaining will return the timer value remaining until the target time will be reached next time. The remaining time is the absolute difference of the target time and time already elapsed. In one shot mode, if the timer is in stopped state, the function will return remaining time value at the moment of stopping. If the timer is expired, the function will return 0. In continuous mode, the return value will be the time remaining in the current iteration only.

Parameters:

  • Channel Numeric identifier of the GPT channel.

Returns:

  • Value of the type Gpt_ValueType

Return: Returns the time remaining until the target time is reached.

Precondition: Gpt Driver must be initialized.

Postcondition: None

5.3.4.6. function Gpt_StartTimer

void Gpt_StartTimer(
    Gpt_ChannelType Channel,
    Gpt_ValueType Value
)

Brief: Gpt_StartTimer : Starts a timer channel.

Gpt_StartTimer will start the selected timer channel with defined target time. If the timer channel is enabled for interrupt notification, then interrupt notification will be triggered after expiration of the selected timer channel. In one shot mode, if the timer is expired then the channel will be stopped in interrupt subroutine. The selected channel will be moved to “Running” state after calling this function.

Parameters:

  • Channel Numeric identifier of the GPT channel.

  • Value Target time in number of ticks.

Returns:

  • None

Return: None

Precondition: Gpt Driver must be initialized.

Postcondition: Postconditions

5.3.4.7. function Gpt_StopTimer

void Gpt_StopTimer(
    Gpt_ChannelType Channel
)

Brief: Gpt_StopTimer : Stops a timer channel.

Gpt_StopTimer will stop the selected timer channel.This will clear all the registers corresponding to the selected channel. The state of the timer channel will be changed to “Stopped”.If the channel is in state “Initialized”,”Expired”,”Stopped” before calling this function,the function will be left without any action.

Parameters:

  • Channel Numeric identifier of the GPT channel.

Returns:

  • None

Return: None

Precondition: Gpt Driver must be initialized.

Postcondition: None

5.3.4.8. function Gpt_SetMode

void Gpt_SetMode(
    Gpt_ModeType Mode
)

Brief: Gpt_SetMode : Sets the operation mode of the GPT.

5.3.4.9. function Gpt_DisableWakeup

void Gpt_DisableWakeup(
    Gpt_ChannelType Channel
)

Brief: Gpt_DisableWakeup : Disables the wakeup interrupt of a channel (relevant in sleep mode).

5.3.4.10. function Gpt_EnableWakeup

void Gpt_EnableWakeup(
    Gpt_ChannelType Channel
)

Brief: Gpt_EnableWakeup : Enables the wakeup interrupt of a channel (relevant in sleep mode).

5.3.4.11. function Gpt_CheckWakeup

void Gpt_CheckWakeup(
    EcuM_WakeupSourceType WakeupSource
)

Brief: Gpt_CheckWakeup : Checks if a wakeup capable GPT channel is the source for a wakeup event and calls the ECU state manager service EcuM_SetWakeupEvent in case of a valid GPT channel wakeup event.

5.3.4.12. function Gpt_SetDriverObjPtr

void Gpt_SetDriverObjPtr(
    Gpt_DriverObjType * Set_DrvObj
)

Brief: Set the Gpt driver object into global pointer.

This function Set the Gpt driver object into global pointer which can be used in ISR notification API.

Parameters:

  • Gpt_DrvObj Gpt_DrvObj is the Gpt driver object defined in Gpt.c

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.13. function Gpt_DeInitPriv

void Gpt_DeInitPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Deinitializes the timer hardware to reset state.

This function deintializes the timer module to its reset state. All the registers are set to their initial values by calling the static inline APIs.

Parameters:

  • ChannelObj ChannelObj contains the channel configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.14. function Gpt_InitPriv

void Gpt_InitPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Initialize the timer instance.

This function initializes the CPU timer using the configuration parameters.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.15. function Gpt_GetCurCountPriv

uint32 Gpt_GetCurCountPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Get the current timer count.

This function queries the current (instantaneous) timer count of the TIM reg.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • Value of Type uint32

Return: This function returns the current (instantaneous) timer count.

Precondition: None

Postcondition: None

5.3.4.16. function Gpt_GetPrdCountPriv

uint32 Gpt_GetPrdCountPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Get the timer period count.

This function queries the period count from the PRD reg. that is programmed.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • Value of Type uint32

Return: Returns the period count of the PRD regsiter.

Precondition: None

Postcondition: None

5.3.4.17. function Gpt_StartTimerPriv

void Gpt_StartTimerPriv(
    const Gpt_ChannelConfigType * ChannelObj,
    uint32 count
)

Brief: Start the timer.

This function starts the timer with the tick count argument.

Parameters:

  • ChannelObj is the structure containing timer configuration.

  • count is timer tick count.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.18. function Gpt_StopTimerPriv

void Gpt_StopTimerPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Stop the timer.

This function stops the running timer.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.19. function Gpt_ClrOvfFlagPriv

void Gpt_ClrOvfFlagPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Clear the Timer Overflow flag.

This function clears the timer overflow flag, which is set on timer expiry

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.20. function Gpt_EnableIntPriv

void Gpt_EnableIntPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Enable the timer interrupt.

This function enables the timer interrupt.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.21. function Gpt_DisableIntPriv

void Gpt_DisableIntPriv(
    const Gpt_ChannelConfigType * ChannelObj
)

Brief: Disable the timer interrupt.

This function disables the timer interrupt.

Parameters:

  • ChannelObj is the structure containing timer configuration.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.22. function Gpt_GetChIdxPriv

void Gpt_GetChIdxPriv(
    const Gpt_DriverObjType * GptDrvObj,
    Gpt_ChannelType Channel,
    uint32 * ChannelIndex
)

Brief: Get the array index of a channel from configuration array/vector.

This function populates the ‘ChannelIndex’ pointer with the array index of the ‘Channel’ present in configuration array

Parameters:

  • GptDrvObj is a structure containing multiple timer configurations.

  • Channel Numeric identifier of the GPT channel.

  • ChannelIndex Pointer to populate the index of channel present in config

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.3.4.23. function Gpt_GetPredefTimerValue

Std_ReturnType Gpt_GetPredefTimerValue(
    Gpt_PredefTimerType PredefTimer,
    uint32 * TimeValuePtr
)

Brief: Gpt_GetPredefTimerValue : Delivers the current value of the desired GPT Predef Timer.

5.3.4.24. function Gpt_IsrNotifyFunction

void Gpt_IsrNotifyFunction(
    Gpt_ChannelType Channel
)

Brief: Gpt_IsrNotifyFunction: Invoked by the respective timer channel ISR.

This Interrupt notification call function is called when interrupt notification is enabled for the channel in Gpt_StartTimer. Once the timer channel is expired/reached zero, interrupt is triggered which calls the Gpt_IsrNotifyFunction call back function inside the timer Isr.

Parameters:

  • Channel Numeric identifier of the GPT channel.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None