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

Gpt Architecture Driver More...

#include "Gpt_Types.h"

Go to the source code of this file.

Macros

#define GPT_TIM6   0
 
#define GPT_TIM7   1
 
#define GPT_ARR_MAX   0X0000FFFF
 
#define GPT_INTERRUPT_FLAG_BIT   0
 
#define GPT_ONE_PULSE_MODE_BIT   3u
 
#define GPT_PRESCALER_LSB   0
 
#define GPT_PRESCALER_MSB   16u
 
#define GPT_AUTO_RELOAD_LSB   0
 
#define GPT_AUTO_RELOAD_MSB   16u
 
#define GPT_COUNTER_ENABLE_BIT   0
 
#define GPT_UPDATE_DISABLE_BIT   1u
 

Functions

void Gpt_Arch_Init (const Gpt_ConfigType *ConfigPtr, uint32 ChannelsToInit)
 Gpt low level Initialization
 
void Gpt_Arch_DeInit (const Gpt_ConfigType *ConfigPtr, uint32 ChannelsToDeinit)
 Gpt low level Deinitialization
 
Gpt_ValueType Gpt_Arch_GetTimeElapsed (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel)
 Returns the time already elapsed
 
Gpt_ValueType Gpt_Arch_GetTimeRemaining (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel)
 Returns the time remaining until the target time is reached
 
void Gpt_Arch_StartTimer (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel, Gpt_ValueType Value)
 Starts a timer channel
 
void Gpt_Arch_StopTimer (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel)
 Stops a timer channel
 
void Gpt_Arch_EnableNotification (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel)
 Enables the interrupt notification for a channel
 
void Gpt_Arch_DisableNotification (const Gpt_ConfigType *ConfigPtr, Gpt_ChannelType Channel)
 Disables the interrupt notification for a channel
 
void Gpt_Arch_Notification_Channel0 (const Gpt_ConfigType *ConfigPtr)
 Executes the callback function defined by the user on the GPT_CHANNEL_0, validating the interrupt flag and turning it off afterwards
 
void Gpt_Arch_Notification_Channel1 (const Gpt_ConfigType *ConfigPtr)
 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 Architecture Driver

Author
Rodrigo Lopez

Gpt driver implementation for the STM32G0xx family of microcontrollers. This file contains the hardware specific implementation of the Gpt driver. The file is implemented as a means of abstraction from the hardware, this way we can avoid to include Arch headers in the actual driver header, making the low level interfaces available only for the inmediate upper layer.

Function Documentation

◆ Gpt_Arch_DeInit()

void Gpt_Arch_DeInit ( const Gpt_ConfigType * ConfigPtr,
uint32 ChannelsToDeinit )

Gpt low level Deinitialization

This function de-initializes the Gpt module.

Parameters
ConfigPtrPointer to driver configuration.
ChannelsToDeinitNumeric identifier of the GPT channels to Deinit.
Requirement
SWS_Gpt_00281, SWS_Gpt_00008, SWS_Gpt_00105, SWS_Gpt_00162, SWS_Gpt_00194

< TIMx_PSC -> [PSC:0]: GPT prescaler least significant bit

< TIMx_PSC -> [PSC:15]: GPT prescaler most significant bit

< TIMx_CR1 -> OPM: One pulse mode bit

< TIMx_SR -> UIF: Update Interrupt flag bit

< TIMx_ARR -> [ARR:0]: GPT auto-reload counter least significant bit

< TIMx_ARR -> [ARR:15]: GPT auto-reload counter most significant bit

◆ Gpt_Arch_DisableNotification()

void Gpt_Arch_DisableNotification ( const Gpt_ConfigType * ConfigPtr,
Gpt_ChannelType Channel )

Disables the interrupt notification for a channel

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

Parameters
ConfigPtrPointer to driver configuration.
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00287, SWS_Gpt_00200

< TIMx_CR1 -> UDIS: Update disable bit

◆ Gpt_Arch_EnableNotification()

