/* Configures PWM a channel with the given parameters. The PWM controller must have been clocked in the PMC prior to calling this function.  */
void PWMC_ConfigureChannel(unsigned char channel, unsigned int prescaler, unsigned int alignment, unsigned int polarity)
/* Configures PWM a channel with the given parameters. The PWM controller must have been clocked in the PMC prior to calling this function.  */
void PWMC_ConfigureChannel(unsigned char channel, unsigned int prescaler, unsigned int alignment, unsigned int polarity)
{
    SANITY_CHECK(prescaler < AT91C_PWMC_CPRE_MCKB);
    SANITY_CHECK((alignment & ~AT91C_PWMC_CALG) == 0);
    SANITY_CHECK((polarity & ~AT91C_PWMC_CPOL) == 0);
    AT91C_BASE_PWMC->PWMC_DIS = 1 << channel;
    AT91C_BASE_PWMC->PWMC_CH[channel].PWMC_CMR = prescaler | alignment | polarity;
}