Firefly开源社区

打印 上一主题 下一主题

firefly-rk3288 第一个LED程序学习心得

433

积分

3

威望

0

贡献

技术达人

Rank: 2

积分
433

firefly-rk3288 第一个LED程序学习心得

发表于 2017-5-6 13:07:52      浏览:8097 | 回复:2        打印      只看该作者   [复制链接] 楼主
本帖最后由 z3j6w9 于 2017-5-6 13:13 编辑

1.模块初始化和退出
sbusys_initcall(hello_init);
module_exit(hello_exit);
2.platform
首先要定义一个platform结构体
static struct platform_driver firefly_hello_driver = {
        .probe                = firefly_hello_probe,
        .remove                = firefly_hello_remove,
        .driver                = {
                .name        = "firefly_hello",
                .owner        = THIS_MODULE,
#ifdef CONFIG_OF
                .of_match_table        = of_firefly_hello_match,
#endif
        },

};
.probe :platform的入口函数
.remove:platform的退出函数
.of_match_table:用来match设备树的信息
static const struct of_device_id of_firefly_hello_match[] = {
        { .compatible = "firefly,hello_led" },
        { },
};
#endif

结构体中的compatible和dts中的compatible是对应的,驱动中通过函数of_get_named_gpio可以获得对应的gpio,使用方式如下
        gpio = of_get_named_gpio_flags(hello_node,"led", 0,&flag);
然后就可以对gpio进行设置
        gpio_direction_output(gpio, GPIO_HIGH);
3.dts配置
    firefly_hello{
        compatible = "firefly,hello_led";
        led = <&gpio8 GPIO_A2 GPIO_ACTIVE_LOW>;
        status = "okay";
    };
备注:
'status'属性用来表示节点的状态的,其实就是硬件的状态,用字符串表示。'okay'表示硬件正常工作,“disabled”表示硬件当前不可用,“fail”表示因为出错不可用,“fail-sss”表示因为某种原因出错不可用,sss表示具体的出错原因。实际中,基本只用'okay'和'disabled'。
回复

使用道具 举报

发表于 2017-5-8 11:35:41        只看该作者  沙发
支持发帖分享
暴走的创客!
回复

使用道具 举报

63

积分

0

威望

0

贡献

游客

积分
63
发表于 2017-9-22 23:45:33        只看该作者  板凳
Xiexie分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表