Analog Devices / platform_drivers

Dependents:   EVAL-CN0535-FMCZ EVAL-CN0535-FMCZ EVAL-AD568x-AD569x EVAL-AD7606 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers delay.cpp Source File

delay.cpp

Go to the documentation of this file.
00001 /***************************************************************************//**
00002  *   @file   delay.cpp
00003  *   @brief  Implementation of Mbed specific delay functionality
00004 ********************************************************************************
00005  * Copyright (c) 2019 - 2021 Analog Devices, Inc.
00006  * All rights reserved.
00007  *
00008  * This software is proprietary to Analog Devices, Inc. and its licensors.
00009  * By using this software you agree to the terms of the associated
00010  * Analog Devices Software License Agreement.
00011 *******************************************************************************/
00012 
00013 /******************************************************************************/
00014 /***************************** Include Files **********************************/
00015 /******************************************************************************/
00016 
00017 #include <mbed.h>
00018 
00019 // Platform drivers needs to be C-compatible to work with other drivers
00020 #ifdef __cplusplus
00021 extern "C"
00022 {
00023 #endif //  _cplusplus 
00024 
00025 #include "delay.h"
00026 
00027 /******************************************************************************/
00028 /********************** Macros and Constants Definitions **********************/
00029 /******************************************************************************/
00030 
00031 /******************************************************************************/
00032 /************************ Functions Definitions *******************************/
00033 /******************************************************************************/
00034 
00035 /**
00036  * @brief Generate microseconds delay.
00037  * @param usecs - Delay in microseconds.
00038  * @return None.
00039  */
00040 void udelay(uint32_t usecs)
00041 {
00042     /* wait_ns is more time efficient function compared to wait_us
00043      * Note: For higher values of delay (more than few msec), it is better to use
00044      * mdelay() function as no error/limit checking is done in this function */
00045     wait_ns(usecs * 1000);
00046 }
00047 
00048 /**
00049  * @brief Generate miliseconds delay.
00050  * @param msecs - Delay in miliseconds.
00051  * @return None.
00052  */
00053 void mdelay(uint32_t msecs)
00054 {
00055     if (msecs) {
00056         thread_sleep_for(msecs);
00057     }
00058 }
00059 
00060 #ifdef __cplusplus  // Closing extern c
00061 }
00062 #endif //  _cplusplus