1 Reply Latest reply on Apr 30, 2020 4:03 AM by RakshithM_16

    Suggestion for better documentation for Cy_IPC_Pipe_SendMessage

    user_1669321

      Hi,

       

      I think the documentation of Cy_IPC_Pipe_SendMessage should be clearer, specifically for the parameter void * msgPtr.

       

      I thought at first that it can be any type of structure, but by stepping through the code, the first element of the structure is actually a scratchpad provided to the PDL. Even in CE223820, the structure ipc_msg_t defines the fields for that, but no comment clarifies it, so I just ignored this structure when I first tried implementing IPC messages.

       

      Even the Function Usage section of the PDL documentation only seems to "suggest" the uint32 array instead of insisting on the fact that the first element must be a uint32 populated with the fields client, user, intrmask.

       

      For anyone wondering, here's my message structure, which works with the function call scheme used in CE223820:

       

      typedef enum {

           MSG_TYPE_1,

           MSG_TYPE_2

      } MsgType;

       

      typedef struct {

           uint32_t scratchpad;

           MsgType type;

           uint8_t* data;

      } IpcSharedMsg;

       

      // CM4 code

      volatile IpcSharedMsg msg;

      ipcMsg.scratchpad = _VAL2FLD(CY_IPC_PIPE_MSG_CLIENT , CY_IPC_EP_CYPIPE_ADDR)

                        | _VAL2FLD(CY_IPC_PIPE_MSG_USR    , 0)

                        | _VAL2FLD(CY_IPC_PIPE_MSG_RELEASE, CY_IPC_CYPIPE_INTR_MASK);

       

      // CM0+ code

      volatile IpcSharedMsg msg;

      ipcMsg.scratchpad = _VAL2FLD(CY_IPC_PIPE_MSG_CLIENT , CY_IPC_EP_CYPIPE_ADDR)

                        | _VAL2FLD(CY_IPC_PIPE_MSG_USR    , 0)

                        | _VAL2FLD(CY_IPC_PIPE_MSG_RELEASE, CY_IPC_CYPIPE_INTR_MASK);

       

      And then I only change the type and data fields, depending on the message.

       

      Thanks,

      Fred