60 #include "HL_system.h"
66 #define PWM_LOWER_THRESHOLD_PERM (1u)
69 #define PWM_UPPER_THRESHOLD_PERM (999u)
72 #define PWM_FULL_PERIOD_PERM (1000u)
82 .etpwmInitialized =
false,
106 etpwm_config_reg_t etPwmConfig = {0};
107 etpwm1GetConfigValue(&etPwmConfig, CurrentValue);
108 return etPwmConfig.CONFIG_TBPRD;
115 uint32_t counterValue = (((uint32_t)basePeriod * (uint32_t)dutyCycle_perm) /
PWM_FULL_PERIOD_PERM);
117 FAS_ASSERT(counterValue <= (uint16_t)UINT16_MAX);
118 return (uint16_t)counterValue;
148 FAS_ASSERT(dutyCycle_perm <= (uint16_t)INT16_MAX);
149 int16_t intermediateDutyCycle_perm = (int16_t)dutyCycle_perm +
pwm_kLinearOffset;
151 if (intermediateDutyCycle_perm < 0) {
152 intermediateDutyCycle_perm = 0;
154 uint16_t correctedDutyCycle_perm = (uint16_t)intermediateDutyCycle_perm;
169 uint32_t capture1 = ecapGetCAP1(ecapREG1);
171 uint32_t capture2 = ecapGetCAP2(ecapREG1);
173 uint32_t capture3 = ecapGetCAP3(ecapREG1);
193 #ifdef UNITY_UNIT_TEST
194 extern int16_t TEST_PWM_GetLinearOffset(
void) {
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
long FSYS_RaisePrivilege(void)
raise privilege
static PWM_INITIALIZATION_STATE_s pwm_state
void PWM_SetDutyCycle(uint16_t dutyCycle_perm)
Set the duty cycle of the PWM (currently only channel 1A)
void PWM_Initialize(void)
Initializes the ETPWM and the ECAP module.
void PWM_StopPwm(void)
Stop the PWM (stops all configured ePWM channels)
static uint16_t PWM_GetEtpwmTimePeriod(void)
#define PWM_UPPER_THRESHOLD_PERM
#define PWM_FULL_PERIOD_PERM
static uint16_t PWM_ComputeCounterValueFromDutyCycle(uint16_t dutyCycle_perm)
void PWM_StartPwm(void)
Start the PWM (starts all configured ePWM channels)
PWM_SIGNAL_s ECAP_GetPwmData(void)
Get dutycycle and frequency of input PWM signal.
void ecapNotification(ecapBASE_t *ecap, uint16 flags)
static PWM_SIGNAL_s ecap_inputPwmSignal
bool PWM_IsEcapModuleInitialized(void)
Get initialization state of ecap module.
#define PWM_LOWER_THRESHOLD_PERM
static const int16_t pwm_kLinearOffset
PWM driver for the TMS570LC43xx.