void
PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut,
uint32_t ui32Width)
{
uint32_t ui32GenBase, ui32Reg;
PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut,
uint32_t ui32Width)
{
uint32_t ui32GenBase, ui32Reg;
//
// Check the arguments.
//
ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
ASSERT(_PWMOutValid(ui32PWMOut));
// Check the arguments.
//
ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
ASSERT(_PWMOutValid(ui32PWMOut));
//
// Compute the generator's base address.
//
ui32GenBase = PWM_OUT_BADDR(ui32Base, ui32PWMOut);
// Compute the generator's base address.
//
ui32GenBase = PWM_OUT_BADDR(ui32Base, ui32PWMOut);
//
// If the counter is in up/down count mode, divide the width by two.
//
if(HWREG(ui32GenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
{
ui32Width /= 2;
}
// If the counter is in up/down count mode, divide the width by two.
//
if(HWREG(ui32GenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
{
ui32Width /= 2;
}
//
// Get the period.
//
ui32Reg = HWREG(ui32GenBase + PWM_O_X_LOAD);
// Get the period.
//
ui32Reg = HWREG(ui32GenBase + PWM_O_X_LOAD);
//
// Make sure the width is not too large.
//
ASSERT(ui32Width < ui32Reg);
// Make sure the width is not too large.
//
ASSERT(ui32Width < ui32Reg);
//
// Compute the compare value.
//
ui32Reg = ui32Reg - ui32Width;
// Compute the compare value.
//
ui32Reg = ui32Reg - ui32Width;