Hi all, I try to enable the communication between an ADC (ADS7823) and a board with an ARM chip. In /dev, I have i2c-0,... i2c-3. So, I suppose that it is not necessary to add another. The board has already an internal ADC and I communicate with it without problem. When I start my program, there is no activity on SCL and SDA. I use a loop when I write on the I2C bus but I see nothing. Regarding the electronic part, it's ok, supply enables. Have you got ideas? BR This is the program : #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <i2c-dev.h> #include <errno.h> int main(void) { int file; char filename[20]; int i2caddrslave = 0x48; // factory pre-set to 10010, A1=A0=GND // b'1001000', 0x48 int Read_Addressing_Byte = 0x91; int Write_Addressing_Byte = 0x90; int Command_Byte = 0x00; int DeviceAddress,i2cWrite; int adapter_nr = 0; sprintf(filename,"/dev/i2c-%d",adapter_nr); printf("Device File: %s\n\n",filename); //************************************** //Opening the device => NO Problem //************************************** if ((file = open(filename,O_RDWR)) < 0) { printf("Error Occured while opening Device File!!\n"); exit(1); } else { printf("Device File Opened Successfully !!\n"); } //************************************* //I2C under control => NO Problem //************************************* DeviceAddress = ioctl(file,I2C_SLAVE_FORCE,i2caddrslave); //I2C_SLAVE if (DeviceAddress < 0) { printf("Error Occrued inside IOCTL!! : devadd = 0x%x\n\n",DeviceAddress); printf("error no= %d\n\n",errno); perror("Error Reason: "); exit(1); } else { printf("Device slave address OK : 0x%x\n\n", i2caddrslave); } //************************************** //I2C Write Register //************************************** while(1){ i2cWrite = i2c_smbus_write_byte_data(file,Write_Addressing_Byte,Command_Byte); if (i2cWrite < 0) { printf("Failed to write 0x%x to device: 0x%x\n",Command_Byte,Write_Addressing_Byte); } else { printf("Write register OK : write 0x%x to device 0x%x\n",Command_Byte,Write_Addressing_Byte); } } close(file); return 0; } Envie de nouveauté ? Le nouveau Hotmail arrive bientôt ! Préparez-vous ! |
_______________________________________________ lm-sensors mailing list lm-sensors@xxxxxxxxxxxxxx http://lists.lm-sensors.org/mailman/listinfo/lm-sensors