장석우 wrote..
: 혹시 제가 뭔가 잘못했나해서 엽기적인 모듈작성했습니다.
: i2c 어드레스만 내보내는것까지만 하는 모듈입니다.
: 모듈 컴파일 된것과 소스도 포함했습니다.
: 모듈은 i2c관련 레지스터 초기화한 다음 바로 i2c 어드레스 내보내는 코드입 니다.
: 일단 SCL이라도 뜨는것좀 보고싶어서 작성해 봤는데 전혀 반응이 없군요ㅠㅠ
:
:
: 장석우 wrote..
: : ez-m28에 i2c 드라이버가 포팅되 있어서 그걸 사용하려고 합니다.
: : 그런데 i2c_smbus_write_word_data 쪽은 포팅이 되있지 않은것 같아서 ioctl로
: : I2C_RDWR을 사용하려고 합니다.
: : 그런데 리턴값이 이상해서요
: : -1이 리턴 됩니다.
: : i2c-dev.c 에서 I2C_RW 쪽을 보면 리턴되는값이 -EFAULT, 0, -ENOMEM입니다.
: :
: : res = ioctl(file, I2C_RDWR,&rdwr_arg);
: :
: : -1이 리턴 된는 경우는 어떤 경우인가요??
: :
: : 다음은 제 코드중 일부분입니다.
: :
: : ///////////////////////////////////////////
: : int main(void)
: : {
: : int file;
: : int addr = CHIP_ID; // The I2C address
: : __u8 registro = 0; // Device register to access
: : __s32 res;
: : char buf[10];
: : int adapter_nr = 0; /* probably dynamically determined */
: : char filename[20];
: : struct i2c_rdwr_ioctl_data rdwr_arg;
: : struct i2c_msg ctl_msgs[5];
: :
: : rdwr_arg.msgs = ctl_msgs;
: :
: : sprintf(filename,"/dev/i2c-%d",adapter_nr);
: : if ((file = open(filename,O_RDWR)) < 0) {
: : /* ERROR HANDLING; you can check errno to see what went wrong */
: : printf("Error : /dev/i2c-%d open fail
",adapter_nr);
: : exit(1);
: : }
: : //printf("step 1
");
: :
: : if (ioctl(file,I2C_SLAVE,addr) < 0) {
: : /* ERROR HANDLING; you can check errno to see what went wrong */
: : printf("Error al n");
: : exit(1);
: : }
: : //printf("step 2
");
: :
: : // for (registro=0;registro<=0x18;registro++) {
: : rdwr_arg.nmsgs = 1;
: : rdwr_arg.msgs[0].addr = TUNER_ADDR;
: : rdwr_arg.msgs[0].flags = 0;
: : rdwr_arg.msgs[0].len = 3;
: : rdwr_arg.msgs[0].buf = &buf[0];
: : buf[0]= 0xAA;
: : //printf("step 3
");
: : res = ioctl(file, I2C_RDWR,&rdwr_arg);
: : if (res < 0) {
: : /* ERROR HANDLING: i2c transaction failed */
: : printf("Falla al leer el registro %d
",registro);
: : printf("res : %d
",res);
: : } else {
: : printf("Registro %d = %d
",registro,res);
: : /* res contains the read word */
: : }
: : // }
: : //printf("step 4
");
: : close (file);
: : }