• 大小: 2KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-15
  • 语言: 其他
  • 标签: 海思ADC  驱动  源码  

资源简介

海思ADC驱动源码,完整驱动源码,可以正常加载与使用。

资源截图

代码片段和文件信息

/*
*****************************************************************
* Copyright 2015-2016 Shenzhen NiuTu All Rights Reserved
*
* ir204.c:
*    This file is use for receiving IrDA event.

*
* @History
* Fly.Han 2016-07-19 am draft
*
*****************************************************************
*/

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include “hi_adc.h“

/***************************Define Macro*************************/
#define ADC_IRQ            19
#define SUPPORT_CHANNEL    0x4

#define SAR_ADC_base       0x200B0000
#define PERI_CRG32_base    0x2003007C

#define ADC_CTRL           0x00  //寄存器配置
#define ADC_GLITCH_SAMPEL  0x04  //滤波毛刺配置
#define ADC_TIME_SCAN      0x08
#define ADC_DATA_MASK      0x0c
#define ADC_INT_MASK       0x10  //int enable 0:disable 1:enable
#define ADC_INT_STATUS     0x14  //int state
#define ADC_INT_CLR        0x18  //int clr
#define ADC_START          0x1c  //start auto scan
#define ADC_STOP           0x20  //stop

#define ADC_IRQ_ENABLE     0x01
#define ADC_IRQ_DISABLE    0x00
#define ADC_CLK_ENABLE     (1<<2)  //0为使能
#define ADC_POWER_ENABLE   0x00
#define TIME_OUT           HZ * 5    // 队列等待时间 

//ADC_CTRL
#define ADC_ACTIVE_BIT(x)     (x << 24)    //precision 11111100(6 bits)11111000(5 bits)...
#define DEGLITCH_BYPASS       (1 << 17)    //滤毛刺 0:enable 1:bypass
#define ADC_RESET             (1 << 15)    //reset 0:quit 1:enter reset
#define POWER_DOWN_MODE       (1 << 14)    //power_down 0:disable 1:enable
#define MODEL_SEL             (1 << 13)    //model 0:single scan 1:continuous scan
#define CHANNEL_SEL(x)        (1 << (x+8)) //channel 0:A 1:B 2:C 3:D
#define ADC_ZERO_MASK         0xffffff00
//ADC_DATA_MASK
//#define get_adc_data(x)       ((SAR_ADC_base+ADC_DATA_MASK) >> (x << 3) & 0xFF)
//ADC_INT_STATUS
//#define ADC_AUTO_BUSY         ((SAR_ADC_base+ADC_INT_STATUS) >> 4 & 0x01)
//#define ADC_INT_FLAG(x)       ((SAR_ADC_base+ADC_INT_STATUS) >> x & 0x01) //中断标志 0:A 1:B 2:C 3:D
//ADC_INT_CLR
//#define ADC_INT_CLR(x)        ((SAR_ADC_base+ADC_INT_CLR) | 0x01 << x) //清除中断标志 0:A 1:B 2:C 3:D

/***********************Define Globle Variate********************/
struct his_adc_driver{
    struct proc_dir_entry  *adc_file;
    void __iomem           *adc_reg_base;
    int                    flag;
    wait_queue_head_t      irq_wait;
};

static char *adc_proc_name = “sar_adc“;
static struct his_adc_driver his_adc;

/****************Driver Information Indicate********************/
MODULE_AUTHOR(“SZNiuTu.“);
MODULE_DEscriptION(“Sar_adc Driver“);
MODULE_LICENSE(“GPL“);

int read_channel(int channel)
{
    unsigned in

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6475  2016-07-22 16:21  hi_adc.c

----------- ---------  ---------- -----  ----

                 6475                    1


评论

共有 条评论