STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Pwm_Arch.c File Reference

Pwm Architecture Driver More...

#include "Std_Types.h"
#include "Pwm_Cfg.h"
#include "Pwm_Arch.h"

Functions

void Pwm_Arch_Init (Pwm_HwUnit *HwUnit, const Pwm_ConfigType *Config)
 Pwm low level Initialization
 
void Pwm_Arch_DeInit (Pwm_HwUnit *HwUnit)
 Pwm low level Deinitialization
 
void Pwm_Arch_SetDutyCycle (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber, uint16 DutyCycle)
 Pwm low level Set Duty Cycle
 
void Pwm_Arch_SetPeriodAndDuty (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle)
 Pwm low level Set Period and Duty
 
void Pwm_Arch_SetOutputToIdle (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber)
 Pwm low level Set Output To Idle
 
Pwm_OutputStateType Pwm_Arch_GetOutputState (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber)
 Pwm low level Get Output State
 
void Pwm_Arch_DisableNotification (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber)
 Pwm low level Disable Notification
 
void Pwm_Arch_EnableNotification (Pwm_HwUnit *HwUnit, Pwm_ChannelType ChannelNumber, Pwm_EdgeNotificationType Notification)
 Pwm low level Enable Notification
 
Std_ReturnType Pwm_Arch_SetPowerState (Pwm_HwUnit *HwUnit, Pwm_PowerStateRequestResultType *Result)
 Pwm low level Set Power State
 
Std_ReturnType Pwm_Arch_GetCurrentPowerState (Pwm_HwUnit *HwUnit, Pwm_PowerStateType *CurrentPowerState, Pwm_PowerStateRequestResultType *Result)
 Pwm low level Get Current Power State
 
Std_ReturnType Pwm_Arch_GetTargetPowerState (Pwm_HwUnit *HwUnit, Pwm_PowerStateType *TargetPowerState, Pwm_PowerStateRequestResultType *Result)
 Pwm low level Get Target Power State
 
Std_ReturnType Pwm_Arch_PreparePowerState (Pwm_HwUnit *HwUnit, Pwm_PowerStateType PowerState, Pwm_PowerStateRequestResultType *Result)
 Pwm low level Prepare Power State
 

Detailed Description

Pwm Architecture Driver

Author
Jazmin Melendrez

Pwm driver implementation for the STM32G0xx family of microcontrollers. This file contains the hardware specific implementation of the Pwm 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

◆ Pwm_Arch_DeInit()

void Pwm_Arch_DeInit ( Pwm_HwUnit * HwUnit)

Pwm low level Deinitialization

This function de-initializes the Pwm module.

Parameters
HwUnitPointer to the hardware unit configuration

◆ Pwm_Arch_DisableNotification()

void Pwm_Arch_DisableNotification ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber )

Pwm low level Disable Notification

Function to disable the PWM signal edge notification.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM

◆ Pwm_Arch_EnableNotification()

void Pwm_Arch_EnableNotification ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber,
Pwm_EdgeNotificationType Notification )

Pwm low level Enable Notification

Function to enable the PWM signal edge notification according to notification parameter.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM
NotificationType of notification PWM_RISING_EDGE or PWM_FALLING_EDGE or PWM_BOTH_EDGES.

◆ Pwm_Arch_GetCurrentPowerState()

Std_ReturnType Pwm_Arch_GetCurrentPowerState ( Pwm_HwUnit * HwUnit,
Pwm_PowerStateType * CurrentPowerState,
Pwm_PowerStateRequestResultType * Result )

Pwm low level Get Current Power State

This function provides the current power state of a specified PWM hardware unit.

Parameters
HwUnitPointer to the hardware unit configuration
CurrentPowerStateThe current power mode of the PWM HW Unit is returned in this parameter
ResultIf the API returns E_OK: PWM_SERVICE_ACCEPTED: Current power mode was returned. If the API returns E_NOT_OK: PWM_NOT_INIT: PWM Module not initialized.
Return values
E_OKMode could be read E_NOT_OK: Service is rejected

◆ Pwm_Arch_GetOutputState()

Pwm_OutputStateType Pwm_Arch_GetOutputState ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber )

Pwm low level Get Output State

