Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Output PSoC 6 CapSense Data Through EZI2C in ModusToolbox 2.0 – KBA229699

Output PSoC 6 CapSense Data Through EZI2C in ModusToolbox 2.0 – KBA229699

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Author: LinglingG_46         Version: **

Translation - Japanese: ModusToolbox 2.0でEZI2Cを介したPSoC 6の CapSenseのデータ出力 – KBA229699 - Community Translated (JA)

Question:
How can I output PSoC® 6 CapSense® Data through EZI2C in ModusToolbox® 2.0?

Answer: 
Instead of using the CapSense Tuner tool, do the following to use EZI2C to output CapSense data to an I2C master:

1. Define a customized I2C data buffer. The buffer type can be an array or a struct.

2. Define each shift register in the buffer to specify the CapSense parameter to be loaded in each register. For instance:

struct

{

      uint16 rawcount[2];

      uint16 baseline[2];

      uint16 diffcount[2];

      uint8 idac[2];

      uint8 compidac[2];

}csd_param;

3. Set up the I2C data buffer to be exposed to the I2C master on a primary slave address request using the following API:

       void Cy_SCB_EZI2C_SetBuffer1(CySCB_Type const *base, uint8_t *buffer, uint32_t size, uint32_t rwBoundary,

  cy_stc_scb_ezi2c_context_t

*context)

4. Manually load the CapSense data in the I2C data buffer during runtime.

You could use codes to implement the steps to acquire the sensor parameters, such as rawcount, baseline,diffcount, modulation IDAC, Compensation IDAC, and so on. The following are the two code snippets to acquire rawcount and IDAC:

Getting Sensor Rawcount

uint32_t Cy_CapSense_getraw(

                uint32_t widgetId,

                uint32_t sensorId,

                const cy_stc_capsense_context_t * context)

{

    uint32_t result = 0uL;

    if (widgetId < context->ptrCommonConfig->numWd)

    {

        if (sensorId < context->ptrWdConfig[widgetId].numSns)

        {

            result = context->ptrWdConfig[widgetId].ptrSnsContext[sensorId].raw;

        }

    }

    return result;

}

Getting Widget IDAC

uint32_t Cy_CapSense_getidac(

                uint32_t widgetId,

                uint32_t sensorId,

                const cy_stc_capsense_context_t * context)

{

    uint32_t result = 0uL;

    if (widgetId < context->ptrCommonConfig->numWd)

    {

        if (sensorId < context->ptrWdConfig[widgetId].numSns)

        {

            result = context->ptrWdConfig[widgetId].ptrWdContext[widgetId].idacMod[0];

        }

    }

    return result;

}

0 Likes
323 Views
Contributors