i am unable to write and read registers from slve Device(Accelometer LIS331DLH)perticular location ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

i am unable to write and read registers from slve Device(Accelometer LIS331DLH)perticular location ?

1,678 次查看
nareshpuli
Contributor III

we are using P2020 Processor with the linux platform,  I2C interface with LIS331DLH Accelerometer sensor

Actually i  am writing the application in the user level  to read Accelerometer LIS331DLH sensor data X-axis, Y-axis,Z-axis Value

here i am facing issue,   i want write the data in particular address to Enable (EN_X_Y_Z); //CTRL_REG1 register enable X-axis, Y-axis,Z-axis in normal mode ,  how we read the data from specific register address? kindly guide me.

 CTRL_REG1= 0x20;  //   Register address

  EN_X_Y_Z= 0x27;  // Data

how can i write 0x27 data in the CTRL Register1 address location 0x20 ,please tell me

 

unsigned char reg_buf[5];

buf[0]= 0x30;  // write address

buf[0]=0x20;  //  register address

buf[1]=0x27;  // data

write(fd, reg_buf, sizeof(buf));  // for your reference i have attached my program

how we write, read I2C register's Data using system call, kindly help me  i am hanging here i am not able to read Accelerometer sensor registers from particular location data , please send sample program.

标签 (1)
0 项奖励
回复
2 回复数

1,361 次查看
Pavel
NXP Employee
NXP Employee

Look at the following pages:

linux/i2c-smbus.h at master · torvalds/linux · GitHub 

c - fatal error: i2c/smbus.h: No such file or directory? - Stack Overflow 

c++ - Why are i2c_smbus function not available? (I2C – Embedded Linux) - Stack Overflow 


Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,361 次查看
Pavel
NXP Employee
NXP Employee

Look at the following pages about using I2C under Linux:

https://www.kernel.org/doc/Documentation/i2c/dev-interface

 

https://github.com/shenki/linux-i2c-example

 

https://github.com/ev3dev/i2c-tools

 

http://www.haifux.org/lectures/258/gpio_spi_i2c_userspace.pdf


Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复