leo hendrickson / Mbed OS example-Ethernet-mbed-Cloud-connect
Committer:
leothedragon
Date:
Tue May 04 08:55:12 2021 +0000
Revision:
0:8f0bb79ddd48
nmn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leothedragon 0:8f0bb79ddd48 1 // ----------------------------------------------------------------------------
leothedragon 0:8f0bb79ddd48 2 // Copyright 2015-2017 ARM Ltd.
leothedragon 0:8f0bb79ddd48 3 //
leothedragon 0:8f0bb79ddd48 4 // SPDX-License-Identifier: Apache-2.0
leothedragon 0:8f0bb79ddd48 5 //
leothedragon 0:8f0bb79ddd48 6 // Licensed under the Apache License, Version 2.0 (the "License");
leothedragon 0:8f0bb79ddd48 7 // you may not use this file except in compliance with the License.
leothedragon 0:8f0bb79ddd48 8 // You may obtain a copy of the License at
leothedragon 0:8f0bb79ddd48 9 //
leothedragon 0:8f0bb79ddd48 10 // http://www.apache.org/licenses/LICENSE-2.0
leothedragon 0:8f0bb79ddd48 11 //
leothedragon 0:8f0bb79ddd48 12 // Unless required by applicable law or agreed to in writing, software
leothedragon 0:8f0bb79ddd48 13 // distributed under the License is distributed on an "AS IS" BASIS,
leothedragon 0:8f0bb79ddd48 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
leothedragon 0:8f0bb79ddd48 15 // See the License for the specific language governing permissions and
leothedragon 0:8f0bb79ddd48 16 // limitations under the License.
leothedragon 0:8f0bb79ddd48 17 // ----------------------------------------------------------------------------
leothedragon 0:8f0bb79ddd48 18
leothedragon 0:8f0bb79ddd48 19 #if defined(ATOMIC_QUEUE_USE_PAL) && !defined(TARGET_LIKE_MBED)
leothedragon 0:8f0bb79ddd48 20
leothedragon 0:8f0bb79ddd48 21 #include <stdint.h>
leothedragon 0:8f0bb79ddd48 22 #include <assert.h>
leothedragon 0:8f0bb79ddd48 23
leothedragon 0:8f0bb79ddd48 24 #include "pal.h"
leothedragon 0:8f0bb79ddd48 25 // Module include
leothedragon 0:8f0bb79ddd48 26 #include "aq_critical.h"
leothedragon 0:8f0bb79ddd48 27
leothedragon 0:8f0bb79ddd48 28 static palMutexID_t mutex = NULLPTR;
leothedragon 0:8f0bb79ddd48 29
leothedragon 0:8f0bb79ddd48 30 void aq_critical_section_enter(void)
leothedragon 0:8f0bb79ddd48 31 {
leothedragon 0:8f0bb79ddd48 32 if (mutex == NULLPTR) {
leothedragon 0:8f0bb79ddd48 33 palStatus_t rc = pal_osMutexCreate(&mutex);
leothedragon 0:8f0bb79ddd48 34 assert(rc == PAL_SUCCESS);
leothedragon 0:8f0bb79ddd48 35 }
leothedragon 0:8f0bb79ddd48 36
leothedragon 0:8f0bb79ddd48 37 palStatus_t rc = pal_osMutexWait(mutex, PAL_RTOS_WAIT_FOREVER);
leothedragon 0:8f0bb79ddd48 38 assert(rc == PAL_SUCCESS);
leothedragon 0:8f0bb79ddd48 39 }
leothedragon 0:8f0bb79ddd48 40
leothedragon 0:8f0bb79ddd48 41 void aq_critical_section_exit(void)
leothedragon 0:8f0bb79ddd48 42 {
leothedragon 0:8f0bb79ddd48 43 palStatus_t rc = pal_osMutexRelease(mutex);
leothedragon 0:8f0bb79ddd48 44 assert(rc == PAL_SUCCESS);
leothedragon 0:8f0bb79ddd48 45 }
leothedragon 0:8f0bb79ddd48 46
leothedragon 0:8f0bb79ddd48 47 #endif // defined(ATOMIC_QUEUE_USE_PAL)