mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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