STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Gpt.h File Reference

GPT driver configuration More...

#include "Gpt_Cfg.h"

Go to the source code of this file.

Functions

void Gpt_Init (const Gpt_ConfigType *ConfigPtr)
 Initialize the GPT registers to the configuration stored on ConfigPtr.
 
void Gpt_DeInit (void)
 Deinitializes the GPT driver.
 
Gpt_ValueType Gpt_GetTimeElapsed (Gpt_ChannelType Channel)
 Returns the time already elapsed.
 
Gpt_ValueType Gpt_GetTimeRemaining (Gpt_ChannelType Channel)
 Returns the time remaining until the target time is reached.
 
void Gpt_StartTimer (Gpt_ChannelType Channel, Gpt_ValueType Value)
 Starts a timer channel.
 
void Gpt_StopTimer (Gpt_ChannelType Channel)
 Stops a timer channel.
 
void Gpt_GetVersionInfo (Std_VersionInfoType *versioninfo)
 Gets the current version.
 
void Gpt_EnableNotification (Gpt_ChannelType Channel)
 Enables the interrupt notification for a channel.
 
void Gpt_DisableNotification (Gpt_ChannelType Channel)
 Disables the interrupt notification for a channel.
 
void Gpt_Notification_Channel0 (void)
 Executes the callback function defined by the user on the GPT_CHANNEL_0, validating the interrupt flag and turning it off afterwards.
 
void Gpt_Notification_Channel1 (void)
 Executes the callback function defined by the user on the GPT_CHANNEL_1, validating the interrupt flag and turning it off afterwards.
 

Detailed Description

GPT driver configuration

Author
Rodrigo Lopez

The GPT driver provides services for starting and stopping timer channels (logical timer instances assigned to a timer hardware), individual for each channel.

The tick duration of a timer channel depends on channel specific settings (part of GPT driver) as well as on system clock and settings of the clock tree controlled by the MCU module.

Function Documentation

◆ Gpt_DeInit()

void Gpt_DeInit ( void )

Deinitializes the GPT driver.

The function deinitializes the hardware used by the GPT driver (depending on configuration) to the power on reset state. Values of registers which are not writeable are excluded.

Requirement
SWS_Gpt_00281, SWS_Gpt_00008, SWS_Gpt_00105, SWS_Gpt_00162, SWS_Gpt_00194, SWS_Gpt_00220

◆ Gpt_DisableNotification()

void Gpt_DisableNotification ( Gpt_ChannelType Channel)

Disables the interrupt notification for a channel.

The function disables the interrupt notification of the referenced channel configured for notification.

Parameters
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00287, SWS_Gpt_00200, SWS_Gpt_00227, SWS_Gpt_00217

◆ Gpt_EnableNotification()

void Gpt_EnableNotification ( Gpt_ChannelType Channel)

Enables the interrupt notification for a channel.

The function enables the interrupt notification of the referenced channel configured for notification.

Parameters
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00286, SWS_Gpt_00199, SWS_Gpt_00226, SWS_Gpt_00214, SWS_Gpt_00377

◆ Gpt_GetTimeElapsed()

Gpt_ValueType Gpt_GetTimeElapsed ( Gpt_ChannelType Channel)

Returns the time already elapsed.

The function returns the time already elapsed. When the channel is in mode “one-shot mode”, this is the value relative to the point in time, the channel has been started.

Parameters
ChannelNumeric identifier of the GPT channel.
Return values
Returnsthe current number of ticks already elapsed.
Requirement
SWS_Gpt_00282, SWS_Gpt_00010, SWS_Gpt_00361, SWS_Gpt_00195, SWS_Gpt_00222, SWS_Gpt_00210

◆ Gpt_GetTimeRemaining()

Gpt_ValueType Gpt_GetTimeRemaining ( Gpt_ChannelType Channel)

Returns the time remaining until the target time is reached.

The function returns the timer value remaining until the target time will be reached next time. he remaining time is the "target time" minus the time already elapsed.

Parameters
ChannelNumeric identifier of the GPT channel.
Return values
Returnsthe remaining number of ticks before the timer overflows.
Requirement
SWS_Gpt_00283, SWS_Gpt_00083, SWS_Gpt_00196, SWS_Gpt_00223, SWS_Gpt_00211

◆ Gpt_GetVersionInfo()

void Gpt_GetVersionInfo ( Std_VersionInfoType * versioninfo)

Gets the current version.

The function gives the versioninfo struct the values of the current version. to eneable this function change the value of GPT_VERSION_INFO_API to STD_ON on the Gpt_Cfg file.

Parameters
versioninfoPointer to Std_VersionInfoType struct.
Requirement
SWS_Gpt_00279, SWS_Gpt_00338

◆ Gpt_Init()

void Gpt_Init ( const Gpt_ConfigType * ConfigPtr)

Initialize the GPT registers to the configuration stored on ConfigPtr.

The function Gpt_Init shall initialize the hardware timer module according to a configuration set referenced by ConfigPtr. The functions disables all interrupt notifications.

Resources that are not configured in the configuration file are not touched.

Parameters
ConfigPtrPointer to ConfigPtr struct array.
Requirement
SWS_Gpt_00280, SWS_Gpt_00006, SWS_Gpt_00107, SWS_Gpt_00068, SWS_Gpt_00258, SWS_Gpt_00307

◆ Gpt_Notification_Channel0()

void Gpt_Notification_Channel0 ( void )

Executes the callback function defined by the user on the GPT_CHANNEL_0, validating the interrupt flag and turning it off afterwards.

The notification prototype Gpt_Notification_Channel0 is for the notification callback function and shall be implemented by the user. The callback notifications Gpt_Notification_<channel> shall be configurable as pointers to user defined functions within the configuration structure.

Requirement
SWS_Gpt_00292, SWS_Gpt_00086, SWS_Gpt_00209, SWS_Gpt_00093, SWS_Gpt_00233, SWS_Gpt_00206

◆ Gpt_Notification_Channel1()

void Gpt_Notification_Channel1 ( void )

Executes the callback function defined by the user on the GPT_CHANNEL_1, validating the interrupt flag and turning it off afterwards.

The notification prototype Gpt_Notification_Channel1 is for the notification callback function and shall be implemented by the user. The callback notifications Gpt_Notification_<channel> shall be configurable as pointers to user defined functions within the configuration structure.

Requirement
SWS_Gpt_00292, SWS_Gpt_00086, SWS_Gpt_00209, SWS_Gpt_00093, SWS_Gpt_00233, SWS_Gpt_00206

◆ Gpt_StartTimer()

void Gpt_StartTimer ( Gpt_ChannelType Channel,
Gpt_ValueType Value )

Starts a timer channel.

The function starts the selected timer channel with a defined target time. If configured and enabled, an interrupt notification or a wakeup interrupt occurs, when the target time is reached.

Parameters
ChannelNumeric identifier of the GPT channel.
ValueTarget time in number of ticks.
Requirement
SWS_Gpt_00284, SWS_Gpt_00274, SWS_Gpt_00275, SWS_Gpt_00212, SWS_Gpt_00218, SWS_Gpt_00224

< TIMx Auto-reload register maximum admissible value

◆ Gpt_StopTimer()

void Gpt_StopTimer ( Gpt_ChannelType Channel)

Stops a timer channel.

The function stops the selected timer channel.

Parameters
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00285, SWS_Gpt_00013, SWS_Gpt_00099, SWS_Gpt_00213, SWS_Gpt_00225