커널 2.4를 사용중 이구요

i2c 사용을 위해 첨부한 파일에 보이는 것과 같이 i2c 설정후 커널 컴파일 하였습니다.

설정이 제대로 된 것인지 잘 모르겠지만

어쨌든 cat /proc/devices 로 확인해본 결과 i2c 89 가 보이는 걸로 봐선 된것 같았습니다.

 

보드의 U2 35,36 핀과 콘트롤 하려는 장치랑 연결하고

 

다음에 이런 코드를 짰는데

  

if( access( "/dev/i2c-0", F_OK) )

{

   printf( "making i2c_dev\n");

   mknod("/dev/i2c-0",S_IRWXU|S_IRWXG|S_IFCHR,(89<<8|(0)));

   //system("mknod /dev/i2c c 89 0\n\n\n\n\n\n");

}

if ( 0 > ( i2c_fd = open( "/dev/i2c-0", O_RDWR) ) )

{

   printf( "i2c open fail\n");

   return 0;

}

if ( ioctl( i2c_fd, I2C_SLAVE,42))

{

   printf( "slave address setting fail\n");

   return 0;

}

i2c_buf[0]= 0x12; //register address

i2c_buf[1]= 0x04; //data 0000 0100 select rgb

if(0>write(i2c_fd,i2c_buf,2))

{

   printf("error\n");

}

i2c_buf[0]= 0x40; //register address

i2c_buf[1]= 0xD0; //data 1101 0000select rgb565

if(0>write(i2c_fd,i2c_buf,2))

{

printf("error2\n");

}

close(i2c_fd);

 

 

error

error2

 

가 나옵니다. 다른 에러 메세지는 없었구요.

어디가 잘못된것인지 도저히 모르겠어요ㅠ.ㅠ