Vybrid VF3x I2C1 device driver integration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vybrid VF3x I2C1 device driver integration

Jump to solution
658 Views
MehmetAliIpin
Contributor V

Dear Sir/Madam,

I have our own Vybrid VF3x board a cash register. I have installed ARM-DS5, and MQX on windows7. I compiled and build all bsp and psp libraries as explained in " Getting Started with ARM® Development Studio 5 (DS-5™) with Freescale MQX™ RTOS" document, exported helloWorld2 project into my workspace, compiled, built, and now I can debug it with openSDA and DS-5 debugger.

I have a real time clock chip in my hardware. I want to integrate its SW into my helloworld2 project.

I am using I2C1 pins, how can I tell to MQX that I, it should prepare relevant pins accordingly? Is

   MQX_FILE_PTR I2C_FILE=NULL;

   I2C_FILE = fopen ("i2c1:", NULL);

enough?

There is an _i2c_init structure; How can I use it to define the I2C parameters, with FILE_PTR?  could you please give me an example?

Best regards.

Mehmet Ali Ipim

Labels (1)
1 Solution
480 Views
susansu
NXP Employee
NXP Employee

Hi,

                You can modify the user_config.h file as follow:

#define BSPCFG_ENABLE_I2C1                 1   //if you use Polled I2C

#define BSPCFG_ENABLE_II2C1                1  //if you use interrupt I2C

Then in the init_bsp.c, _bsp_enable_card will install I2C component.

Best Regards,

Susan

View solution in original post

0 Kudos
4 Replies
480 Views
susansu
NXP Employee
NXP Employee

Hi Mehmet,

                If you want to set the i2c baud rate ,for example 100KHZ, you can refer to the following code:

                param = 100000; // baud rate 100KHZ

                ioctl (fd, IO_IOCTL_I2C_SET_BAUD, &param);

                In my opinion, IO_IOCTL_I2C_SET_BAUD  is  to tell the ioctl function to run the related code, in function _ki2c_polled_ioctl which is defined in mqx/source/io/i2c/polled/i2c_pol_ki2c.c:

               

                case IO_IOCTL_I2C_SET_BAUD:

                    if (NULL == param_ptr)

                    {

                                 result = I2C_ERROR_INVALID_PARAMETER;

                    }

                    else if (i2c_ptr->S & I2C_S_BUSY_MASK)

                    {

                                 result = I2C_ERROR_DEVICE_BUSY;

                    }

                   else

                   {

                               i2c_ptr->F = _ki2c_set_baudrate( BSP_I2C_CLOCK, *param_ptr );

                   }

                  break;

                Hope this could be useful!

Best Regards,

Susan

480 Views
DavidS
NXP Employee
NXP Employee

Hi Mehmet,

Please try using the C:\Freescale\Freescale_MQX_4_0_2_GA\mqx\examples\i2c project as reference to using I2C.

Susan is correct for enabling the BSP to pre-load the polled or interrupt driver for I2C but best to only enable one or the other and not both.

Regards,

David

480 Views
MehmetAliIpin
Contributor V

Dear Susan/David,

Thank you for your helps. I have read the project and i2c.c file for example. for the baud rate

#define IO_IOCTL_I2C_SET_BAUD                         _IO(IO_TYPE_I2C,0x01)

id defined. What the value for this? for example is it 100KHz, 400kHz?

Thanks and best regards.

Mehmet

0 Kudos
481 Views
susansu
NXP Employee
NXP Employee

Hi,

                You can modify the user_config.h file as follow:

#define BSPCFG_ENABLE_I2C1                 1   //if you use Polled I2C

#define BSPCFG_ENABLE_II2C1                1  //if you use interrupt I2C

Then in the init_bsp.c, _bsp_enable_card will install I2C component.

Best Regards,

Susan

0 Kudos