| 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
acmp_001.h
Go to the documentation of this file.
1 /*
2 * @brief Analog comparator 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 licenser 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 __ACMP_001_H_
33 #define __ACMP_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 CTRL;
52 __IO uint32_t LAD;
53 } ACMP_001_T;
54
55 #define ACMP_COMPSA_BIT (1 << 6) /* Comparator output control bit */
56 #define ACMP_COMPSTAT_BIT (1 << 21) /* Comparator status, reflects the state of the comparator output */
57 #define ACMP_COMPEDGE_BIT (1 << 23) /* Comparator edge-detect status */
58 #define ACMP_LADENAB_BIT (1 << 0) /* Voltage ladder enable bit */
59
61 typedef enum IP_ACMP_001_EDGESEL {
62 ACMP_EDGESEL_FALLING = (0 << 3), /* Set the COMPEDGE bit on falling edge */
63 ACMP_EDGESEL_RISING = (1 << 3), /* Set the COMPEDGE bit on rising edge */
64 ACMP_EDGESEL_BOTH = (2 << 3) /* Set the COMPEDGE bit on falling and rising edges */
65 } IP_ACMP_001_EDGESEL_T;
66
68 typedef enum IP_ACMP_HYS_001 {
69 ACMP_HYS_NONE = (0 << 25), /* No hysteresis (the output will switch as the voltages cross) */
70 ACMP_HYS_5MV = (1 << 25), /* 5mV hysteresis */
71 ACMP_HYS_10MV = (2 << 25), /* 10mV hysteresis */
72 ACMP_HYS_20MV = (3 << 25) /* 20mV hysteresis */
73 } IP_ACMP_HYS_001_T;
74
80 STATIC INLINE void IP_ACMP_Init(ACMP_001_T *pACMP) {}
81
87 STATIC INLINE void IP_ACMP_Deinit(ACMP_001_T *pACMP) {}
88
94 STATIC INLINE uint32_t IP_ACMP_GetCompStatus(ACMP_001_T *pACMP)
95 {
96 return pACMP->CTRL & (ACMP_COMPSTAT_BIT | ACMP_COMPEDGE_BIT);
97 }
98
104 void IP_ACMP_EdgeClear(ACMP_001_T *pACMP);
105
112 void IP_ACMP_SetEdgeSelection(ACMP_001_T *pACMP, IP_ACMP_001_EDGESEL_T edgeSel);
113
119 STATIC INLINE void IP_ACMP_EnableSyncCompOut(ACMP_001_T *pACMP)
120 {
121 pACMP->CTRL |= ACMP_COMPSA_BIT;
122 }
123
129 STATIC INLINE void IP_ACMP_DisableSyncCompOut(ACMP_001_T *pACMP)
130 {
131 pACMP->CTRL &= ~ACMP_COMPSA_BIT;
132 }
133
142 void IP_ACMP_SetPosVoltRef(ACMP_001_T *pACMP, uint32_t Posinput);
143
152 void IP_ACMP_SetNegVoltRef(ACMP_001_T *pACMP, uint32_t Neginput);
153
160 void IP_ACMP_SetHysteresis(ACMP_001_T *pACMP, IP_ACMP_HYS_001_T hys);
161
173 void IP_ACMP_SetupAMCPRefs(ACMP_001_T *pACMP, IP_ACMP_001_EDGESEL_T edgeSel,
174 uint32_t Posinput, uint32_t Neginput, IP_ACMP_HYS_001_T hys);
175
186 void IP_ACMP_SetupVoltLadder(ACMP_001_T *pACMP, uint32_t ladsel, bool ladrefVDDCMP);
187
193 STATIC INLINE void IP_ACMP_EnableVoltLadder(ACMP_001_T *pACMP)
194 {
195 pACMP->LAD |= ACMP_LADENAB_BIT;
196 }
197
203 STATIC INLINE void IP_ACMP_DisableVoltLadder(ACMP_001_T *pACMP)
204 {
205 pACMP->LAD &= ~ACMP_LADENAB_BIT;
206 }
207
212 #ifdef __cplusplus
213 }
214 #endif
215
216 #endif /* __ACMP_001_H_ */