aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Svärd <jonny.svaerd@arm.com>2023-01-16 16:05:36 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2023-01-25 13:32:14 +0000
commit87f6f7ebf5a51be7c819503894f486d05f2a8b31 (patch)
tree0feef6ceed67c358b9572be171b4ffc58cc88d44
parent8f813b382c1ad54b9c9f5d34bab1e8892383c530 (diff)
downloadethos-u-core-platform-87f6f7ebf5a51be7c819503894f486d05f2a8b31.tar.gz
Change app examples to use counting semaphore
Adapt to Ethos-U driver changes Change-Id: I5a10f9166f4d9ac32a1502409e1708ea62844944
-rw-r--r--applications/freertos/main.cpp8
-rw-r--r--applications/message_handler/lib/core_driver_mutex.cpp10
2 files changed, 7 insertions, 11 deletions
diff --git a/applications/freertos/main.cpp b/applications/freertos/main.cpp
index d579944..712b9a4 100644
--- a/applications/freertos/main.cpp
+++ b/applications/freertos/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2022 Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright 2019-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -167,7 +167,7 @@ int ethosu_mutex_unlock(void *mutex) {
}
void *ethosu_semaphore_create(void) {
- SemaphoreHandle_t sem = xSemaphoreCreateBinary();
+ SemaphoreHandle_t sem = xSemaphoreCreateCounting(255, 0); // max, initial val
if (sem == NULL) {
printf("Error: Failed to create semaphore.\n");
}
@@ -192,10 +192,8 @@ int ethosu_semaphore_give(void *sem) {
return -1;
}
} else {
- /* A FreeRTOS binary semaphore is fundamentally a queue that can only hold one item. If the queue is full,
- * xSemaphoreGive will return a pdFALSE value. Ignoring the return value in here, as a semaphore give failure
- * does not affect the application correctness. */
if (xSemaphoreGive(handle) != pdTRUE) {
+ printf("Error: Failed to give semaphore.\n");
// do nothing
}
}
diff --git a/applications/message_handler/lib/core_driver_mutex.cpp b/applications/message_handler/lib/core_driver_mutex.cpp
index bc043fa..d023ad2 100644
--- a/applications/message_handler/lib/core_driver_mutex.cpp
+++ b/applications/message_handler/lib/core_driver_mutex.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Arm Limited.
+ * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -49,7 +49,7 @@ int ethosu_mutex_unlock(void *mutex) {
}
void *ethosu_semaphore_create(void) {
- return xSemaphoreCreateBinary();
+ return xSemaphoreCreateCounting(255, 0);
}
int ethosu_semaphore_take(void *sem) {
@@ -69,11 +69,9 @@ int ethosu_semaphore_give(void *sem) {
return -1;
}
} else {
- /* A FreeRTOS binary semaphore is fundamentally a queue that can only hold one item. If the queue is full,
- * xSemaphoreGive will return a pdFALSE value. Ignoring the return value in here, as a semaphore give failure
- * does not affect the application correctness. */
if (xSemaphoreGive(handle) != pdTRUE) {
- // do nothing
+ printf("Error: Failed to give semaphore.\n");
+ return -1;
}
}
return 0;