frm.c

来自「硬件的cpu是arm920i2c总线和camera之间的连接驱动在嵌入式linu」· C语言 代码 · 共 61 行

C
61
字号
#include <linux/kernel.h>#include <linux/module.h>#include <linux/compatmac.h>#include <linux/hdreg.h>#include <linux/vmalloc.h>#include <linux/fs.h>#include <linux/module.h>#include <linux/blkpg.h>#include <asm/irq.h>#include <asm/arch/hardware.h>#include <asm/arch/irqs.h>extern int sensorFrameCount;#define TIMER2_IRQ	58#ifndef U32typedef unsigned long U32;#endif#define MX1_TMR2_VA_VASE	(IO_ADDRESS(0x203000))#define _reg_TMR_TCTL2     (*((volatile U32 *)(MX1_TMR2_VA_VASE+0x00)))#define _reg_TMR_TPRER2    (*((volatile U32 *)(MX1_TMR2_VA_VASE+0x04)))#define _reg_TMR_TCMP2     (*((volatile U32 *)(MX1_TMR2_VA_VASE+0x08)))#define _reg_TMR_TSTAT2    (*((volatile U32 *)(MX1_TMR2_VA_VASE+0x14)))static void timer2_intr_handler(int irq, void *dev_id, struct pt_regs *regs){//	static int count=0;		if (_reg_TMR_TSTAT2)   	_reg_TMR_TSTAT2 = 0;    // clear interrupt		printk("Frame rate: %d\n", sensorFrameCount);	sensorFrameCount = 0;	   	//	printk("%d\n", count++);}int init_module(){	if (request_irq(TIMER2_IRQ, timer2_intr_handler, SA_INTERRUPT, "timer2", NULL))		printk("request_irq for timer2 failed !\n");	else		printk("request_irq for timer2 suceed :-)\n");   _reg_TMR_TPRER2 = 0;    	// divide by 1   _reg_TMR_TCMP2 = 32768;   	// 1 Hz for 32768 Hz souce   _reg_TMR_TCTL2 = 0x19;  	// compare intr, 32K source, enable timer		return 0;}void cleanup_module(){		free_irq(TIMER2_IRQ, NULL);}

⌨️ 快捷键说明

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