⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 bootloader源代码
💻 C
字号:
/***************************************** Copyright (c) 2001-2002  Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//* This file is part of the boot loader *//* * timer.c * * timer for ARM */#include "util.h"#include "uart.h"#include "jasper.h"#include "jasper_const.h"#include "io.h"static int g_ticks = 0;static unsigned int g_last = 0;void timer_init(void){	__raw_writel(0xffff, JASPER_TIMER_BASE + TIMER_TMR0LOAD);	__raw_writel(0xc8, JASPER_TIMER_BASE + TIMER_TMR0CTL);}unsigned int timer_getticks(void){	unsigned int timerval = __raw_readl(JASPER_TIMER_BASE + TIMER_TMR0VAL);		if ((g_last & 0x8000) != (timerval & 0x8000))		++g_ticks;	g_last = timerval;	return g_ticks;}int timer_timeout(unsigned int startticks, int timeout){	unsigned int ticks = timer_getticks();		if (timeout == 0)		return 1;	else if (timeout > 0) {		if ((ticks - startticks) > (timeout >> 8))			return 1;	}	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -