1 /**********************************************************************
\r
2 * $Id$ lpc18xx_evrt.c 2011-06-02
\r
4 * @file lpc18xx_evrt.c
\r
5 * @brief Contains all functions support for Event Router firmware
\r
8 * @date 02. June. 2011
\r
9 * @author NXP MCU SW Application Team
\r
11 * Copyright(C) 2011, NXP Semiconductor
\r
12 * All rights reserved.
\r
14 ***********************************************************************
\r
15 * Software that is described herein is for illustrative purposes only
\r
16 * which provides customers with programming information regarding the
\r
17 * products. This software is supplied "AS IS" without any warranties.
\r
18 * NXP Semiconductors assumes no responsibility or liability for the
\r
19 * use of the software, conveys no license or title under any patent,
\r
20 * copyright, or mask work right to the product. NXP Semiconductors
\r
21 * reserves the right to make changes in the software without
\r
22 * notification. NXP Semiconductors also make no representation or
\r
23 * warranty that such application will be suitable for the specified
\r
24 * use without further testing or modification.
\r
25 **********************************************************************/
\r
27 /* Peripheral group ----------------------------------------------------------- */
\r
28 /** @addtogroup EVRT
\r
32 /* Includes ------------------------------------------------------------------- */
\r
33 #include "lpc18xx_evrt.h"
\r
35 /* If this source file built with example, the LPC18xx FW library configuration
\r
36 * file in each example directory ("lpc18xx_libcfg.h") must be included,
\r
37 * otherwise the default FW library configuration file must be included instead
\r
39 #ifdef __BUILD_WITH_EXAMPLE__
\r
40 #include "lpc18xx_libcfg.h"
\r
42 #include "lpc18xx_libcfg_default.h"
\r
43 #endif /* __BUILD_WITH_EXAMPLE__ */
\r
45 /* Public Functions ----------------------------------------------------------- */
\r
46 /** @addtogroup EVRT_Public_Functions
\r
50 /********************************************************************//**
\r
51 * @brief Initializes the EVRT peripheral.
\r
52 * @param[in] EVRTx EVRT peripheral selected, should be: LPC_EVRT
\r
54 *********************************************************************/
\r
55 void EVRT_Init (LPC_EVENTROUTER_Type *EVRTx)
\r
59 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
61 // Clear all register to be default
\r
62 EVRTx->HILO = 0x0000;
\r
63 EVRTx->EDGE = 0x0000;
\r
64 EVRTx->CLR_EN = 0xFFFF;
\r
68 EVRTx->CLR_STAT = 0xFFFFF;
\r
69 }while((EVRTx->STATUS != 0)&&(i<10));
\r
72 /*********************************************************************//**
\r
73 * @brief De-initializes the EVRT peripheral registers to their
\r
74 * default reset values.
\r
75 * @param[in] EVRTx EVRT peripheral selected, should be: LPC_EVRT
\r
77 **********************************************************************/
\r
78 void EVRT_DeInit(LPC_EVENTROUTER_Type *EVRTx)
\r
80 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
82 EVRTx->CLR_EN = 0xFFFF;
\r
83 EVRTx->CLR_STAT = 0xFFFF;
\r
86 /*********************************************************************//**
\r
87 * @brief Setting up the type of interrupt sources to EVRT
\r
88 * @param[in] EVRTx EVRT peripheral selected, should be: LPC_EVRT
\r
89 * @param[in] EVRT_Src EVRT source, should be:
\r
90 * - EVRT_SRC_WAKEUP0 :WAKEUP0 event
\r
91 * - EVRT_SRC_WAKEUP1 :WAKEUP1 event
\r
92 * - EVRT_SRC_WAKEUP2 :WAKEUP2 event
\r
93 * - EVRT_SRC_WAKEUP3 :WAKEUP3 event
\r
94 * - EVRT_SRC_ATIMER :Alarm timer eveny
\r
95 * - EVRT_SRC_RTC :RTC event
\r
96 * - EVRT_SRC_BOD :BOD event
\r
97 * - EVRT_SRC_WWDT :WWDT event
\r
98 * - EVRT_SRC_ETHERNET :ETHERNET event
\r
99 * - EVRT_SRC_USB0 :USB0 event
\r
100 * - EVRT_SRC_USB1 :USB1 event
\r
101 * - EVRT_SRC_CCAN :CCAN event
\r
102 * - EVRT_SRC_COMBINE_TIMER2 :Combined timer output 2 event
\r
103 * - EVRT_SRC_COMBINE_TIMER6 :Combined timer output 6 event
\r
104 * - EVRT_SRC_QEI :QEI event
\r
105 * - EVRT_SRC_COMBINE_TIMER14 :Combined timer output 14 event
\r
106 * - EVRT_SRC_RESET :RESET event
\r
107 * type Active type, should be:
\r
108 * - EVRT_SRC_ACTIVE_LOW_LEVEL :Active low level
\r
109 * - EVRT_SRC_ACTIVE_HIGH_LEVEL :Active high level
\r
110 * - EVRT_SRC_ACTIVE_FALLING_EDGE :Active falling edge
\r
111 * - EVRT_SRC_ACTIVE_RISING_EDGE :Active rising edge
\r
112 * @param[in] type EVRT source active type, should be:
\r
113 * - EVRT_SRC_ACTIVE_LOW_LEVEL :Active low level
\r
114 * - EVRT_SRC_ACTIVE_HIGH_LEVEL :Active high level
\r
115 * - EVRT_SRC_ACTIVE_FALLING_EDGE :Active falling edge
\r
116 * - EVRT_SRC_ACTIVE_RISING_EDGE :Active rising edge
\r
118 **********************************************************************/
\r
119 void EVRT_ConfigIntSrcActiveType(LPC_EVENTROUTER_Type *EVRTx, EVRT_SRC_ENUM EVRT_Src, EVRT_SRC_ACTIVE_TYPE type)
\r
121 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
122 CHECK_PARAM(PARAM_EVRT_SOURCE(EVRT_Src));
\r
123 CHECK_PARAM(PARAM_EVRT_SOURCE_ACTIVE_TYPE(type));
\r
127 case EVRT_SRC_ACTIVE_LOW_LEVEL:
\r
128 EVRTx->HILO &= ~(1<<(uint8_t)EVRT_Src);
\r
129 EVRTx->EDGE &= ~(1<<(uint8_t)EVRT_Src);
\r
131 case EVRT_SRC_ACTIVE_HIGH_LEVEL:
\r
132 EVRTx->HILO |= (1<<(uint8_t)EVRT_Src);
\r
133 EVRTx->EDGE &= ~(1<<(uint8_t)EVRT_Src);
\r
135 case EVRT_SRC_ACTIVE_FALLING_EDGE:
\r
136 EVRTx->HILO &= ~(1<<(uint8_t)EVRT_Src);
\r
137 EVRTx->EDGE |= (1<<(uint8_t)EVRT_Src);
\r
139 case EVRT_SRC_ACTIVE_RISING_EDGE:
\r
140 EVRTx->HILO |= (1<<(uint8_t)EVRT_Src);
\r
141 EVRTx->EDGE |= (1<<(uint8_t)EVRT_Src);
\r
148 /*********************************************************************//**
\r
149 * @brief Enable or disable interrupt sources to EVRT
\r
150 * @param[in] EVRTx EVRT peripheral selected, should be LPC_EVRT
\r
151 * @param[in] EVRT_Src EVRT source, should be:
\r
152 * - EVRT_SRC_WAKEUP0 :WAKEUP0 event
\r
153 * - EVRT_SRC_WAKEUP1 :WAKEUP1 event
\r
154 * - EVRT_SRC_WAKEUP2 :WAKEUP2 event
\r
155 * - EVRT_SRC_WAKEUP3 :WAKEUP3 event
\r
156 * - EVRT_SRC_ATIMER :Alarm timer eveny
\r
157 * - EVRT_SRC_RTC :RTC event
\r
158 * - EVRT_SRC_BOD :BOD event
\r
159 * - EVRT_SRC_WWDT :WWDT event
\r
160 * - EVRT_SRC_ETHERNET :ETHERNET event
\r
161 * - EVRT_SRC_USB0 :USB0 event
\r
162 * - EVRT_SRC_USB1 :USB1 event
\r
163 * - EVRT_SRC_CCAN :CCAN event
\r
164 * - EVRT_SRC_COMBINE_TIMER2 :Combined timer output 2 event
\r
165 * - EVRT_SRC_COMBINE_TIMER6 :Combined timer output 6 event
\r
166 * - EVRT_SRC_QEI :QEI event
\r
167 * - EVRT_SRC_COMBINE_TIMER14 :Combined timer output 14 event
\r
168 * - EVRT_SRC_RESET :RESET event
\r
169 * @param[in] state ENABLE or DISABLE
\r
171 **********************************************************************/
\r
172 void EVRT_SetUpIntSrc(LPC_EVENTROUTER_Type *EVRTx, EVRT_SRC_ENUM EVRT_Src, FunctionalState state)
\r
174 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
175 CHECK_PARAM(PARAM_EVRT_SOURCE(EVRT_Src));
\r
177 if(state == ENABLE)
\r
178 EVRTx->SET_EN = (1<<(uint8_t)EVRT_Src);
\r
180 EVRTx->CLR_EN = (1<<(uint8_t)EVRT_Src);
\r
183 /*********************************************************************//**
\r
184 * @brief Check if a source is sending interrupt to EVRT
\r
185 * @param[in] EVRTx EVRT peripheral selected, should be LPC_EVRT
\r
186 * @param[in] EVRT_Src EVRT source, should be:
\r
187 * - EVRT_SRC_WAKEUP0 :WAKEUP0 event
\r
188 * - EVRT_SRC_WAKEUP1 :WAKEUP1 event
\r
189 * - EVRT_SRC_WAKEUP2 :WAKEUP2 event
\r
190 * - EVRT_SRC_WAKEUP3 :WAKEUP3 event
\r
191 * - EVRT_SRC_ATIMER :Alarm timer eveny
\r
192 * - EVRT_SRC_RTC :RTC event
\r
193 * - EVRT_SRC_BOD :BOD event
\r
194 * - EVRT_SRC_WWDT :WWDT event
\r
195 * - EVRT_SRC_ETHERNET :ETHERNET event
\r
196 * - EVRT_SRC_USB0 :USB0 event
\r
197 * - EVRT_SRC_USB1 :USB1 event
\r
198 * - EVRT_SRC_CCAN :CCAN event
\r
199 * - EVRT_SRC_COMBINE_TIMER2 :Combined timer output 2 event
\r
200 * - EVRT_SRC_COMBINE_TIMER6 :Combined timer output 6 event
\r
201 * - EVRT_SRC_QEI :QEI event
\r
202 * - EVRT_SRC_COMBINE_TIMER14 :Combined timer output 14 event
\r
203 * - EVRT_SRC_RESET :RESET event
\r
204 * @return TRUE or FALSE
\r
205 **********************************************************************/
\r
206 Bool EVRT_IsSourceInterrupting(LPC_EVENTROUTER_Type *EVRTx, EVRT_SRC_ENUM EVRT_Src)
\r
208 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
209 CHECK_PARAM(PARAM_EVRT_SOURCE(EVRT_Src));
\r
211 if(EVRTx->STATUS & (1<<(uint8_t)EVRT_Src))
\r
216 /*********************************************************************//**
\r
217 * @brief Clear pending interrupt EVRT source
\r
218 * @param[in] EVRTx EVRT peripheral selected, should be LPC_EVRT
\r
219 * @param[in] EVRT_Src EVRT source, should be:
\r
220 * - EVRT_SRC_WAKEUP0 :WAKEUP0 event
\r
221 * - EVRT_SRC_WAKEUP1 :WAKEUP1 event
\r
222 * - EVRT_SRC_WAKEUP2 :WAKEUP2 event
\r
223 * - EVRT_SRC_WAKEUP3 :WAKEUP3 event
\r
224 * - EVRT_SRC_ATIMER :Alarm timer eveny
\r
225 * - EVRT_SRC_RTC :RTC event
\r
226 * - EVRT_SRC_BOD :BOD event
\r
227 * - EVRT_SRC_WWDT :WWDT event
\r
228 * - EVRT_SRC_ETHERNET :ETHERNET event
\r
229 * - EVRT_SRC_USB0 :USB0 event
\r
230 * - EVRT_SRC_USB1 :USB1 event
\r
231 * - EVRT_SRC_CCAN :CCAN event
\r
232 * - EVRT_SRC_COMBINE_TIMER2 :Combined timer output 2 event
\r
233 * - EVRT_SRC_COMBINE_TIMER6 :Combined timer output 6 event
\r
234 * - EVRT_SRC_QEI :QEI event
\r
235 * - EVRT_SRC_COMBINE_TIMER14 :Combined timer output 14 event
\r
236 * - EVRT_SRC_RESET :RESET event
\r
238 **********************************************************************/
\r
239 void EVRT_ClrPendIntSrc(LPC_EVENTROUTER_Type *EVRTx, EVRT_SRC_ENUM EVRT_Src)
\r
241 CHECK_PARAM(PARAM_EVRTx(EVRTx));
\r
242 CHECK_PARAM(PARAM_EVRT_SOURCE(EVRT_Src));
\r
244 EVRTx->CLR_STAT = (1<<(uint8_t)EVRT_Src);
\r
257 /* --------------------------------- End Of File ------------------------------ */
\r