LPCOpen Platform for LPC18XX/43XX microcontrollers: C:/w/lpcopen_docs/software/lpc_core/lpc_chip/chip_18xx_43xx/evrt_18xx_43xx.c Source File

| LPCOpen Platform for LPC18XX/43XX microcontrollers 18XX43XX LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

evrt_18xx_43xx.c
Go to the documentation of this file.
1 /*
2 * @brief LPC18xx/43xx event router driver
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 #include "chip.h"
33
34 /*****************************************************************************
35 * Private types/enumerations/variables
36 ****************************************************************************/
37
38 /*****************************************************************************
39 * Public types/enumerations/variables
40 ****************************************************************************/
41
42 /*****************************************************************************
43 * Private functions
44 ****************************************************************************/
45
46 /*****************************************************************************
47 * Public functions
48 ****************************************************************************/
49
50 /* Initialize the EVRT */
51 void Chip_EVRT_Init(void)
52 {
53 uint8_t i = 0;
54 // Clear all register to be default
55 LPC_EVRT->HILO = 0x0000;
56 LPC_EVRT->EDGE = 0x0000;
57 LPC_EVRT->CLR_EN = 0xFFFF;
58 do {
59 i++;
60 LPC_EVRT->CLR_STAT = 0xFFFFF;
61 } while ((LPC_EVRT->STATUS != 0) && (i < 10));
62 }
63
64 /* Set up the type of interrupt type for a source to EVRT */
65 void Chip_EVRT_ConfigIntSrcActiveType(CHIP_EVRT_SRC_T EVRT_Src, CHIP_EVRT_SRC_ACTIVE_T type)
66 {
67 switch (type) {
68 case EVRT_SRC_ACTIVE_LOW_LEVEL:
69 LPC_EVRT->HILO &= ~(1 << (uint8_t) EVRT_Src);
70 LPC_EVRT->EDGE &= ~(1 << (uint8_t) EVRT_Src);
71 break;
72
73 case EVRT_SRC_ACTIVE_HIGH_LEVEL:
74 LPC_EVRT->HILO |= (1 << (uint8_t) EVRT_Src);
75 LPC_EVRT->EDGE &= ~(1 << (uint8_t) EVRT_Src);
76 break;
77
78 case EVRT_SRC_ACTIVE_FALLING_EDGE:
79 LPC_EVRT->HILO &= ~(1 << (uint8_t) EVRT_Src);
80 LPC_EVRT->EDGE |= (1 << (uint8_t) EVRT_Src);
81 break;
82
83 case EVRT_SRC_ACTIVE_RISING_EDGE:
84 LPC_EVRT->HILO |= (1 << (uint8_t) EVRT_Src);
85 LPC_EVRT->EDGE |= (1 << (uint8_t) EVRT_Src);
86 break;
87
88 default:
89 break;
90 }
91 }
92
93 /* Enable or disable interrupt sources to EVRT */
94 void Chip_EVRT_SetUpIntSrc(CHIP_EVRT_SRC_T EVRT_Src, FunctionalState state)
95 {
96 if (state == ENABLE) {
97 LPC_EVRT->SET_EN = (1 << (uint8_t) EVRT_Src);
98 }
99 else {
100 LPC_EVRT->CLR_EN = (1 << (uint8_t) EVRT_Src);
101 }
102 }
103
104 /* Check if a source is sending interrupt to EVRT */
105 IntStatus Chip_EVRT_IsSourceInterrupting(CHIP_EVRT_SRC_T EVRT_Src)
106 {
107 if (LPC_EVRT->STATUS & (1 << (uint8_t) EVRT_Src)) {
108 return SET;
109 }
110 else {return RESET; }
111 }