按键驱动

    • 一、补充知识
      • 1.中断
        • 1.1 概念
        • 1.2 Linux中断上下部分区别:
        • 1.3 处理原则
        • 1.4 中断下半部
        • 1.5 中断使用
      • 2. 定时器
        • jiffies
      • 3. 等待队列
        • 3.1 定义并初始化"等待队列头"
        • 3.2 等待事件
        • 3.3唤醒队列
    • 二、驱动程序编写
      • 1. 创建描述设备数据结构
      • 2. 编写模块
      • 3.模块配置
      • 4. 配置卸载
      • 5. 关联函数
        • 5.1 open
        • 5.2 poll
        • 5.3 read
        • 5.4 中断服务函数(上半部)
        • 5.5 定时器函数(下半部)
      • 6 完整源码
        • 1. platdrv_key.c
        • 2. Makefile
    • 三、设备程序编写
      • 1. 抽象数据结构
      • 2. 编写模块
        • 1. 完善设备信息
        • 2.完善模块信息
      • 3. 完整源码
        • 1. platdev_key.h
        • 2. platdev_key.c
        • 3. Makefile

一、补充知识

1.中断

装载至:https://blog.csdn.net/qq_20553613/article/details/80629255

1.1 概念

不同于裸机编程,操作系统是多个进程和多个线程执行,宏观上达到并行运行的状态,外设中断则会打断内核中任务调度和运行,及屏蔽其外设的中断响应,如果中断函数耗时过长则使得系统实时性和并发性降低。中断原则是尽可能处理少的事务,而一些设备中往往需要处理大量的耗时事务。为了提高系统的实时性和并发性,Linux内核将中断处理程序分为上半部(top half)和下半部(bottom half)。上半部分任务比较少,处理一些寄存器操作、时间敏感任务,以及“登记中断”通知内核及时处理下半部的任务。下半部分,则负责处理中断任务中的大部分工作,如一个总线通信系统中数据处理部分。

1.2 Linux中断上下部分区别:

1)上半部由外设中断触发,下半部由上半部触发。
2)上半部不会被其他中断打断,下半部是可以被打断的。
3)上半部分处理任务要快,主要任务、耗时任务放在下半部。

一般来说,在中断上半部执行完毕,下半部即在内核的调度下被执行,当然如果有其他更高优先级需处理的任务,会先处理该任务再调度处理下半部,或者在系统空闲时间进行处理。

1.3 处理原则

对于Linux系统设备而言,一个完整的中断程序由上半部和下半部分共同构成,在编写设备驱动程序前,就需考虑好上半部和下半部的分配。很多时候上半部与下半部并没有严格的区分界限,主要由程序员根据实际设计,如某些外设中断可以没有下半部。关于上下半部的划分原则,就是主要事务、耗时事务划分在下半部处理。

关于中断上下部分的设计,可以参考以下原则:
1)与硬件相关的操作,如操作寄存器,必须放在上半部。
2)对时间敏感、要求实时性的任务放在上半部。
3)该任务不能被其他中断或者进程打断的放在上半部。
4)实时性要求不高的任务、耗时任务放在下半部。

1.4 中断下半部

Linux下半部实现,通过内核版本更新中实现下衍化,最原始的实现手段是BH(bottom half)后在2.5版本移除,在2.3版本引入软中断(softirq)和tasklet机制,在2.5版本引入工作队列(work queue在)。因此,目前使用方式是三种,软中断、tasklet机制、工作队列。

1.5 中断使用

Linux驱动中断涉及到的主要函数有:

request_irq()    申请中断

free_irq()      释放中断

irq_interrupt()    中断服务

2. 定时器

转载至:https://blog.csdn.net/dreamInTheWorld/article/details/107471967
内核定时器为了可以在某个时间点上调用函数,内核定时器的调度函数运行过一次后就不会再被运行了,
但是在del_timer销毁定时之前,可以使用add_timer(注册)或者mod_timer(修改)重新调用
一般重新调用的场景有
1 通过在被调度的函数中重新调度自己来周期运行。
2 通过某个中断服务函数中重新唤起调用

add_timer 把定时器注册连接到内核专门的链表中(最终也是通过调用mod_timer实现)
mod_timer 重新注册定时器到内核专门的链表中(不管定时器函数是否被运行过)
del_timer 注销一个定时器(它不会等待其他CPU上的调度结束,在单核处理器上,可以直接使用)
del_timer_sync 注销一个定时器(用于SMP多核系统,会进入休眠等待其他CPU上的调度结束)
timer_pending 判断一个定时器是否被添加到了内核链表中以等待被调度运行
setup_timer 建个定时器 主要负责给 function 和 data 进行赋值工作

jiffies

时间中断由系统定时硬件以周期性间隔产生,这个间隔由内核根据HZ的值设定,我们应保留默认的HZ值不要自行调整,每当时间中断发生的时,内核内部计数器的值就增加一,计数器的值在系统引导时被初始化为0,读取变量jiffies的值就可以获取计数器的值,这里值得注意的是jiffies应被看成只读变量。Linux系统的宏HZ的值一般在体系相关的目录,arch/arm/include/asm/param.h
在这里插入图片描述所以本机配置, 1 jiffies = 10ms

3. 等待队列

3.1 定义并初始化"等待队列头"

wait_queue_head_t w_queue;
init_waitqueue_head(&w_queue); //会将自旋锁初始化为未锁,等待队列初始化为空的双向循环链表。

3.2 等待事件

  • wait_event(queue,condition);等待以queue为等待队列头等待队列被唤醒,condition必须满足,否则阻塞
  • wait_event_interruptible(queue,condition);可被信号打断
  • wait_event_timeout(queue,condition,timeout);阻塞等待的超时时间,时间到了,不论condition是否满足,都要返回
  • wait_event_interruptible_timeout(queue,condition,timeout)

3.3唤醒队列

  • wake_up()与wake_event()或者wait_event_timeout成对使用
  • wake_up_intteruptible()与wait_event_intteruptible()或者wait_event_intteruptible_timeout()成对使用。

等待队列的流程:首先,定义并初始化等待队列,把进程的状态置成TASK_UNINTERRUPTIBLE或TASK_INTERRUPTIBLE,并将对待队列添加到等待队列头。最后,当进程被其他地方唤醒,将等待队列移除等待队列头。

二、驱动程序编写

