20 #define REG_TEMP_MSB 0x00 21 #define REG_TEMP_LSB 0x01 22 #define REG_STATUS 0x02 23 #define REG_CONFIG 0x03 28 static char dev_name[MAX_DEVNAMELRN];
30 static int adt7410_register(
struct st_device *dev,
char *param)
36 SYSERR_PRINT(
"Cannot open device \"%s\"\n", dev_name);
45 static int get_temp(
void)
47 unsigned short val = 0;
48 unsigned char data[2];
61 val = ((((
unsigned short)data[0] << 8) + data[1]) >> 3);
64 if(val & (0x8000 >> 3)) {
69 tl = (val & 15) * 10 / 16;
71 return (th * 100) + (tl * 10);
74 static int adt7410_ioctl(
struct st_device *dev,
unsigned int com,
unsigned int arg,
void *param)
80 DKPRINTF(0x01,
"ENVSNSR_GET_TEMP %d\n", rtn);
90 DKPRINTF(0x01,
"ENVSNSR_GET_THP T:%d H:%d P:%d\n", thp[0], thp[1], thp[2]);
95 SYSERR_PRINT(
"Unknown ioctl(%08X)\n", com);
102 const struct st_device adt7410_device = {
104 .explan =
"ATD7410 I2C Temperature Sensor",
105 .register_dev = adt7410_register,
106 .ioctl = adt7410_ioctl,
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
#define IOCMD_I2C_MEMADDRSIZE
Memory Address Size 8bit or 16bit etc
struct st_device * open_device(char *name)
デバイスをオープンする
int read_device(struct st_device *dev, void *buf, unsigned int count)
デバイスよりデータを読み出す
int seek_device(struct st_device *dev, int offset, int whence)
デバイスのアクセスポイントを設定する
#define DEF_DEV_NAME_ENVSNSR
標準環境センサデバイス名
#define I2C_MEM_ADDR_SIZE_8BIT
I2Cスレーブデバイスメモリアドレスサイズは8ビット
int unlock_device(struct st_device *dev)
デバイスをアンロックする
#define IOCMD_ENVSNSR_GET_THP
TEMP & HUM & PRES
#define IOCMD_I2C_SLAVE_ADDR7
Set Save 7bit Address
環境センサ(温度、湿度、気圧等)ドライバ ioctl 用マクロ定義
uchar * strncopy(uchar *dest, const uchar *src, unsigned int n)
文字列コピー
#define IOCMD_ENVSNSR_GET_TEMP
温度を取得する(℃)
int close_device(struct st_device *dev)
デバイスをクローズする
int ioctl_device(struct st_device *dev, unsigned int com, unsigned int arg, void *param)
デバイスを制御する
char name[MAX_DEVNAMELRN]
デバイス名文字列
int lock_device(struct st_device *dev, unsigned int timeout)
デバイスをロックする