int main(void) { uint32_t ticks = 0; uint32_t timerstate; or1k_timer_init(100); gpio_init(); or1k_timer_enable(); while (1) { while (ticks == or1k_timer_get_ticks()) { } ticks++; timerstate = or1k_timer_disable(); // do something atomar or1k_timer_restore(timerstate); if (ticks == 100) { printf("A second elapsed\n"); // Increment the GPIO counter gpio_increment(); or1k_timer_reset_ticks(); ticks = 0; } } return 0; }
void __malloc_unlock(struct _reent *ptr) { // Decrement counter. The lock may be unlocked recursively _malloc_lock_cnt--; // If this was the last recursive unlock call if(_malloc_lock_cnt == 0){ // reset owner _malloc_lock_own = 0; // Restore IEE flag or1k_interrupts_restore(_malloc_lock_restore_interrupts); // Restore TEE flag or1k_timer_restore(_malloc_lock_restore_timer); } return; }
void or1k_critical_end(uint32_t restore) { or1k_timer_restore(restore & 0x1); or1k_interrupts_restore((restore >> 1) & 0x1); }