PSOC4 Component API Use documentation issue?

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

cross mob
David_Zhang
Level 5
Level 5
Distributor - Arrow(GC)
First like received 50 sign-ins 25 sign-ins

      when  i start use PSOC for touch key, i use component capsense v5.1, but i can't find how to use API to get key touch, and how the struct define, why  you define like this

how to use it , it's very hard to use it .  all component api just has simple translate , it 's no useful for engineer to development. all component disperse one to another place, it's very hard to read, why not to describe one issue clearly. For explam:

        we find blow api to set buff:

EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam),sizeof(CapSense_dsRam),(uint8_t *)&(CapSense_dsRam));

       and then we know capsense_dsRam is struct, we jump to see it :

       oh, my god, why so many parameter, what does it mean, how to use it ? there is no explain? and there is no example code.

       it take serval house to see the function , but i still understand how to use it, so i just want to give up, it's bad experinence, and want to choose other MCU like STM32;

       i think sample code and struction is important for new customer,  help ?

/***************************************************************************//**

* \brief Declares the top-level RAM Data Structure

*******************************************************************************/

typedef struct

{

    /**

     *  16-bit CRC calculated by the customizer for the component

     *  configuration. Used by the Tuner application to identify if

     *  the FW corresponds to the specific user configuration.

     */

    uint16 configId;

    /**

     *  Used by the Tuner application to identify device-specific configuration.

     */

    uint16 deviceId;

    /**

     *  Used by the Tuner application to identify the system clock frequency.

     */

    uint16 hwClock;

    /**

     *  Tuner Command Register. Used for the communication

     *  between the Tuner GUI and the component.

     */

    uint16 tunerCmd;

    /**

     *  This counter gets incremented after each scan.

     */

    uint16 scanCounter;

    /**

     *  Status information: Current Widget, Scan active, Error code.

     */

    volatile uint32 status;

    /**

     *  The bitmask that sets which Widgets are enabled and

     *  scanned, each bit corresponds to one widget.

     */

    uint32 wdgtEnable [CapSense_WDGT_STATUS_WORDS];

    /**

     *  The bitmask that reports activated Widgets (widgets that

     *  detect a touch signal above the threshold), each bit

     *  corresponds to one widget.

     */

    uint32 wdgtStatus [CapSense_WDGT_STATUS_WORDS];

    /**

     *  For Buttons, Sliders, Matrix Buttons and CSD Touchpad each bit

     *  reports status of the individual sensor of the widget: 1 - active

     *  (above the finger threshold); 0 - inactive; For the CSD Touchpad

     *  and CSD Matrix Buttons, the column sensors occupy the least

     *  significant bits. For the Proximity widget, each sensor uses two

     *  bits with the following meaning: 00 - Not active; 01 - Proximity

     *  detected (signal above finger threshold); 11 - A finger touch

     *  detected (signal above the touch threshold); For the CSX Touchpad

     *  Widget, this register provides a number of the detected touches.

     *  The array size is equal to the total number of widgets. The size of

     *  the array element depends on the max number of sensors per

     *  widget used in the current design. It could be 1, 2 or 4 bytes.

     */

    CapSense_SNS_STS_TYPE snsStatus [CapSense_TOTAL_WIDGETS];

    /**

     *  The configuration register for global parameters of the

     *  SENSE_HW0 block.

     */

    uint16 csd0Config;

    /**

     *  The modulator clock divider for the CSD widgets.

     */

    uint8  modCsdClk;

    /**

     *  RAM Widget Objects.

     */

    CapSense_RAM_WD_LIST_STRUCT wdgtList;

    /**

     *  RAM Sensor Objects.

     */

    CapSense_RAM_SNS_LIST_STRUCT snsList;

    /**

     *  The selected widget ID.

     */

    uint8  snrTestWidgetId;

    /**

     *  The selected sensor ID.

     */

    uint8  snrTestSensorId;

    /**

     *  The scan counter.

     */

    uint16 snrTestScanCounter;

    /**

     *  The sensor raw counts.

     */

    uint16 snrTestRawCount [CapSense_NUM_SCAN_FREQS];

} CapSense_RAM_STRUCT;

0 Likes
1 Solution
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Hi David,

"CapSense_UpdateAllBaselines();" Can be removed. This API is required in CapSense_CSD v2.x Component in most cases, but for CapSense v3.x/4.x/5.x Components, the function has been executed in "CapSense_ProcessAllWidgets();".

The code should work as you expected unless CapSense not fine-tuned.

Thanks,

Ryan

View solution in original post

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Nobody said that CapSense_dsRam is for the component's user. It is mainly designed to perform the required capabilities of capsense. When you want to read the value for some buttons just use the APIs to get the data and store that in your own Buffer. There are several examples available which show how to handle that.

If you are not content with the implementation of a component feel free to design your own one. See "Component Author Guide" in your cypress docs.

Bob

0 Likes
David_Zhang
Level 5
Level 5
Distributor - Arrow(GC)
First like received 50 sign-ins 25 sign-ins

     i can't find the example for it,  Capsense V5.1 componet the sample code show in the file, no struction to tell how to use it ,so can you help send the  code <There are several examples available which show how to handle that.>, thanks;

0 Likes
lock attach
Attachments are accessible only for community members.

Update to latest Creator version (4.2), right click on Capsense component and select find code example. Might require an update components.

Attached is the example project:

Bob

0 Likes
David_Zhang
Level 5
Level 5
Distributor - Arrow(GC)
First like received 50 sign-ins 25 sign-ins

Dear Bob:

    your code have show how to I2C to get touch value,  with uint32 CapSense_IsWidgetActive(uint32 widgetId) we know which button is  touched, but how i read the touch value through MCU i2c, for exapmle:

                  uint8  Capsense_Read_Buf[2];

                 

     __enable_irq(); /* Enable global interrupts. */

     EZI2C_Start(); /* Start EZI2C Component */

   

    //EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam),sizeof(CapSense_dsRam),(uint8_t *)&(CapSense_dsRam));

   

    EZI2C_EzI2CSetBuffer1(sizeof(Capsense_Read_Buf), sizeof(Capsense_Read_Buf),Capsense_Read_Buf);

   

    CapSense_Start(); /* Initialize Component */

    CapSense_ScanAllWidgets(); /* Scan all widgets */

   

    for(;;)

    {   

        if(CapSense_NOT_BUSY == CapSense_IsBusy())

        {

            CapSense_UpdateAllBaselines();

            CapSense_ProcessAllWidgets(); /* Process all widgets */

            //CapSense_RunTuner(); /* To sync with Tuner application */

            if (CapSense_IsAnyWidgetActive()) /* Scan result verification */

            {

                 Capsense_Read_Buf[0] = 0x54;

            }else{

                 Capsense_Read_Buf[0] = 0xAA;

            }

            CapSense_ScanAllWidgets(); /* Start next scan */

        }

    }

if it's write? when i read the key is 0XAA without touched.

0 Likes

David, what board are you using? Self made pcb? Prototype Kit?? Which one CY8CKIT-0xx???

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Hi David,

"CapSense_UpdateAllBaselines();" Can be removed. This API is required in CapSense_CSD v2.x Component in most cases, but for CapSense v3.x/4.x/5.x Components, the function has been executed in "CapSense_ProcessAllWidgets();".

The code should work as you expected unless CapSense not fine-tuned.

Thanks,

Ryan

0 Likes