1. 创建描述设备数据结构

  • 判断按键是否按下, 我们不仅仅需要按键的数据信息,还需要一个状态位来判断当前的状态, 我们令这个为位status, 当status为1时按键按下, status为0时按键没有按下,status为2时按键为未确定位, 用于消抖。状态位确定之后, 我们再设置标志ev_press位来标志当前状态。
  • 既然需要消抖,熟悉单片机的朋友肯定第一时间相到延时, 但是这里为了不占用内核的太多时间, 我们采用定时器来完成中断的下半部工作, 关于这个下半部, 后面会详细分析。
  • 那么问题来了,有多个中断源需要判断, 我们应该如何处理, 这里需要用到一个多路复用的知识, 建立等待队列, 用户空间调用select或者poll, 会关联到内核内.poll函数来监视等待队列。
  • 注册驱动, 我们需要注册cdev结构体。
  • 自动创建结点, 需要创建class结构体。

2. 编写模块

驱动模块主体无非声明模块作者,协议以及模块描述, 也可以添加出传入模块参数, 再完成模块入口和出口函数编写:

static struct platform_driver s3c_button_driver = {.probe = s3c_button_probe,.remove = s3c_button_remove,.driver = {.name = "s3c_key",.owner = THIS_MODULE,},
};
static int __init s3c_button_init(void)
{int     rv=0;rv = platform_driver_register(&s3c_button_driver);if(rv){printk(KERN_ERR "%s:%d: Can't  regist button driver %d.\n", __FUNCTION__, __LINE__, rv);platform_driver_unregister(&s3c_button_driver);return rv;}printk("Regist button driver sucessfully!\n");return 0;
}static void s3c_button_exit(void)
{printk("%s:%d remove the BUTTON platform driver.\n", __FUNCTION__, __LINE__);platform_driver_unregister(&s3c_button_driver);
}module_init(s3c_button_init);
module_exit(s3c_button_exit);module_param(dev_major, int, S_IRUGO);
module_param(dev_minor, int, S_IRUGO);MODULE_AUTHOR("Moqiu <comeonqiuliang@163.com>");
MODULE_DESCRIPTION("FL2440 BUTTON DRIVER");
MODULE_LICENSE("GPL");

3.模块配置

模块配置也就分为四步:

  • 硬件初始化, 本模块我们将硬件初始化放到open函数中进行
  • 分配主次设备号
  • 分配cdev结构体
  • 绑定主次设备号、fops到cdev结构体中,并注册给Linux内核
static struct file_operations s3c_button_fops = {.owner = THIS_MODULE,.open = button_open,.read = button_read,.poll = button_poll,.release = button_release,
};static int s3c_button_probe(struct platform_device *dev)
{int    result = 0;dev_t  devno;if(0 != dev_major){devno = MKDEV(dev_major, dev_minor);result = register_chrdev_region(devno, 1, DEV_NAME);}else{result = alloc_chrdev_region(&devno, dev_major, 1, DEV_NAME);dev_major = MAJOR(devno);}if(result < 0){printk("%s driver can't get major %d\n", DEV_NAME, dev_major);return result;}memset(&button_device, 0,sizeof(button_device));button_device.data = dev->dev.platform_data;cdev_init(&(button_device.cdev), &s3c_button_fops);button_device.cdev.owner = THIS_MODULE;result = cdev_add(&(button_device.cdev), devno, 1);if(result){printk(KERN_NOTICE "error %d add %s device", result, DEV_NAME);goto ERROR;}button_device.dev_class = class_create(THIS_MODULE, DEV_NAME);if(IS_ERR(button_device.dev_class)){printk("%s driver create class failure\n", DEV_NAME);result = -ENOMEM;goto ERROR;}#if  LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)device_create(button_device.dev_class, NULL, devno, NULL, DEV_NAME);
#elsedevice_create(button_device.dev_class, NULL, devno, DEV_NAME);
#endifreturn 0;
ERROR:printk("s3c %s driver install faliure.\n", DEV_NAME);cdev_del(&(button_device.cdev));unregister_chrdev_region(devno, 1);return result;
}

4. 配置卸载

卸载需要将原有申请的cdev结构体删除释放, 删除已安装结点:

static int s3c_button_remove(struct platform_device *dev)
{dev_t devno = MKDEV(dev_major, dev_minor);cdev_del(&(button_device.cdev));device_destroy(button_device.dev_class, devno);class_destroy(button_device.dev_class);unregister_chrdev_region(devno, 1);printk("s3c %s driver removed \n", DEV_NAME);return 0;
}

5. 关联函数

通过file_operations 类型结构体来配置我们的相应的关联函数:

static struct file_operations s3c_button_fops = {.owner = THIS_MODULE,.open = button_open,.read = button_read,.poll = button_poll,.release = button_release,
};

5.1 open

用户程序空间进行系统调用open后, 会关联button_open函数,在VFS层完成驱动设备的绑定,并且完成硬件初始化工作,定时器初始化和poll等待队列初始化,主要工作包括配置GPIO口并且为每个IO口申请一个定时器和装置位的用户空间, 绑定定时器相应函数:

static int button_open(struct inode *inode, struct file *file)
{struct button_device *pdev;struct s3c_button_platform_data *pdata;int i, result;pdev = container_of(inode->i_cdev, struct button_device, cdev);pdata = pdev->data;file->private_data = pdev;pdev->timers = (struct timer_list *)kmalloc(pdata->nbuttons * sizeof(struct timer_list), GFP_KERNEL);if(NULL == pdev->timers){printk("Alloc %s driver for timers faliure.\n", DEV_NAME);return -ENOMEM;}memset(pdev->timers, 0, pdata->nbuttons*sizeof(struct timer_list));pdev->status = (unsigned char *)kmalloc(pdata->nbuttons*sizeof(unsigned char), GFP_KERNEL);if(NULL == pdev->status){printk("Alloc %s driver for status faliure.\n", DEV_NAME);result = -ENOMEM;goto ERROR;}memset(pdev->status, 0, pdata->nbuttons*sizeof(unsigned char));init_waitqueue_head(&(pdev->waitq));for(i=0; i<pdata->nbuttons; i++){pdev->status[i] = BUTTON_UP;setup_timer(&(pdev->timers[i]), s3c_button_timer_handler, i);s3c2410_gpio_cfgpin(pdata->buttons[i].gpio, pdata->buttons[i].setting);irq_set_irq_type(pdata->buttons[i].nIRQ, IRQ_TYPE_EDGE_FALLING);result =  request_irq(pdata->buttons[i].nIRQ, s3c_button_intterupt, IRQF_DISABLED, DEV_NAME, (void*)i);if(result){result = -EBUSY;goto ERROR1;}}return 0;ERROR1:kfree((unsigned char *)pdev->status);while(--i){disable_irq(pdata->buttons[i]. nIRQ);free_irq(pdata->buttons[i].nIRQ, (void*)i);}ERROR:kfree(pdev->timers);return result;}

