this hurts

Dependencies:   FFT

Committer:
shyamgatech
Date:
Thu Dec 03 18:15:35 2020 +0000
Revision:
7:0d62545e6d73
Parent:
0:d6c9b09b4042
addded gui mbed code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
annieluo2 0:d6c9b09b4042 1 /* mbed Microcontroller Library
annieluo2 0:d6c9b09b4042 2 * Copyright (c) 2006-2012 ARM Limited
annieluo2 0:d6c9b09b4042 3 *
annieluo2 0:d6c9b09b4042 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
annieluo2 0:d6c9b09b4042 5 * of this software and associated documentation files (the "Software"), to deal
annieluo2 0:d6c9b09b4042 6 * in the Software without restriction, including without limitation the rights
annieluo2 0:d6c9b09b4042 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
annieluo2 0:d6c9b09b4042 8 * copies of the Software, and to permit persons to whom the Software is
annieluo2 0:d6c9b09b4042 9 * furnished to do so, subject to the following conditions:
annieluo2 0:d6c9b09b4042 10 *
annieluo2 0:d6c9b09b4042 11 * The above copyright notice and this permission notice shall be included in
annieluo2 0:d6c9b09b4042 12 * all copies or substantial portions of the Software.
annieluo2 0:d6c9b09b4042 13 *
annieluo2 0:d6c9b09b4042 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
annieluo2 0:d6c9b09b4042 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
annieluo2 0:d6c9b09b4042 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
annieluo2 0:d6c9b09b4042 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
annieluo2 0:d6c9b09b4042 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
annieluo2 0:d6c9b09b4042 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
annieluo2 0:d6c9b09b4042 20 * SOFTWARE.
annieluo2 0:d6c9b09b4042 21 */
annieluo2 0:d6c9b09b4042 22 #include "rtos/Semaphore.h"
annieluo2 0:d6c9b09b4042 23
annieluo2 0:d6c9b09b4042 24 #include <string.h>
annieluo2 0:d6c9b09b4042 25
annieluo2 0:d6c9b09b4042 26 namespace rtos {
annieluo2 0:d6c9b09b4042 27
annieluo2 0:d6c9b09b4042 28 Semaphore::Semaphore(int32_t count) {
annieluo2 0:d6c9b09b4042 29 #ifdef CMSIS_OS_RTX
annieluo2 0:d6c9b09b4042 30 memset(_semaphore_data, 0, sizeof(_semaphore_data));
annieluo2 0:d6c9b09b4042 31 _osSemaphoreDef.semaphore = _semaphore_data;
annieluo2 0:d6c9b09b4042 32 #endif
annieluo2 0:d6c9b09b4042 33 _osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
annieluo2 0:d6c9b09b4042 34 }
annieluo2 0:d6c9b09b4042 35
annieluo2 0:d6c9b09b4042 36 int32_t Semaphore::wait(uint32_t millisec) {
annieluo2 0:d6c9b09b4042 37 return osSemaphoreWait(_osSemaphoreId, millisec);
annieluo2 0:d6c9b09b4042 38 }
annieluo2 0:d6c9b09b4042 39
annieluo2 0:d6c9b09b4042 40 osStatus Semaphore::release(void) {
annieluo2 0:d6c9b09b4042 41 return osSemaphoreRelease(_osSemaphoreId);
annieluo2 0:d6c9b09b4042 42 }
annieluo2 0:d6c9b09b4042 43
annieluo2 0:d6c9b09b4042 44 Semaphore::~Semaphore() {
annieluo2 0:d6c9b09b4042 45 osSemaphoreDelete(_osSemaphoreId);
annieluo2 0:d6c9b09b4042 46 }
annieluo2 0:d6c9b09b4042 47
annieluo2 0:d6c9b09b4042 48 }