LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cmp_001.h File Reference
#include "sys_config.h"
#include "cmsis.h"

Go to the source code of this file.

Data Structures

struct  IP_CMP_001_T
 Comparator (CMP) register block structure. More...
 

Macros

#define CMP_NUM   2
 
#define CMP_CTRL_BITMASK   (0xF30F)
 
#define CMP_CTRL_PD_IREF_BITMASK   (0x03)
 
#define CMP_CTRL_PD_IREF(n)   ((((uint32_t) (n)) & 0x03))
 
#define CMP_CTRL_PD_VBG_BITMASK   (((uint32_t) 0x03) << 2)
 
#define CMP_CTRL_PD_VBG(n)   ((((uint32_t) (n)) & 0x03) << 2)
 
#define CMP_CTRL_ROSC_BITMASK   ((uint32_t) 0x300)
 
#define CMP_CTRL_ROSCCTL_CMP1   (0x00)
 
#define CMP_CTRL_ROSCCTL_CMP0   (((uint32_t) 0x01) << 8)
 
#define CMP_CTRL_EXT_RESET_INTERNAL   (0x00)
 
#define CMP_CTRL_EXT_RESET_CMPRESET   (((uint32_t) 0x01) << 9)
 
#define CMP_CTRL_TIMERCAPTURE_BITMASK   ((uint32_t) 0xF000)
 
#define CMP_CTRL_T0CAP2_0LEVEL   (0x00)
 
#define CMP_CTRL_T0CAP2_1LEVEL   (((uint32_t) 0x01) << 12)
 
#define CMP_CTRL_T0CAP3_0EDGE   (0x00)
 
#define CMP_CTRL_T0CAP3_1EDGE   (((uint32_t) 0x01) << 13)
 
#define CMP_CTRL_T1CAP2_1EDGE   (0x00)
 
#define CMP_CTRL_T1CAP2_0LEVEL   (((uint32_t) 0x01) << 14)
 
#define CMP_CTRL_T1CAP3_1LEVEL   (0x00)
 
#define CMP_CTRL_T1CAP3_0EDGE   (((uint32_t) 0x01) << 15)
 
#define CMP_CTRLx_BITMASK   ((uint32_t) 0x1F7FF77F)
 
#define CMP_CTRLx_EN_BITMASK   (0x03)
 
#define CMP_CTRLx_EN(n)   ((((uint32_t) (n)) & 0x03))
 
#define CMP_CTRLx_OE   (((uint32_t) 0x01) << 2)
 
#define CMP_CTRLx_STAT   (((uint32_t) 0x01) << 3)
 
#define CMP_CTRLx_VM_BITMASK   (((uint32_t) 0x07) << 4)
 
#define CMP_CTRLx_VM(n)   ((((uint32_t) (n)) & 0x07) << 4)
 
#define CMP_CTRLx_VP_BITMASK   (((uint32_t) 0x07) << 8)
 
#define CMP_CTRLx_VP(n)   ((((uint32_t) (n)) & 0x07) << 8)
 
#define CMP_CTRLx_SYNC   (((uint32_t) 0x01) << 12)
 
#define CMP_CTRLx_HYS_BITMASK   (((uint32_t) 0x03) << 13)
 
#define CMP_CTRLx_HYS(n)   ((((uint32_t) (n)) & 0x03) << 13)
 
#define CMP_CTRLx_INTCTRL_BITMASK   ((uint32_t) 0x78000)
 
#define CMP_CTRLx_INTPOL_NORMAL   (0x00)
 
#define CMP_CTRLx_INTPOL_INV   (((uint32_t) 0x01) << 15)
 
#define CMP_CTRLx_INTTYPE_EDGE   (0x00)
 
#define CMP_CTRLx_INTTYPE_LEVEL   (((uint32_t) 0x01) << 16)
 
#define CMP_CTRLx_INTEDGE_BITMASK   (((uint32_t) 0x03) << 17)
 
#define CMP_CTRLx_INTEDGE(n)   ((((uint32_t) (n)) & 0x03) << 17)
 
#define CMP_CTRLx_INTFLAG   (((uint32_t) 0x01) << 19)
 
#define CMP_CTRLx_VLADEN_BITMASK   (((uint32_t) 0x03) << 20)
 
#define CMP_CTRLx_VLADEN(n)   ((((uint32_t) (n)) & 0x03) << 20)
 
#define CMP_CTRLx_VLADREF_VREFCMP   (0x00)
 
#define CMP_CTRLx_VLADREF_VDDA   (((uint32_t) 0x01) << 22)
 
#define CMP_CTRLx_VSEL_BITMASK   ((uint32_t) ((0x1F) << 24))
 
#define CMP_CTRLx_VSEL(n)   ((((uint32_t) (n)) & 0x1F) << 24)
 

Enumerations

