Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <stdlib.h>
- #include <linux/i2c-dev.h>
- #include <linux/i2c.h>
- #include <sys/ioctl.h>
- #include <math.h>
- #include <wiringPi.h>
- int begin()
- {
- printf("jetztkommtbeginblubs\n");
- int fd = 0;
- char *fileName = "/dev/i2c-1";
- // Open port for reading and writing
- if ((fd = open(fileName, O_RDWR)) < 0)
- {
- exit(1);
- }
- // Set the port options and set the address of the device
- int pantato=ioctl(fd, I2C_SLAVE, 0x70);
- if (pantato < 0)
- {
- printf("hurensohni2c\n");;
- close(fd);
- exit(1);
- }else{
- printf("i2cistsehrgut\n");
- printf("%d\n",pantato);
- printf("i2cistsehrsehrgut\n");
- }
- return fd;
- }
- void switch_channel(int fd, int channel){
- int check;
- check = wiringPiI2CWrite(fd, channel);
- printf("check is\n");
- printf("%d\n",check);
- //~ check = wiringPiI2CWriteReg8(address, SWITCH, channel);
- if (check==-1)
- {
- printf("could not switch\n");
- }else{
- printf("Switched to channel: %i \n",channel);
- }
- }
- int main(int argc, char **argv)
- {
- printf("ehm\n");
- int fd = begin();
- switch_channel(fd, 0x04);
- printf("donewithallclosingnow\n");
- close (fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement