@@ -66,6 +66,18 @@ void RPC::new_service_cb(struct rpmsg_device *rdev, const char *name, uint32_t d
6666 }
6767}
6868
69+ osThreadId eventHandlerThreadId;
70+
71+ void eventHandler () {
72+ eventHandlerThreadId = osThreadGetId ();
73+ while (1 ) {
74+ osEvent v = osSignalWait (0 , osWaitForever);
75+ #ifdef CORE_CM4
76+ delay (50 );
77+ #endif
78+ OPENAMP_check_for_message ();
79+ }
80+ }
6981
7082#ifdef CORE_CM4
7183int RPC::begin () {
@@ -75,6 +87,9 @@ int RPC::begin() {
7587 /* HW semaphore Notification enable*/
7688 HAL_HSEM_ActivateNotification (__HAL_HSEM_SEMID_TO_MASK (HSEM_ID_0));
7789
90+ eventThread = new rtos::Thread (osPriorityHigh);
91+ eventThread->start (&eventHandler);
92+
7893 /* Inilitize OpenAmp and libmetal libraries */
7994 if (MX_OPENAMP_Init (RPMSG_REMOTE, NULL ) != 0 ) {
8095 return 0 ;
@@ -107,10 +122,6 @@ int RPC::begin() {
107122 return 0 ;
108123 }
109124
110- eventThread = new rtos::Thread (osPriorityNormal);
111- eventThread->start (callback (&eventQueue, &events::EventQueue::dispatch_forever));
112- ticker.attach (eventQueue.event (&OPENAMP_check_for_message), 0 .01f );
113-
114125 dispatcherThread = new rtos::Thread (osPriorityNormal);
115126 dispatcherThread->start (mbed::callback (this , &RPC::dispatch));
116127
@@ -157,8 +168,8 @@ int RPC::begin() {
157168 // HAL_SYSCFG_EnableCM4BOOT();
158169 HAL_RCCEx_EnableBootCore (RCC_BOOT_C2);
159170
160- /* Initialize the mailbox use notify the other core on new message */
161- MAILBOX_Init ( );
171+ eventThread = new rtos::Thread (osPriorityHigh);
172+ eventThread-> start (&eventHandler );
162173
163174 /* Initialize OpenAmp and libmetal libraries */
164175 if (MX_OPENAMP_Init (RPMSG_MASTER, new_service_cb) != HAL_OK) {
@@ -191,10 +202,6 @@ int RPC::begin() {
191202 OPENAMP_send (&rp_endpoints[1 ], &message, sizeof (message));
192203 OPENAMP_send (&rp_endpoints[2 ], &message, sizeof (message));
193204
194- // eventThread = new rtos::Thread(osPriorityNormal);
195- // eventThread->start(callback(&eventQueue, &events::EventQueue::dispatch_forever));
196- // ticker.attach(eventQueue.event(&OPENAMP_check_for_message), 0.01f);
197-
198205 dispatcherThread = new rtos::Thread (osPriorityNormal);
199206 dispatcherThread->start (mbed::callback (this , &RPC::dispatch));
200207
0 commit comments