资源简介
本人在华清远见培训嵌入式期间整理的部分驱动代码,方便初学者学习。

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define I2C_RDWR 0x0707
/*********定义struct i2c_rdwr_ioctl_data和struct
* i2c_msg,要和内核一致*******/
struct i2c_msg
{
unsigned short addr;
unsigned short flags;
unsigned short len;
unsigned char *buf;
};
struct i2c_rdwr_ioctl_data
{
struct i2c_msg *msgs;
int nmsgs;
/* nmsgs这个数量决定了有多少开始信号,对于“单开始时序”,取1*/
};
/***********主程序***********/
int main()
{
int fd i;
struct i2c_rdwr_ioctl_data pm_data;
struct i2c_msg msgs[2];
if ((fd = open(“/dev/i2c-0“O_RDWR)) < 0)
{
perror(“open error“);
exit(-1);
}
msgs[0].addr = 0x2d; // tps659101 设备地址
msgs[0].flags = 0; // write
msgs[0].len = 2;
msgs[0].buf = (unsigned char *)malloc(2);
msgs[0].buf[0] = 0x33; //vaux2 register address
msgs[0].buf[1] = 0xd;
pm_data.msgs = msgs;
pm_data.nmsgs = 1;
#if 1
if (ioctl(fd I2C_RDWR (unsigned long)&pm_data) < 0)
{
perror(“ioctl error 1“);
exit(-1);
}
printf(“write over...\n“);
#endif
/*******************************************************************/
#if 0
usleep(100000);
msgs[0].addr = 0x50; // at24c02a 设备地址
msgs[0].flags = 0; // write
msgs[0].len = 1;
msgs[0].buf[0] = 0x0; //address in at24c02a
msgs[1].addr = 0x50; // at24c02a 设备地址
msgs[1].flags = 1; // read
msgs[1].len = 8; // len for read
msgs[1].buf = malloc(8);// read content
e2prom_data.msgs = msgs;
e2prom_data.nmsgs = 2;
if (ioctl(fd I2C_RDWR (unsigned long)&e2prom_data) < 0)
{
perror(“ioctl error 2“);
exit(-1);
}
for (i=0; i<8; i++)
{
printf(“0x%x “ msgs[1].buf[i]);
}
printf(“\n“);
#endif
close(fd);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1837 2013-10-14 10:10 驱动开发\adc_power.c
文件 378 2013-06-23 14:18 驱动开发\block\sbull\Makefile
文件 8380 2013-06-20 16:16 驱动开发\block\sbull\sbull.c
文件 42042 2013-06-26 15:16 驱动开发\dm9000.c
文件 27403 2013-04-12 09:06 驱动开发\DM9000寄存器说明.docx
文件 378 2013-06-23 14:18 驱动开发\driver\block\sbull\Makefile
文件 8380 2013-06-20 16:16 驱动开发\driver\block\sbull\sbull.c
文件 42042 2013-06-26 15:16 驱动开发\driver\dm9000.c
文件 27403 2013-04-12 09:06 驱动开发\driver\DM9000寄存器说明.docx
文件 1837 2013-10-14 10:10 驱动开发\driver\fs210_adc\adc_power.c
文件 4114 2013-10-14 14:13 驱动开发\driver\fs210_adc\fs210_adc.c
文件 6889 2013-10-12 14:11 驱动开发\driver\fs210_async\fs210_key_all.c
文件 533 2013-10-12 14:11 驱动开发\driver\fs210_async\key_test_async.c
文件 6050 2013-10-11 14:08 驱动开发\driver\fs210_key\fs210_key.c
文件 402 2012-07-01 12:30 驱动开发\driver\fs210_key\key_test.c
文件 2976 2013-10-12 16:03 驱动开发\driver\fs210_wtd\fs210_wdt.c
文件 532 2013-10-12 16:03 驱动开发\driver\fs210_wtd\wdt_test.c
文件 3267 2013-09-02 13:27 驱动开发\driver\pwm\fs210_pwm.c
文件 171 2013-09-02 13:19 驱动开发\driver\pwm\fs210_pwm.h
文件 1015 2013-09-02 13:17 驱动开发\driver\pwm\pwm_music.c
文件 5048 2013-06-07 15:46 驱动开发\driver\pwm\pwm_music.h
文件 1755 2013-10-14 16:52 驱动开发\driver\s5pv210_e2prom\e2prom_app_mode.c
文件 8149 2013-10-15 10:39 驱动开发\driver\s5pv210_i2c\e2prom_test
文件 1047 2013-10-15 11:57 驱动开发\driver\s5pv210_i2c\e2prom_test.c
文件 3936 2013-10-15 11:57 驱动开发\driver\s5pv210_i2c\fs210_e2prom.c
文件 94829 2013-10-15 10:39 驱动开发\driver\s5pv210_i2c\fs210_e2prom.ko
文件 1755 2013-10-14 16:52 驱动开发\e2prom_app_mode.c
文件 1121 2013-09-09 09:48 驱动开发\ex1-hello-world\hello.c
文件 422 2012-07-04 11:05 驱动开发\ex1-hello-world\Makefile
文件 474 2011-03-10 08:29 驱动开发\ex1-hello-world\README
............此处省略331个文件信息
相关资源
- 《嵌入式Linux系统开发标准教程》第
- 嵌入式 L inux C 语言应用程序设计.pd
- 嵌入式华清远见培训 ARM代码内部资料
- 华清远见嵌入式培训---驱动教程源码
- FPGA设计初级班提高班培训实验指导手
- 华清远见-嵌入式Linux应用程序开发详
- 华清远见物联网仓储管理系统 Zigbee模
- Vxworks设备驱动开发详解-曹桂平著
- 华清远见开发板源代码集合(入门到
- 华清远见内部高清文档资料
- 《FPGA应用开发入门与典型》文字版超
- 华清远见培训全部资料
- 我的嵌入式Linux应用开发之路(第二版
- 华清远见智能家居项目
- 华清远见uboot和linux内核移植实验手册
- 华清远见学习资料
- 基于华清远见4412UDP通信的pwm按键控制
- 华清远见嵌入式Linux课程
评论
共有 条评论