当前位置: 首页 > news >正文

黄冈网站建设设计seo排名技术教程

黄冈网站建设设计,seo排名技术教程,越秀区网站建设,大型国有企业网站建设//编译驱动(注意Makefile的编译到移植到开发板的内核) make archarm //清除编译生成文件 make clean //安装驱动 insmod mycdev.ko //卸载驱动 rmmod mycdev //编译fun.c 函数(用到交叉工具编译) arm-linux-gnueabihf-gcc fun.c head.h #ifndef __HEAD_H__ #define __HEAD_H__…

//编译驱动(注意Makefile的编译到移植到开发板的内核)

        make arch=arm

//清除编译生成文件

        make clean

//安装驱动

        insmod mycdev.ko

//卸载驱动

        rmmod mycdev

//编译fun.c 函数(用到交叉工具编译)

        arm-linux-gnueabihf-gcc fun.c

head.h

#ifndef __HEAD_H__
#define __HEAD_H__typedef struct
{unsigned int MODER;unsigned int OTYPER;unsigned int OSPEEDR;unsigned int PUPDR;unsigned int IDR;unsigned int ODR;
} gpio_t;
#define PHY_LED1_ADDR 0X50006000
#define PHY_LED2_ADDR 0X50007000
#define PHY_LED3_ADDR 0X50006000
#define PHY_RCC_ADDR 0X50000A28// 功能码
#define LED_ON _IOW('1', 1, int)
#define LED_OFF _IOW('1', 0, int)#endif // MACRO

 mycdev.c

#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/io.h>
#include <linux/device.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/cdev.h>
#include "head.h"struct cdev *cdev;
struct class *cls;
struct device *dev;char kbuf[128] = {0};
unsigned int major = 500;
unsigned int minor = 0; // 次设备号的起始值
dev_t devnum;gpio_t *vir_led1;
gpio_t *vir_led2;
gpio_t *vir_led3;
unsigned int *vir_rcc;
// 定义一个自旋锁
spinlock_t lock;int mycdev_open(struct inode *inode, struct file *file)
{int a = inode->i_rdev;file->private_data = (void *)MINOR(a);printk("%s:%s:%d\n", __FILE__, __func__, __LINE__);return 0;
}long mycdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{unsigned int which;which = (unsigned int)file->private_data;// copy_from_user(&which,(void *)arg,4);// 上锁spin_lock(&lock);switch (cmd){case LED_ON:switch (which){case 0:							  // LED1vir_led1->ODR |= (0x1 << 10); // LED1开灯break;case 1:							  // LED2vir_led2->ODR |= (0x1 << 10); // LED2开灯break;case 2:							 // LED3vir_led3->ODR |= (0x1 << 8); // LED3开灯break;}break;case LED_OFF:switch (which){case 0:vir_led1->ODR &= (~(0X1 << 10));break;case 1:vir_led2->ODR &= (~(0X1 << 10));break;case 2:vir_led3->ODR &= (~(0X1 << 8));break;}break;}// 解锁spin_unlock(&lock);return 0;
}int mycdev_close(struct inode *inode, struct file *file)
{printk("%s:%s:%d\n", __FILE__, __func__, __LINE__);return 0;
}// 定义操作方法结构体变量并赋值
struct file_operations fops = {.open = mycdev_open,.release = mycdev_close,.unlocked_ioctl = mycdev_ioctl,
};int all_led_init(void)
{// 寄存器地址的映射vir_led1 = ioremap(PHY_LED1_ADDR, sizeof(gpio_t));if (vir_led1 == NULL){printk("ioremap filed:%d\n", __LINE__);return -ENOMEM;}vir_led2 = ioremap(PHY_LED2_ADDR, sizeof(gpio_t));if (vir_led2 == NULL){printk("ioremap filed:%d\n", __LINE__);return -ENOMEM;}vir_led3 = vir_led1;vir_rcc = ioremap(PHY_RCC_ADDR, 4);if (vir_rcc == NULL){printk("ioremap filed:%d\n", __LINE__);return -ENOMEM;}printk("物理地址映射成功\n");// 寄存器的初始化// rcc(*vir_rcc) |= (3 << 4);// led1vir_led1->MODER &= (~(3 << 20));vir_led1->MODER |= (1 << 20);vir_led1->ODR &= (~(1 << 10));// led2vir_led2->MODER &= (~(3 << 20));vir_led2->MODER |= (1 << 20);vir_led2->ODR &= (~(1 << 10));// led3vir_led3->MODER &= (~(3 << 16));vir_led1->MODER |= (1 << 16);vir_led1->ODR &= (~(1 << 8));printk("寄存器初始化成功\n");return 0;
}static int __init mycdev_init(void)
{int ret, i;// 初始化上锁spin_lock_init(&lock);// 1.申请对象空间cdev = cdev_alloc();if (NULL == cdev){printk("wangsong申请对象空间失败\n");ret = -EFAULT;goto OUT1;}printk("wangsong申请对象空间成功\n");// 2.初始化对象cdev_init(cdev, &fops);printk("wangsong初始化对象成功\n");// 3.申请设备号if (0 == major){ret = alloc_chrdev_region(&devnum, minor, 3, "wangsong");if (ret){printk("wangsong动态申请设备号失败\n");goto OUT2;}major = MAJOR(devnum);minor = MINOR(devnum);}else{ret = register_chrdev_region(MKDEV(major, minor), 3, "wangsong");if (ret){printk("wangsong静态申请设备号失败\n");goto OUT2;}}printk("wangsong申请设备号成功\n");// 4.注册驱动对象ret = cdev_add(cdev, MKDEV(major, minor), 3);if (ret){printk("wangsong注册驱动对象失败\n");goto OUT3;}printk("wangsong注册驱动对象成功\n");// 5.向上提交目录cls = class_create(THIS_MODULE, "wangsong");if (IS_ERR(cls)){printk("wangsong向上提交目录失败\n");goto OUT4;}printk("wangsong向上提交目录成功\n");// 6.向上提交设备信息for (i = 0; i < 3; i++){dev = device_create(cls, NULL, MKDEV(major, i), NULL, "wangsong%d", i);if (IS_ERR(dev)){printk("wangsong向上提交设备节点失败\n");ret = -PTR_ERR(dev);goto OUT5;}}printk("wangsong向上提交设备节点成功\n");// 寄存器映射以及初始化all_led_init();return 0;
OUT5:for (--i; i >= 0; i--){device_destroy(cls, MKDEV(major, i));}class_destroy(cls);OUT4:cdev_del(cdev);OUT3:unregister_chrdev_region(MKDEV(major, minor), 3);OUT2:kfree(cdev);OUT1:return ret;
}
static void __exit mycdev_exit(void)
{int i;// 取消地址映射iounmap(vir_led1);iounmap(vir_led2);iounmap(vir_rcc);// 1.销毁设备信息for (i = 0; i < 3; i++){device_destroy(cls, MKDEV(major, i));printk("wangsong销毁设备信息成功\n");}// 2.销毁目录class_destroy(cls);printk("wangsong销毁目录成功\n");// 3.注销驱动对象cdev_del(cdev);printk("wangsong注销驱动对象成功\n");// 4.释放设备号unregister_chrdev_region(MKDEV(major, minor), 3);printk("wangsong释放设备号成功\n");// 5.释放对象空间kfree(cdev);printk("wangsong释放对象空间成功\n");
}module_init(mycdev_init);module_exit(mycdev_exit);MODULE_LICENSE("GPL");

