Use esp structure passed to thread
@@ -52,7 +52,7 @@ esp_thread_producer(void* const arg) {
ESP_CORE_PROTECT(); /* Protect system */
while (1) {
ESP_CORE_UNPROTECT(); /* Unprotect system */
- time = esp_sys_mbox_get(&esp.mbox_producer, (void **)&msg, 0); /* Get message from queue */
+ time = esp_sys_mbox_get(&e->mbox_producer, (void **)&msg, 0); /* Get message from queue */
ESP_THREAD_PRODUCER_HOOK(); /* Execute producer thread hook */
ESP_CORE_PROTECT(); /* Protect system */
if (time == ESP_SYS_TIMEOUT || msg == NULL) { /* Check valid message */
@@ -110,7 +110,7 @@ esp_thread_producer(void* const arg) {
} else {
ESP_MSG_VAR_FREE(msg); /* Release message structure */
}
- esp.msg = NULL;
+ e->msg = NULL;
}
}
@@ -124,6 +124,7 @@ esp_thread_producer(void* const arg) {
*/
void
esp_thread_process(void* const arg) {
+ esp_t* e = arg; /* Thread argument is main structure */
esp_msg_t* msg;
uint32_t time;
@@ -131,7 +132,7 @@ esp_thread_process(void* const arg) {
ESP_CORE_PROTECT(); /* Protect system */
while (1) {
ESP_CORE_UNPROTECT(); /* Unprotect system */
- time = espi_get_from_mbox_with_timeout_checks(&esp.mbox_process, (void **)&msg, 10); /* Get message from queue */
+ time = espi_get_from_mbox_with_timeout_checks(&e->mbox_process, (void **)&msg, 10); /* Get message from queue */
ESP_THREAD_PROCESS_HOOK(); /* Execute process thread hook */
ESP_CORE_PROTECT(); /* Protect system */
@@ -147,7 +148,7 @@ esp_thread_process(void* const arg) {
* If there are no timeouts to process, we can wait unlimited time.
* In case new timeout occurs, thread will wake up by writing new element to mbox process queue
*/
- time = espi_get_from_mbox_with_timeout_checks(&esp.mbox_process, (void **)&msg, 0);
+ time = espi_get_from_mbox_with_timeout_checks(&e->mbox_process, (void **)&msg, 0);
ESP_THREAD_PROCESS_HOOK(); /* Execute process thread hook */
ESP_UNUSED(time);
#endif /* !ESP_CFG_INPUT_USE_PROCESS */
