驱动开发day13

使用开发板监测温湿度,温度控制灯的亮灭

驱动代码i2c.c

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "si7006.h"
int major;
struct class *cls;
struct device *dev;
struct i2c_client *tclient;
struct device_node *node;
struct gpio_desc *gpiono;
int i2c_read_hum_tem(unsigned char reg)
{
    int ret;
    char r_buf[]={reg};
    unsigned short val;
    struct i2c_msg r_msg[]={
        [0]={
            .addr=tclient->addr,
            .flags=0,
            .len=1,
            .buf=r_buf,
        },
        [1]={
            .addr=tclient->addr,
            .flags=1,
            .len=2,
            .buf=(char *)&val,
        },
    };
    ret=i2c_transfer(tclient-&

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