5.2 poll

当用户空间调用select或者poll多路复用后,会自动绑定button_poll, button_poll会将需要监视的文件描述符加入监视队列中。

static unsigned int button_poll(struct file *file, poll_table *wait)
{struct button_device *pdev  = file->private_data;unsigned int mask = 0;poll_wait(file, &(pdev->waitq), wait);if(pdev->ev_press){mask |= POLLIN | POLLRDNORM;}return mask;
}

poll()函数最后应该返回设备资源的可获取状态

常量 说明
POLLIN 普通或优先级带数据可读
POLLRDNORM 普通数据可读
POLLRDBAND 优先级带数据可读
POLLPRI 高优先级数据可读
POLLOUT 普通数据可写
POLLWRNORM 普通数据可写
POLLWRBAND 优先级带数据可写
POLLERR 发生错误
POLLHUP 发生挂起
POLLNVAL 描述字不是一个打开的文件

5.3 read

当.poll检测到相应事件时,执行button_read函数, button_read函数阻塞在 wait_event_interruptible(pdev->waitq, pdev->ev_press); 等待pdev->ev_press为真及wake_up_interruptible函数唤醒,

static int button_read(struct file* file, char __user *buf, size_t count, loff_t *ppos)
{struct button_device *pdev = file->private_data;struct s3c_button_platform_data *pdata;int i, ret;unsigned int status = 0;pdata = pdev->data;printk("ev_press: %d\n",  pdev->ev_press);if(!pdev->ev_press){if(file->f_flags & O_NONBLOCK){printk("read() without block mode.\n");return -EAGAIN;}else{printk("read() blocked here now.\n");wait_event_interruptible(pdev->waitq, pdev->ev_press);}}pdev->ev_press = 0;for(i=0; i<pdata->nbuttons; i++){printk("button[%d] status=%d\n",i, pdev->status[i]);status |= (pdev->status[i]<<i);}ret = copy_to_user(buf, (void *)&status, min(sizeof(status), count));return ret ? -EFAULT : min(sizeof(status), count);
}

5.4 中断服务函数(上半部)

当检测到相应的中断信号时, 进入中断服务函数中,中断服务函数通过中断号确认中断源,因为存在各种干扰,在中断服务函数中我们将按键状态设为未定义态, 消抖后再判断按键状态,消抖我们通过下半部来进行。 因为下半部是通过上半部触发, 所以我们在中断服务函数中配置定时器超时时间, 启动定时器,由定时器绑定的函数进行下半部操作, 中断上半部执行完成。

static irqreturn_t s3c_button_intterupt (int irq, void *de_id)
{int     i;int     found =0 ;struct  s3c_button_platform_data *pdata = button_device.data;for(i=0; i<pdata->nbuttons; i++){if(irq == pdata->buttons[i].nIRQ){found = 1;break;}}if(!found)return IRQ_NONE;if(BUTTON_UP == button_device.status[i]){button_device.status[i] = BUTTON_UNCERTAIN;mod_timer(&(button_device.timers[i]), jiffies+TIMER_DOWN);}return IRQ_HANDLED;
}

5.5 定时器函数(下半部)

在定时器函数中, 再次判断按键是否按下, 由此完成消抖功能。

static void s3c_button_timer_handler(unsigned long data)
{struct s3c_button_platform_data *pdata = button_device.data;int  num = (int)data;int status = s3c2410_gpio_getpin(pdata->buttons[num].gpio);if(LOWLEVEL == status){if(BUTTON_UNCERTAIN == button_device.status[num]){button_device.status[num] = BUTTON_DOWN;printk("%s presssed.\n", pdata->buttons[num].name);button_device.ev_press = 1;wake_up_interruptible(&(button_device.waitq));}mod_timer(&(button_device.timers[num]), jiffies+TIMER_DELAY_UP);}else{button_device.status[num] =  BUTTON_UP;}return;
}

6 完整源码

1. platdrv_key.c

