| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

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 {
51 __IO uint32_t INTVAL;
52 __O uint32_t TIMER;
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 {
80 MRT_MODE_REPEAT = 0,
81 MRT_MODE_ONESHOT = 1
82 } IP_MRT_001_MODE_T;
83
88 STATIC INLINE void IP_MRT_Init(void)
89 {}
90
95 STATIC INLINE void IP_MRT_DeInit(void)
96 {}
97
103 STATIC INLINE uint32_t IP_MRT_GetInterval(IP_MRT_001_T *pMRT)
104 {
105 return (uint32_t) pMRT->INTVAL;
106 }
107
117 STATIC INLINE void IP_MRT_SetInterval(IP_MRT_001_T *pMRT, uint32_t interval)
118 {
119 pMRT->INTVAL = interval;
120 }
121
127 STATIC INLINE uint32_t IP_MRT_GetTimer(IP_MRT_001_T *pMRT)
128 {
129 return (uint32_t) pMRT->TIMER;
130 }
131
137 STATIC INLINE bool IP_MRT_GetEnabled(IP_MRT_001_T *pMRT)
138 {
139 return (bool) (pMRT->CTRL & IP_MRT_001_CTRL_INTEN_MASK);
140 }
141
147 STATIC INLINE void IP_MRT_SetEnabled(IP_MRT_001_T *pMRT)
148 {
149 pMRT->CTRL |= IP_MRT_001_CTRL_INTEN_MASK;
150 }
151
157 STATIC INLINE IP_MRT_001_MODE_T IP_MRT_GetMode(IP_MRT_001_T *pMRT)
158 {
159 return (IP_MRT_001_MODE_T) ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) >> 1);
160 }
161
168 STATIC INLINE void IP_MRT_SetMode(IP_MRT_001_T *pMRT, IP_MRT_001_MODE_T mode)
169 {
170 pMRT->CTRL |= IP_MRT_001_CTRL_MODE_SHIFT(mode);
171 }
172
178 STATIC INLINE bool IP_MRT_IsRepeatMode(IP_MRT_001_T *pMRT)
179 {
180 return ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) > 0) ? false : true;
181 }
182
188 STATIC INLINE bool IP_MRT_IsOneShotMode(IP_MRT_001_T *pMRT)
189 {
190 return ((pMRT->CTRL & IP_MRT_001_CTRL_MODE_MASK) > 0) ? true : false;
191 }
192
198 STATIC INLINE bool IP_MRT_IntPending(IP_MRT_001_T *pMRT)
199 {
200 return (bool) (pMRT->STAT & IP_MRT_001_STAT_INTFLAG);
201 }
202
208 STATIC INLINE void IP_MRT_IntClear(IP_MRT_001_T *pMRT)
209 {
210 pMRT->STAT |= IP_MRT_001_STAT_INTFLAG;
211 }
212
218 STATIC INLINE bool IP_MRT_Running(IP_MRT_001_T *pMRT)
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_ */