LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mrt_001.h
Go to the documentation of this file.
1 /*
2  * @brief Multi-Rate Timer (MRT) registers and driver functions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __MRT_001_H_
33 #define __MRT_001_H_
34 
35 #include "sys_config.h"
36 #include "cmsis.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
50 typedef struct {
53  __IO uint32_t CTRL;
54  __IO uint32_t STAT;
55 } IP_MRT_001_T;
56 
60 /* MRT Time interval register bit fields */
61 #define IP_MRT_001_INTVAL_IVALUE (0xFFFFFF)
62 #define IP_MRT_001_INTVAL_LOAD (1 << 31)
63 
64 /* MRT Control register bit fields & masks */
65 #define IP_MRT_001_CTRL_MODE_REPEAT (0x00)
66 #define IP_MRT_001_CTRL_MODE_ONESHOT (0x01)
67 #define IP_MRT_001_CTRL_INTEN_MASK (0x01)
68 #define IP_MRT_001_CTRL_MODE_POS (0x01)
69 #define IP_MRT_001_CTRL_MODE_MASK (0x06)
70 #define IP_MRT_001_CTRL_MODE_SHIFT(x) (x << 1)
71 
72 /* MRT Status register bit fields & masks */
73 #define IP_MRT_001_STAT_INTFLAG (0x01)
74 #define IP_MRT_001_STAT_RUNNING (0x02)
75 
79 typedef enum IP_MRT_001_MODE {
83 
89 {}
90 
96 {}
97 
104 {
105  return (uint32_t) pMRT->INTVAL;
106 }
107 
118 {
119  pMRT->INTVAL = interval;
120 }
121 
128 {
129  return (uint32_t) pMRT->TIMER;
130 }
131 
138 {
139  return (bool) (pMRT->CTRL & IP_MRT_001_CTRL_INTEN_MASK);
140 }
141 
148 {
150 }
151 
158 {
159  return (IP_MRT_001_MODE_T) ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) >> 1);
160 }
161 
169 {
170  pMRT->CTRL |= IP_MRT_001_CTRL_MODE_SHIFT(mode);
171 }
172 
179 {
180  return ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) > 0) ? false : true;
181 }
182 
189 {
190  return ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) > 0) ? true : false;
191 }
192 
199 {
200  return (bool) (pMRT->STAT & IP_MRT_001_STAT_INTFLAG);
201 }
202 
209 {
210  pMRT->STAT |= IP_MRT_001_STAT_INTFLAG;
211 }
212 
219 {
220  return (bool) (pMRT->STAT & IP_MRT_001_STAT_RUNNING);
221 }
222 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif /* __MRT_001_H_ */