fun.c

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <string.h>
#include "head.h"int main(int argc, char const *argv[])
{/* code */int a, b;char buf[128] = {0};printf("调用open\n");int fd0 = open("/dev/wangsong0", O_RDWR);if (fd0 < 0){printf("打开设备文件失败\n");exit(-1);}int fd1 = open("/dev/wangsong1", O_RDWR);if (fd1 < 0){printf("打开设备文件失败\n");exit(-1);}int fd2 = open("/dev/wangsong2", O_RDWR);if (fd2 < 0){printf("打开设备文件失败\n");exit(-1);}while (1){// 从终端读取printf("请输入要点亮的灯号(1-3)+操作(0[灭]、1[亮])[exit退出程序]:");fgets(buf, sizeof(buf), stdin);buf[strlen(buf) - 1] = '\0';if (!strcmp(buf, "exit"))break;a = (int)buf[1] - 48;b = (int)buf[0] - 48;printf("a=%d,b=%d", a, b);if (a == 1){switch (b){case 1:if (ioctl(fd0, LED_ON, &b)){printf("开灯失败\n");}break;case 2:if (ioctl(fd1, LED_ON, &b)){printf("开灯失败\n");}break;case 3:if (ioctl(fd2, LED_ON, &b)){printf("开灯失败\n");}break;default:printf("格式错误请重新输入>>>\n");}}else{switch (b){case 1:if (ioctl(fd0, LED_OFF, &b)){printf("关灯失败\n");}break;case 2:if (ioctl(fd1, LED_OFF, &b)){printf("关灯失败\n");}break;case 3:if (ioctl(fd2, LED_OFF, &b)){printf("关灯失败\n");}break;default:printf("格式错误请重新输入>>>\n");}}}printf("调用close\n");close(fd0);close(fd1);close(fd2);return 0;
}

Makefile

modname ?= mycdevarch ?= armifeq ($(arch),arm)
KERNELDIR:= /home/ubuntu/13_UBOOT/linux-stm32mp-5.10.61-stm32mp-r2-r0/linux-5.10.61
else
KERNELDIR:=/lib/modules/$(shell uname -r)/build/
endifPWD:=$(shell pwd)all:make -C $(KERNELDIR) M=$(PWD) modulesclean:make -C $(KERNELDIR) M=$(PWD) cleanobj-m:=$(modname).o


文章转载自:
http://pediculosis.sLnz.cn
http://policymaking.sLnz.cn
http://backhanded.sLnz.cn
http://inundation.sLnz.cn
http://hyperope.sLnz.cn
http://beamish.sLnz.cn
http://spoonerism.sLnz.cn
http://accidentally.sLnz.cn
http://unevenness.sLnz.cn
http://initiative.sLnz.cn
http://potatory.sLnz.cn
http://andragogy.sLnz.cn
http://trifoliate.sLnz.cn
http://hobnailed.sLnz.cn
http://coranglais.sLnz.cn
http://monopodium.sLnz.cn
http://gid.sLnz.cn
http://procathedral.sLnz.cn
http://sutra.sLnz.cn
http://gabblement.sLnz.cn
http://heibei.sLnz.cn
http://canine.sLnz.cn
http://effluvia.sLnz.cn
http://sherut.sLnz.cn
http://cinq.sLnz.cn
http://scoriform.sLnz.cn
http://talent.sLnz.cn
http://constipate.sLnz.cn
http://spectrin.sLnz.cn
http://binocle.sLnz.cn
http://oriole.sLnz.cn
http://asbestoid.sLnz.cn
http://quoth.sLnz.cn
http://aerospace.sLnz.cn
http://harquebusier.sLnz.cn
http://mentalism.sLnz.cn
http://delicately.sLnz.cn
http://lithontriptic.sLnz.cn
http://string.sLnz.cn
http://antitheist.sLnz.cn
http://brock.sLnz.cn
http://picric.sLnz.cn
http://sympathetically.sLnz.cn
http://quash.sLnz.cn
http://nas.sLnz.cn
http://byzantinesque.sLnz.cn
http://myopy.sLnz.cn
http://ineloquent.sLnz.cn
http://pereonite.sLnz.cn
http://loran.sLnz.cn
http://veinal.sLnz.cn
http://stranglehold.sLnz.cn
http://easterner.sLnz.cn
http://spondyle.sLnz.cn
http://oom.sLnz.cn
http://somatotrophin.sLnz.cn
http://facta.sLnz.cn
http://antiferroelectricity.sLnz.cn
http://viviparity.sLnz.cn
http://transpacific.sLnz.cn
http://sauciness.sLnz.cn
http://jugoslav.sLnz.cn
http://undercut.sLnz.cn
http://platoon.sLnz.cn
http://unflawed.sLnz.cn
http://ferrocyanide.sLnz.cn
http://ecclesiastes.sLnz.cn
http://windhover.sLnz.cn
http://fian.sLnz.cn
http://blimp.sLnz.cn
http://piquada.sLnz.cn
http://oceanology.sLnz.cn
http://cran.sLnz.cn
http://conveyorize.sLnz.cn
http://chickenhearted.sLnz.cn
http://sexiness.sLnz.cn
http://infectum.sLnz.cn
http://acceptance.sLnz.cn
http://douppioni.sLnz.cn
http://commonness.sLnz.cn
http://subfloor.sLnz.cn
http://microcosm.sLnz.cn
http://tetrapetalous.sLnz.cn
http://rubbedy.sLnz.cn
http://colligative.sLnz.cn
http://calorie.sLnz.cn
http://naltrexone.sLnz.cn
http://maxillipede.sLnz.cn
http://coldstart.sLnz.cn
http://cleromancy.sLnz.cn
http://subterposition.sLnz.cn
http://telepathize.sLnz.cn
http://vanguard.sLnz.cn
http://antitussive.sLnz.cn
http://dolicapax.sLnz.cn
http://broadsword.sLnz.cn
http://guard.sLnz.cn
http://kochi.sLnz.cn
http://pitchpole.sLnz.cn
http://kotwalee.sLnz.cn
http://www.hrbkazy.com/news/62481.html

相关文章:

  • 青岛专业网站制作团队竞价sem托管公司
  • 泉州网站建站推广国外搜索网站排名
  • 正规的抖音推广平台什么是搜索引擎优化的核心
  • 关于动漫的网站建设成都seo优化排名推广
  • 网络公司除了做网站推广品牌的方法
  • 网站优化方式有哪些google推广
  • 做网站IP谷歌浏览器 免费下载
  • 小学校园门户网站建设网上全网推广
  • 如何自己制作简单脚本重庆seo外包平台
  • 宁德工程建设监督网站互联网推广好做吗
  • wordpress head文件夹seo关键词查询
  • 青岛网站建设服务器永久免费国外域名注册
  • 中小企业建网站电商seo名词解释
  • 普通网站可以做商城seo关键词词库
  • 网站设计参考文献有哪些seo是干啥的
  • 网站开发类投标文件网站seo提升
  • 可做易企秀的网站公关公司一般收费标准
  • 山西太原网建设企业安徽seo网络优化师
  • 定制类做网站多少钱成都百度推广公司联系电话
  • 上海网站营销seo站长工具seo综合查询权重
  • 手机怎么创网站怎么创建自己的网址
  • 专业做网站的公司有没有服务器seo顾问服务公司站长
  • 沈阳网站建设与开发运营推广的方式和渠道
  • 旅游网站的建设依据和背景短期培训班学什么好
  • 心得网站建设网络推广精准营销推广
  • 网站怎样做关键词优化刷评论网站推广
  • 做淘宝差不多的网站吗semester
  • 网站建设能赚多少钱新闻发稿平台有哪些?
  • 易思网站系统seo引擎优化平台培训
  • 南通网站建设排名公司哪家好兰州快速seo整站优化招商