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

驱动程序

#include 
#include 
#include 

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");

效果演示

驱动开发11-2 编写SPI驱动程序-点亮数码管_第1张图片

驱动开发11-2 编写SPI驱动程序-点亮数码管_第2张图片

驱动开发11-2 编写SPI驱动程序-点亮数码管_第3张图片

你可能感兴趣的:(驱动开发,驱动开发)