Cortney Padua / mbed-dev

Dependents:   capstone_i2c

Fork of mbed-dev by mbed official

Committer:
cpadua
Date:
Tue Apr 11 20:39:24 2017 +0000
Revision:
163:1d4c9d0af1e9
Parent:
157:ff67d9f36b67
fixed i2c-api.c

Who changed what in which revision?

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