3.4.2内核下I2C驱动之24CXX实例
#include "linux/kernel.h"
#include "linux/module.h"
#include "linux/platform_device.h"
#include "linux/i2c.h"
#include "linux/err.h"
#include "linux/regmap.h"
#include "linux/slab.h"
static struct i2c_board_info at24cxx_info = {
};
static struct i2c_client *at24cxx_client;
static int at24cxx_dev_init(void)
{
}
static void at24cxx_dev_exit(void)
{
}
module_init(at24cxx_dev_init);
module_exit(at24cxx_dev_exit);
MODULE_LICENSE("GPL");
=================================================================
at24cxx_drv.c部分:
#include "linux/kernel.h"
#include "linux/module.h"
#include "linux/platform_device.h"
#include "linux/i2c.h"
#include "linux/err.h"
#include "linux/regmap.h"
#include "linux/slab.h"
#include "linux/fs.h"
#include "asm/uaccess.h"
static int major;
static struct class *class;
static struct i2c_client *at24cxx_client;
// 传入: buf[0] : addr
// 输出: buf[0] : data
//
static ssize_t at24cxx_read(struct file * file, char __user *buf, size_t count, loff_t *off)
{
}
// buf[0] : addr
// buf[1] : data
//
static ssize_t at24cxx_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
{
}
static struct file_operations at24cxx_fops = {
};
static int __devinit at24cxx_probe(struct i2c_client *client,
{
}
static int __devexit at24cxx_remove(struct i2c_client *client)
{
}
static const struct i2c_device_id at24cxx_id_table[] = {
};
// 1. 分配/设置i2c_driver //
static struct i2c_driver at24cxx_driver = {
};
static int at24cxx_drv_init(void)
{
}
static void at24cxx_drv_exit(void)
{
}
module_init(at24cxx_drv_init);
module_exit(at24cxx_drv_exit);
MODULE_LICENSE("GPL");
=================================================================
i2c_test.c测试程序:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
// i2c_test r addr
// i2c_test w addr val
void print_usage(char *file)
{
}
int main(int argc, char **argv)
{
3 4 2内核I2C驱动24CXX实 相关文章:
- 在Linux系统中批量建立用户的shell (04-08)
- 达芬奇数字媒体片上系统的架构和Linux启动过程(06-02)
- 3DES算法的FPGA高速实现(06-21)
- linux下Intel 3945ABG 安装无线网卡驱动(06-25)
- 基于s3c2410的CramFS根文件系统的移植(07-13)
- AD7888与S3C2410的SPI接口及Linux下嵌入式驱动的实现(11-06)