cmd.h
#ifndef __CMD_H__
#define __CMD_H__
#define spi_1_to_4 _IOW('k',0,int)
#define spi_a_f _IOW('k',1,int)
#define spi_OFF _IOW('f',0,int)
#endif
spi_sg.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/device.h>
#define CNAME "m74hc595"
#define spi_1_to_4 _IOW('k',0,int)
#define spi_a_f _IOW('k',1,int)
char buf1_4[]={0x1,0x2,0x4,0x8,0xf}; // 1-4
char a_fbuf[]={
0x3f, //0
0x06, //1
0x5b, //2
0x4f, //3
0x66, //4
0x6d, //5
0x7d, //6
0x07, //7
0x7f, //8
0x6f, //9
0x58, //c
0x77, //R
}; // a-f
int smg2=0;
struct spi_device *sspi;
int spi_open(struct inode* inode, struct file* file)
{
return 0;
}
long spi_ioctl(struct file* file,unsigned int cmd, unsigned long args)
{
char O_2dian;
switch (cmd) {
case spi_1_to_4:
spi_write(sspi,&am