STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
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 | |
Gpt Architecture Driver
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.
void Gpt_Arch_DeInit | ( | const Gpt_ConfigType * | ConfigPtr, |
uint32 | ChannelsToDeinit ) |
Gpt low level Deinitialization
This function de-initializes the Gpt module.
ConfigPtr | Pointer to driver configuration. |
ChannelsToDeinit | Numeric identifier of the GPT channels to Deinit. |
< 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
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.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
< TIMx_CR1 -> UDIS: Update disable bit
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.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
< TIMx_CR1 -> UDIS: Update disable bit
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.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
Returns | the current number of ticks already elapsed. |
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.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
Returns | the remaining number of ticks before the timer overflows. |
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.
ConfigPtr | Pointer to driver configuration. |
ChannelsToInit | Number of channels to init. |
< 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
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.
ConfigPtr | Pointer to driver configuration. |
< TIMx_SR -> UIF: Update Interrupt flag bit
< TIMx_SR -> UIF: Update Interrupt flag bit
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.
ConfigPtr | Pointer to driver configuration. |
< TIMx_SR -> UIF: Update Interrupt flag bit
< TIMx_SR -> UIF: Update Interrupt flag bit
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.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
Value | Target time in number of ticks. |
< 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
void Gpt_Arch_StopTimer | ( | const Gpt_ConfigType * | ConfigPtr, |
Gpt_ChannelType | Channel ) |
Stops a timer channel
The function stops the selected timer channel.
ConfigPtr | Pointer to driver configuration. |
Channel | Numeric identifier of the GPT channel. |
< TIMx_CR1 -> CEN: Counter enable bit