新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 應用調試-----輸入模擬器之編寫測試模擬功能

        應用調試-----輸入模擬器之編寫測試模擬功能

        作者: 時間:2016-11-21 來源:網絡 收藏
        自定義myprintk函數,把信息打印到mymsg文件內:
        自定義print函數緩存打印數據到環形緩沖區
        ====================================================================
        觸摸屏驅動源碼:
        #include "linux/errno.h"
        #include "linux/kernel.h"
        #include "linux/module.h"
        #include "linux/slab.h"
        #include "linux/input.h"
        #include "linux/init.h"
        #include "linux/serio.h"
        #include "linux/delay.h"
        #include "linux/platform_device.h"
        #include "linux/clk.h"
        #include "asm/io.h"
        #include "asm/irq.h"
        #include "asm/uaccess.h"
        #include "asm/plat-s3c24xx/ts.h"
        #include "asm/arch/regs-adc.h"
        #include "asm/arch/regs-gpio.h"
        struct s3c_ts_regs {
        unsigned long adccon;
        unsigned long adctsc;
        unsigned long adcdly;
        unsigned long adcdat0;
        unsigned long adcdat1;
        unsigned long adcupdn;
        };
        static struct input_dev *s3c_ts_dev;
        static volatile struct s3c_ts_regs *s3c_ts_regs;
        static struct timer_list ts_timer;
        #define MYLOG_BUF_LEN (1024*1024)
        #define INPUT_REPLAY 0
        #define INPUT_TAG 1
        static char *replay_buf;
        static int replay_r = 0;
        static int replay_w = 0;
        static int major = 0;
        static struct class *cls;
        static struct timer_list replay_timer;
        extern int myprintk(const char *fmt, ...);
        static ssize_t replay_write(struct file * file, const char __user *buf, size_t size, loff_t *offset)
        {
        int err;
        // 把應用程序傳入的數據寫入replay_buf //
        if (replay_w + size "= MYLOG_BUF_LEN)
        {
        printk("replay_buf full!n");
        return -EIO;
        }
        err = copy_from_user(replay_buf + replay_w, buf, size);
        if (err)
        {
        return -EIO;
        }
        else
        {
        replay_w += size;
        }
        return size;
        }
        // app: ioctl(fd, CMD, ..); //
        static int replay_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
        {
        char buf[100];
        switch (cmd)
        {
        case INPUT_REPLAY:
        {
        // 啟動回放: 根據replay_buf里的數據來上報事件 //
        replay_timer.expires = jiffies + 1;
        printk("replay_ioctl add_timern");
        add_timer(&replay_timer);
        break;
        }
        case INPUT_TAG:
        {
        copy_from_user(buf, (const void __user *)arg, 100);
        buf[99] = 主站蜘蛛池模板: 寿光市| 遂川县| 镇沅| 仙游县| 天门市| 富锦市| 静乐县| 东山县| 闻喜县| 阳新县| 兰州市| 宜兰市| 镇江市| 巨野县| 富顺县| 大竹县| 钦州市| 松滋市| 屏南县| 赤峰市| 东丽区| 铜川市| 江陵县| 奉化市| 阿克| 盐边县| 孝义市| 镇宁| 义马市| 托克逊县| 上蔡县| 垣曲县| 阳朔县| 应用必备| 汝南县| 巴南区| 达州市| 思茅市| 西盟| 昭苏县| 斗六市|