/* * The application must provide a function that configures a peripheral to * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() * in FreeRTOSConfig.h to call the function. This file contains a function * that is suitable for use on the Atmel SAMA5. */ void vConfigureTickInterrupt( void ) { /* NOTE: The PIT interrupt is cleared by the configCLEAR_TICK_INTERRUPT() macro in FreeRTOSConfig.h. */ /* Enable the PIT clock. */ PMC->PMC_PCER0 = 1 << ID_PIT; /* Initialize the PIT to the desired frequency - specified in uS. */ PIT_Init( 1000000UL / configTICK_RATE_HZ, BOARD_MCK / 1000000 ); /* Configure interrupt on PIT. Note this is on the system interrupt, which is shared with other system peripherals, so System_Handler() must be installed in place of FreeRTOS_Tick_Handler() if other system handlers are required. The tick must be given the lowest priority (0 in the SAMA5 AIC) */ IRQ_ConfigureIT( ID_PIT, AIC_SMR_SRCTYPE_EXT_POSITIVE_EDGE, FreeRTOS_Tick_Handler ); /* See commend directly above IRQ_ConfigureIT( ID_PIT, 0, System_Handler ); */ IRQ_EnableIT( ID_PIT ); PIT_EnableIT(); /* Enable the pit. */ PIT_Enable(); /* Prevent compiler warnings in the case where System_Handler() is not used as the handler. See the comments above the System_Handler() function prototype at the top of this file. */ ( void ) System_Handler; }
static void platform_systimer_init() { PIT_SetPIV( SYSTIMER_LIMIT ); AIC_ConfigureIT( AT91C_ID_SYS, 0, ISR_Pit ); PIT_EnableIT(); AIC_EnableIT( AT91C_ID_SYS ); PIT_Enable(); }
/** * \brief Configures the PIT & reset tickCount. * Systick interrupt handler will generates 1ms interrupt and increase a * tickCount. * \note IRQ handler must be configured before invoking this function. * \note PIT is enabled automatically in this function. * \param new_mck Current master clock. */ extern uint32_t TimeTick_Configure( uint32_t new_mck ) { _dwTickCount = 0 ; PIT_Init( 1000, new_mck / 1000000 ); PIT_EnableIT(); PIT_Enable(); return 0; }
static void prvSetupTimerInterrupt( void ) { const uint32_t ulPeriodIn_uS = ( 1.0 / ( double ) configTICK_RATE_HZ ) * port1SECOND_IN_uS; /* Setup the PIT for the required frequency. */ PIT_Init( ulPeriodIn_uS, BOARD_MCK / port1MHz_IN_Hz ); /* Setup the PIT interrupt. */ AIC_DisableIT( AT91C_ID_SYS ); AIC_ConfigureIT( AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, vPortTickISR ); AIC_EnableIT( AT91C_ID_SYS ); PIT_EnableIT(); }
unsigned long int SysTick_Config(unsigned long int ticks) { unsigned long int rate = SystemCoreClock/ticks; /* Configure timer to interrupt specified times per second */ PIT_Init(1000000/rate, SystemCoreClock/1000000); PIT_EnableIT(); PIT_Enable(); /* Configure timer interrupt */ AIC_ConfigureIT(AT91C_ID_SYS, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, TimerISR); AIC_EnableIT(AT91C_ID_SYS); return 0; }
//------------------------------------------------------------------------------ /// Configures the PIT to generate 1ms ticks. //------------------------------------------------------------------------------ static void ConfigurePit(void) { // Initialize and enable the PIT PIT_Init(PIT_PERIOD, BOARD_MCK / 1000000); // Disable the interrupt on the interrupt controller IRQ_DisableIT(AT91C_ID_SYS); // Configure the AIC for PIT interrupts IRQ_ConfigureIT(AT91C_ID_SYS, 0, ISR_Pit); // Enable the interrupt on the interrupt controller IRQ_EnableIT(AT91C_ID_SYS); // Enable the interrupt on the pit PIT_EnableIT(); // Enable the pit PIT_Enable(); }
void PitInit(unsigned int msperiod) { PIT_DisableIT(); // Initialize the PIT to the desired frequency PIT_Init(0, 0); // PIT timer runs at MCK/16 // calculates the PIT Value accurate to a Millisecond interrupt // msperiod can not be larget than 349 because PIV is at a 20bit limit if(msperiod > 349) msperiod = 349; PIT_SetPIV((MCK/(16*1000))*msperiod); // Configure interrupt on PIT AIC_DisableIT(AT91C_ID_SYS); AIC_ConfigureIT(AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, ISR_Pit); AIC_EnableIT(AT91C_ID_SYS); PIT_EnableIT(); // Enable the pit PIT_Enable(); }
/* * The application must provide a function that configures a peripheral to * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() * in FreeRTOSConfig.h to call the function. This file contains a function * that is suitable for use on the Atmel SAMA5. */ void vConfigureTickInterrupt( void ) { /* NOTE: The PIT interrupt is cleared by the configCLEAR_TICK_INTERRUPT() macro in FreeRTOSConfig.h. */ /* Enable the PIT clock. */ PMC->PMC_PCER0 = 1 << ID_PIT; /* Initialize the PIT to the desired frequency - specified in uS. */ PIT_Init( 1000000UL / configTICK_RATE_HZ, ( BOARD_MCK / 2 ) / 1000000 ); /* Enable IRQ / select PIT interrupt. */ PMC->PMC_PCER1 = ( 1 << ( ID_IRQ - 32 ) ); AIC->AIC_SSR = ID_PIT; /* Ensure interrupt is disabled before setting the mode and installing the handler. The priority of the tick interrupt should always be set to the lowest possible. */ AIC->AIC_IDCR = AIC_IDCR_INTD; AIC->AIC_SMR = AIC_SMR_SRCTYPE_EXT_POSITIVE_EDGE; AIC->AIC_SVR = ( uint32_t ) FreeRTOS_Tick_Handler; /* Start with the interrupt clear. */ AIC->AIC_ICCR = AIC_ICCR_INTCLR; /* Enable the interrupt in the AIC and peripheral. */ AIC_EnableIT( ID_PIT ); PIT_EnableIT(); /* Enable the peripheral. */ PIT_Enable(); /* Prevent compiler warnings in the case where System_Handler() is not used as the handler. See the comments above the System_Handler() function prototype at the top of this file. */ ( void ) System_Handler; }