Function to read the internal state of the PWM output signal.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM
Return values
PWM_HIGHThe PWM output state is high PWM_LOW: The PWM output state is low

◆ Pwm_Arch_GetTargetPowerState()

Std_ReturnType Pwm_Arch_GetTargetPowerState ( Pwm_HwUnit * HwUnit,
Pwm_PowerStateType * TargetPowerState,
Pwm_PowerStateRequestResultType * Result )

Pwm low level Get Target Power State

The API returns the requested power state of the HW unit. This shall coincide with the current power state if no transition is ongoing.

Parameters
HwUnitPointer to the hardware unit configuration
TargetPowerStateThe Target power mode of the PWM HW Unit is returned in this parameter.
ResultIf the API returns E_OK: PWM_SERVICE_ACCEPTED:Target power mode was returned. If the API returns E_NOT_OK: PWM_NOT_INIT: PWM Module not initialized.
Return values
E_OKMode could be read E_NOT_OK: Service is rejected

◆ Pwm_Arch_Init()

void Pwm_Arch_Init ( Pwm_HwUnit * HwUnit,
const Pwm_ConfigType * Config )

Pwm low level Initialization

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

Parameters
HwUnitPointer to the hardware unit configuration
ConfigPointer to driver configuration

◆ Pwm_Arch_PreparePowerState()

Std_ReturnType Pwm_Arch_PreparePowerState ( Pwm_HwUnit * HwUnit,
Pwm_PowerStateType PowerState,
Pwm_PowerStateRequestResultType * Result )

Pwm low level Prepare Power State

This API starts the needed process to allow the PWM HW module to enter the requested power state. Initiates all actions needed to enable a HW module to enter the target power state.

Parameters
HwUnitPointer to the hardware unit configuration.
PowerStateThe Target power mode of the PWM HW Unit is returned in this parameter.
ResultIf the API returns E_OK: PWM_SERVICE_ACCEPTED: PWM Module power state preparation was started. If the API returns E_NOT_OK: PWM_NOT_INIT: PWM Module not initialized. PWM_SEQUENCE_ERROR: wrong API call sequence (Current Power State = Target Power State). PWM_POWER_STATE_NOT_SUPP: PWM Module does not support the requested power state. PWM_TRANS_NOT_POSSIBLE: PWM Module cannot transition directly from the current power state to the requested power state or the HW peripheral is still busy
Return values
E_OKPreparation process started E_NOT_OK: Service is rejected

◆ Pwm_Arch_SetDutyCycle()

void Pwm_Arch_SetDutyCycle ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber,
uint16 DutyCycle )

Pwm low level Set Duty Cycle

This function sets the duty cycle of the PWM channel.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM
DutyCycleMin=0x0000 Max=0x8000

◆ Pwm_Arch_SetOutputToIdle()

void Pwm_Arch_SetOutputToIdle ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber )

Pwm low level Set Output To Idle

This function sets the PWM output to the configured Idle state.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM

◆ Pwm_Arch_SetPeriodAndDuty()

void Pwm_Arch_SetPeriodAndDuty ( Pwm_HwUnit * HwUnit,
Pwm_ChannelType ChannelNumber,
Pwm_PeriodType Period,
uint16 DutyCycle )

Pwm low level Set Period and Duty

This function sets the period and the duty cycle of a PWM channel.

Parameters
HwUnitPointer to the hardware unit configuration
ChannelNumberNumeric identifier of the PWM
PeriodPeriod of the PWM signal
DutyCycleMin=0x0000 Max=0x8000

◆ Pwm_Arch_SetPowerState()

Std_ReturnType Pwm_Arch_SetPowerState ( Pwm_HwUnit * HwUnit,
Pwm_PowerStateRequestResultType * Result )

Pwm low level Set Power State

This function configures the Pwm module so that it enters the already prepared power state, chosen between a predefined set of configured ones.

Parameters
HwUnitPointer to the hardware unit configuration
ResultIf the API returns E_OK: PWM_SERVICE_ACCEPTED:Power state change executed. If the API returns E_NOT_OK: PWM_NOT_INIT: PWM Module not initialized. PWM_SEQUENCE_ERROR: wrong API call sequence. PWM_HW_FAILURE: the HW module has a failure which prevents it to enter the required power state
Return values
E_OKPower Mode changed E_NOT_OK: request rejected