uint32_t time_get_tick_ms(void) { uint32_t tmp; systick_interrupt_disable(); tmp = system_ms; systick_interrupt_enable(); return tmp; }
void bootFile(const char * filename){ FIL file; UINT readbytes; FRESULT res; res=f_open(&file, filename, FA_OPEN_EXISTING|FA_READ); if(res!=F_OK){ lcdPrintln("FOPEN ERROR"); lcdPrintln(f_get_rc_string(res)); lcdDisplay(); getInputWait(); return; }; uint8_t *destination=&_app_start; #define BLOCK 1024 * 128 do { res=f_read(&file, destination, BLOCK, &readbytes); destination+=readbytes; }while(res==F_OK && readbytes==BLOCK); lcdDisplay(); if(res!=F_OK){ lcdPrint("Read Error:"); lcdPrintln(f_get_rc_string(res)); lcdDisplay(); getInputWait(); return; }; systick_interrupt_disable(); /* TODO: maybe disable all interrupts? */ boot((void*)&_app_start); };
void cc3k_global_irq_enable(char val) { if (val) { nvic_enable_irq(NVIC_EXTI0_1_IRQ); systick_interrupt_enable(); } else { nvic_disable_irq(NVIC_EXTI0_1_IRQ); systick_interrupt_disable(); } }
void panic(void) { int i; nvic_disable_irq(NVIC_EXTI0_1_IRQ); systick_interrupt_disable(); while(1) { led(0, 0); led(1, 0); for (i=0;i<100000;i++) asm volatile("nop"); led(0, 1); led(1, 1); for (i=0;i<100000;i++) asm volatile("nop"); } }
// will overflow once after 292 years ... uint64_t systick_jiffy(void) { volatile uint64_t val; volatile uint64_t ms; systick_interrupt_disable(); val = STK_CVR; ms = systick_ms; systick_interrupt_enable(); return val + ms * STK_RVR; }
void sys_tick_handler(void) { uint32_t next_timer = 0; volatile uint32_t reload = systick_get_reload(); uint32_t this_timeslice; SysTick_Hook(); jiffies+= clock_interval; _n_int++; next_timer = ktimers_check(); #ifdef CONFIG_LOWPOWER if (next_timer < 0 || next_timer > 1000){ next_timer = 1000; /* Wake up every second if timer is too long, or if no timers */ } /* Checking deep sleep */ if (next_timer >= 1000 && scheduler_can_sleep()) { systick_interrupt_disable(); cputimer_start(next_timer); return; } #ifdef CONFIG_TICKLESS this_timeslice = task_timeslice(); if (_sched_active && (this_timeslice == 0) && (!task_running())) { schedule(); } else { systick_interrupt_disable(); cputimer_start(this_timeslice); } return; #endif #endif if (_sched_active && ((task_timeslice() == 0) || (!task_running()))) { schedule(); (void)next_timer; } }
void timer_set(struct timer *timer, int timeout) { struct timer volatile *t = g_timer; timer->value = timeout; /* check if timer is already in list */ while (t != NULL) { if (t == timer) return; t = t->next; } systick_interrupt_disable(); timer->next = g_timer; g_timer = timer; systick_interrupt_enable(); }
void jump_to_app() { const uint32_t *app_base = (const uint32_t *)APP_LOAD_ADDRESS; /* * We refuse to program the first word of the app until the upload is marked * complete by the host. So if it's not 0xffffffff, we should try booting it. */ if (app_base[0] == 0xffffffff) return; /* * The second word of the app is the entrypoint; it must point within the * flash area (or we have a bad flash). */ if (app_base[1] < APP_LOAD_ADDRESS) return; if (app_base[1] >= (APP_LOAD_ADDRESS + board_info.fw_size)) return; /* just for paranoia's sake */ flash_lock(); /* kill the systick interrupt */ systick_interrupt_disable(); systick_counter_disable(); /* and set a specific LED pattern */ led_off(LED_ACTIVITY); led_on(LED_BOOTLOADER); /* the interface */ cfini(); /* switch exception handlers to the application */ SCB_VTOR = APP_LOAD_ADDRESS; /* extract the stack and entrypoint from the app vector table and go */ do_jump(app_base[0], app_base[1]); }
void systickDisable(){ systick_interrupt_disable(); systick_counter_disable(); };