asf/sam/drivers/pwm/pwm.c
uint32_t pwm_channel_update_period(Pwm *p_pwm, pwm_channel_t *p_channel,
		uint32_t ul_period)
{
	uint32_t ch_num = p_channel->channel;

	/** Check parameter */
	if (p_channel->ul_duty > ul_period) {
		return PWM_INVALID_ARGUMENT;
	} else {
		/* Save new period value */
		p_channel->ul_period = ul_period;

#if (SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM)
		/* Set CPD bit to change period value */
		p_pwm->PWM_CH_NUM[ch_num].PWM_CMR |= PWM_CMR_CPD;

		p_pwm->PWM_CH_NUM[ch_num].PWM_CUPD = ul_period;
#else
		p_pwm->PWM_CH_NUM[ch_num].PWM_CPRDUPD = ul_period;
#endif
	}

	return 0;
}
/**
 * \brief Change the period of the PWM channel.
 *
 * \param p_pwm Pointer to a PWM instance.
 * \param p_channel Configurations of the specified PWM channel.
 * \param ul_period New period value.
 *
 * \retval 0 if changing succeeds, otherwise fails.
 */
\brief Change the period of the PWM channel.
\param p_pwm Pointer to a PWM instance.
\param p_channel Configurations of the specified PWM channel.
\param ul_period New period value.

\retval 0 if changing succeeds, otherwise fails.
\ brief Change the period of the PWM channel . \ param p_pwm Pointer to a PWM instance . \ param p_channel Configurations of the specified PWM channel . \ param ul_period New period value . \ retval 0 if changing succeeds otherwise fails .
uint32_t pwm_channel_update_period(Pwm *p_pwm, pwm_channel_t *p_channel,
		uint32_t ul_period)
{
	uint32_t ch_num = p_channel->channel;
	if (p_channel->ul_duty > ul_period) {
		return PWM_INVALID_ARGUMENT;
	} else {
		p_channel->ul_period = ul_period;
#if (SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM)
		p_pwm->PWM_CH_NUM[ch_num].PWM_CMR |= PWM_CMR_CPD;
		p_pwm->PWM_CH_NUM[ch_num].PWM_CUPD = ul_period;
#else
		p_pwm->PWM_CH_NUM[ch_num].PWM_CPRDUPD = ul_period;
#endif
	}
	return 0;
}
uint32_t pwm_channel_update_period ( Pwm * p_pwm , pwm_channel_t * p_channel , uint32_t ul_period ) { uint32_t ch_num = p_channel -> channel ; if ( p_channel -> ul_duty > ul_period ) { return PWM_INVALID_ARGUMENT ; } else { p_channel -> ul_period = ul_period ; #if ( SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM ) p_pwm -> PWM_CH_NUM [ ch_num ] . PWM_CMR |= PWM_CMR_CPD ; p_pwm -> PWM_CH_NUM [ ch_num ] . PWM_CUPD = ul_period ; #else p_pwm -> PWM_CH_NUM [ ch_num ] . PWM_CPRDUPD = ul_period ; #endif } return 0 ; }
\brief Change the period of the PWM channel.
\ brief Change the period of the PWM channel .
/** Check parameter */ /* Save new period value */ /* Set CPD bit to change period value */