AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/at91sam7s/timer.c
void TimerInit(
    void)
{
    unsigned int pcsr;
    /* enable the Timer0 peripheral clock */
    volatile AT91PS_PMC pPMC = AT91C_BASE_PMC;

    pcsr = pPMC->PMC_PCSR;
    pPMC->PMC_PCER = pcsr | (1 << AT91C_ID_TC0);
    /* Set up the AIC  registers for Timer 0 */
    volatile AT91PS_AIC pAIC = AT91C_BASE_AIC;
    /* Disable timer 0 interrupt */
    /* in AIC Interrupt Disable Command Register */
    pAIC->AIC_IDCR = (1 << AT91C_ID_TC0);
    /* Set the TC0 IRQ handler address in */
    /* AIC Source Vector Register[12] */
    pAIC->AIC_SVR[AT91C_ID_TC0] = (unsigned int) Timer0IrqHandler;
    /* Set the interrupt source type and priority */
    /* in AIC Source Mode Register[12] */
    pAIC->AIC_SMR[AT91C_ID_TC0] =
        (AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | 0x4);
    /* Clear the TC0 interrupt */
    /* in AIC Interrupt Clear Command Register */
    pAIC->AIC_ICCR = (1 << AT91C_ID_TC0);
    /* Remove disable timer 0 interrupt */
    /* in AIC Interrupt Disable Command Reg */
    pAIC->AIC_IDCR = (0 << AT91C_ID_TC0);
    /* Enable the TC0 interrupt */
    /* in AIC Interrupt Enable Command Register */
    pAIC->AIC_IECR = (1 << AT91C_ID_TC0);
    /* Setup timer0 to generate a 1 msec periodic interrupt */
    Timer0_Setup(1);
}
/*  ***************************************************************************** */
/* */
/*     Timer 0 Initialization */
/* */
/*  From James P Lynch main.c example code */
/*  Modified by Steve Karg */
/*    Moved timer startup code from main */
/*    modified the peripheral clock init */
/*  ***************************************************************************** */
Timer 0 Initialization

From James P Lynch main.c example code
Modified by Steve Karg
Moved timer startup code from main
modified the peripheral clock init
Timer 0 Initialization From James P Lynch main . c example code Modified by Steve Karg Moved timer startup code from main modified the peripheral clock init
void TimerInit(
    void)
{
    unsigned int pcsr;
    volatile AT91PS_PMC pPMC = AT91C_BASE_PMC;
    pcsr = pPMC->PMC_PCSR;
    pPMC->PMC_PCER = pcsr | (1 << AT91C_ID_TC0);
    volatile AT91PS_AIC pAIC = AT91C_BASE_AIC;
    pAIC->AIC_IDCR = (1 << AT91C_ID_TC0);
    pAIC->AIC_SVR[AT91C_ID_TC0] = (unsigned int) Timer0IrqHandler;
    pAIC->AIC_SMR[AT91C_ID_TC0] =
        (AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | 0x4);
    pAIC->AIC_ICCR = (1 << AT91C_ID_TC0);
    pAIC->AIC_IDCR = (0 << AT91C_ID_TC0);
    pAIC->AIC_IECR = (1 << AT91C_ID_TC0);
    Timer0_Setup(1);
}
void TimerInit ( void ) { unsigned int pcsr ; volatile AT91PS_PMC pPMC = AT91C_BASE_PMC ; pcsr = pPMC -> PMC_PCSR ; pPMC -> PMC_PCER = pcsr | ( 1 << AT91C_ID_TC0 ) ; volatile AT91PS_AIC pAIC = AT91C_BASE_AIC ; pAIC -> AIC_IDCR = ( 1 << AT91C_ID_TC0 ) ; pAIC -> AIC_SVR [ AT91C_ID_TC0 ] = ( unsigned int ) Timer0IrqHandler ; pAIC -> AIC_SMR [ AT91C_ID_TC0 ] = ( AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE | 0x4 ) ; pAIC -> AIC_ICCR = ( 1 << AT91C_ID_TC0 ) ; pAIC -> AIC_IDCR = ( 0 << AT91C_ID_TC0 ) ; pAIC -> AIC_IECR = ( 1 << AT91C_ID_TC0 ) ; Timer0_Setup ( 1 ) ; }
Timer 0 Initialization
Timer 0 Initialization
/* enable the Timer0 peripheral clock */ /* Set up the AIC  registers for Timer 0 */ /* Disable timer 0 interrupt */ /* in AIC Interrupt Disable Command Register */ /* Set the TC0 IRQ handler address in */ /* AIC Source Vector Register[12] */ /* Set the interrupt source type and priority */ /* in AIC Source Mode Register[12] */ /* Clear the TC0 interrupt */ /* in AIC Interrupt Clear Command Register */ /* Remove disable timer 0 interrupt */ /* in AIC Interrupt Disable Command Reg */ /* Enable the TC0 interrupt */ /* in AIC Interrupt Enable Command Register */ /* Setup timer0 to generate a 1 msec periodic interrupt */