truct spi_device *sensor_spi=NULL; //spi_device 设备结构体信息
int sensor_spi_write(unsigned int addr, unsigned int val, size_t len)
{
int status;
unsigned char write_buf[2];
write_buf[0] = addr; //在某个地址写什么值
write_buf[1] = val;
status = spi_write(sensor_spi, write_buf,2); //将数据传送到spi总线0上
if (status)
dev_err(&sensor_spi->dev, "%s error %d\n", __FUNCTION__, status);
return status;
}
1