#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/kref.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/string.h>
#include <linux/bcd.h>
#include <linux/miscdevice.h>
#include <linux/poll.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/proc_fs.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
#include <linux/usb.h>
#include <asm/uaccess.h>
#include <asm/delay.h>
#include <linux/syscalls.h>  /*    For sys_access*/
#include <linux/platform_device.h>
#include <linux/unistd.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/irq.h>
#include <mach/regs-gpio.h>
#include "platdev_key.h"#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
#include <mach/hardware.h>
#include <mach/gpio.h>
#include <asm/irq.h>
#else
#include <asm-arm/irq.h>
#include <asm/arch/gpio.h>
#include <asm/arch/hardware.h>
#endif#define  DEV_NAME   "key"#ifndef  DEV_MAJOR  
#define  DEV_MAJOR 0
#endif#define BUTTON_UP    0
#define BUTTON_DOWN  1
#define BUTTON_UNCERTAIN    2#define TIMER_DOWN (HZ/50)
#define TIMER_DELAY_UP (HZ/10)#define HIGHLEVEL                   1
#define LOWLEVEL                    0static int dev_major = DEV_MAJOR;
static int dev_minor = 0;struct button_device
{unsigned char                  *status;struct s3c_button_platform_data *data;struct timer_list               *timers;wait_queue_head_t               waitq;volatile    int                 ev_press;struct cdev                     cdev;struct class                    *dev_class;}button_device;static irqreturn_t s3c_button_intterupt (int irq, void *de_id)
{int     i;int     found =0 ;struct  s3c_button_platform_data *pdata = button_device.data;for(i=0; i<pdata->nbuttons; i++){if(irq == pdata->buttons[i].nIRQ){found = 1;break;}}if(!found)return IRQ_NONE;if(BUTTON_UP == button_device.status[i]){button_device.status[i] = BUTTON_UNCERTAIN;mod_timer(&(button_device.timers[i]), jiffies+TIMER_DOWN);}return IRQ_HANDLED;
}static void s3c_button_timer_handler(unsigned long data)
{struct s3c_button_platform_data *pdata = button_device.data;int  num = (int)data;int status = s3c2410_gpio_getpin(pdata->buttons[num].gpio);if(LOWLEVEL == status){if(BUTTON_UNCERTAIN == button_device.status[num]){button_device.status[num] = BUTTON_DOWN;printk("%s presssed.\n", pdata->buttons[num].name);button_device.ev_press = 1;wake_up_interruptible(&(button_device.waitq));}mod_timer(&(button_device.timers[num]), jiffies+TIMER_DELAY_UP);}else{button_device.status[num] =  BUTTON_UP;}return;}static int button_open(struct inode *inode, struct file *file)
{struct button_device *pdev;struct s3c_button_platform_data *pdata;int i, result;pdev = container_of(inode->i_cdev, struct button_device, cdev);pdata = pdev->data;file->private_data = pdev;pdev->timers = (struct timer_list *)kmalloc(pdata->nbuttons * sizeof(struct timer_list), GFP_KERNEL);if(NULL == pdev->timers){printk("Alloc %s driver for timers faliure.\n", DEV_NAME);return -ENOMEM;}memset(pdev->timers, 0, pdata->nbuttons*sizeof(struct timer_list));pdev->status = (unsigned char *)kmalloc(pdata->nbuttons*sizeof(unsigned char), GFP_KERNEL);if(NULL == pdev->status){printk("Alloc %s driver for status faliure.\n", DEV_NAME);result = -ENOMEM;goto ERROR;}memset(pdev->status, 0, pdata->nbuttons*sizeof(unsigned char));init_waitqueue_head(&(pdev->waitq));for(i=0; i<pdata->nbuttons; i++){pdev->status[i] = BUTTON_UP;setup_timer(&(pdev->timers[i]), s3c_button_timer_handler, i);s3c2410_gpio_cfgpin(pdata->buttons[i].gpio, pdata->buttons[i].setting);irq_set_irq_type(pdata->buttons[i].nIRQ, IRQ_TYPE_EDGE_FALLING);result =  request_irq(pdata->buttons[i].nIRQ, s3c_button_intterupt, IRQF_DISABLED, DEV_NAME, (void*)i);if(result){result = -EBUSY;goto ERROR1;}}return 0;ERROR1:kfree((unsigned char *)pdev->status);while(--i){disable_irq(pdata->buttons[i]. nIRQ);free_irq(pdata->buttons[i].nIRQ, (void*)i);}ERROR:kfree(pdev->timers);return result;}static int button_read(struct file* file, char __user *buf, size_t count, loff_t *ppos)
{struct button_device *pdev = file->private_data;struct s3c_button_platform_data *pdata;int i, ret;unsigned int status = 0;pdata = pdev->data;printk("ev_press: %d\n",  pdev->ev_press);if(!pdev->ev_press){if(file->f_flags & O_NONBLOCK){printk("read() without block mode.\n");return -EAGAIN;}else{printk("read() blocked here now.\n");wait_event_interruptible(pdev->waitq, pdev->ev_press);}}pdev->ev_press = 0;for(i=0; i<pdata->nbuttons; i++){printk("button[%d] status=%d\n",i, pdev->status[i]);status |= (pdev->status[i]<<i);}ret = copy_to_user(buf, (void *)&status, min(sizeof(status), count));return ret ? -EFAULT : min(sizeof(status), count);
}static unsigned int button_poll(struct file *file, poll_table *wait)
{struct button_device *pdev  = file->private_data;unsigned int mask = 0;poll_wait(file, &(pdev->waitq), wait);if(pdev->ev_press){mask |= POLLIN | POLLRDNORM;}return mask;
}static int button_release(struct inode *inode, struct file *file)
{int     i;struct  button_device *pdev =  file->private_data;struct  s3c_button_platform_data *pdata;pdata = pdev->data;for(i=0; i<pdata->nbuttons; i++){disable_irq(pdata->buttons[i].nIRQ);free_irq(pdata->buttons[i].nIRQ, (void*)i);del_timer(&(pdev->timers[i]));}kfree(pdev->timers);kfree((unsigned char *)pdev->status);return 0;
}static struct file_operations s3c_button_fops = {.owner = THIS_MODULE,.open = button_open,.read = button_read,.poll = button_poll,.release = button_release,
};static int s3c_button_probe(struct platform_device *dev)
{int    result = 0;dev_t  devno;if(0 != dev_major){devno = MKDEV(dev_major, dev_minor);result = register_chrdev_region(devno, 1, DEV_NAME);}else{result = alloc_chrdev_region(&devno, dev_major, 1, DEV_NAME);dev_major = MAJOR(devno);}if(result < 0){printk("%s driver can't get major %d\n", DEV_NAME, dev_major);return result;}memset(&button_device, 0,sizeof(button_device));button_device.data = dev->dev.platform_data;cdev_init(&(button_device.cdev), &s3c_button_fops);button_device.cdev.owner = THIS_MODULE;result = cdev_add(&(button_device.cdev), devno, 1);if(result){printk(KERN_NOTICE "error %d add %s device", result, DEV_NAME);goto ERROR;}button_device.dev_class = class_create(THIS_MODULE, DEV_NAME);if(IS_ERR(button_device.dev_class)){printk("%s driver create class failure\n", DEV_NAME);result = -ENOMEM;goto ERROR;}#if  LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)device_create(button_device.dev_class, NULL, devno, NULL, DEV_NAME);
#elsedevice_create(button_device.dev_class, NULL, devno, DEV_NAME);#endifreturn 0;ERROR:printk("s3c %s driver install faliure.\n", DEV_NAME);cdev_del(&(button_device.cdev));unregister_chrdev_region(devno, 1);return result;
}static int s3c_button_remove(struct platform_device *dev)
{dev_t devno = MKDEV(dev_major, dev_minor);cdev_del(&(button_device.cdev));device_destroy(button_device.dev_class, devno);class_destroy(button_device.dev_class);unregister_chrdev_region(devno, 1);printk("s3c %s driver removed \n", DEV_NAME);return 0;
}static struct platform_driver s3c_button_driver = {.probe = s3c_button_probe,.remove = s3c_button_remove,.driver = {.name = "s3c_key",.owner = THIS_MODULE,},
};static int __init s3c_button_init(void)
{int     rv=0;rv = platform_driver_register(&s3c_button_driver);if(rv){printk(KERN_ERR "%s:%d: Can't  regist button driver %d.\n", __FUNCTION__, __LINE__, rv);platform_driver_unregister(&s3c_button_driver);return rv;}printk("Regist button driver sucessfully!\n");return 0;}static void s3c_button_exit(void)
{printk("%s:%d remove the BUTTON platform driver.\n", __FUNCTION__, __LINE__);platform_driver_unregister(&s3c_button_driver);
}module_init(s3c_button_init);
module_exit(s3c_button_exit);module_param(dev_major, int, S_IRUGO);
module_param(dev_minor, int, S_IRUGO);MODULE_AUTHOR("Moqiu <comeonqiuliang@163.com>");
MODULE_DESCRIPTION("FL2440 BUTTON DRIVER");
MODULE_LICENSE("GPL");

