驱动开发11-2 编写SPI驱动程序-点亮数码管

驱动程序

cs 复制代码
#include <linux/init.h>
#include <linux/module.h>
#include <linux/spi/spi.h>

int m74hc595_probe(struct spi_device *spi)
{
    printk("%s:%d\n",__FILE__,__LINE__);
    char buf[]={0XF,0X6D};
    spi_write(spi,buf,sizeof(buf));
    return 0;
}
int m74hc595_remove(struct spi_device *spi)
{
    printk("%s:%d\n",__FILE__,__LINE__);
    return 0;
}
//设备树匹配表
struct of_device_id of_table[] = {
    {.compatible="hqyj,m74hc595"},
    {},
};
//定义SPI对象并初始化
struct spi_driver m74hc575 = {
    .probe = m74hc595_probe,
    .remove = m74hc595_remove,
    .driver = {
        .name = "m74hc595",
        .of_match_table = of_table,
    },
};
module_spi_driver(m74hc575);
MODULE_LICENSE("GPL");

效果演示

相关推荐
FLPGYH4 小时前
BMC 深度解析:服务器带外管理的核心技术架构与实践
linux·服务器·c++·驱动开发
赖small强13 小时前
【Linux驱动开发】Linux SDIO 底层原理与实现细节详解
linux·驱动开发·sdio
独行soc16 小时前
2025年渗透测试面试题总结-250(题目+回答)
网络·驱动开发·python·安全·web安全·渗透测试·安全狮
赖small强1 天前
【Linux驱动开发】Linux Input子系统架构深度解析
linux·驱动开发·input·按键驱动·libinput
偶像你挑的噻2 天前
4-Linux驱动开发-字符设备驱动
linux·运维·驱动开发
赖small强2 天前
【Linux驱动开发】Linux块设备驱动开发详解
linux·驱动开发·块设备·字符设备
智者知已应修善业2 天前
【proteus数电74LS175+74LS48抢答器仿真扩展为矩阵键盘16路】2022-9-1
驱动开发·经验分享·笔记·硬件架构·proteus·硬件工程
偶像你挑的噻2 天前
3-Linux驱动开发-简单内核模块代码详解
linux·驱动开发·stm32·嵌入式硬件
赖small强2 天前
【Linux驱动开发】 Linux字符设备开发详细指南
linux·驱动开发·字符设备
p66666666682 天前
【☀Linux驱动开发笔记☀】linux下led驱动(非设备树)_03
linux·驱动开发·笔记·嵌入式硬件·学习