当前位置: 技术问答>linux和unix
为什么我的A/D驱动读出的数据都是一样的呀?
来源: 互联网 发布时间:2016-05-01
本文导语: 大家帮忙看一下,我的A/D驱动,使用中断方式,读出的数据没有变化,为什么? #include #include #include #include #include #include /* printk() */ #include /* kmalloc() */ #include /* everything... */ #include ...
大家帮忙看一下,我的A/D驱动,使用中断方式,读出的数据没有变化,为什么?
#include
#include
#include
#include
#include
#include /* printk() */
#include /* kmalloc() */
#include /* everything... */
#include /* error codes */
#include /* size_t */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "s3c2410-adc.h"
#include
#include
#define DEVICE_NAME "adc"
static int adc_major = 252;
typedef struct {
struct semaphore lock;
wait_queue_head_t wait;
int channel;
int prescale;
}ADC_DEV;
static ADC_DEV adcdev;
int IRQ_flag=64;
static unsigned long *adccon, *adctsc, *adcdly, *adcdat0, *adcdat1, *adcupdn;
static irqreturn_t adcdone_int_handler(int irq,void *dev_id,struct pt_regs *regs) //*********irq_handle()********//
{
wake_up(&adcdev.wait);
printk("wake_up adcdev.wait ...n");
return IRQ_HANDLED;
}
static int s3c2410_adc_open(struct inode *inode, struct file *filp) //********open()***********//
{
init_MUTEX(&adcdev.lock);
init_waitqueue_head(&(adcdev.wait));
adcdev.channel=0;
adcdev.prescale=19; //#define IRQ_FREQ 2500000 prescale=50000000/IRQ_FREQ-1;
printk("open OKn");
//try_module_get(THIS_MODULE);
return 0;
}
static ssize_t s3c2410_adc_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)//*****write()*****//
{
return 0;
}
static ssize_t s3c2410_adc_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)//*********read()**********//
{
int ret = 0;
int i=0;
unsigned long temp0,temp1;
if (down_interruptible(&adcdev.lock))
return -ERESTARTSYS;
writel((readl(S3C2410_CLKCON) | S3C2410_CLKCON_ADC),S3C2410_CLKCON); //
writel((0x01
#include
#include
#include
#include
#include
#include /* printk() */
#include /* kmalloc() */
#include /* everything... */
#include /* error codes */
#include /* size_t */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "s3c2410-adc.h"
#include
#include
#define DEVICE_NAME "adc"
static int adc_major = 252;
typedef struct {
struct semaphore lock;
wait_queue_head_t wait;
int channel;
int prescale;
}ADC_DEV;
static ADC_DEV adcdev;
int IRQ_flag=64;
static unsigned long *adccon, *adctsc, *adcdly, *adcdat0, *adcdat1, *adcupdn;
static irqreturn_t adcdone_int_handler(int irq,void *dev_id,struct pt_regs *regs) //*********irq_handle()********//
{
wake_up(&adcdev.wait);
printk("wake_up adcdev.wait ...n");
return IRQ_HANDLED;
}
static int s3c2410_adc_open(struct inode *inode, struct file *filp) //********open()***********//
{
init_MUTEX(&adcdev.lock);
init_waitqueue_head(&(adcdev.wait));
adcdev.channel=0;
adcdev.prescale=19; //#define IRQ_FREQ 2500000 prescale=50000000/IRQ_FREQ-1;
printk("open OKn");
//try_module_get(THIS_MODULE);
return 0;
}
static ssize_t s3c2410_adc_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)//*****write()*****//
{
return 0;
}
static ssize_t s3c2410_adc_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)//*********read()**********//
{
int ret = 0;
int i=0;
unsigned long temp0,temp1;
if (down_interruptible(&adcdev.lock))
return -ERESTARTSYS;
writel((readl(S3C2410_CLKCON) | S3C2410_CLKCON_ADC),S3C2410_CLKCON); //
writel((0x01