SD5075芯片经过ALARM引脚检测温度的变化,经过模数转换器的转换,把温度值写入寄存器中,SOC再通过IIC读取寄存器的值,从而拿到温度值。
寄存器列表:
通过配置0x01寄存器为0x00,通过寄存器0x00读取到温度结果。
三.代码实现
#include <linux/miscdevice.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/compat.h>
#include <linux/printk.h>
#include <linux/kobject.h>
#include <linux/version.h>
#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x00)
#define DRIVER_NAME "IST_TEMP"
/*define logging*/
#define IST_TEMP_DEBUG 0
#if IST_TEMP_DEBUG
#define DBG(format, args...) \
printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ##args)
#define ERR(format, args...) \
printk(KERN_ERR "%s: " format, DRIVER_NAME, ##args)
#define WARNING(format, args...) \
printk(KERN_WARN "%s: " format, DRIVER_NAME, ##args)
#define INFO(format, args...) \
printk(KERN_INFO "%s: " format, DRIVER_NAME, ##args)
#else
#define DBG(format, args...)
#define ERR(format, args...)
#define WARNING(format, args...)
#define INFO(format, args...)
#endi