void Gpt_Arch_EnableNotification ( const Gpt_ConfigType * ConfigPtr,
Gpt_ChannelType Channel )

Enables the interrupt notification for a channel

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

Parameters
ConfigPtrPointer to driver configuration.
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00286, SWS_Gpt_00199

< TIMx_CR1 -> UDIS: Update disable bit

◆ Gpt_Arch_GetTimeElapsed()

Gpt_ValueType Gpt_Arch_GetTimeElapsed ( const Gpt_ConfigType * ConfigPtr,
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
ConfigPtrPointer to driver configuration.
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

◆ Gpt_Arch_GetTimeRemaining()

Gpt_ValueType Gpt_Arch_GetTimeRemaining ( const Gpt_ConfigType * ConfigPtr,
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
ConfigPtrPointer to driver configuration.
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

◆ Gpt_Arch_Init()

void Gpt_Arch_Init ( const Gpt_ConfigType * ConfigPtr,
uint32 ChannelsToInit )

Gpt low level Initialization

This function initialize all internals variables and the used GPT structure of the microcontroller according to the parameters specified in ConfigPtr and HwUnit. Furthermore disable all notifications.

Parameters
ConfigPtrPointer to driver configuration.
ChannelsToInitNumber of channels to init.
Requirement
SWS_Gpt_00280, SWS_Gpt_00006, SWS_Gpt_00107, SWS_Gpt_00068, SWS_Gpt_00258

< TIMx_PSC -> [PSC:0]: GPT prescaler least significant bit

< TIMx_PSC -> [PSC:15]: GPT prescaler most significant bit

< TIMx_CR1 -> OPM: One pulse mode bit

< TIMx_SR -> UIF: Update Interrupt flag bit

◆ Gpt_Arch_Notification_Channel0()

void Gpt_Arch_Notification_Channel0 ( const Gpt_ConfigType * ConfigPtr)

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.

Parameters
ConfigPtrPointer to driver configuration.
Requirement
SWS_Gpt_00292, SWS_Gpt_00086, SWS_Gpt_00209, SWS_Gpt_00093, SWS_Gpt_00233, SWS_Gpt_00206

< TIMx_SR -> UIF: Update Interrupt flag bit

< TIMx_SR -> UIF: Update Interrupt flag bit

◆ Gpt_Arch_Notification_Channel1()

void Gpt_Arch_Notification_Channel1 ( const Gpt_ConfigType * ConfigPtr)

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.

Parameters
ConfigPtrPointer to driver configuration.
Requirement
SWS_Gpt_00292, SWS_Gpt_00086, SWS_Gpt_00209, SWS_Gpt_00093, SWS_Gpt_00233, SWS_Gpt_00206

< TIMx_SR -> UIF: Update Interrupt flag bit

< TIMx_SR -> UIF: Update Interrupt flag bit

◆ Gpt_Arch_StartTimer()

void Gpt_Arch_StartTimer ( const Gpt_ConfigType * ConfigPtr,
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
ConfigPtrPointer to driver configuration.
ChannelNumeric identifier of the GPT channel.
ValueTarget time in number of ticks.
Requirement
SWS_Gpt_00284, SWS_Gpt_00274, SWS_Gpt_00275

< TIMx_ARR -> [ARR:0]: GPT auto-reload counter least significant bit

< TIMx_ARR -> [ARR:15]: GPT auto-reload counter most significant bit

< TIMx_CR1 -> CEN: Counter enable bit

◆ Gpt_Arch_StopTimer()

void Gpt_Arch_StopTimer ( const Gpt_ConfigType * ConfigPtr,
Gpt_ChannelType Channel )

Stops a timer channel

The function stops the selected timer channel.

Parameters
ConfigPtrPointer to driver configuration.
ChannelNumeric identifier of the GPT channel.
Requirement
SWS_Gpt_00285, SWS_Gpt_00013

< TIMx_CR1 -> CEN: Counter enable bit