asf/sam/drivers/pwm/pwm.c
uint32_t pwm_init(Pwm *p_pwm, pwm_clock_t *clock_config)
{
	uint32_t clock = 0;
	uint32_t result;

	/* Clock A */
	if (clock_config->ul_clka != 0) {
		result = pwm_clocks_generate(clock_config->ul_clka, clock_config->ul_mck);
		if (result == PWM_INVALID_ARGUMENT) {
			return result;
		}

		clock = result;
	}

	/* Clock B */
	if (clock_config->ul_clkb != 0) {
		result = pwm_clocks_generate(clock_config->ul_clkb, clock_config->ul_mck);

		if (result == PWM_INVALID_ARGUMENT) {
			return result;
		}

		clock |= (result << 16);
	}
#if (SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM)
	p_pwm->PWM_MR = clock;
#else
	p_pwm->PWM_CLK = clock;
#endif
	return 0;
}
/**
 * \brief Initialize the PWM source clock (clock A and clock B).
 *
 * \param p_pwm Pointer to a PWM instance.
 * \param clock_config PWM clock configuration.
 *
 * \retval 0 if initialization succeeds, otherwise fails.
 */
\brief Initialize the PWM source clock (clock A and clock B).
\param p_pwm Pointer to a PWM instance.
\param clock_config PWM clock configuration.

\retval 0 if initialization succeeds, otherwise fails.
\ brief Initialize the PWM source clock ( clock A and clock B ) . \ param p_pwm Pointer to a PWM instance . \ param clock_config PWM clock configuration . \ retval 0 if initialization succeeds otherwise fails .
uint32_t pwm_init(Pwm *p_pwm, pwm_clock_t *clock_config)
{
	uint32_t clock = 0;
	uint32_t result;
	if (clock_config->ul_clka != 0) {
		result = pwm_clocks_generate(clock_config->ul_clka, clock_config->ul_mck);
		if (result == PWM_INVALID_ARGUMENT) {
			return result;
		}
		clock = result;
	}
	if (clock_config->ul_clkb != 0) {
		result = pwm_clocks_generate(clock_config->ul_clkb, clock_config->ul_mck);
		if (result == PWM_INVALID_ARGUMENT) {
			return result;
		}
		clock |= (result << 16);
	}
#if (SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM)
	p_pwm->PWM_MR = clock;
#else
	p_pwm->PWM_CLK = clock;
#endif
	return 0;
}
uint32_t pwm_init ( Pwm * p_pwm , pwm_clock_t * clock_config ) { uint32_t clock = 0 ; uint32_t result ; if ( clock_config -> ul_clka != 0 ) { result = pwm_clocks_generate ( clock_config -> ul_clka , clock_config -> ul_mck ) ; if ( result == PWM_INVALID_ARGUMENT ) { return result ; } clock = result ; } if ( clock_config -> ul_clkb != 0 ) { result = pwm_clocks_generate ( clock_config -> ul_clkb , clock_config -> ul_mck ) ; if ( result == PWM_INVALID_ARGUMENT ) { return result ; } clock |= ( result << 16 ) ; } #if ( SAM3N || SAM4N || SAM4C || SAM4CP || SAM4CM ) p_pwm -> PWM_MR = clock ; #else p_pwm -> PWM_CLK = clock ; #endif return 0 ; }
\brief Initialize the PWM source clock (clock A and clock B).
\ brief Initialize the PWM source clock ( clock A and clock B ) .
/* Clock A */ /* Clock B */