Can't get fopen ("i2c0:", NULL) to work

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Can't get fopen ("i2c0:", NULL) to work

跳至解决方案
1,755 次查看
MikeMarynowski
Contributor III

Hi,

 

I'm currently trying out the 52259 eval board and MQX 3.3 and the following lines:

 

  
ftouch = fopen ("i2c0:", NULL);   if (ftouch == NULL) {   printf ("Failed to open the I2C driver!\n");   _task_block();}

 

 

always ends up going into the failed block.  I have enabled I2C0 in user_config.h for the BSP.  I also tried the i2c sample project in MQX samples and the same thing happens.

 

Any idea why that might be?

 

Thanks,

 

--Mike

标签 (1)
0 项奖励
1 解答
677 次查看
MikeMarynowski
Contributor III
Nevermind...got it working.

在原帖中查看解决方案

0 项奖励
6 回复数
678 次查看
MikeMarynowski
Contributor III
Nevermind...got it working.
0 项奖励
677 次查看
navin_b
Contributor I

Hi,

    I am new to FreeScale and MQX. I am facing similar problem as described by Mike. Can some body please help me?

 

Thanks in advance

Message Edited by navin_b on 2010-02-08 06:44 AM
0 项奖励
677 次查看
MikeMarynowski
Contributor III
You have to go through the board configuration and set the desired pins as I2C primary function instead of GPIO function.
0 项奖励
677 次查看
navin_b
Contributor I
Thanks for answering but my problem is little different from yours. The example code works fine ( it does open the file successfully) but in my project (the one i create in CW) it does not happen so. Can you please say which file should i modify to change the primary function.
0 项奖励
677 次查看
navin_b
Contributor I
I was doing it wrong way. sorry, mistake on my part. I forgot to build libs in config directory.
0 项奖励
677 次查看
MikeMarynowski
Contributor III

Also, just tried the I2C sample in MQX 3.2, same thing. 

 

That version passes I2C_DEVICE_MASTER_MODE explicitly as the second parameter to fopen, so that's not the problem.

 

EDIT:

 

I can fopen the SDA0 / SCL0 pins on PORT_AS just fine as GPIO, so I'm not sure why the I2C fopen is failing.

Message Edited by MikeMarynowski on 2009-10-17 01:51 AM
0 项奖励