zoukankan      html  css  js  c++  java
  • rk3288-cc上编写一个hello world

    一、编写一个hello world驱动

    懒,不写了

    二、编写Kconfig和Makefile

    我们在kernel/driver目录下创建一个hello目录

    然后创建一个Kconfig文件:

    config HELLO
        tristate "Hello world for Firefly"
        help
            Hello for Firefly

    然后创建一个Makefile文件:

    obj-$(CONFIG_HELLO)    += hello.o

    接着在上一级目录里,就是driver目录Kconfig加入:

    source "drivers/hello/Kconfig"

    然后再上一级目录的,Makefile中加入:

    obj-$(CONFIG_HELLO)             += hello/

    然后重新编译内核,制作镜像,烧录。

    观察启动输出是否有打印信息

    三、GPIO设置

    GPIO常用系统调用函数,位于include/linux/gpio.h:

    1. 申请GPIO
    static inline int gpio_request(unsigned gpio, const char *label)
    
    2. 设置GPIO电平
    static inline int gpio_set_value(unsigned int gpio, int value)
    
    3. 获取GPIO电平
    static inline int gpio_get_value(unsgined int gpio)
    
    4. 设置GPIO为输出,并设置电平
    static inline int gpio_direction_output(unsigned gpio, int value)
    
    5. 设置GPIO为输入
    static inline int gpio_direction_input(unsigned gpio)

     ROC-RK3328-CC 的 GPIO 驱动是在以下 pinctrl 文件中实现的:

    kernel/drivers/pinctrl/pinctrl-rockchip.c
  • 相关阅读:
    Token 分析
    maven导入依赖下载jar包速度太慢
    springboot 自动装配
    @ComponentScan
    mysql8.0忘记密码或出现Access denied for user 'root'@'localhost' (using password: YES)
    SpringBoot静态资源处理
    @RestController
    PythonGUI:Tkinter学习笔记01
    Python2和Python3有什么区别?
    Python的Random模块
  • 原文地址:https://www.cnblogs.com/ch122633/p/10959419.html
Copyright © 2011-2022 走看看