/* Configures a SSC peripheral. If the divided clock is not used, the master clock frequency can be set to 0.  */
void SSC_Configure(AT91S_SSC *ssc, unsigned int id, unsigned int bitRate, unsigned int masterClock)
/* Configures a SSC peripheral. If the divided clock is not used, the master clock frequency can be set to 0.  */
void SSC_Configure(AT91S_SSC *ssc, unsigned int id, unsigned int bitRate, unsigned int masterClock)
{
    AT91C_BASE_PMC->PMC_PCER = 1 << id;
    ssc->SSC_CR = AT91C_SSC_RXDIS | AT91C_SSC_TXDIS | AT91C_SSC_SWRST;
    ssc->SSC_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
    if (bitRate != 0) {
        ssc->SSC_CMR = masterClock / (2 * bitRate);
    }
    else {
        ssc->SSC_CMR = 0;
    }
}