驱动程序
#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");
效果演示
文章来源:https://www.toymoban.com/news/detail-736858.html
文章来源地址https://www.toymoban.com/news/detail-736858.html
到了这里,关于驱动开发11-2 编写SPI驱动程序-点亮数码管的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!