i2c

Using Python smbus on a Raspberry Pi - confused with syntax

点点圈 提交于 2019-12-04 13:32:53
问题 I am trying to use python-smbus on a Raspberry Pi to communicate with an MMA7660 accelerometer chip using I2C. In the code below, I am reading registers 0x00, 0x01, 0x02 and 0x03 of the chip, and I am getting the exact same values for all. Looking at the values, and tilting the chip, I can see that they all correspond to register 0x00, the X value register. Output: ... 1 1 1 2 3 3 3 3 1 1 1 1 59 60 60 60 51 51 51 51 58 58 58 58 3 3 3 3 62 62 62 62 58 58 58 58 62 62 62 62 ... Code: import

Raspberry Pi's terminal response has weird font that cannot be recognized

半世苍凉 提交于 2019-12-04 06:17:24
问题 I am coming here following problem for raspberry pi. The original problem from this link seems to be solved. I want to read from Arduino using I2C using Raspberry Pi but another problem rises as terminal does not give me proper answer. It looks like this weird font from raspberry pi 来源: https://stackoverflow.com/questions/58255579/raspberry-pis-terminal-response-has-weird-font-that-cannot-be-recognized

Does i2c driver need to be implemented just like any other character device driver?

微笑、不失礼 提交于 2019-12-03 21:54:25
I'm a noob to Linux device drivers so please bear with me. I'm trying to implement a i2c driver (client). It's at the point where I can insmod , .probe gets called (because of device-tree entries) and in the .probe I can read/write to the device. Great. However I need to be able to initiate read/writes from userspace to the driver. In order to do this, should an i2c driver be shaped like any other char device driver? Meaning having a file_operations struct so userspace can open , close , read , write , and ioctls ? I'm asking because in all the i2c client examples I've seen, nobody has

How to prevent “error: 'symbol' undeclared here” despite EXPORT_SYMBOL in a Linux kernel module?

心已入冬 提交于 2019-12-03 20:10:28
问题 I'm embedding some driver into a Linux kernel when I get this error (I'm adding the device in the board file and registering it): error: 'kxtf9_get_slave_descr' undeclared here (not in a function) I located the function above in a driver file struct ext_slave_descr *kxtf9_get_slave_descr(void) { return &kxtf9_descr; } EXPORT_SYMBOL(kxtf9_get_slave_descr); Shouldn't it made "visible" by EXPORT_SYMBOL? The C file containing the code above has no header file (I didn't write it, I just found it

I2C_SLAVE ioctl purpose

好久不见. 提交于 2019-12-03 16:13:04
问题 I am writing code for implementing a simple i2c read/write function using the general linux i2c driver linux/i2c-dev.h I am confused about the ioctl : I2C_SLAVE The kernel documentation states as follows : You can do plain i2c transactions by using read(2) and write(2) calls. You do not need to pass the address byte; instead, set it through ioctl I2C_SLAVE before you try to access the device However I am using the ioctl I2C_RDWR where I again set the slave address using i2c_msg.addr . The

Using Python smbus on a Raspberry Pi - confused with syntax

99封情书 提交于 2019-12-03 08:42:19
I am trying to use python-smbus on a Raspberry Pi to communicate with an MMA7660 accelerometer chip using I2C. In the code below, I am reading registers 0x00, 0x01, 0x02 and 0x03 of the chip, and I am getting the exact same values for all. Looking at the values, and tilting the chip, I can see that they all correspond to register 0x00, the X value register. Output: ... 1 1 1 2 3 3 3 3 1 1 1 1 59 60 60 60 51 51 51 51 58 58 58 58 3 3 3 3 62 62 62 62 58 58 58 58 62 62 62 62 ... Code: import smbus import time bus = smbus.SMBus(1) # I2C address for MMA7660 addr = 0x4C try: bus.write_byte_data(addr,

I want to read from Arduino using I2C using Raspberry Pi

折月煮酒 提交于 2019-12-02 16:18:15
问题 I want to read from Arduino using c++ code via Raspberry Pi. However, I am facing some difficulty in finding solution. Is there any good source of information I can find for this problem? So far I've been able to write upto this much, but I know it definitely does not work. Many sources on the web seems to focus on the python, and sending data to arduino rather than receiving data from arduino. '''C++ #include <iostream> #include <stdio.h> #include <string> #include <sstream> #include <linux

Raspberry Pi's terminal response has weird font that cannot be recognized

痴心易碎 提交于 2019-12-02 10:07:37
I am coming here following problem for raspberry pi. The original problem from this link seems to be solved. I want to read from Arduino using I2C using Raspberry Pi but another problem rises as terminal does not give me proper answer. It looks like this weird font from raspberry pi 来源: https://stackoverflow.com/questions/58255579/raspberry-pis-terminal-response-has-weird-font-that-cannot-be-recognized

Why am I only receiving the first address byte? (I2C Protocol)

家住魔仙堡 提交于 2019-12-02 04:44:19
Expecting the slave to ACKnowledge and return data, but it does not. This is my protocol . This is my Datasheet The datasheet mentions "The slave will answer by sending bytes with MSB first. Byte0 and byte1 contain the prediction value. All bytes are acknowledged by the master." Edit: Source Library Also FYI I'm on an Arduino Fio but I am not inheriting the Arduino library. #include <avr/io.h> #include <util/delay.h> #include <stdlib.h> #include <uart.h> #include <i2c_master.h> #define LED PB5 #define I2C_READ 0x5A char buffer[1]; //char data[9]; uint16_t val = 0; uint8_t status = 0; void

i2c registering macro not found?

若如初见. 提交于 2019-12-01 23:39:22
问题 I ame working on I2C driver on a raspPi: /* register I2C device static */ static const struct i2c_board_info rasp_i2c_devices[] = { { "mbed", mbedID }, }; /* in the init function of my module */ i2c_register_board_info(0,rasp_i2c_devices,ARRAY_SIZE(rasp_i2c_devices)); When i compile i get following error: make[1]: Entering directory `/home/zilleplus/rasp/linux' Building modules, stage 2. MODPOST 1 modules WARNING: "i2c_register_board_info" [/home/zilleplus/LedCube/Module/I2C/I2Crasp.ko]