This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BOOSTXL-CAPKEYPAD: Where is default application I2C protocol documented?

Part Number: BOOSTXL-CAPKEYPAD

The BOOSTXL-CAPKEYPAD eval board comes preloaded with an application that uses I2C to communicate with the outside world.  Where can I find documentation of the protocol that it expects?

  • Hi Jim,

    That is documented in the Captivate Technology Guide, software chapter, communication module.

    The Captivate Software API has descriptions of the functions.

  • Unfortunately, this doesn't directly address my concern.  I'm looking for the I2C protocol that it expects from the master, not the driver API.  We're using a micro from Silicon Labs as the master in our new product.  The MSP430 in our design will act as slave and only drive a keypad; pretty close to what the BOOSTXL-CAPKEYPAD already does out of the box.  I need to know the I2C protocol, so that I can send the proper commands to it to read back the keypress states.

  • Ok, understand.

    You have 2 options; one is to follow the REGISTER_I2C protocol, the other is to create your own.

    Option 1 - REGISTER_I2C is already integrated into the Captivate library and is documented in the Host Processor communications section of the software chapter.  It provides example of what is needed to communicate with the MSP430.  Note that in the GUI you must select this protocol or you can hand edit the CAPT_UserConfig.h file, line 81: #define CAPT_INTERFACE  (__CAPT_REGISTERI2C_INTERFACE__).

    You will discover that the host can ask for sensor data, status and others.  The downside to using this method is the host is wasting a lot of time polling to see ifa key pressed.  Not very efficient, so you can easily add an interrupt that will allow the MSP430 to notify the host when it has data. To do this, look in your CCS or IAR project directory and find captivate>comm>CAPT_CommConfig.h file.  Around line #12 you will see some #defines that are used to select which GPIO you want the I2C driver to use. I believe it is already set for the BOOSTXL-KEYPAD.

    Since the REGISTER_I2C driver is not designed to activate this interrupt, you will need to do it in the user callback you will need to create and register.  Information on how to do that is here.  When you register your callback, the Captivate library will know to automatically call it after each measurement. In the callback, all you do is just call the I2C slave driver function to activate the interrupt pin.

    void I2CSlave_setRequestFlag(void)

    Option 2 - A custom protocol may be the way to go.  Since you will already have a user callback to generate the interrupt request,  you a few lines of code to read the sensor data of interest, stuff it in a buffer you designate, then generate the interrupt.  The advantage to the custom protocol is you can send whatever data you want.  If its only they value of the key that's pressed, then you lo.

    How do know which button was pressed?  Well that's what CAPT_getDominantButton() is for. 

    To use the I2C drivers you have to disable the interface to the Captivate GUI:

    //=====================
    // Modify CAPT_UserConfig.h, line 81, set to NONE
    //=====================
    #define CAPT_INTERFACE  (__CAPT_NONE_INTERFACE__)

    This will prevent the I2C driver from initializing the REGISTER_I2C or REGISTER_BULK resources.

    Next, you need to add a few lines of code to the CAPT_CommConfig.h  to "re-enable" the I2C driver so you can call the I2C functions.  See the text in bold.
    //=====================
    // Modify CAPT_CommConfig.h, around line 140 to look like this:
    //=====================
    #if 1
    #define UART__ENABLE            (false)
    #define I2CSLAVE__ENABLE        (true)
    #define FUNCTIONTIMER__ENABLE   (true)
    #elif (CAPT_INTERFACE==__CAPT_UART_INTERFACE__)
    #define UART__ENABLE            (true)
    #define I2CSLAVE__ENABLE        (false)
    #define FUNCTIONTIMER__ENABLE    (false)
    #elif (CAPT_INTERFACE==__CAPT_BULKI2C_INTERFACE__)
    #define UART__ENABLE            (false)
    #define I2CSLAVE__ENABLE        (true)
    #define FUNCTIONTIMER__ENABLE    (true)
    #elif (CAPT_INTERFACE==__CAPT_REGISTERI2C_INTERFACE__)
    #define UART__ENABLE            (false)
    #define I2CSLAVE__ENABLE        (true)
    #define FUNCTIONTIMER__ENABLE    (true)
    #endif

    Now for the code... in your callback function you create a buffer
    //=====================
    // Create a transmit buffer
    //=====================
    uint8_t     TXBuffer[16];


    Early in your code, before enabling Captivate, perform these 3 actions:
    //=====================
    // Some where early in your code do these:
    //=====================

        MAP_CAPT_registerCallback(&keypadSensor, &sensorCallback);

        I2CSlave_openPort(&slaveI2c);

        I2CSlave_setTransmitBuffer(TXBuffer, sizeof(TXBuffer)); // here you use your buffer name
           

    Then create the callback:
    //=====================
    // Callback Function
    //=====================
    void sensorCallback(tSensor* pSensor)
    {
        // Only check for dominant button if the sensor is in touch state
        if (pSensor->bSensorTouch==true)
        {
            TXBuffer[0] = CAPT_getDominantButton(keypadSensor);
            
            I2CSlave_setRequestFlag();
        }
        
    }

    
    
  • It's been a few days since I have heard from you so I’m assuming your question has been answered.
    If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

**Attention** This is a public forum