The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_SDT32620B/TOOLCHAIN_IAR/tmr_utils.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 167:84c0a372a020 | 1 | /** |
AnnaBridge | 167:84c0a372a020 | 2 | * @file |
AnnaBridge | 167:84c0a372a020 | 3 | * @brief Timer utility functions. |
AnnaBridge | 167:84c0a372a020 | 4 | */ |
AnnaBridge | 167:84c0a372a020 | 5 | /* ***************************************************************************** |
AnnaBridge | 167:84c0a372a020 | 6 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
AnnaBridge | 167:84c0a372a020 | 7 | * |
AnnaBridge | 167:84c0a372a020 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
AnnaBridge | 167:84c0a372a020 | 9 | * copy of this software and associated documentation files (the "Software"), |
AnnaBridge | 167:84c0a372a020 | 10 | * to deal in the Software without restriction, including without limitation |
AnnaBridge | 167:84c0a372a020 | 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
AnnaBridge | 167:84c0a372a020 | 12 | * and/or sell copies of the Software, and to permit persons to whom the |
AnnaBridge | 167:84c0a372a020 | 13 | * Software is furnished to do so, subject to the following conditions: |
AnnaBridge | 167:84c0a372a020 | 14 | * |
AnnaBridge | 167:84c0a372a020 | 15 | * The above copyright notice and this permission notice shall be included |
AnnaBridge | 167:84c0a372a020 | 16 | * in all copies or substantial portions of the Software. |
AnnaBridge | 167:84c0a372a020 | 17 | * |
AnnaBridge | 167:84c0a372a020 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
AnnaBridge | 167:84c0a372a020 | 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
AnnaBridge | 167:84c0a372a020 | 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
AnnaBridge | 167:84c0a372a020 | 21 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
AnnaBridge | 167:84c0a372a020 | 22 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
AnnaBridge | 167:84c0a372a020 | 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
AnnaBridge | 167:84c0a372a020 | 24 | * OTHER DEALINGS IN THE SOFTWARE. |
AnnaBridge | 167:84c0a372a020 | 25 | * |
AnnaBridge | 167:84c0a372a020 | 26 | * Except as contained in this notice, the name of Maxim Integrated |
AnnaBridge | 167:84c0a372a020 | 27 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
AnnaBridge | 167:84c0a372a020 | 28 | * Products, Inc. Branding Policy. |
AnnaBridge | 167:84c0a372a020 | 29 | * |
AnnaBridge | 167:84c0a372a020 | 30 | * The mere transfer of this software does not imply any licenses |
AnnaBridge | 167:84c0a372a020 | 31 | * of trade secrets, proprietary technology, copyrights, patents, |
AnnaBridge | 167:84c0a372a020 | 32 | * trademarks, maskwork rights, or any other form of intellectual |
AnnaBridge | 167:84c0a372a020 | 33 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
AnnaBridge | 167:84c0a372a020 | 34 | * ownership rights. |
AnnaBridge | 167:84c0a372a020 | 35 | * |
AnnaBridge | 167:84c0a372a020 | 36 | * $Date: 2016-10-10 19:49:16 -0500 (Mon, 10 Oct 2016) $ |
AnnaBridge | 167:84c0a372a020 | 37 | * $Revision: 24675 $ |
AnnaBridge | 167:84c0a372a020 | 38 | * |
AnnaBridge | 167:84c0a372a020 | 39 | **************************************************************************** */ |
AnnaBridge | 167:84c0a372a020 | 40 | |
AnnaBridge | 167:84c0a372a020 | 41 | /* Define to prevent redundant inclusion */ |
AnnaBridge | 167:84c0a372a020 | 42 | #ifndef _TMR_UTILS_H |
AnnaBridge | 167:84c0a372a020 | 43 | #define _TMR_UTILS_H |
AnnaBridge | 167:84c0a372a020 | 44 | |
AnnaBridge | 167:84c0a372a020 | 45 | /***** Includes *****/ |
AnnaBridge | 167:84c0a372a020 | 46 | #include "mxc_config.h" |
AnnaBridge | 167:84c0a372a020 | 47 | #include "tmr_regs.h" |
AnnaBridge | 167:84c0a372a020 | 48 | #include "mxc_sys.h" |
AnnaBridge | 167:84c0a372a020 | 49 | |
AnnaBridge | 167:84c0a372a020 | 50 | #ifdef __cplusplus |
AnnaBridge | 167:84c0a372a020 | 51 | extern "C" { |
AnnaBridge | 167:84c0a372a020 | 52 | #endif |
AnnaBridge | 167:84c0a372a020 | 53 | |
AnnaBridge | 167:84c0a372a020 | 54 | /** |
AnnaBridge | 167:84c0a372a020 | 55 | * @ingroup tmr |
AnnaBridge | 167:84c0a372a020 | 56 | * @defgroup tmr_utils Timer Utility Functions |
AnnaBridge | 167:84c0a372a020 | 57 | * @{ |
AnnaBridge | 167:84c0a372a020 | 58 | */ |
AnnaBridge | 167:84c0a372a020 | 59 | /* **** Definitions **** */ |
AnnaBridge | 167:84c0a372a020 | 60 | /** Macro to convert the parameter \p s from seconds to micro-seconds. */ |
AnnaBridge | 167:84c0a372a020 | 61 | #define SEC(s) (((unsigned long)s) * 1000000UL) |
AnnaBridge | 167:84c0a372a020 | 62 | /** Macro to convert the parameter \p ms from milli-seconds to micro-seconds. */ |
AnnaBridge | 167:84c0a372a020 | 63 | #define MSEC(ms) (ms * 1000UL) |
AnnaBridge | 167:84c0a372a020 | 64 | /** Macro to convert the parameter \p us to micro-seconds. */ |
AnnaBridge | 167:84c0a372a020 | 65 | #define USEC(us) (us) |
AnnaBridge | 167:84c0a372a020 | 66 | |
AnnaBridge | 167:84c0a372a020 | 67 | /* **** Globals **** */ |
AnnaBridge | 167:84c0a372a020 | 68 | |
AnnaBridge | 167:84c0a372a020 | 69 | /* **** Function Prototypes **** */ |
AnnaBridge | 167:84c0a372a020 | 70 | |
AnnaBridge | 167:84c0a372a020 | 71 | /** |
AnnaBridge | 167:84c0a372a020 | 72 | * @brief Delays for the specified number of microseconds. |
AnnaBridge | 167:84c0a372a020 | 73 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 74 | * @param us Number of microseconds to delay. |
AnnaBridge | 167:84c0a372a020 | 75 | */ |
AnnaBridge | 167:84c0a372a020 | 76 | void TMR_Delay(mxc_tmr_regs_t* tmr, unsigned long us); |
AnnaBridge | 167:84c0a372a020 | 77 | |
AnnaBridge | 167:84c0a372a020 | 78 | /** |
AnnaBridge | 167:84c0a372a020 | 79 | * @brief Start the timeout time for the specified number of microseconds. |
AnnaBridge | 167:84c0a372a020 | 80 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 81 | * @param us Number of microseconds in the timeout. |
AnnaBridge | 167:84c0a372a020 | 82 | */ |
AnnaBridge | 167:84c0a372a020 | 83 | void TMR_TO_Start(mxc_tmr_regs_t* tmr, unsigned long us); |
AnnaBridge | 167:84c0a372a020 | 84 | |
AnnaBridge | 167:84c0a372a020 | 85 | /** |
AnnaBridge | 167:84c0a372a020 | 86 | * @brief Check if the timeout has occured. |
AnnaBridge | 167:84c0a372a020 | 87 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 88 | * @return #E_NO_ERROR if the timeout has not occurred, #E_TIME_OUT if it has. |
AnnaBridge | 167:84c0a372a020 | 89 | */ |
AnnaBridge | 167:84c0a372a020 | 90 | int TMR_TO_Check(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 91 | |
AnnaBridge | 167:84c0a372a020 | 92 | /** |
AnnaBridge | 167:84c0a372a020 | 93 | * @brief Stops the timer for the timeout. |
AnnaBridge | 167:84c0a372a020 | 94 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 95 | */ |
AnnaBridge | 167:84c0a372a020 | 96 | void TMR_TO_Stop(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 97 | |
AnnaBridge | 167:84c0a372a020 | 98 | /** |
AnnaBridge | 167:84c0a372a020 | 99 | * @brief Clears the timeout flag. |
AnnaBridge | 167:84c0a372a020 | 100 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 101 | */ |
AnnaBridge | 167:84c0a372a020 | 102 | void TMR_TO_Clear(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 103 | |
AnnaBridge | 167:84c0a372a020 | 104 | /** |
AnnaBridge | 167:84c0a372a020 | 105 | * @brief Get the number of microseconds elapsed since TMR_TO_Start(). |
AnnaBridge | 167:84c0a372a020 | 106 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 107 | * @return Number of microseconds since TMR_TO_Start(). |
AnnaBridge | 167:84c0a372a020 | 108 | */ |
AnnaBridge | 167:84c0a372a020 | 109 | unsigned TMR_TO_Elapsed(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 110 | |
AnnaBridge | 167:84c0a372a020 | 111 | /** |
AnnaBridge | 167:84c0a372a020 | 112 | * @brief Get the number of microseconds remaining in the timeout. |
AnnaBridge | 167:84c0a372a020 | 113 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 114 | * @return Number of microseconds since TMR_TO_Start(). |
AnnaBridge | 167:84c0a372a020 | 115 | */ |
AnnaBridge | 167:84c0a372a020 | 116 | unsigned TMR_TO_Remaining(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 117 | |
AnnaBridge | 167:84c0a372a020 | 118 | /** |
AnnaBridge | 167:84c0a372a020 | 119 | * @brief Start the stopwatch. |
AnnaBridge | 167:84c0a372a020 | 120 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 121 | */ |
AnnaBridge | 167:84c0a372a020 | 122 | void TMR_SW_Start(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 123 | |
AnnaBridge | 167:84c0a372a020 | 124 | /** |
AnnaBridge | 167:84c0a372a020 | 125 | * @brief Stop the stopwatch and return the number of microseconds that |
AnnaBridge | 167:84c0a372a020 | 126 | * have elapsed. |
AnnaBridge | 167:84c0a372a020 | 127 | * @param tmr TMR module to operate on |
AnnaBridge | 167:84c0a372a020 | 128 | * @return Number of microseconds since TMR_TO_Start(). |
AnnaBridge | 167:84c0a372a020 | 129 | */ |
AnnaBridge | 167:84c0a372a020 | 130 | unsigned TMR_SW_Stop(mxc_tmr_regs_t* tmr); |
AnnaBridge | 167:84c0a372a020 | 131 | /**@} end of defgroup tmr_utils*/ |
AnnaBridge | 167:84c0a372a020 | 132 | #ifdef __cplusplus |
AnnaBridge | 167:84c0a372a020 | 133 | } |
AnnaBridge | 167:84c0a372a020 | 134 | #endif |
AnnaBridge | 167:84c0a372a020 | 135 | |
AnnaBridge | 167:84c0a372a020 | 136 | #endif /* _TMR_UTILS_H */ |