Renesas GR-PEACH OpenCV Development / gr-peach-opencv-project-sd-card_update

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:54 2017 +0000
Revision:
167:2ee3e82cb6f5
gr-peach-opencv-project-sd-card

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 167:2ee3e82cb6f5 1 /* mbed Microcontroller Library
thedo 167:2ee3e82cb6f5 2 * Copyright (c) 2006-2013 ARM Limited
thedo 167:2ee3e82cb6f5 3 *
thedo 167:2ee3e82cb6f5 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 167:2ee3e82cb6f5 5 * you may not use this file except in compliance with the License.
thedo 167:2ee3e82cb6f5 6 * You may obtain a copy of the License at
thedo 167:2ee3e82cb6f5 7 *
thedo 167:2ee3e82cb6f5 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 167:2ee3e82cb6f5 9 *
thedo 167:2ee3e82cb6f5 10 * Unless required by applicable law or agreed to in writing, software
thedo 167:2ee3e82cb6f5 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 167:2ee3e82cb6f5 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 167:2ee3e82cb6f5 13 * See the License for the specific language governing permissions and
thedo 167:2ee3e82cb6f5 14 * limitations under the License.
thedo 167:2ee3e82cb6f5 15 */
thedo 167:2ee3e82cb6f5 16
thedo 167:2ee3e82cb6f5 17 // This implementation of the wait functions will be compiled only
thedo 167:2ee3e82cb6f5 18 // if the RTOS is present.
thedo 167:2ee3e82cb6f5 19 #ifdef MBED_CONF_RTOS_PRESENT
thedo 167:2ee3e82cb6f5 20
thedo 167:2ee3e82cb6f5 21 #include "platform/mbed_wait_api.h"
thedo 167:2ee3e82cb6f5 22 #include "hal/us_ticker_api.h"
thedo 167:2ee3e82cb6f5 23 #include "rtos/rtos.h"
thedo 167:2ee3e82cb6f5 24 #include "platform/mbed_critical.h"
thedo 167:2ee3e82cb6f5 25
thedo 167:2ee3e82cb6f5 26 void wait(float s) {
thedo 167:2ee3e82cb6f5 27 wait_us(s * 1000000.0f);
thedo 167:2ee3e82cb6f5 28 }
thedo 167:2ee3e82cb6f5 29
thedo 167:2ee3e82cb6f5 30 void wait_ms(int ms) {
thedo 167:2ee3e82cb6f5 31 wait_us(ms * 1000);
thedo 167:2ee3e82cb6f5 32 }
thedo 167:2ee3e82cb6f5 33
thedo 167:2ee3e82cb6f5 34 void wait_us(int us) {
thedo 167:2ee3e82cb6f5 35 uint32_t start = us_ticker_read();
thedo 167:2ee3e82cb6f5 36 // Use the RTOS to wait for millisecond delays if possible
thedo 167:2ee3e82cb6f5 37 int ms = us / 1000;
thedo 167:2ee3e82cb6f5 38 if ((ms > 0) && core_util_are_interrupts_enabled()) {
thedo 167:2ee3e82cb6f5 39 Thread::wait((uint32_t)ms);
thedo 167:2ee3e82cb6f5 40 }
thedo 167:2ee3e82cb6f5 41 // Use busy waiting for sub-millisecond delays, or for the whole
thedo 167:2ee3e82cb6f5 42 // interval if interrupts are not enabled
thedo 167:2ee3e82cb6f5 43 while ((us_ticker_read() - start) < (uint32_t)us);
thedo 167:2ee3e82cb6f5 44 }
thedo 167:2ee3e82cb6f5 45
thedo 167:2ee3e82cb6f5 46 #endif // #if MBED_CONF_RTOS_PRESENT
thedo 167:2ee3e82cb6f5 47
thedo 167:2ee3e82cb6f5 48