/* Architecture's entry point */ void __init2(void) { /* * The main application expects IRQs disabled. */ IRQ_DISABLE; /* Set the appropriate clocking configuration */ clock_init(); /* Initialize IRQ vector table in RAM */ sysirq_init(); #if (CONFIG_KERN && CONFIG_KERN_PREEMPT) /* * Voluntary context switch handler. * * This software interrupt can always be triggered and must be * dispatched as soon as possible, thus we just disable IRQ priority * for it. */ sysirq_setHandler(FAULT_SVCALL, svcall_handler); sysirq_setPriority(FAULT_SVCALL, IRQ_PRIO_MAX); /* * Preemptible context switch handler * * The priority of this IRQ must be the lowest priority in the system * in order to run last in the interrupt service routines' chain. */ sysirq_setHandler(FAULT_PENDSV, pendsv_handler); sysirq_setPriority(FAULT_PENDSV, IRQ_PRIO_MIN); #endif }
int main(void) { /* initialize LED and debug unit */ led_init(); sysirq_init(); AT91F_DBGU_Init(); AT91F_PIOA_CfgPMC(); wdt_init(); pit_init(); blinkcode_init(); /* initialize USB */ req_ctx_init(); usbcmd_gen_init(); udp_open(); /* call application specific init function */ _init_func(); // Enable User Reset and set its minimal assertion to 960 us AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4 << 8) | (unsigned int)(0xA5 << 24); #ifdef DEBUG_CLOCK_PA6 AT91F_PMC_EnablePCK(AT91C_BASE_PMC, 0, AT91C_PMC_CSS_PLL_CLK); AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, 0, AT91C_PA6_PCK0); #endif /* switch on first led */ led_switch(2, 1); DEBUGPCRF("entering main (idle) loop"); while (1) { /* Call application specific main idle function */ _main_func(); dbgu_rb_flush(); /* restart watchdog timer */ wdt_restart(); #ifdef CONFIG_IDLE //cpu_idle(); #endif } }
void timer_hw_init(void) { sysirq_init(); cpu_flags_t flags; MOD_CHECK(sysirq); IRQ_SAVE_DISABLE(flags); PIT_MR = TIMER_HW_CNT; /* Register system interrupt handler. */ sysirq_setHandler(SYSIRQ_PIT, timer_handler); /* Enable interval timer and interval timer interrupts */ PIT_MR |= BV(PITEN); sysirq_setEnable(SYSIRQ_PIT, true); /* Reset counters, this is needed to start timer and interrupt flags */ uint32_t dummy = PIVR; (void) dummy; IRQ_RESTORE(flags); }