/* Initializes the DBGU with the given parameters, and enables both the transmitter and the receiver.  */
void DBGU_Configure(unsigned int mode, unsigned int baudrate, unsigned int mck)
/* Initializes the DBGU with the given parameters, and enables both the transmitter and the receiver.  */
void DBGU_Configure(unsigned int mode, unsigned int baudrate, unsigned int mck)
{
    AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RSTRX | AT91C_US_RSTTX;
    AT91C_BASE_DBGU->DBGU_IDR = 0xFFFFFFFF;
    AT91C_BASE_DBGU->DBGU_BRGR = mck / (baudrate * 16);
    AT91C_BASE_DBGU->DBGU_MR = mode;
    AT91C_BASE_DBGU->DBGU_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
    AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RXEN | AT91C_US_TXEN;
}