tiny6410溫度感測器驅動學習1(測試通過)

2021-06-06 19:33:03 字數 1770 閱讀 6734

參考的驅動**如下

#include    #include    #include    #include    #include    #include    #include    #include    #include    #define    device_name "temp"  //裝置名字

static struct cdev cdev;

struct class *tem_class;

static dev_t devno;

static int major = 243;

void tem_reset(void)

void tem_wbyte(unsigned char data)

udelay(60);

gpio_set_value(s3c64xx_gpn(8), 1);

udelay(15);

data >>= 1;

}gpio_set_value(s3c64xx_gpn(8), 1);

}unsigned char tem_rbyte(void)

udelay(60);

}s3c_gpio_cfgpin(s3c64xx_gpn(8), s3c_gpio_sfn(1));

return ret;

}static ssize_t tem_read(struct file *filp, char *buf, size_t len, loff_t *offset)

static struct file_operations tem_fops =

;static int __init tem_init(void)

cdev_init(&cdev, &tem_fops);

cdev.owner = this_module;

cdev.ops = &tem_fops;

result = cdev_add(&cdev, devno, 1);

if (result)

tem_class = class_create(this_module, "tmp_class");

if (is_err(tem_class))

device_create(tem_class, null, devno, device_name, device_name);

return 0;

fail2:

cdev_del(&cdev);

fail1:

unregister_chrdev_region(devno, 1);

return result;

}static void __exit tem_exit(void)

module_init(tem_init);

module_exit(tem_exit);

module_license("gpl");

module_author([email protected]);

#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()

else

close(fd);

}}

tiny6410 驅動程式 定時器

drv timer.c driver timer test include include include include static struct timer list my timer static void timer func unsigned long data my timer.exp...

tiny6410 按鍵中斷驅動 poll機制

驅動程式key drv int.c include include include include include include include include include include include include include include include include incl...

基於Tiny6410的LED驅動程式

從電路圖中看出,gpio低電平有效 led亮 gpk共有16個埠,每個埠由三個暫存器控制 控制暫存器 gpkcon 資料暫存器 gpkdat 和上拉暫存器 gpkpud 每個暫存器都是32位,如下圖所示。gpk的控制暫存器分為兩個,gpkcon0控制0 8好埠,gpkcon1控制9 15號埠。控制暫...