asf/sam/drivers/pwm/pwm.c
uint32_t pwm_cmp_init(Pwm *p_pwm, pwm_cmp_t *p_cmp)
{
	uint32_t unit = p_cmp->unit;

	p_pwm->PWM_CMP[unit].PWM_CMPV = PWM_CMPV_CV(p_cmp->ul_value) |
			(p_cmp->b_is_decrementing << 24);

	p_pwm->PWM_CMP[unit].PWM_CMPM = PWM_CMPM_CTR(p_cmp->ul_trigger) |
			PWM_CMPM_CPR(p_cmp->ul_period) |
			PWM_CMPM_CUPR(p_cmp->ul_update_period);

	/** Boolean of generating a match pulse */
	if (p_cmp->b_pulse_on_line_0) {
		p_pwm->PWM_ELMR[0] |= (1 << unit);
	} else {
		p_pwm->PWM_ELMR[0] &= ~((uint32_t) (1 << unit));
	}
	/** Boolean of generating a match pulse */
	if (p_cmp->b_pulse_on_line_1) {
		p_pwm->PWM_ELMR[1] |= (1 << unit);
	} else {
		p_pwm->PWM_ELMR[1] &= ~((uint32_t) (1 << unit));
	}

	/** Boolean of comparison enable */
	if (p_cmp->b_enable) {
		p_pwm->PWM_CMP[unit].PWM_CMPM |= PWM_CMPM_CEN;
	} else {
		p_pwm->PWM_CMP[unit].PWM_CMPM &= ~PWM_CMPM_CEN;
	}

	return 0;
}
/**
 * \brief Initialize PWM comparison unit.
 *
 * \param p_pwm Pointer to a PWM instance.
 * \param p_cmp Configurations of PWM comparison tagged by unit.
 *
 * \retval 0 if initialization succeeds, otherwise fails.
 */
\brief Initialize PWM comparison unit.
\param p_pwm Pointer to a PWM instance.
\param p_cmp Configurations of PWM comparison tagged by unit.

\retval 0 if initialization succeeds, otherwise fails.
\ brief Initialize PWM comparison unit . \ param p_pwm Pointer to a PWM instance . \ param p_cmp Configurations of PWM comparison tagged by unit . \ retval 0 if initialization succeeds otherwise fails .
uint32_t pwm_cmp_init(Pwm *p_pwm, pwm_cmp_t *p_cmp)
{
	uint32_t unit = p_cmp->unit;
	p_pwm->PWM_CMP[unit].PWM_CMPV = PWM_CMPV_CV(p_cmp->ul_value) |
			(p_cmp->b_is_decrementing << 24);
	p_pwm->PWM_CMP[unit].PWM_CMPM = PWM_CMPM_CTR(p_cmp->ul_trigger) |
			PWM_CMPM_CPR(p_cmp->ul_period) |
			PWM_CMPM_CUPR(p_cmp->ul_update_period);
	if (p_cmp->b_pulse_on_line_0) {
		p_pwm->PWM_ELMR[0] |= (1 << unit);
	} else {
		p_pwm->PWM_ELMR[0] &= ~((uint32_t) (1 << unit));
	}
	if (p_cmp->b_pulse_on_line_1) {
		p_pwm->PWM_ELMR[1] |= (1 << unit);
	} else {
		p_pwm->PWM_ELMR[1] &= ~((uint32_t) (1 << unit));
	}
	if (p_cmp->b_enable) {
		p_pwm->PWM_CMP[unit].PWM_CMPM |= PWM_CMPM_CEN;
	} else {
		p_pwm->PWM_CMP[unit].PWM_CMPM &= ~PWM_CMPM_CEN;
	}
	return 0;
}
uint32_t pwm_cmp_init ( Pwm * p_pwm , pwm_cmp_t * p_cmp ) { uint32_t unit = p_cmp -> unit ; p_pwm -> PWM_CMP [ unit ] . PWM_CMPV = PWM_CMPV_CV ( p_cmp -> ul_value ) | ( p_cmp -> b_is_decrementing << 24 ) ; p_pwm -> PWM_CMP [ unit ] . PWM_CMPM = PWM_CMPM_CTR ( p_cmp -> ul_trigger ) | PWM_CMPM_CPR ( p_cmp -> ul_period ) | PWM_CMPM_CUPR ( p_cmp -> ul_update_period ) ; if ( p_cmp -> b_pulse_on_line_0 ) { p_pwm -> PWM_ELMR [ 0 ] |= ( 1 << unit ) ; } else { p_pwm -> PWM_ELMR [ 0 ] &= ~ ( ( uint32_t ) ( 1 << unit ) ) ; } if ( p_cmp -> b_pulse_on_line_1 ) { p_pwm -> PWM_ELMR [ 1 ] |= ( 1 << unit ) ; } else { p_pwm -> PWM_ELMR [ 1 ] &= ~ ( ( uint32_t ) ( 1 << unit ) ) ; } if ( p_cmp -> b_enable ) { p_pwm -> PWM_CMP [ unit ] . PWM_CMPM |= PWM_CMPM_CEN ; } else { p_pwm -> PWM_CMP [ unit ] . PWM_CMPM &= ~ PWM_CMPM_CEN ; } return 0 ; }
\brief Initialize PWM comparison unit.
\ brief Initialize PWM comparison unit .
/** Boolean of generating a match pulse */ /** Boolean of generating a match pulse */ /** Boolean of comparison enable */