+ Reply to Thread
Results 1 to 1 of 1

Thread: GPIO library importance in I2C and its functions explanations?

  1. #1
    New Member New Member Qlirim is on a distinguished road
    Join Date
    Mar 2019
    Posts
    1
    Points
    15

    GPIO library importance in I2C and its functions explanations?

    I've been assigned in a project where I have to communicate mpr121 capacitive touch sensing keyboard with 8051 microcontroller with I2C using Easy8051a board.
    I have pretty much learned the theoretical part of I2C communications but struggling with the implementations I've come across a GitHub project where they use GPIO library with some functions very hard to understand.
    My question is why do we need GPIO to implement an I2C communication rather doing in the standard way, can we use GPIO with all microcontrollers like the 8051 and I want to know the meaning of the functions below.
    If anyone could give me a push on this, I'd be very grateful. Thank you!

    Here are the GPIO functions..

    void Init_I2C_GPIO(void)
    {
    GPIO_DIS_OUTPUT(SCL);
    PIN_PULLUP_EN(GPIO_PIN_REG(SCL));
    GPIO_DIS_OUTPUT(SDA);
    PIN_PULLUP_EN(GPIO_PIN_REG(SDA));
    }


    void SCL_0()
    {
    GPIO_OUTPUT_SET(SCL, 0);
    PIN_PULLUP_DIS(GPIO_PIN_REG(SCL));
    }


    void SCL_1()
    {
    GPIO_OUTPUT_SET(SCL, 1);
    PIN_PULLUP_EN(GPIO_PIN_REG(SCL));
    }


    void SDA_0()
    {
    GPIO_OUTPUT_SET(SDA, 0);
    PIN_PULLUP_DIS(GPIO_PIN_REG(SDA));
    }


    void SDA_1()
    {
    GPIO_OUTPUT_SET(SDA, 1);
    PIN_PULLUP_EN(GPIO_PIN_REG(SDA));
    }


    unsigned char SDA_R()
    {
    return GPIO_INPUT_GET(SDA);
    //return 0;
    }

    I have a clue with middle 4 but at 5th SDA_R() and first Init_I2C_GPIO() not quite understandable.

    Why not go the standard way like this:

    void I2CInit()
    {
    SDA = 1;
    SCL = 1;
    }

    void I2CStart()
    {
    SDA = 0;
    SCL = 0;
    }

    void I2CRestart()
    {
    SDA = 1;
    SCL = 1;
    SDA = 0;
    SCL = 0;
    }

    void I2CStop()
    {
    SCL = 0;
    SDA = 0;
    SCL = 1;
    SDA = 1;
    }

    How can i translate SDA_R() to the standard way shown above?
    ?????? ?????? GPIO.jpg‎  
    Last edited by Qlirim; Mar 8th, 2019 at 03:35 PM.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.