就是塔塔的个人空间 https://www.eechina.com/space-uid-136863.html [收藏] [复制] [RSS]

博客

iTOP3568开发板helloworld驱动实验-驱动编写

已有 132 次阅读2023-8-30 10:25 |个人分类:RK3568

本小节来编写一个最简单的驱动——helloworld 驱动。helloworld.c 如下(图 3-1)所示代码:
1 #include
2 #include
3
4 static int __init helloworld_init(void) //驱动入口函数
5 {
6 printk(KERN_EMERG "helloworld_init\r\n");//注意:内核打印用 printk 而不是 printf
7 return 0;
8 }
9
10 static void __exit helloworld_exit(void) //驱动出口函数
11 {
12 printk(KERN_EMERG "helloworld_exit\r\n");
13 }
14
15 module_init(helloworld_init); //注册入口函数
16 module_exit(helloworld_exit); //注册出口函数
17 MODULE_LICENSE("GPL v2"); //同意 GPL 开源协议
18 MODULE_AUTHOR("topeet"); //作者信息

看似非常简单的 helloworld 驱动代码,却五脏俱全。一个简单的 helloworld 驱动包含驱动
的基本框架。我们继续往下看。
更多内容可以关注B站:搜索迅为RK3568开发板


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
返回顶部