From c1bf7c6c1bfd4bd601a76790d37603bfe2365dc5 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 27 Sep 2017 11:22:49 +0530 Subject: examples: rpmsg: Update Vybrid rpmsg examples Update Vybrid rpmsg examples bringing it in sync with FreeRTOS BSP 1.0.1 release for iMX7 from NXP. Signed-off-by: Sanchayan Maity Signed-off-by: Stefan Agner --- .../demo_apps/rpmsg/pingpong/pingpong.c | 94 ++++++++-------------- 1 file changed, 34 insertions(+), 60 deletions(-) (limited to 'examples/vf6xx_colibri_m4/demo_apps/rpmsg/pingpong/pingpong.c') diff --git a/examples/vf6xx_colibri_m4/demo_apps/rpmsg/pingpong/pingpong.c b/examples/vf6xx_colibri_m4/demo_apps/rpmsg/pingpong/pingpong.c index 6fa1d1c..4cef46c 100644 --- a/examples/vf6xx_colibri_m4/demo_apps/rpmsg/pingpong/pingpong.c +++ b/examples/vf6xx_colibri_m4/demo_apps/rpmsg/pingpong/pingpong.c @@ -39,6 +39,7 @@ #include #include "debug_console_vf6xx.h" #include "pin_mux.h" +#include "rpmsg/rpmsg_rtos.h" /* * function decalaration for platform provided facility @@ -51,48 +52,49 @@ extern void platform_interrupt_disable(void); */ #define APP_MSCM_IRQ_PRIORITY 3 -/* Internal functions */ -static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl); -static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl); -static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *, unsigned long); +typedef struct the_message +{ + uint32_t DATA; +} THE_MESSAGE, *THE_MESSAGE_PTR; -/* Globals */ -static struct remote_device *rdev; -static struct rpmsg_channel *app_chnl; -static uint32_t msg_var; -static SemaphoreHandle_t app_sema; /*! * @brief A basic RPMSG task */ -void PingPongTask(void *pvParameters) +static void PingPongTask (void* param) { - printf("RPMSG PingPong Demo...\r\n"); - - app_sema = xSemaphoreCreateCounting(2, 0); + int result; + struct remote_device *rdev = NULL; + struct rpmsg_channel *app_chnl = NULL; + THE_MESSAGE msg = {0}; + int len; + + /* Print the initial banner */ + PRINTF("\r\nRPMSG PingPong FreeRTOS RTOS API Demo...\r\n"); + + PRINTF("RPMSG Init as Remote\r\n"); + result = rpmsg_rtos_init(0 /*REMOTE_CPU_ID*/, &rdev, RPMSG_MASTER, &app_chnl); + assert(0 == result); + + PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst); + + while (true) + { + /* receive/send data to channel default ept */ + result = rpmsg_rtos_recv(app_chnl->rp_ept, &msg, &len, sizeof(THE_MESSAGE), NULL, 0xFFFFFFFF); + assert(0 == result); + PRINTF("Get Data From Master Side : %d\r\n", msg.DATA); + msg.DATA++; + result = rpmsg_rtos_send(app_chnl->rp_ept, &msg, sizeof(THE_MESSAGE), app_chnl->dst); + assert(0 == result); + } - printf("RPMSG Init as Remote\r\n"); + /* If destruction required */ /* - * RPMSG Init as REMOTE - */ - rpmsg_init(0, &rdev, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, RPMSG_MASTER); + PRINTF("\r\nMessage pingpong finished\r\n"); - /* - * rpmsg_channel_created will post the first semaphore + rpmsg_rtos_deinit(rdev); */ - xSemaphoreTake(app_sema, portMAX_DELAY); - printf("Name service handshake is done, M4 has setup a rpmsg channel [%lu ---> %lu]\r\n", app_chnl->src, app_chnl->dst); - - - /* - * pingpong demo loop - */ - for (;;) { - xSemaphoreTake(app_sema, portMAX_DELAY); - printf("Get Data From A5 : %lu\r\n", msg_var); - msg_var++; - rpmsg_send(app_chnl, (void*)&msg_var, sizeof(uint32_t)); - } } int main(void) @@ -125,34 +127,6 @@ int main(void) while (true); } -/* rpmsg_rx_callback will call into this for a channel creation event*/ -static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) -{ - /* - * we should give the created rp_chnl handler to app layer - */ - app_chnl = rp_chnl; - - /* - * sync to application layer - */ - xSemaphoreGiveFromISR(app_sema, NULL); -} - -static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) -{ - rpmsg_destroy_ept(rp_chnl->rp_ept); -} - -static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len, - void * priv, unsigned long src) -{ - msg_var = *(uint32_t*)data; - /* - * sync to application layer - */ - xSemaphoreGiveFromISR(app_sema, NULL); -} /******************************************************************************* * EOF ******************************************************************************/ -- cgit v1.2.3