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; }
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; }
/*! * @brief Initialisation thread. runs once. */ void InitThread(void *data) { for (;;) { OS_SemaphoreWait(InitSemaphore, 0); Random_Init(); //Switches mate Switch_Init(S1Callback, (void *) 0, S2Callback, (void *) 0); Toggle_Init(ToggleModeFinished); Game_Init(GameModeFinished); Touch_Init(); //Initialize all the modules LEDs_Init(); I2C_Init(100000, MODULE_CLOCK); Accel_Init(&AccelSetup); PIT_Init(MODULE_CLOCK, &PitCallback, (void *) 0); PIT_Set(500000000, bFALSE); PIT_Enable(bTRUE); Packet_Init(BAUD_RATE, MODULE_CLOCK); Flash_Init(); CMD_Init(); //Best to do this one last //TODO: disabled for yellow RTC_Init((void (*)(void*))OS_SemaphoreSignal, (void *) RtcSemaphore); Timer_Init(); Timer_Set(&PacketTimer); Timer_Set(&AccTimer); CMD_SpecialGetStartupValues(); LEDs_On(LED_ORANGE); } }
/****************************************************************************** * @brief PIT_Init - Initialize PIT module. * * @param *pConfig Pointer to PIT configure struct * * @return none ******************************************************************************/ void PIT_Init( PitConfigType *pConfig ) { PIT_Disable(); PIT_MicroForceLoadEnable( pConfig->bMicroTimerSel ); PIT_TimerForceLoadEnable( pConfig->u8PitChannelSel ); PIT_MicroLoadVal( pConfig->bMicroTimerSel, pConfig->u8MicroTimerVal ); PIT_TimerLoadVal( pConfig->u8PitChannelSel, pConfig->u16PitLoadVal ); PIT_MultiplexSel( pConfig->u8PitChannelSel, pConfig->bMicroTimerSel ); PIT_ChannelEnable( pConfig->u8PitChannelSel ); if( pConfig->bChannelIntEn ) { PIT_IntEnable( pConfig->u8PitChannelSel ); } PIT_Enable(); }
//------------------------------------------------------------------------------ /// 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; }