도와주세요!!
커널 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
가 나옵니다. 다른 에러 메세지는 없었구요.
어디가 잘못된것인지 도저히 모르겠어요ㅠ.ㅠ
슬레이브 ID를 잘못주면 반응을 하지 않습니다.
소스중
ioctl( i2c_fd, I2C_SLAVE,42)) 에서 슬레이브 ID 가 42 인가요 아니면 0x42 인가요 확인해보세요
스코프를 I2C 버스에 연결한 후 클럭과 데이타가 나온다면 커널과 하드웨어, 그리고 디바이스드라이버
연결까지는 문제가 없는 거구요... 역시 의심할껀 슬레이브 ID 입니다.
참고로 슬레이브 ID는 7bit 만을 사용합니다. D7 은 항상 '0' 이란걸 기억하세요