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

📄 18b20.c

📁 linux-2.6.12下的温度传感器18b20驱动程序代码
💻 C
字号:
#include "stdio.h"
#include "sys/types.h"
#include "sys/ioctl.h"
#include "stdlib.h"
#include "termios.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "sys/time.h"
main()
{
        int fd;
        char buf,ret;
        fd=open("/dev/18b20",O_RDWR | O_NDELAY | O_NOCTTY);
        if(fd<0)
        {
                printf("open 18b20 error\n");
                exit(1);
        }
        else
        {
                printf("success\n");
               while(1)    {
                        read(fd,&buf,1);
                        ret=buf;
                        printf("%d \n",ret);
                        sleep(1);
                }
        }
        close(fd);
}


⌨️ 快捷键说明

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