Hallo Forum,
ich habe es erfolgreich geschafft einen PCF8574 mit meinem Raspberry Pi über I²C anzusprechen.
Allerdings ist mir eine Sache nicht ganz klar....
Ich verwende dieses Programm hier:
Die Adresse vom PCF ist die Adresse ohne R/W Bit. Und wenn ich mittelsCode:// Compile with: GCC /var/Programme/UART.c -o /var/Programme/UART #include <stdio.h> #include <stdlib.h> #include <linux/i2c-dev.h> #include <linux/i2c.h> #include <fcntl.h> #include <string.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> char Device[] = "/dev/i2c-0"; int fd; int res; int address = 0x20; char Buffer[1]; int main(int argc, char** argv) // Programmstart { fd = open(Device, O_RDWR); if (ioctl(fd, I2C_SLAVE, address) < 0) // Set the port options and set the address of the device we wish to speak to { printf("Unable to get bus access to talk to slave\n"); exit(1); } res = write(fd, argv[1], 1); close(fd); return 0; }
sudo i2cdetect -y -a 0
den Bus nach Geräten absuche, taucht dort nur diese Adresse auf.
Wird das R/W Bit Hard oder Softwaremässig gesetzt oder wie funktioniert das?
Danke für die Antwort!







Zitieren


Lesezeichen