<<< Previous topic - Next topic >>> |
|
Author |
Message |
kdw
Joined: 05 May 2006 Posts: 1461
|
Posted: 02.09.2011, 13:58 Post subject: I2C nutzen ... |
|
|
Hallo Forum.
Zunächst einmal müssen die erforderlichen Module im Dateisystem des DNP/9265 abgelegt und geladen werden:
Code: | root@emblinux:~$ insmod <path_to_module>/i2c-core.ko
root@emblinux:~$ insmod <path_to_module>/i2c-dev.ko
root@emblinux:~$ insmod <path_to_module>/i2c-algo-bit.ko
root@emblinux:~$ insmod <path_to_module>/i2c-gpio.ko |
Dann kann man I2C nutzen. Der folgenden Code zeigt, wie man abfragen kann, ob die Treiber geladen wurden:
Code: | #include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
int main(void) {
int fd;
//open device
if ((fd = open("/dev/i2c0",O_RDWR)) < 0) {
printf( "Fehler I2C open errno:%d %s",
errno, strerror(errno));
return 1;
}
//do somethings
//close device
close(fd);
return 0;
}
|
Gruß
KDW |
|
Back to top |
|
|
hne
Joined: 11 Jul 2008 Posts: 210 Location: Hannover
|
Posted: 23.10.2012, 17:54 Post subject: |
|
|
Der I2C-Bus muss in der SSV-Hardware-Config aktiviert werden, d.h. über den uBoot geändert werden.
Dazu die ist die Datei /Linux/product_recovery/buildup-3791/linux/kernel/ssvhwcnf-dnp9265.bin von der CDROM entsprechend von "i2c=0" auf "i2c=1" zu ändern.
Achtung!
Die Zeile endet mit einem 00h! Bitte einen Linux-Editor nehmen, der die 00h am Ende nicht entfernt, z.B. "mcedit".
Wie diese Datei eingespielt wird, steht in der Datei /Linux/product_recovery/buildup-3791/HOWTO-install, ebenfalls auf der CDROM. _________________ Henry Nestler |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|