enum  IP_CMP_ENCTRL_T { CMP_ENCTRL_DISABLE, CMP_ENCTRL_DIS_IN_DS_PWD, CMP_ENCTRL_DIS_IN_PWD, CMP_ENCTRL_ENABLE }
 Comparator control definition. More...
 
enum  IP_CMP_INPUT_T {
  CMP_INPUT_VREF_DIV, CMP_INPUT_CMPx_IN0, CMP_INPUT_CMPx_IN1, CMP_INPUT_CMPx_IN2,
  CMP_INPUT_CMPx_IN3, CMP_INPUT_CMP_OTHER_IN0, CMP_INPUT_INTERNAL_09VBG
}
 Comparator VM/VP input definitions. More...
 
enum  IP_CMP_HYS_T { CMP_HYS_NONE = CMP_CTRLx_HYS(0), CMP_HYS_5MV = CMP_CTRLx_HYS(1), CMP_HYS_10MV = CMP_CTRLx_HYS(2), CMP_HYS_15MV = CMP_CTRLx_HYS(3) }
 Comparator hysteresis selection definitions. More...
 
enum  IP_CMP_INTEDGE_T { CMP_INTEDGE_FALLING = CMP_CTRLx_INTEDGE(0), CMP_INTEDGE_RISING = CMP_CTRLx_INTEDGE(1), CMP_INTEDGE_BOTH = CMP_CTRLx_INTEDGE(2) }
 Comparator interrupt edge selection definitions. More...
 

Functions

STATIC INLINE void IP_CMP_Init (IP_CMP_001_T *pCMP)
 Initializes the CMP.
 
STATIC INLINE void IP_CMP_DeInit (IP_CMP_001_T *pCMP)
 De-initializes the CMP.
 
STATIC INLINE void IP_CMP_EnableCurrentSrc (IP_CMP_001_T *pCMP, IP_CMP_ENCTRL_T en)
 Enables comparator current source.
 
STATIC INLINE void IP_CMP_EnableBandGap (IP_CMP_001_T *pCMP, IP_CMP_ENCTRL_T en)
 Enables comparator bandgap reference.
 
STATIC INLINE void IP_CMP_ControlROSC (IP_CMP_001_T *pCMP, uint32_t flag)
 Control CMP_ROSC.
 
STATIC INLINE void IP_CMP_SetTimerCapInput (IP_CMP_001_T *pCMP, uint32_t flag)
 Control CMP_ROSC.
 
STATIC INLINE void IP_CMP_SetupVoltLadder (IP_CMP_001_T *pCMP, uint8_t id, uint16_t ladSel, uint32_t flag)
 Sets up voltage ladder.
 
STATIC INLINE void IP_CMP_EnableVoltLadder (IP_CMP_001_T *pCMP, uint8_t id, IP_CMP_ENCTRL_T en)
 Enables voltage ladder.
 
STATIC INLINE void IP_CMP_SetPosVoltRef (IP_CMP_001_T *pCMP, uint8_t id, IP_CMP_INPUT_T input)
 Selects positive voltage input.
 
STATIC INLINE void IP_CMP_SetNegVoltRef (IP_CMP_001_T *pCMP, uint8_t id, IP_CMP_INPUT_T input)
 Selects negative voltage input.
 
STATIC INLINE void IP_CMP_SetHysteresis (IP_CMP_001_T *pCMP, uint8_t id, IP_CMP_HYS_T hys)
 Selects hysteresis level.
 
STATIC INLINE void IP_CMP_Enable (IP_CMP_001_T *pCMP, uint8_t id, IP_CMP_ENCTRL_T en)
 Enables specified comparator.
 
STATIC INLINE FlagStatus IP_CMP_GetCmpStatus (IP_CMP_001_T *pCMP, uint8_t id)
 Returns the current comparator status.
 
STATIC INLINE void IP_CMP_EnableOuput (IP_CMP_001_T *pCMP, uint8_t id)
 Enable comparator output.
 
STATIC INLINE void IP_CMP_DisableOutput (IP_CMP_001_T *pCMP, uint8_t id)
 Disable comparator output.
 
STATIC INLINE void IP_CMP_EnableSyncCmpOut (IP_CMP_001_T *pCMP, uint8_t id)
 Synchronizes Comparator output to bus clock.
 
STATIC INLINE void IP_CMP_DisableSyncCmpOut (IP_CMP_001_T *pCMP, uint8_t id)
 Sets comparator output to be used directly (no sync)
 
STATIC INLINE void IP_CMP_ConfigInt (IP_CMP_001_T *pCMP, uint8_t id, uint32_t intFlag, IP_CMP_INTEDGE_T edgeSel)
 Sets up comparator interrupt.
 
STATIC INLINE FlagStatus IP_CMP_GetIntStatus (IP_CMP_001_T *pCMP, uint8_t id)
 Get the CMP interrupt status.
 
STATIC INLINE void IP_CMP_CMP_ClearIntStatus (IP_CMP_001_T *pCMP, uint8_t id)
 Clears the CMP interrupt status.