📄 frm.c
字号:
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Copyright (C) 2002, 2003 Motorola Semiconductors HK Ltd * */#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -