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.

MCU-PLUS-SDK-AM64X: About Registering RPMessage Callbacks in Callback Mode

Part Number: MCU-PLUS-SDK-AM64X

I am trying to use the RPMessage feature in callback mode, and I would like to confirm whether my understanding is correct. Could you please review the following points?


1.

In the function int32_t RPMessage_controlEndPtInit(void) within ipc_rpmsg.c, the following behavior is implemented:
When localEndPt equals RPMESSAGE_CTRL_ENDPOINT_ID, the callback function RPMessage_controlEndPtHandler is invoked.


2.

The return type of the callback function RPMessage_controlEndPtHandler should be RPMessage_RecvCallback, not void.
I am asking because I found the following post indicating that using void did not work for someone:
https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1203769/mcu-plus-sdk-am243x-rpmessage-with-callback-interrupt


3.

When localEndPt is set to a value that is not RPMESSAGE_CTRL_ENDPOINT_ID, it should be possible to configure RPMessage so that a different callback function is invoked.


4.

If I write code like the following, I believe the callback function RPMessage_User_Callback_Handler will be triggered for local endpoints 0 through 6:

for (int i = 0 ; i < 7 ; i++)
{
    RPMessage_CreateParams_init(&createPrms);
    createPrms.localEndPt = i;
    createPrms.recvCallback = RPMessage_User_Callback_Handler;
    status = RPMessage_construct(&gIpcRpmsgCtrl.controlEndPtObj, &createPrms);
    if (SystemP_SUCCESS != status)
    {
        break;
    }
}

5.

Callback registration is performed at the moment when RPMessage_construct is called, and there is no restriction on when RPMessage_construct can be invoked (i.e., callbacks can be added or removed freely within the application).

Could you please confirm whether the above understanding is correct?

  • In the function int32_t RPMessage_controlEndPtInit(void) within ipc_rpmsg.c, the following behavior is implemented:
    When localEndPt equals RPMESSAGE_CTRL_ENDPOINT_ID, the callback function RPMessage_controlEndPtHandler is invoked.

    Yes, this is correct.

    The return type of the callback function RPMessage_controlEndPtHandler should be RPMessage_RecvCallback, not void.

    As I can see in the driver code, the RPMessage_controlEndPtHandler() is not returning any value, hence the return type void is correct here.

    When localEndPt is set to a value that is not RPMESSAGE_CTRL_ENDPOINT_ID, it should be possible to configure RPMessage so that a different callback function is invoked.

    By above, do you mean to configure callback function for a endpoint different than RPMESSAGE_CTRL_ENDPOINT_ID?

    If I write code like the following, I believe the callback function RPMessage_User_Callback_Handler will be triggered for local endpoints 0 through 6

    Yes, the above is true.

    Callback registration is performed at the moment when RPMessage_construct is called, and there is no restriction on when RPMessage_construct can be invoked (i.e., callbacks can be added or removed freely within the application).

    Yes, you can call the RPMessage_construct API within the application.

    Regards,

    Tushar

  • Hi Tushar-san,

    Thank you very much for your clear answers.
    I have reviewed your comments, and I now understand the behavior correctly.

    Regarding your question:

    >“By above, do you mean to configure a callback function for an endpoint different than RPMESSAGE_CTRL_ENDPOINT_ID?”

    Yes — that is exactly what I meant.
    I wanted to confirm that for endpoints other than RPMESSAGE_CTRL_ENDPOINT_ID, it is possible to assign a user‑defined callback function through RPMessage_construct, and your explanation has clarified this.

    Thanks again for your support.

    Best regards,
    Hiroki Hoshina