Use GPIO to emulate I2C in i.MX53 w/ Clock Stretch feature -blog archive

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

Use GPIO to emulate I2C in i.MX53 w/ Clock Stretch feature -blog archive

1,239 Views
AlanZhang
Contributor V

Some I2C devices need "Clock Stretch" feature, that maybe occupied a dedicated I2C resource from i.MX53, so it would be better to share a pair of GPIO pins to be used for this purpose. Following is a concrete example to approach this object.

 

Step 1: Define the allocated GPIO pins used for this purpose.

Platform file: mx53_xxx.c (xxx stands for your board's name, like smd referring to FSL's i.MX53 tablet ref design)

#define MX53_PCBA_MHL_SW_I2C_SCL   (5 * 32 + 8)        /* GPIO6-8 */

#define MX53_PCBA_MHL_SW_I2C_SDA   (5 * 32 + 10)      /* GPIO6-10 */

Then in system-level interface declaration array:

static iomux_v3_cfg_t mx53_pcba_pads[] = {

    ............

    MX53_PAD_NANDF_RBO_GPIO6_10,

    MX53_PAD_NANDF_ALE_GPIO6_8,

    ............

};

Also pls check arch/arm/plat-mxc/include/mach/iomux-mx53.h to see whether these 2 PADs configurations are appropriate to I2C application scene. Here, they are defined as :

#define MX53_PAD_NANDF_RBO__GPIO6_10    (MX53_PAD_NANDF_RBO__GPIO6_10 | MUX_PAD_CTRL(MX53_I2C_PAD_CTRL_1))

#define MX53_PAD_NANDF_ALE__GPIO6_8      (MX53_PAD_NANDF_ALE__GPIO6_8 | MUX_PAD_CTRL(MX53_I2C_PAD_CTRL_1))

 

That is all code involving configurations we need to set up.

85-MfgConfigDialog.jpg

Figure 1. i.MX53 pin-out

87-part_sch.jpghttps://community.nxp.com/blogs/89-part_sch.jpg" target="_self

Figure 2. SiI92326 pin-out

 

Step 2: Code the I2C emulation code

Here I attach the GPL license I2C emulator program.

mhl_i2c.c

Tags (1)
0 Kudos
Reply
0 Replies