⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temperature.h

📁 在linux中arm9对温度传感器18B20进行的驱动开发
💻 H
字号:

#ifndef _Tmprture_H_
#define _Tmprture_H_
// ----------------------------------------------------------------------

// 包含的 头文件
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#include <asm/uaccess.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/delay.h>

// 温测	寄存器定义
//#define	regsSftClk	(*((volatile unsigned long *)0x809300C0))	// 系统软件锁寄存器
//#define	regsDevCfg	(*((volatile unsigned long *)0x80930080))	// 系统配置寄存器
//#define regsDir		(*((volatile unsigned long *)0x80840014))	// 
//#define regsDat		(*((volatile unsigned long *)0x80840004))	// 

#define	regsSftClk	(*((volatile unsigned long *)0x809300C0))	// 系统软件锁寄存器
#define	regsDevCfg	(*((volatile unsigned long *)0x80930080))	// 系统配置寄存器
#define regsDir		(*((volatile unsigned long *)0x80840014))	// 
#define regsDat		(*((volatile unsigned long *)0x80840004))	// 

//#define gpiobint	(*((volatile unsigned long *)0x808400B8))	// 

// 温测 设备操作接口。
//struct file_operation{
	//struct module *owner;
	//loff_t can_lseek(struct file *, loff_t, int);
	ssize_t tptRead(struct file *filp,char *buf,size_t count, loff_t *offp);
	ssize_t tptWrite(struct file *filp,const char *buf,size_t count,loff_t *offp);
	//int (*readdir) (struct file *, void *, filldir_t);
	//unsigned int (*poll) (struct file *, struct poll_table_struct *);
//	int ycIoctl(struct inode *inode, struct file *filp,unsigned int cmd,unsigned long arg);
	//int (*mmap) (struct file *, struct vm_area_struct *);
	int tptOpen(struct inode* inode,struct file* filp);
	//int (*flush) (struct file *);
	int tptRelease(struct inode* inode,struct file* filp);
	//int (*fsync) (struct file *, struct dentry *, int datasync);
	//int (*fasync) (int, struct file *, int);
	//int (*lock) (struct file *, int, struct file_lock *);
	//ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
	//ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
	//ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
	//unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
//}

// 温测模块初始化函数,用于完成接口函数注册。
int init_module(void);
// 温测模块善后处理函数,用于完成接口函数注销。
void cleanup_module(void);

void reset18b20(void);	// 发送复位脉冲
void presence18b20(void);	// 等待DS18B20的应答
void send(unsigned char com_word);	// 发送一个字节命令
void read(void);	// 读取数据
void setoutputmode(void);	// 设置输出模式
void setinputmode(void);	// 设置输入模式
void scan_temp(void);	// 转换温度
void get_temp(void);	// 获取温度值
//-----------------------------------------------------------

// ----------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -