STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
Pwm Driver More...
Macros | |
#define | PWM_CHANNEL_MIN 1 |
#define | PWM_CHANNEL_MAX 2 |
#define | Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId) |
Variables | |
static Pwm_HwUnit | HwUnit_Pwm |
Variable for the initial value of the pwm configuration array. | |
Pwm Driver
The driver provides functions for initialization and control of the microcontroller internal PWM stage (pulse width modulation). The PWM module generates pulses with variable pulse width. It allows the selection of the duty cycle and the signal period time.
#define Det_ReportError | ( | ModuleId, | |
InstanceId, | |||
ApiId, | |||
ErrorId ) |
ModuleId | module id number |
InstanceId | Instance Id |
ApiId | Pai id |
ErrorId | Error code |
void Pwm_DeInit | ( | void | ) |
Pwm Deinitialization
This function de-initializes the Pwm module.
void Pwm_DisableNotification | ( | Pwm_ChannelType | ChannelNumber | ) |
Pwm Disable Notification
Function to disable the PWM signal edge notification.
ChannelNumber | Numeric identifier of the PWM |
< Minimum valid PWM channel number.
void Pwm_EnableNotification | ( | Pwm_ChannelType | ChannelNumber, |
Pwm_EdgeNotificationType | Notification ) |
Pwm Enable Notification
Function to enable the PWM signal edge notification according to notification parameter.
ChannelNumber | Numeric identifier of the PWM |
Notification | Type of notification PWM_RISING_EDGE or PWM_FALLING_EDGE or PWM_BOTH_EDGES. |
< Minimum valid PWM channel number.
Std_ReturnType Pwm_GetCurrentPowerState | ( | Pwm_PowerStateType * | CurrentPowerState, |
Pwm_PowerStateRequestResultType * | Result ) |
Pwm Get Current Power State
This API returns the current power state of the PWM HW unit.
CurrentPowerState | The current power mode of the PWM HW Unit is returned in this parameter |
Result | If 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. |
E_OK | Mode could be read E_NOT_OK: Service is rejected |
Pwm_OutputStateType Pwm_GetOutputState | ( | Pwm_ChannelType | ChannelNumber | ) |
Pwm Get Output State
Function to read the internal state of the PWM output signal.
ChannelNumber | Numeric identifier of the PWM |
PWM_HIGH | The PWM output state is high PWM_LOW: The PWM output state is low |
< Minimum valid PWM channel number.
Std_ReturnType Pwm_GetTargetPowerState | ( | Pwm_PowerStateType * | TargetPowerState, |
Pwm_PowerStateRequestResultType * | Result ) |
Pwm Get Target Power State
This API returns the Target power state of the PWM HW unit.
TargetPowerState | The Target power mode of the PWM HW Unit is returned in this parameter. |
Result | If 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. |
E_OK | Mode could be read E_NOT_OK: Service is rejected |
void Pwm_GetVersionInfo | ( | Std_VersionInfoType * | versioninfo | ) |
Pwm Get Version Info
This function returns the version information of this module.
versioninfo | Pointer to where to store the version information of this module. |
void Pwm_Init | ( | const Pwm_ConfigType * | ConfigPtr | ) |
Pwm Initialization
Service for PWM initialization.
ConfigPtr | Pointer to driver configuration |
Std_ReturnType Pwm_PreparePowerState | ( | Pwm_PowerStateType | PowerState, |
Pwm_PowerStateRequestResultType * | Result ) |
Pwm Prepare Power State
This API starts the needed process to allow the PWM HW module to enter the requested power state.
PowerState | The Target power mode of the PWM HW Unit is returned in this parameter. |
Result | If 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 |
E_OK | Preparation process started E_NOT_OK: Service is rejected |
void Pwm_SetDutyCycle | ( | Pwm_ChannelType | ChannelNumber, |
uint16 | DutyCycle ) |
Pwm Set Duty Cycle
This function sets the duty cycle of the PWM channel.
ChannelNumber | Numeric identifier of the PWM |
DutyCycle | Min=0x0000 Max=0x8000 |
< Minimum valid PWM channel number.
void Pwm_SetOutputToIdle | ( | Pwm_ChannelType | ChannelNumber | ) |
Pwm Set Output To Idle
This function sets the PWM output to the configured Idle state.
ChannelNumber | Numeric identifier of the PWM |
< Minimum valid PWM channel number.
void Pwm_SetPeriodAndDuty | ( | Pwm_ChannelType | ChannelNumber, |
Pwm_PeriodType | Period, | ||
uint16 | DutyCycle ) |
Pwm Set Period and Duty
This function sets the period and the duty cycle of a PWM channel.
ChannelNumber | Numeric identifier of the PWM |
Period | Period of the PWM signal |
DutyCycle | Min=0x0000 Max=0x8000 |
< Minimum valid PWM channel number.
Std_ReturnType Pwm_SetPowerState | ( | Pwm_PowerStateRequestResultType * | Result | ) |
Pwm 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.
Result | If 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 |
E_OK | Power Mode changed E_NOT_OK: request rejected |
|
static |
Variable for the initial value of the pwm configuration array.
< Add static when no testing