]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/lpc_core/lpc_ip/ritimer_001.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / lpc_core / lpc_ip / ritimer_001.h
1 /*\r
2  * @brief Repetitive Interrupt Timer registers and control functions\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * All rights reserved.\r
7  *\r
8  * @par\r
9  * Software that is described herein is for illustrative purposes only\r
10  * which provides customers with programming information regarding the\r
11  * LPC products.  This software is supplied "AS IS" without any warranties of\r
12  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
13  * all warranties, express or implied, including all implied warranties of\r
14  * merchantability, fitness for a particular purpose and non-infringement of\r
15  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
16  * or liability for the use of the software, conveys no license or rights under any\r
17  * patent, copyright, mask work right, or any other intellectual property rights in\r
18  * or to any products. NXP Semiconductors reserves the right to make changes\r
19  * in the software without notification. NXP Semiconductors also makes no\r
20  * representation or warranty that such application will be suitable for the\r
21  * specified use without further testing or modification.\r
22  *\r
23  * @par\r
24  * Permission to use, copy, modify, and distribute this software and its\r
25  * documentation is hereby granted, under NXP Semiconductors' and its\r
26  * licensor's relevant copyrights in the software, without fee, provided that it\r
27  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
28  * copyright, permission, and disclaimer notice must appear in all copies of\r
29  * this code.\r
30  */\r
31 \r
32 #ifndef __RITIMER_001_H_\r
33 #define __RITIMER_001_H_\r
34 \r
35 #include "sys_config.h"\r
36 #include "cmsis.h"\r
37 \r
38 #ifdef __cplusplus\r
39 extern "C" {\r
40 #endif\r
41 \r
42 /** @defgroup IP_RITIMER_001 IP: RITimer register block and driver\r
43  * @ingroup IP_Drivers\r
44  * Repetitive Interrupt Timer\r
45  * @{\r
46  */\r
47 \r
48 /**\r
49  * @brief Repetitive Interrupt Timer register block structure\r
50  */\r
51 typedef struct {                                /*!< RITIMER Structure      */\r
52         __IO uint32_t  COMPVAL;         /*!< Compare register       */\r
53         __IO uint32_t  MASK;            /*!< Mask register. This register holds the 32-bit mask value. A 1 written to any bit will force a compare on the corresponding bit of the counter and compare register. */\r
54         __IO uint32_t  CTRL;            /*!< Control register.      */\r
55         __IO uint32_t  COUNTER;         /*!< 32-bit counter         */\r
56 #if defined(CHIP_LPC1347)\r
57         __IO uint32_t  COMPVAL_H;       /*!< Compare upper register */\r
58         __IO uint32_t  MASK_H;          /*!< Mask upper register    */\r
59         __I  uint32_t  RESERVED0[1]; \r
60         __IO uint32_t  COUNTER_H;       /*!< Counter upper register */\r
61 #endif\r
62 } IP_RITIMER_001_T;\r
63 \r
64 /**\r
65  * @brief RITIMER register support bitfields and mask\r
66  */\r
67 \r
68 /*\r
69  * RIT control register\r
70  */\r
71 /**     Set by H/W when the counter value equals the masked compare value */\r
72 #define RIT_CTRL_INT    ((uint32_t) (1))\r
73 /** Set timer enable clear to 0 when the counter value equals the masked compare value  */\r
74 #define RIT_CTRL_ENCLR  ((uint32_t) _BIT(1))\r
75 /** Set timer enable on debug */\r
76 #define RIT_CTRL_ENBR   ((uint32_t) _BIT(2))\r
77 /** Set timer enable */\r
78 #define RIT_CTRL_TEN    ((uint32_t) _BIT(3))\r
79 \r
80 /**\r
81  * @brief       Initialize the RIT\r
82  * @param       pRITimer        : RIT peripheral selected\r
83  * @return      None\r
84  */\r
85 void IP_RIT_Init(IP_RITIMER_001_T *pRITimer);\r
86 \r
87 /**\r
88  * @brief       DeInitialize the RIT\r
89  * @param       pRITimer        : RIT peripheral selected\r
90  * @return      None\r
91  */\r
92 void IP_RIT_DeInit(IP_RITIMER_001_T *pRITimer);\r
93 \r
94 /**\r
95  * @brief       Enable Timer\r
96  * @param       pRITimer        : RIT peripheral selected\r
97  * @return      None\r
98  */\r
99 STATIC INLINE void IP_RIT_Enable(IP_RITIMER_001_T *pRITimer)\r
100 {\r
101         pRITimer->CTRL |= RIT_CTRL_TEN;\r
102 }\r
103 \r
104 /**\r
105  * @brief       Disable Timer\r
106  * @param       pRITimer        : RIT peripheral selected\r
107  * @return      None\r
108  */\r
109 STATIC INLINE void IP_RIT_Disable(IP_RITIMER_001_T *pRITimer)\r
110 {\r
111         pRITimer->CTRL &= ~RIT_CTRL_TEN;\r
112 }\r
113 \r
114 \r
115 /**\r
116  * @brief       Timer Enable on debug\r
117  * @param       pRITimer        : RIT peripheral selected\r
118  * @return      None\r
119  */\r
120 STATIC INLINE void IP_RIT_TimerDebugEnable(IP_RITIMER_001_T *pRITimer)\r
121 {\r
122         pRITimer->CTRL |= RIT_CTRL_ENBR;\r
123 }\r
124 \r
125 /**\r
126  * @brief       Timer Disable on debug\r
127  * @param       pRITimer        : RIT peripheral selected\r
128  * @return      None\r
129  */\r
130 STATIC INLINE void IP_RIT_TimerDebugDisable(IP_RITIMER_001_T *pRITimer)\r
131 {\r
132         pRITimer->CTRL &= ~RIT_CTRL_ENBR;\r
133 }\r
134 \r
135 \r
136 /**\r
137  * @brief       Check whether interrupt flag is set or not\r
138  * @param       pRITimer        : RIT peripheral selected\r
139  * @return      Current interrupt status, could be SET or UNSET\r
140  */\r
141 IntStatus IP_RIT_GetIntStatus(IP_RITIMER_001_T *pRITimer);\r
142 \r
143 /**\r
144  * @brief       Set a tick value for the interrupt to time out\r
145  * @param       pRITimer        : RIT peripheral selected\r
146  * @param       val                     : value (in ticks) of the interrupt to be set\r
147  * @return      None\r
148  */\r
149 STATIC INLINE void IP_RIT_SetCOMPVAL(IP_RITIMER_001_T *pRITimer, uint32_t val)\r
150 {\r
151         pRITimer->COMPVAL = val;\r
152 }\r
153 \r
154 /**\r
155  * @brief       Enables or clears the RIT or interrupt\r
156  * @param       pRITimer        : RIT peripheral selected\r
157  * @param       val                     : RIT to be set, one or more RIT_CTRL_* values\r
158  * @return      None\r
159  */\r
160 STATIC INLINE void IP_RIT_EnableCTRL(IP_RITIMER_001_T *pRITimer, uint32_t val)\r
161 {\r
162         pRITimer->CTRL |= val;\r
163 }\r
164 \r
165 /**\r
166  * @brief       Get the RIT Counter value\r
167  * @param       pRITimer        : RIT peripheral selected\r
168  * @return      the counter value\r
169  */\r
170 STATIC INLINE uint32_t IP_RIT_GetCounter(IP_RITIMER_001_T *pRITimer)\r
171 {\r
172         return pRITimer->COUNTER;\r
173 }\r
174 \r
175 /**\r
176  * @}\r
177  */\r
178 \r
179 #ifdef __cplusplus\r
180 }\r
181 #endif\r
182 \r
183 #endif /* __RITIMER_001_H_ */\r