2. Makefile

LINUX_SRC = ${shell pwd}/../../linux/linux-3.0/
CROSS_COMPILE=/opt/xtools/arm920t/bin/arm-linux-
INST_PATH=/tftpPWD := $(shell pwd)EXTRA_CFLAGS+=-DMODULEobj-m += platdev_key.o
obj-m += platdrv_key.omodules:@echo ${LINUX_SRC}@make -C $(LINUX_SRC) M=$(PWD) modules@make clearuninstall:rm -f ${INST_PATH}/*.koinstall: uninstallcp -af *.ko ${INST_PATH}clear:@rm -f *.o *.cmd *.mod.c@rm -rf  *~ core .depend  .tmp_versions Module.symvers modules.order -f@rm -f .*ko.cmd .*.o.cmd .*.o.dclean: clear@rm -f  *.ko

三、设备程序编写

1. 抽象数据结构

在这里插入图片描述
从图中我们可以得知, 按键s2、s3、s4、s5分别连在GPF0、GPF2、GPF3、GPF4上,其对应的中断线为EINT0、EINT2、EINT3和EINT4, 所以我们可以抽象一个数据结构来描述按键信息:

struct s3c_button_info 
{unsigned char           num;char *                  name;int                     nIRQ;unsigned int            setting;unsigned int            gpio;
};

为了加强可移植性, 可以再添加一个数据结构来描述多个按键:

struct s3c_button_platform_data{struct s3c_button_info *buttons;int    nbuttons;
};

2. 编写模块

1. 完善设备信息

通过上文抽象的数据结构,把我们的设备信息完善:

static struct s3c_button_info s3c_buttons[] = {[0] = {.num = 1,.name = "KEY1",.nIRQ = IRQ_EINT0,.gpio = S3C2410_GPF(0),.setting = S3C2410_GPF0_EINT0,},[1] = {.num = 2,.name = "KEY2",.nIRQ = IRQ_EINT2,.gpio = S3C2410_GPF(2),.setting = S3C2410_GPF2_EINT2,},[2] = {.num = 3,.name = "KEY3",.nIRQ = IRQ_EINT3,.gpio = S3C2410_GPF(3),.setting = S3C2410_GPF3_EINT3,},[3] = {.num = 4,.name = "KEY4",.nIRQ = IRQ_EINT4,.gpio = S3C2410_GPF(4),.setting = S3C2410_GPF4_EINT4,},
};static struct s3c_button_platform_data s3c_button_data =
{.buttons = s3c_buttons,.nbuttons = ARRAY_SIZE(s3c_buttons),
};

2.完善模块信息

  • 首先编写模块的基本信息, 包括作者、模块描述和模块协议:
MODULE_AUTHOR("Moqiu <comeonqiuliang@163.com>");
MODULE_DESCRIPTION("FL2440 BUTTON DEVICE");
MODULE_LICENSE("GPL");
  • 然后编写模块入口和出口
module_init(s3c_button_dev_init);
module_exit(s3c_button_dev_exit);
  • 完善入口函数, 注册设备,注册设备需要建立设备相应的数据结构
static struct s3c_button_platform_data s3c_button_data =
{.buttons = s3c_buttons,.nbuttons = ARRAY_SIZE(s3c_buttons),
};
static void platform_button_release(struct device *dev)
{return ;
}
static struct platform_device s3c_button_device = {.name = "s3c_key",.id = 1,.dev ={.platform_data = &s3c_button_data,.release = platform_button_release,},
};static int __init s3c_button_dev_init(void)
{int     rv=0;rv = platform_device_register(&s3c_button_device);if(rv){printk(KERN_ERR "%s:%d: Can't  regist button device %d.\n", __FUNCTION__, __LINE__, rv);return rv;}printk("Regist button device sucessfully!\n");return 0;
}
  • 完善出口函数,此函数为卸载模块时调用
static void s3c_button_dev_exit(void)
{printk("%s:%d remove the s3c button device.\n", __FUNCTION__, __LINE__);platform_device_unregister(&s3c_button_device);
}

3. 完整源码

1. platdev_key.h

#ifndef  _PLATDEV_KEY_H_
#define  _PLATDEV_KEY_H_#include <linux/platform_device.h>
#include <linux/version.h>
#include <mach/regs-gpio.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
#include <mach/hardware.h>
#include <mach/gpio.h>
#include <asm/irq.h>
#else
#include <asm-arm/irq.h>
#include <asm/arch/gpio.h>
#include <asm/arch/hardware.h>
#endifstruct s3c_button_info 
{unsigned char           num;char *                  name;int                     nIRQ;unsigned int            setting;unsigned int            gpio;
};struct s3c_button_platform_data{struct s3c_button_info *buttons;int    nbuttons;
};#endif

2. platdev_key.c

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>#include "platdev_key.h"static struct s3c_button_info s3c_buttons[] = {[0] = {.num = 1,.name = "KEY1",.nIRQ = IRQ_EINT0,.gpio = S3C2410_GPF(0),.setting = S3C2410_GPF0_EINT0,},[1] = {.num = 2,.name = "KEY2",.nIRQ = IRQ_EINT2,.gpio = S3C2410_GPF(2),.setting = S3C2410_GPF2_EINT2,},[2] = {.num = 3,.name = "KEY3",.nIRQ = IRQ_EINT3,.gpio = S3C2410_GPF(3),.setting = S3C2410_GPF3_EINT3,},[3] = {.num = 4,.name = "KEY4",.nIRQ = IRQ_EINT4,.gpio = S3C2410_GPF(4),.setting = S3C2410_GPF4_EINT4,},
};static struct s3c_button_platform_data s3c_button_data =
{.buttons = s3c_buttons,.nbuttons = ARRAY_SIZE(s3c_buttons),
};static void platform_button_release(struct device *dev)
{return ;
}static struct platform_device s3c_button_device = {.name = "s3c_key",.id = 1,.dev ={.platform_data = &s3c_button_data,.release = platform_button_release,},
};static int __init s3c_button_dev_init(void)
{int     rv=0;rv = platform_device_register(&s3c_button_device);if(rv){printk(KERN_ERR "%s:%d: Can't  regist button device %d.\n", __FUNCTION__, __LINE__, rv);return rv;}printk("Regist button device sucessfully!\n");return 0;
}static void s3c_button_dev_exit(void)
{printk("%s:%d remove the s3c button device.\n", __FUNCTION__, __LINE__);platform_device_unregister(&s3c_button_device);
}module_init(s3c_button_dev_init);
module_exit(s3c_button_dev_exit);MODULE_AUTHOR("Moqiu <comeonqiuliang@163.com>");
MODULE_DESCRIPTION("FL2440 BUTTON DEVICE");
MODULE_LICENSE("GPL");

3. Makefile

PWD=$(shell pwd)
CROSS_COMPILE=/opt/xtools/arm920t/bin/arm-linux-export CC=${CROSS_COMPILE}gcc
CFLAGS+=-I`dirname ${PWD}`SRCFILES = $(wildcard *.c)
BINARIES=$(SRCFILES:%.c=%)all: binaries binaries: ${BINARIES}@echo " Compile over"
%: %.c$(CC) -o $@ $< $(CFLAGS)clean:@rm -f version.h@rm -f *.o $(BINARIES)@rm -rf *.gdb *.a *.so *.elf*distclean: clean@rm -f tags cscope*.PHONY: clean
查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 数学建模

    (一)线性规划线性规划问题是在一组线性约束条件的限制下,求一线性目标函数最大或最小的问题。线性规划的Matlab标准形式:其中和为维列向量,、为适当维数的矩阵,、为适当维数的列向量。例如线性规划的Matlab标准型为1、求解线性规划问题c = [2;3;-5]; a = [-2 5 -1;1 3 1]…...

    2024/4/28 8:38:34
  2. Java中数据的存储方式

    Java中内存的划分方法区:用于存放类的相关信息栈区(Stack):存放的是变量的相关信息 如:局部变量;方法的运行一定要在栈中 ​ 局部变量:方法中的参数或者是方法{}中的变量 ​ 作用域:只在当前方法中有效,超出该方法则无效堆区(Heap):凡是new出来的东西,都存储在堆区中 ​ 堆区内…...

    2024/4/11 3:47:18
  3. Mybatis连接数据库和使用Mybatis要注意的坑

    使用mybatis连接数据库首先要导入jar 可以自己找需要的jar:maven中央仓库 //mybatis <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --> <dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId>&l…...

    2024/4/27 23:11:37
  4. 随笔:列表(序列)遍历的一个小坑

    问题描述:循环按序号遍历列表时,对列表中元素删除,可能会影响启遍因效果# 功能描述:将从l1中,删除s1中的元素 l1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j&q…...

    2024/4/28 3:45:37
  5. I.MX6ULL镜像文件

    文章目录1 I.MX6ULL镜像文件 1 I.MX6ULL镜像文件 boot ROM程序: 选择内部启动方式,启动boot ROM程序初始化时钟、外部DDR3 从外部存储介质加载代码必须解决两个问题:DDR3初始化参数如何确定?代码加载到哪里?镜像文件中就描述了这些问题。 镜像文件的五要素:空偏移芯片厂商…...

    2024/4/27 6:20:30
  6. 短视频软件开发 SDK 架构设计实践

    短视频发展史图 1图 1 所示是短视频及直播的发展史,众所周知,2016 年是直播元年,在这期间诞生了很多直播平台,比如熊猫、映客、斗鱼等;而在 2017 年,短视频的火爆程度并不亚于直播,可能大家都以为短视频是从 2017 年开始火爆起来的,但其实早在 2015 年就已经诞生出快手…...

    2024/4/27 19:40:48
  7. Mybatis开始驼峰匹配

    可以在mybatis-config.xml配置文件中,通过settings标签进行设置配置文件代码:<settings><!--开启驼峰匹配--><setting name="mapUnderscoreToCamelCase" value="true"/></settings>...

    2024/4/22 8:10:55
  8. SPARK YARN CLUSTER模式的启动过程

    通过submit命令启动后${SPARK_HOME}/bin/spark-submit --master yarn-cluster --class com.bigdata.WordCount --executor-memory 2G \ --num-executors 4 ${SPARK_HOME}/wordcount-1.0-SNAPSHOT.jar hdfs://spark-master:9000 /temp/inputdir /temp/outputdir实际上启动的是o…...

    2024/4/23 15:45:29
  9. 阿里云”7天实践训练营“[day3]总结笔记

    搭建Linux学习环境Linux远程管理一、命令终端二、文件传输三、代码编辑四、设置安全组为Linux环境安装图形化桌面(Gnome)Ubuntu安装方式CentOS安装方式Linux基本操作 Linux远程管理 一般来说 Linux 的远程管理分三个模块:命令终端、文件传输和代码编辑。 一、命令终端 命令终…...

    2024/4/26 19:49:03
  10. 实验·搭建nginx网站

    实验搭建nginx网站 实验环境 CentOS 7.6 nginx源码包 nginx-1.12.2.tar 实验步骤===>开启nginx统计模块并可以正常访问 #创建用户nginx [root@localhost opt]# useradd -M -s /sbin/nologin nginx#安装环境 [root@localhost opt]# yum -y install gcc gcc-c++ pcre pcre-dev…...

    2024/3/29 2:16:06
  11. Semaphore 使用信号量控制对资源的N个副本的并发访问

    目录Semaphore:主程序:打印机组:Semaphore:这是一个计数器,用来控制N个共享资源的访问,这是一种基本的并发编程工具。主程序:该DEMO模拟20个任务,共享3个打印机的过程。并使其有序使用打印机。package xyz.jangle.thread.test.n3_2.semaphore;/*** Semaphore DEMO 使用…...

    2024/4/22 7:56:59
  12. P1029 最大公约数和最小公倍数问题

    这道题蛮简单的,但是也需要一点预备知识,两个数的最小公倍数和最大公约数的乘积等于这两个数的乘积. 证明:x0 y0的最大公约数是A,最小公倍数是B, x1=x0/A,y1=y0/A 那么x1 y1一定是互质的 所以x1 * y1 * A=B 展开一下就可以得到 A*B=x0 * y0 至于为什么x1y1A=B,可以去康一下最…...

    2024/4/19 8:19:45
  13. 递归——N皇后问题(c++)

    声明:解法来自 北京大学 郭炜老师的程序设计与算法(二)算法基础 仅作学习笔记 问题描述在一个N*N的棋盘上放置N个皇后,每行一个并使其不能互相攻击(同一行、同一列、同一斜线上的皇后都会自动攻击)样例输入4样例输出2 4 1 3 3 1 4 2代码 #include<iostream> #inclu…...

    2024/4/19 5:43:41
  14. python赋值操作、浅拷贝、深拷贝以及函数传递参数详细解析

    学过C语言的同学都能分清楚变量和指针的区别,而python的变量全部是指针的形式,所以在变量的赋值操作时(如a=b),只是将索引复制了一份。如果想把指针索引的内容进行复制, 则需要用到浅拷贝和深拷贝。下面来介绍一下python的赋值操作、浅拷贝和深拷贝的区别。 赋值操作 如果…...

    2024/4/26 22:57:55
  15. springCloud服务注入进consul,出现错误Service ‘consul-provider-payment‘ check unhealthy

    出错如下;自己查了一下,原来是默认把心跳协议关了3. 解决方法就很简单了,在application文件中,把心跳协议打开就好了。4. 最后重启一下就好了...

    2024/4/24 7:35:31
  16. 最新版v8运行javascript示例代码

    这里提供最新版v8(v8.6.228)运行javascript简单的示例代码,仅供参考。在openSUSE编译通过。g++ demo.cpp -o demo -O2 -fPIC -fPIE -lv8 -pthread./demo My name is John. My favourite food is fish./****demo.cpp***/#include <v8.h> #include <libplatform/libp…...

    2024/3/29 2:16:00
  17. 今天换了个工位,WiFi没网了?

    公司是一个三层小别墅,我们开发组在三楼,屋子有点大,空调也不太给力,今天我们都把桌子搬到空调旁边了。搬完之后有三个人连上WiFi没网了,这三个人分别是我、另一个java开发、一个实施。为什么别人都有网?那个Java开发直接插了个网线……直接解决。就那一根网线,那我跟那…...

    2024/4/26 19:49:48
  18. 7 python打开及读取Excel表格内容

    ##作业 ##1、打开阿里云天池电商婴儿用户数据.xlsx ##2、找到其中空着的格子 ##3、输出这些格子的坐标,如A1,C10等 from openpyxl import load_workbook wb=load_workbook(filename=阿里云天池电商婴儿用户数据.xlsx) sheet=wb.active area=sheet[f{sheet.dimensions}] for ce…...

    2024/4/13 6:14:15
  19. leetcode200题之动态规划(二)

    1. 比特位计数(1)res[i]含义:数字 i 二进制中1的个数(2)数组关系:奇数:二进制表示中,奇数一定比前面那个偶数多一个 1,因为多的就是最低位的 1。偶数:二进制表示中,偶数中 1 的个数一定和除以 2 之后的那个数一样多。因为最低位是 0,除以 2 就是右移一位,也就是把…...

    2024/4/27 4:58:04
  20. leetcode刷题记录(14)-简单

    1.合并二叉树题目:给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为 NULL 的思路:递归合并。从上到下依次递归…...

    2024/4/27 23:04:43

