@@ -66,6 +66,18 @@ void RPC::new_service_cb(struct rpmsg_device *rdev, const char *name, uint32_t d
66
66
}
67
67
}
68
68
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
+ }
69
81
70
82
#ifdef CORE_CM4
71
83
int RPC::begin () {
@@ -75,6 +87,9 @@ int RPC::begin() {
75
87
/* HW semaphore Notification enable*/
76
88
HAL_HSEM_ActivateNotification (__HAL_HSEM_SEMID_TO_MASK (HSEM_ID_0));
77
89
90
+ eventThread = new rtos::Thread (osPriorityHigh);
91
+ eventThread->start (&eventHandler);
92
+
78
93
/* Inilitize OpenAmp and libmetal libraries */
79
94
if (MX_OPENAMP_Init (RPMSG_REMOTE, NULL ) != 0 ) {
80
95
return 0 ;
@@ -107,10 +122,6 @@ int RPC::begin() {
107
122
return 0 ;
108
123
}
109
124
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
-
114
125
dispatcherThread = new rtos::Thread (osPriorityNormal);
115
126
dispatcherThread->start (mbed::callback (this , &RPC::dispatch));
116
127
@@ -157,8 +168,8 @@ int RPC::begin() {
157
168
// HAL_SYSCFG_EnableCM4BOOT();
158
169
HAL_RCCEx_EnableBootCore (RCC_BOOT_C2);
159
170
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 );
162
173
163
174
/* Initialize OpenAmp and libmetal libraries */
164
175
if (MX_OPENAMP_Init (RPMSG_MASTER, new_service_cb) != HAL_OK) {
@@ -191,10 +202,6 @@ int RPC::begin() {
191
202
OPENAMP_send (&rp_endpoints[1 ], &message, sizeof (message));
192
203
OPENAMP_send (&rp_endpoints[2 ], &message, sizeof (message));
193
204
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
-
198
205
dispatcherThread = new rtos::Thread (osPriorityNormal);
199
206
dispatcherThread->start (mbed::callback (this , &RPC::dispatch));
200
207
0 commit comments