Hi,
* Matthias Fechner <[EMAIL PROTECTED]> [10-03-07 00:42]:
> It seems now that everything works fine. I will check it for the next
> days. And will give some feedback.
ok, I checked now the driver some time at it failed. So it seems that
that the patch had not solved the problem.
I have attached the programm to check it.
I changed the time to 2 seconds but that didn't help.
Best regards,
Matthias
--
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook
/* read the data from max6633 */
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "i2c-dev.h"
#include "version.h"
static __inline__ unsigned short swap_bytes(unsigned short val)
{
return(val >> 8) | (val << 8);
}
int main(void)
{
int res,address,file;
char filename[20];
unsigned short temp;
long funcs;
int i2cbus;
int errorCount,successfullCount;
errorCount=successfullCount=0;
i2cbus=1;
address=0x40;
sprintf(filename,"/dev/i2c-%d",i2cbus);
if((file=open(filename,O_RDWR))<0)
{
fprintf(stderr,"Error: could not open file %s: %s\n",filename,strerror(errno));
exit(1);
}
/* check adapter functionality */
if(ioctl(file,I2C_FUNCS,&funcs) < 0)
{
fprintf(stderr, "Error: could not get the adapter functionality matrix: %s\n",strerror(errno));
goto ERROR0;
}
if(!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA))
{
fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
fprintf(stderr," does not have byte read capability\n");
goto ERROR0;
}
if(!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA))
{
fprintf(stderr,"Error: Adapter for i2cbus %d",i2cbus);
fprintf(stderr," does not have word read capability\n");
goto ERROR0;
}
/* use FORCE so that we can look at registers even when a driver
is also running */
if(ioctl(file,I2C_SLAVE,address) <0)
{
fprintf(stderr,"Error: Could not set address to %d: %s\n",address, strerror(errno));
goto ERROR0;
}
fprintf(stderr,"Read with word_data\n");
while(1)
{
temp=res=i2c_smbus_read_word_data(file,0);
if(res<0)
{
fprintf(stderr,"Error: Could not read the value from the i2c device\n");
errorCount++;
}else
{
successfullCount++;
}
temp=swap_bytes(temp);
temp=temp >> 3;
printf("Succes: %i, Errorcount: %i, Temp: %f\n",successfullCount,errorCount,(float)(temp*0.0625));
sleep(1);
}
printf("\nCalculate temp\n");
close(file);
exit(0);
ERROR0:
close(file);
exit(1);
}
_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded