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

📄 sp_timer.c

📁 凌阳公司机sunplus1002在这个芯片下
💻 C
字号:
/******************************************************************************  Module Name: sp_timer.c Description: This is a hardware  timer  Copyright @ 2006 Sunmedia, Inc. All rights reserved. History: Created by zhangjie on 7/8/2006 *****************************************************************************/#include "sp_timer.h"#include <cyg/kernel/kapi.h>#include <cyg/hal/plf_intr.h>#include <cyg/io/io.h>#include <cyg/hal/types.h>#include <cyg/infra/diag.h>#include "types.h"#include "string.h"#define TIMER0_VECTOR CYGNUM_HAL_INTERRUPT_TIMER0  #define CLKRTC	(2<<14)#define RPT	(1<<13)#define GO	(1<<11)static TIMERCALLBACK pCallback = NULL;static cyg_interrupt int_timer;static cyg_handle_t int_timer_hd = 0;cyg_uint32 isr_timer(cyg_vector_t vector, cyg_addrword_t data){	cyg_interrupt_mask(vector);//mask the smartcard interrrupt	cyg_interrupt_acknowledge(vector); //notify the cpu 	return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR);}void dsr_timer(cyg_vector_t vector,				cyg_ucount32 count,				cyg_addrword_t data) {	if (pCallback)	{		(pCallback)();	}	cyg_interrupt_unmask(vector);}void startTimer(UINT32 timeVal){	regs0->timer0_cnt = timeVal;	regs0->timer0_ctrl = (CLKRTC|GO)&~RPT;	cyg_interrupt_unmask(TIMER0_VECTOR);}void stopTimer(void){	regs0->timer0_ctrl &= ~GO; }void registerTimerCallback(TIMERCALLBACK pfun){	pCallback = pfun;}void createTimer(void){	if (!int_timer_hd)	{		cyg_interrupt_create(TIMER0_VECTOR,					    	0,					    	0,					    	&isr_timer,					    	&dsr_timer,					    	& int_timer_hd,					    	&int_timer);					    			cyg_interrupt_attach(int_timer_hd);	}}

⌨️ 快捷键说明

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