最新文章

  1. uniapp 对接谷歌第三方登录

    1.登录谷歌开发者后台 https://console.developers.google.com/ 2.添加凭证 3.拿到客户端id后&#xff0c;项目中配置google登录&#xff1a; 示例代码&#xff1a; async googleLogin(){const { provider } await uni.getProvider({ service:oauth })if(provider.includes…...

    2024/4/28 11:38:01
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. Visual Studio 2022 快速注释代码

    在 Visual Studio 2022 中&#xff0c;可以使用快捷键来快速注释或取消注释代码。以下是如何进行操作的步骤&#xff1a; 注释 1. 单行注释&#xff1a; 对于当前行或选定的多行代码&#xff0c;按下 Ctrl /&#xff08;斜杠&#xff09;可以添加单行注释符号&#xff08;在…...

    2024/4/25 17:40:04
  4. C++ 【原型模式】

    简单介绍 原型模式是一种创建型设计模式 | 它使你能够复制已有对象&#xff0c;客户端不需要知道要复制的对象是哪个类的实例&#xff0c;只需通过原型工厂获取该对象的副本。 以后需要更改具体的类或添加新的原型类&#xff0c;客户端代码无需改变&#xff0c;只需修改原型工…...

    2024/4/24 19:02:05
  5. 【嵌入式开发 Linux 常用命令系列 4.3 -- git add 不 add untracked file】

    请阅读【嵌入式开发学习必备专栏 】 文章目录 git add 不add untracked file git add 不add untracked file 如果你想要Git在执行git add .时不添加未跟踪的文件&#xff08;untracked files&#xff09;&#xff0c;你可以使用以下命令&#xff1a; git add -u这个命令只会加…...

    2024/4/25 4:06:17
  6. 416. 分割等和子集问题(动态规划)

    题目 题解 class Solution:def canPartition(self, nums: List[int]) -> bool:# badcaseif not nums:return True# 不能被2整除if sum(nums) % 2 ! 0:return False# 状态定义&#xff1a;dp[i][j]表示当背包容量为j&#xff0c;用前i个物品是否正好可以将背包填满&#xff…...

    2024/4/28 4:04:40
  7. 【Java】ExcelWriter自适应宽度工具类(支持中文)

    工具类 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;/*** Excel工具类** author xiaoming* date 2023/11/17 10:40*/ public class ExcelUti…...

    2024/4/27 3:39:11
  8. Spring cloud负载均衡@LoadBalanced LoadBalancerClient

    LoadBalance vs Ribbon 由于Spring cloud2020之后移除了Ribbon&#xff0c;直接使用Spring Cloud LoadBalancer作为客户端负载均衡组件&#xff0c;我们讨论Spring负载均衡以Spring Cloud2020之后版本为主&#xff0c;学习Spring Cloud LoadBalance&#xff0c;暂不讨论Ribbon…...

    2024/4/27 12:24:35
  9. TSINGSEE青犀AI智能分析+视频监控工业园区周界安全防范方案

    一、背景需求分析 在工业产业园、化工园或生产制造园区中&#xff0c;周界防范意义重大&#xff0c;对园区的安全起到重要的作用。常规的安防方式是采用人员巡查&#xff0c;人力投入成本大而且效率低。周界一旦被破坏或入侵&#xff0c;会影响园区人员和资产安全&#xff0c;…...

    2024/4/27 12:24:46
  10. VB.net WebBrowser网页元素抓取分析方法

    在用WebBrowser编程实现网页操作自动化时&#xff0c;常要分析网页Html&#xff0c;例如网页在加载数据时&#xff0c;常会显示“系统处理中&#xff0c;请稍候..”&#xff0c;我们需要在数据加载完成后才能继续下一步操作&#xff0c;如何抓取这个信息的网页html元素变化&…...

    2024/4/27 3:39:08
  11. 【Objective-C】Objective-C汇总

    方法定义 参考&#xff1a;https://www.yiibai.com/objective_c/objective_c_functions.html Objective-C编程语言中方法定义的一般形式如下 - (return_type) method_name:( argumentType1 )argumentName1 joiningArgument2:( argumentType2 )argumentName2 ... joiningArgu…...

    2024/4/27 3:39:07
  12. 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】

    &#x1f468;‍&#x1f4bb;博客主页&#xff1a;花无缺 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! 本文由 花无缺 原创 收录于专栏 【洛谷算法题】 文章目录 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】&#x1f30f;题目描述&#x1f30f;输入格…...

    2024/4/27 3:39:07
  13. 【ES6.0】- 扩展运算符(...)

    【ES6.0】- 扩展运算符... 文章目录 【ES6.0】- 扩展运算符...一、概述二、拷贝数组对象三、合并操作四、参数传递五、数组去重六、字符串转字符数组七、NodeList转数组八、解构变量九、打印日志十、总结 一、概述 **扩展运算符(...)**允许一个表达式在期望多个参数&#xff0…...

    2024/4/27 12:44:49
  14. 摩根看好的前智能硬件头部品牌双11交易数据极度异常!——是模式创新还是饮鸩止渴?

    文 | 螳螂观察 作者 | 李燃 双11狂欢已落下帷幕&#xff0c;各大品牌纷纷晒出优异的成绩单&#xff0c;摩根士丹利投资的智能硬件头部品牌凯迪仕也不例外。然而有爆料称&#xff0c;在自媒体平台发布霸榜各大榜单喜讯的凯迪仕智能锁&#xff0c;多个平台数据都表现出极度异常…...

    2024/4/27 21:08:20
  15. Go语言常用命令详解(二)

    文章目录 前言常用命令go bug示例参数说明 go doc示例参数说明 go env示例 go fix示例 go fmt示例 go generate示例 总结写在最后 前言 接着上一篇继续介绍Go语言的常用命令 常用命令 以下是一些常用的Go命令&#xff0c;这些命令可以帮助您在Go开发中进行编译、测试、运行和…...

    2024/4/28 9:00:42
  16. 用欧拉路径判断图同构推出reverse合法性:1116T4

    http://cplusoj.com/d/senior/p/SS231116D 假设我们要把 a a a 变成 b b b&#xff0c;我们在 a i a_i ai​ 和 a i 1 a_{i1} ai1​ 之间连边&#xff0c; b b b 同理&#xff0c;则 a a a 能变成 b b b 的充要条件是两图 A , B A,B A,B 同构。 必要性显然&#xff0…...

    2024/4/27 18:40:35
  17. 【NGINX--1】基础知识

    1、在 Debian/Ubuntu 上安装 NGINX 在 Debian 或 Ubuntu 机器上安装 NGINX 开源版。 更新已配置源的软件包信息&#xff0c;并安装一些有助于配置官方 NGINX 软件包仓库的软件包&#xff1a; apt-get update apt install -y curl gnupg2 ca-certificates lsb-release debian-…...

    2024/4/28 4:14:21
  18. Hive默认分割符、存储格式与数据压缩

    目录 1、Hive默认分割符2、Hive存储格式3、Hive数据压缩 1、Hive默认分割符 Hive创建表时指定的行受限&#xff08;ROW FORMAT&#xff09;配置标准HQL为&#xff1a; ... ROW FORMAT DELIMITED FIELDS TERMINATED BY \u0001 COLLECTION ITEMS TERMINATED BY , MAP KEYS TERMI…...

    2024/4/27 13:52:15
  19. 【论文阅读】MAG:一种用于航天器遥测数据中有效异常检测的新方法

    文章目录 摘要1 引言2 问题描述3 拟议框架4 所提出方法的细节A.数据预处理B.变量相关分析C.MAG模型D.异常分数 5 实验A.数据集和性能指标B.实验设置与平台C.结果和比较 6 结论 摘要 异常检测是保证航天器稳定性的关键。在航天器运行过程中&#xff0c;传感器和控制器产生大量周…...

    2024/4/27 13:38:13
  20. --max-old-space-size=8192报错

    vue项目运行时&#xff0c;如果经常运行慢&#xff0c;崩溃停止服务&#xff0c;报如下错误 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 因为在 Node 中&#xff0c;通过JavaScript使用内存时只能使用部分内存&#xff08;64位系统&…...

    2024/4/27 1:03:20
  21. 基于深度学习的恶意软件检测

    恶意软件是指恶意软件犯罪者用来感染个人计算机或整个组织的网络的软件。 它利用目标系统漏洞&#xff0c;例如可以被劫持的合法软件&#xff08;例如浏览器或 Web 应用程序插件&#xff09;中的错误。 恶意软件渗透可能会造成灾难性的后果&#xff0c;包括数据被盗、勒索或网…...

    2024/4/27 3:22:12
  22. JS原型对象prototype

    让我简单的为大家介绍一下原型对象prototype吧&#xff01; 使用原型实现方法共享 1.构造函数通过原型分配的函数是所有对象所 共享的。 2.JavaScript 规定&#xff0c;每一个构造函数都有一个 prototype 属性&#xff0c;指向另一个对象&#xff0c;所以我们也称为原型对象…...

    2024/4/27 22:51:49
  23. C++中只能有一个实例的单例类

    C中只能有一个实例的单例类 前面讨论的 President 类很不错&#xff0c;但存在一个缺陷&#xff1a;无法禁止通过实例化多个对象来创建多名总统&#xff1a; President One, Two, Three; 由于复制构造函数是私有的&#xff0c;其中每个对象都是不可复制的&#xff0c;但您的目…...

    2024/4/28 7:31:46
  24. python django 小程序图书借阅源码

    开发工具&#xff1a; PyCharm&#xff0c;mysql5.7&#xff0c;微信开发者工具 技术说明&#xff1a; python django html 小程序 功能介绍&#xff1a; 用户端&#xff1a; 登录注册&#xff08;含授权登录&#xff09; 首页显示搜索图书&#xff0c;轮播图&#xff0…...

    2024/4/28 8:32:05
  25. 电子学会C/C++编程等级考试2022年03月(一级)真题解析

    C/C++等级考试(1~8级)全部真题・点这里 第1题:双精度浮点数的输入输出 输入一个双精度浮点数,保留8位小数,输出这个浮点数。 时间限制:1000 内存限制:65536输入 只有一行,一个双精度浮点数。输出 一行,保留8位小数的浮点数。样例输入 3.1415926535798932样例输出 3.1…...

    2024/4/27 20:28:35
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57