MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
tmr_utils.h
1 
5 /* *****************************************************************************
6  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
22  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * Except as contained in this notice, the name of Maxim Integrated
27  * Products, Inc. shall not be used except as stated in the Maxim Integrated
28  * Products, Inc. Branding Policy.
29  *
30  * The mere transfer of this software does not imply any licenses
31  * of trade secrets, proprietary technology, copyrights, patents,
32  * trademarks, maskwork rights, or any other form of intellectual
33  * property whatsoever. Maxim Integrated Products, Inc. retains all
34  * ownership rights.
35  *
36  * $Date: 2018-09-10 16:20:17 -0500 (Mon, 10 Sep 2018) $
37  * $Revision: 37771 $
38  *
39  **************************************************************************** */
40 
41 /* Define to prevent redundant inclusion */
42 #ifndef _TMR_UTILS_H
43 #define _TMR_UTILS_H
44 
45 /***** Includes *****/
46 #include "mxc_config.h"
47 #include "tmr_regs.h"
48 #include "mxc_sys.h"
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
60 /* **** Definitions **** */
61 
63 #define SEC(s) (((unsigned long)s) * 1000000UL)
64 
66 #define MSEC(ms) (ms * 1000UL)
67 
69 #define USEC(us) (us)
70 
71 /* **** Globals **** */
72 
73 /* **** Function Prototypes **** */
74 
81 void TMR_Delay(mxc_tmr_regs_t *tmr, unsigned long us, const sys_cfg_tmr_t *sys_cfg);
82 
89 void TMR_TO_Start(mxc_tmr_regs_t *tmr, unsigned long us, const sys_cfg_tmr_t *sys_cfg);
90 
97 
102 void TMR_TO_Stop(mxc_tmr_regs_t *tmr);
103 
108 void TMR_TO_Clear(mxc_tmr_regs_t *tmr);
109 
115 unsigned int TMR_TO_Elapsed(mxc_tmr_regs_t *tmr);
116 
122 unsigned int TMR_TO_Remaining(mxc_tmr_regs_t *tmr);
123 
130 void TMR_SW_Start(mxc_tmr_regs_t *tmr, const sys_cfg_tmr_t *sys_cfg);
131 
139 unsigned int TMR_SW_Stop(mxc_tmr_regs_t *tmr);
140 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* _TMR_UTILS_H */
void TMR_TO_Start(mxc_tmr_regs_t *tmr, unsigned long us, const sys_cfg_tmr_t *sys_cfg)
Start the timeout time for the specified number of microseconds.
unsigned int TMR_SW_Stop(mxc_tmr_regs_t *tmr)
Stop the stopwatch and return the number of microseconds that have elapsed.
unsigned int TMR_TO_Elapsed(mxc_tmr_regs_t *tmr)
Get the number of microseconds elapsed since TMR_TO_Start().
void TMR_TO_Clear(mxc_tmr_regs_t *tmr)
Clears the timeout flag.
int TMR_TO_Check(mxc_tmr_regs_t *tmr)
Check if the timeout has occurred.
unsigned int TMR_TO_Remaining(mxc_tmr_regs_t *tmr)
Get the number of microseconds remaining in the timeout.
void TMR_SW_Start(mxc_tmr_regs_t *tmr, const sys_cfg_tmr_t *sys_cfg)
Start the stopwatch.
Structure type to access the TMR Registers.
Definition: tmr_regs.h:88
void TMR_TO_Stop(mxc_tmr_regs_t *tmr)
Stops the timer for the timeout.
void TMR_Delay(mxc_tmr_regs_t *tmr, unsigned long us, const sys_cfg_tmr_t *sys_cfg)
Delays for the specified number of microseconds.