aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Svärd <jonny.svaerd@arm.com>2023-12-18 18:26:44 +0100
committerJonny Svärd <jonny.svaerd@arm.com>2023-12-19 16:15:57 +0000
commit244a310a799a414c38c7e9f4bb757319f9bb6866 (patch)
tree3a2914e0b4c346eccf9ff3549847d9d3c784d6d2
parent918cd906a3f3d2b130a5a3c551d795cf43150f1c (diff)
downloadethos-u-core-platform-244a310a799a414c38c7e9f4bb757319f9bb6866.tar.gz
Add app support for core_driver inference timeout
Update example applications to support new core_driver inference timeout feature. Change-Id: Ib7283421aa8db9a3b5f1dd6d1bd44803491f0399 Signed-off-by: Jonny Svärd <jonny.svaerd@arm.com>
-rw-r--r--applications/freertos/main.cpp6
-rw-r--r--applications/message_handler_openamp/core_driver_mutex.cpp7
-rw-r--r--applications/threadx_demo/main.cpp9
3 files changed, 10 insertions, 12 deletions
diff --git a/applications/freertos/main.cpp b/applications/freertos/main.cpp
index 6ba369b..2dbc3a8 100644
--- a/applications/freertos/main.cpp
+++ b/applications/freertos/main.cpp
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright 2019-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
- *
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
@@ -174,10 +173,9 @@ void *ethosu_semaphore_create(void) {
return (void *)sem;
}
-int ethosu_semaphore_take(void *sem) {
+int ethosu_semaphore_take(void *sem, uint64_t timeout) {
SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(sem);
- if (xSemaphoreTake(handle, portMAX_DELAY) != pdTRUE) {
- printf("Error: Failed to take semaphore.\n");
+ if (xSemaphoreTake(handle, (TickType_t)timeout) != pdTRUE) {
return -1;
}
return 0;
diff --git a/applications/message_handler_openamp/core_driver_mutex.cpp b/applications/message_handler_openamp/core_driver_mutex.cpp
index d023ad2..7948bd0 100644
--- a/applications/message_handler_openamp/core_driver_mutex.cpp
+++ b/applications/message_handler_openamp/core_driver_mutex.cpp
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
- *
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
@@ -52,10 +51,10 @@ void *ethosu_semaphore_create(void) {
return xSemaphoreCreateCounting(255, 0);
}
-int ethosu_semaphore_take(void *sem) {
+int ethosu_semaphore_take(void *sem, uint64_t timeout) {
SemaphoreHandle_t handle = reinterpret_cast<SemaphoreHandle_t>(sem);
- if (xSemaphoreTake(handle, portMAX_DELAY) != pdTRUE) {
- printf("Error: Failed to take semaphore.\n");
+ if (xSemaphoreTake(handle, (TickType_t)timeout) != pdTRUE) {
+ // Semaphore take timed out
return -1;
}
return 0;
diff --git a/applications/threadx_demo/main.cpp b/applications/threadx_demo/main.cpp
index 1211c78..c77c758 100644
--- a/applications/threadx_demo/main.cpp
+++ b/applications/threadx_demo/main.cpp
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright 2019-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
- *
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
@@ -192,13 +191,15 @@ void *ethosu_semaphore_create(void) {
return (void *)semaphore;
}
-int ethosu_semaphore_take(void *sem) {
+int ethosu_semaphore_take(void *sem, uint64_t timeout) {
UINT status;
- status = tx_semaphore_get(reinterpret_cast<TX_SEMAPHORE *>(sem), TX_WAIT_FOREVER);
+ status = tx_semaphore_get(reinterpret_cast<TX_SEMAPHORE *>(sem), (ULONG)timeout);
if (status != TX_SUCCESS) {
- printf("Semaphore get/take, error - %u\n", status);
+ if (status != TX_NO_INSTANCE) {
+ printf("Semaphore get/take, error - %u\n", status);
+ }
return -1;
}