Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**************************************************************************//**
sahilmgandhi 18:6a4db94011d3 2 * @file ACMP.h
sahilmgandhi 18:6a4db94011d3 3 * @version V0.10
sahilmgandhi 18:6a4db94011d3 4 * $Revision: 10 $
sahilmgandhi 18:6a4db94011d3 5 * $Date: 15/08/11 10:26a $
sahilmgandhi 18:6a4db94011d3 6 * @brief M451 Series ACMP Driver Header File
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * @note
sahilmgandhi 18:6a4db94011d3 9 * Copyright (C) 2014~2015 Nuvoton Technology Corp. All rights reserved.
sahilmgandhi 18:6a4db94011d3 10 *
sahilmgandhi 18:6a4db94011d3 11 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 12 #ifndef __ACMP_H__
sahilmgandhi 18:6a4db94011d3 13 #define __ACMP_H__
sahilmgandhi 18:6a4db94011d3 14
sahilmgandhi 18:6a4db94011d3 15 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 16 /* Include related headers */
sahilmgandhi 18:6a4db94011d3 17 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 18 #include "M451Series.h"
sahilmgandhi 18:6a4db94011d3 19
sahilmgandhi 18:6a4db94011d3 20 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 21 extern "C"
sahilmgandhi 18:6a4db94011d3 22 {
sahilmgandhi 18:6a4db94011d3 23 #endif
sahilmgandhi 18:6a4db94011d3 24
sahilmgandhi 18:6a4db94011d3 25
sahilmgandhi 18:6a4db94011d3 26 /** @addtogroup Standard_Driver Standard Driver
sahilmgandhi 18:6a4db94011d3 27 @{
sahilmgandhi 18:6a4db94011d3 28 */
sahilmgandhi 18:6a4db94011d3 29
sahilmgandhi 18:6a4db94011d3 30 /** @addtogroup ACMP_Driver ACMP Driver
sahilmgandhi 18:6a4db94011d3 31 @{
sahilmgandhi 18:6a4db94011d3 32 */
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34
sahilmgandhi 18:6a4db94011d3 35 /** @addtogroup ACMP_EXPORTED_CONSTANTS ACMP Exported Constants
sahilmgandhi 18:6a4db94011d3 36 @{
sahilmgandhi 18:6a4db94011d3 37 */
sahilmgandhi 18:6a4db94011d3 38
sahilmgandhi 18:6a4db94011d3 39
sahilmgandhi 18:6a4db94011d3 40
sahilmgandhi 18:6a4db94011d3 41 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 42 /* ACMP_CTL constant definitions */
sahilmgandhi 18:6a4db94011d3 43 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 44 #define ACMP_CTL_FILTSEL_OFF (0UL << 13) /*!< ACMP_CTL setting for filter function disabled. */
sahilmgandhi 18:6a4db94011d3 45 #define ACMP_CTL_FILTSEL_1PCLK (1UL << 13) /*!< ACMP_CTL setting for 1 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 46 #define ACMP_CTL_FILTSEL_2PCLK (2UL << 13) /*!< ACMP_CTL setting for 2 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 47 #define ACMP_CTL_FILTSEL_4PCLK (3UL << 13) /*!< ACMP_CTL setting for 4 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 48 #define ACMP_CTL_FILTSEL_8PCLK (4UL << 13) /*!< ACMP_CTL setting for 8 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 49 #define ACMP_CTL_FILTSEL_16PCLK (5UL << 13) /*!< ACMP_CTL setting for 16 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 50 #define ACMP_CTL_FILTSEL_32PCLK (6UL << 13) /*!< ACMP_CTL setting for 32 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 51 #define ACMP_CTL_FILTSEL_64PCLK (7UL << 13) /*!< ACMP_CTL setting for 64 PCLK filter count. */
sahilmgandhi 18:6a4db94011d3 52 #define ACMP_CTL_INTPOL_RF (0UL << 8) /*!< ACMP_CTL setting for selecting rising edge and falling edge as interrupt condition. */
sahilmgandhi 18:6a4db94011d3 53 #define ACMP_CTL_INTPOL_R (1UL << 8) /*!< ACMP_CTL setting for selecting rising edge as interrupt condition. */
sahilmgandhi 18:6a4db94011d3 54 #define ACMP_CTL_INTPOL_F (2UL << 8) /*!< ACMP_CTL setting for selecting falling edge as interrupt condition. */
sahilmgandhi 18:6a4db94011d3 55 #define ACMP_CTL_POSSEL_P0 (0UL << 6) /*!< ACMP_CTL setting for selecting ACMPx_P0 pin as the source of ACMP V+. */
sahilmgandhi 18:6a4db94011d3 56 #define ACMP_CTL_POSSEL_P1 (1UL << 6) /*!< ACMP_CTL setting for selecting ACMPx_P1 pin as the source of ACMP V+. */
sahilmgandhi 18:6a4db94011d3 57 #define ACMP_CTL_POSSEL_P2 (2UL << 6) /*!< ACMP_CTL setting for selecting ACMPx_P2 pin as the source of ACMP V+. */
sahilmgandhi 18:6a4db94011d3 58 #define ACMP_CTL_POSSEL_P3 (3UL << 6) /*!< ACMP_CTL setting for selecting ACMPx_P3 pin as the source of ACMP V+. */
sahilmgandhi 18:6a4db94011d3 59 #define ACMP_CTL_NEGSEL_PIN (0UL << 4) /*!< ACMP_CTL setting for selecting the voltage of ACMP negative input pin as the source of ACMP V-. */
sahilmgandhi 18:6a4db94011d3 60 #define ACMP_CTL_NEGSEL_CRV (1UL << 4) /*!< ACMP_CTL setting for selecting internal comparator reference voltage as the source of ACMP V-. */
sahilmgandhi 18:6a4db94011d3 61 #define ACMP_CTL_NEGSEL_VBG (2UL << 4) /*!< ACMP_CTL setting for selecting internal Band-gap voltage as the source of ACMP V-. */
sahilmgandhi 18:6a4db94011d3 62 #define ACMP_CTL_NEGSEL_DAC (3UL << 4) /*!< ACMP_CTL setting for selecting DAC output voltage as the source of ACMP V-. */
sahilmgandhi 18:6a4db94011d3 63 #define ACMP_CTL_HYSTERESIS_ENABLE (1UL << 2) /*!< ACMP_CTL setting for enabling the hysteresis function. */
sahilmgandhi 18:6a4db94011d3 64 #define ACMP_CTL_HYSTERESIS_DISABLE (0UL << 2) /*!< ACMP_CTL setting for disabling the hysteresis function. */
sahilmgandhi 18:6a4db94011d3 65
sahilmgandhi 18:6a4db94011d3 66 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 67 /* ACMP_VREF constant definitions */
sahilmgandhi 18:6a4db94011d3 68 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 69 #define ACMP_VREF_CRVSSEL_VDDA (0UL << 6) /*!< ACMP_VREF setting for selecting analog supply voltage VDDA as the CRV source voltage */
sahilmgandhi 18:6a4db94011d3 70 #define ACMP_VREF_CRVSSEL_INTVREF (1UL << 6) /*!< ACMP_VREF setting for selecting internal reference voltage as the CRV source voltage */
sahilmgandhi 18:6a4db94011d3 71
sahilmgandhi 18:6a4db94011d3 72
sahilmgandhi 18:6a4db94011d3 73 /*@}*/ /* end of group ACMP_EXPORTED_CONSTANTS */
sahilmgandhi 18:6a4db94011d3 74
sahilmgandhi 18:6a4db94011d3 75
sahilmgandhi 18:6a4db94011d3 76 /** @addtogroup ACMP_EXPORTED_FUNCTIONS ACMP Exported Functions
sahilmgandhi 18:6a4db94011d3 77 @{
sahilmgandhi 18:6a4db94011d3 78 */
sahilmgandhi 18:6a4db94011d3 79
sahilmgandhi 18:6a4db94011d3 80 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 81 /* Define Macros and functions */
sahilmgandhi 18:6a4db94011d3 82 /*---------------------------------------------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 83
sahilmgandhi 18:6a4db94011d3 84
sahilmgandhi 18:6a4db94011d3 85 /**
sahilmgandhi 18:6a4db94011d3 86 * @brief This macro is used to enable output inverse function
sahilmgandhi 18:6a4db94011d3 87 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 88 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 89 * @return None
sahilmgandhi 18:6a4db94011d3 90 * @details This macro will set ACMPOINV bit of ACMP_CTL register to enable output inverse function.
sahilmgandhi 18:6a4db94011d3 91 */
sahilmgandhi 18:6a4db94011d3 92 #define ACMP_ENABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_ACMPOINV_Msk)
sahilmgandhi 18:6a4db94011d3 93
sahilmgandhi 18:6a4db94011d3 94 /**
sahilmgandhi 18:6a4db94011d3 95 * @brief This macro is used to disable output inverse function
sahilmgandhi 18:6a4db94011d3 96 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 97 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 98 * @return None
sahilmgandhi 18:6a4db94011d3 99 * @details This macro will clear ACMPOINV bit of ACMP_CTL register to disable output inverse function.
sahilmgandhi 18:6a4db94011d3 100 */
sahilmgandhi 18:6a4db94011d3 101 #define ACMP_DISABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_ACMPOINV_Msk)
sahilmgandhi 18:6a4db94011d3 102
sahilmgandhi 18:6a4db94011d3 103 /**
sahilmgandhi 18:6a4db94011d3 104 * @brief This macro is used to select ACMP negative input source
sahilmgandhi 18:6a4db94011d3 105 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 106 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 107 * @param[in] u32Src is comparator negative input selection. Including:
sahilmgandhi 18:6a4db94011d3 108 * - \ref ACMP_CTL_NEGSEL_PIN
sahilmgandhi 18:6a4db94011d3 109 * - \ref ACMP_CTL_NEGSEL_CRV
sahilmgandhi 18:6a4db94011d3 110 * - \ref ACMP_CTL_NEGSEL_VBG
sahilmgandhi 18:6a4db94011d3 111 * - \ref ACMP_CTL_NEGSEL_DAC
sahilmgandhi 18:6a4db94011d3 112 * @return None
sahilmgandhi 18:6a4db94011d3 113 * @details This macro will set NEGSEL (ACMP_CTL[5:4]) to determine the source of negative input.
sahilmgandhi 18:6a4db94011d3 114 */
sahilmgandhi 18:6a4db94011d3 115 #define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) ((acmp)->CTL[(u32ChNum)%2] = ((acmp)->CTL[(u32ChNum)%2] & ~ACMP_CTL_NEGSEL_Msk) | (u32Src))
sahilmgandhi 18:6a4db94011d3 116
sahilmgandhi 18:6a4db94011d3 117 /**
sahilmgandhi 18:6a4db94011d3 118 * @brief This macro is used to enable hysteresis function
sahilmgandhi 18:6a4db94011d3 119 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 120 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 121 * @return None
sahilmgandhi 18:6a4db94011d3 122 * @details This macro will set HYSEN bit of ACMP_CTL register to enable hysteresis function.
sahilmgandhi 18:6a4db94011d3 123 */
sahilmgandhi 18:6a4db94011d3 124 #define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_HYSEN_Msk)
sahilmgandhi 18:6a4db94011d3 125
sahilmgandhi 18:6a4db94011d3 126 /**
sahilmgandhi 18:6a4db94011d3 127 * @brief This macro is used to disable hysteresis function
sahilmgandhi 18:6a4db94011d3 128 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 129 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 130 * @return None
sahilmgandhi 18:6a4db94011d3 131 * @details This macro will clear HYSEN bit of ACMP_CTL register to disable hysteresis function.
sahilmgandhi 18:6a4db94011d3 132 */
sahilmgandhi 18:6a4db94011d3 133 #define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_HYSEN_Msk)
sahilmgandhi 18:6a4db94011d3 134
sahilmgandhi 18:6a4db94011d3 135 /**
sahilmgandhi 18:6a4db94011d3 136 * @brief This macro is used to enable interrupt
sahilmgandhi 18:6a4db94011d3 137 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 138 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 139 * @return None
sahilmgandhi 18:6a4db94011d3 140 * @details This macro will set ACMPIE bit of ACMP_CTL register to enable interrupt function.
sahilmgandhi 18:6a4db94011d3 141 * If wake-up function is enabled, the wake-up interrupt will be enabled as well.
sahilmgandhi 18:6a4db94011d3 142 */
sahilmgandhi 18:6a4db94011d3 143 #define ACMP_ENABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_ACMPIE_Msk)
sahilmgandhi 18:6a4db94011d3 144
sahilmgandhi 18:6a4db94011d3 145 /**
sahilmgandhi 18:6a4db94011d3 146 * @brief This macro is used to disable interrupt
sahilmgandhi 18:6a4db94011d3 147 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 148 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 149 * @return None
sahilmgandhi 18:6a4db94011d3 150 * @details This macro will clear ACMPIE bit of ACMP_CTL register to disable interrupt function.
sahilmgandhi 18:6a4db94011d3 151 */
sahilmgandhi 18:6a4db94011d3 152 #define ACMP_DISABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_ACMPIE_Msk)
sahilmgandhi 18:6a4db94011d3 153
sahilmgandhi 18:6a4db94011d3 154 /**
sahilmgandhi 18:6a4db94011d3 155 * @brief This macro is used to enable ACMP
sahilmgandhi 18:6a4db94011d3 156 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 157 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 158 * @return None
sahilmgandhi 18:6a4db94011d3 159 * @details This macro will set ACMPEN bit of ACMP_CTL register to enable analog comparator.
sahilmgandhi 18:6a4db94011d3 160 */
sahilmgandhi 18:6a4db94011d3 161 #define ACMP_ENABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_ACMPEN_Msk)
sahilmgandhi 18:6a4db94011d3 162
sahilmgandhi 18:6a4db94011d3 163 /**
sahilmgandhi 18:6a4db94011d3 164 * @brief This macro is used to disable ACMP
sahilmgandhi 18:6a4db94011d3 165 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 166 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 167 * @return None
sahilmgandhi 18:6a4db94011d3 168 * @details This macro will clear ACMPEN bit of ACMP_CTL register to disable analog comparator.
sahilmgandhi 18:6a4db94011d3 169 */
sahilmgandhi 18:6a4db94011d3 170 #define ACMP_DISABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_ACMPEN_Msk)
sahilmgandhi 18:6a4db94011d3 171
sahilmgandhi 18:6a4db94011d3 172 /**
sahilmgandhi 18:6a4db94011d3 173 * @brief This macro is used to get ACMP output value
sahilmgandhi 18:6a4db94011d3 174 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 175 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 176 * @return ACMP output value
sahilmgandhi 18:6a4db94011d3 177 * @details This macro will return the ACMP output value.
sahilmgandhi 18:6a4db94011d3 178 */
sahilmgandhi 18:6a4db94011d3 179 #define ACMP_GET_OUTPUT(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPO0_Msk<<((u32ChNum)%2)))?1:0)
sahilmgandhi 18:6a4db94011d3 180
sahilmgandhi 18:6a4db94011d3 181 /**
sahilmgandhi 18:6a4db94011d3 182 * @brief This macro is used to get ACMP interrupt flag
sahilmgandhi 18:6a4db94011d3 183 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 184 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 185 * @return ACMP interrupt occurred (1) or not (0)
sahilmgandhi 18:6a4db94011d3 186 * @details This macro will return the ACMP interrupt flag.
sahilmgandhi 18:6a4db94011d3 187 */
sahilmgandhi 18:6a4db94011d3 188 #define ACMP_GET_INT_FLAG(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum)%2)))?1:0)
sahilmgandhi 18:6a4db94011d3 189
sahilmgandhi 18:6a4db94011d3 190 /**
sahilmgandhi 18:6a4db94011d3 191 * @brief This macro is used to clear ACMP interrupt flag
sahilmgandhi 18:6a4db94011d3 192 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 193 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 194 * @return None
sahilmgandhi 18:6a4db94011d3 195 * @details This macro will write 1 to ACMPIFn bit of ACMP_STATUS register to clear interrupt flag.
sahilmgandhi 18:6a4db94011d3 196 */
sahilmgandhi 18:6a4db94011d3 197 #define ACMP_CLR_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum)%2)))
sahilmgandhi 18:6a4db94011d3 198
sahilmgandhi 18:6a4db94011d3 199 /**
sahilmgandhi 18:6a4db94011d3 200 * @brief This macro is used to clear ACMP wake-up interrupt flag
sahilmgandhi 18:6a4db94011d3 201 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 202 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 203 * @return None
sahilmgandhi 18:6a4db94011d3 204 * @details This macro will write 1 to WKIFn bit of ACMP_STATUS register to clear interrupt flag.
sahilmgandhi 18:6a4db94011d3 205 */
sahilmgandhi 18:6a4db94011d3 206 #define ACMP_CLR_WAKEUP_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_WKIF0_Msk<<((u32ChNum)%2)))
sahilmgandhi 18:6a4db94011d3 207
sahilmgandhi 18:6a4db94011d3 208 /**
sahilmgandhi 18:6a4db94011d3 209 * @brief This macro is used to enable ACMP wake-up function
sahilmgandhi 18:6a4db94011d3 210 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 211 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 212 * @return None
sahilmgandhi 18:6a4db94011d3 213 * @details This macro will set WKEN (ACMP_CTL[16]) to enable ACMP wake-up function.
sahilmgandhi 18:6a4db94011d3 214 */
sahilmgandhi 18:6a4db94011d3 215 #define ACMP_ENABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_WKEN_Msk)
sahilmgandhi 18:6a4db94011d3 216
sahilmgandhi 18:6a4db94011d3 217 /**
sahilmgandhi 18:6a4db94011d3 218 * @brief This macro is used to disable ACMP wake-up function
sahilmgandhi 18:6a4db94011d3 219 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 220 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 221 * @return None
sahilmgandhi 18:6a4db94011d3 222 * @details This macro will clear WKEN (ACMP_CTL[16]) to disable ACMP wake-up function.
sahilmgandhi 18:6a4db94011d3 223 */
sahilmgandhi 18:6a4db94011d3 224 #define ACMP_DISABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_WKEN_Msk)
sahilmgandhi 18:6a4db94011d3 225
sahilmgandhi 18:6a4db94011d3 226 /**
sahilmgandhi 18:6a4db94011d3 227 * @brief This macro is used to select ACMP positive input pin
sahilmgandhi 18:6a4db94011d3 228 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 229 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 230 * @param[in] u32Pin Comparator positive pin selection. Including:
sahilmgandhi 18:6a4db94011d3 231 * - \ref ACMP_CTL_POSSEL_P0
sahilmgandhi 18:6a4db94011d3 232 * - \ref ACMP_CTL_POSSEL_P1
sahilmgandhi 18:6a4db94011d3 233 * - \ref ACMP_CTL_POSSEL_P2
sahilmgandhi 18:6a4db94011d3 234 * - \ref ACMP_CTL_POSSEL_P3
sahilmgandhi 18:6a4db94011d3 235 * @return None
sahilmgandhi 18:6a4db94011d3 236 * @details This macro will set POSSEL (ACMP_CTL[7:6]) to determine the comparator positive input pin.
sahilmgandhi 18:6a4db94011d3 237 */
sahilmgandhi 18:6a4db94011d3 238 #define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) ((acmp)->CTL[(u32ChNum)%2] = ((acmp)->CTL[(u32ChNum)%2] & ~ACMP_CTL_POSSEL_Msk) | (u32Pin))
sahilmgandhi 18:6a4db94011d3 239
sahilmgandhi 18:6a4db94011d3 240 /**
sahilmgandhi 18:6a4db94011d3 241 * @brief This macro is used to enable ACMP filter function
sahilmgandhi 18:6a4db94011d3 242 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 243 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 244 * @return None
sahilmgandhi 18:6a4db94011d3 245 * @details This macro will set OUTSEL (ACMP_CTL[12]) to enable output filter function.
sahilmgandhi 18:6a4db94011d3 246 */
sahilmgandhi 18:6a4db94011d3 247 #define ACMP_ENABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] |= ACMP_CTL_OUTSEL_Msk)
sahilmgandhi 18:6a4db94011d3 248
sahilmgandhi 18:6a4db94011d3 249 /**
sahilmgandhi 18:6a4db94011d3 250 * @brief This macro is used to disable ACMP filter function
sahilmgandhi 18:6a4db94011d3 251 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 252 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 253 * @return None
sahilmgandhi 18:6a4db94011d3 254 * @details This macro will clear OUTSEL (ACMP_CTL[12]) to disable output filter function.
sahilmgandhi 18:6a4db94011d3 255 */
sahilmgandhi 18:6a4db94011d3 256 #define ACMP_DISABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)%2] &= ~ACMP_CTL_OUTSEL_Msk)
sahilmgandhi 18:6a4db94011d3 257
sahilmgandhi 18:6a4db94011d3 258 /**
sahilmgandhi 18:6a4db94011d3 259 * @brief This macro is used to set ACMP filter function
sahilmgandhi 18:6a4db94011d3 260 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 261 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 262 * @param[in] u32Cnt is comparator filter count setting.
sahilmgandhi 18:6a4db94011d3 263 * - \ref ACMP_CTL_FILTSEL_OFF
sahilmgandhi 18:6a4db94011d3 264 * - \ref ACMP_CTL_FILTSEL_1PCLK
sahilmgandhi 18:6a4db94011d3 265 * - \ref ACMP_CTL_FILTSEL_2PCLK
sahilmgandhi 18:6a4db94011d3 266 * - \ref ACMP_CTL_FILTSEL_4PCLK
sahilmgandhi 18:6a4db94011d3 267 * - \ref ACMP_CTL_FILTSEL_8PCLK
sahilmgandhi 18:6a4db94011d3 268 * - \ref ACMP_CTL_FILTSEL_16PCLK
sahilmgandhi 18:6a4db94011d3 269 * - \ref ACMP_CTL_FILTSEL_32PCLK
sahilmgandhi 18:6a4db94011d3 270 * - \ref ACMP_CTL_FILTSEL_64PCLK
sahilmgandhi 18:6a4db94011d3 271 * @return None
sahilmgandhi 18:6a4db94011d3 272 * @details When ACMP output filter function is enabled, the output sampling count is determined by FILTSEL (ACMP_CTL[15:13]).
sahilmgandhi 18:6a4db94011d3 273 */
sahilmgandhi 18:6a4db94011d3 274 #define ACMP_SET_FILTER(acmp, u32ChNum, u32Cnt) ((acmp)->CTL[(u32ChNum)%2] = ((acmp)->CTL[(u32ChNum)%2] & ~ACMP_CTL_FILTSEL_Msk) | (u32Cnt))
sahilmgandhi 18:6a4db94011d3 275
sahilmgandhi 18:6a4db94011d3 276 /**
sahilmgandhi 18:6a4db94011d3 277 * @brief This macro is used to select comparator reference voltage
sahilmgandhi 18:6a4db94011d3 278 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 279 * @param[in] u32Level The comparator reference voltage setting.
sahilmgandhi 18:6a4db94011d3 280 * The formula is:
sahilmgandhi 18:6a4db94011d3 281 * comparator reference voltage = CRV source voltage x (1/6 + u32Level/24)
sahilmgandhi 18:6a4db94011d3 282 * The range of u32Level is 0 ~ 15.
sahilmgandhi 18:6a4db94011d3 283 * @return None
sahilmgandhi 18:6a4db94011d3 284 * @details When CRV is selected as ACMP negative input source, the CRV level is determined by CRVCTL (ACMP_VREF[3:0]).
sahilmgandhi 18:6a4db94011d3 285 */
sahilmgandhi 18:6a4db94011d3 286 #define ACMP_CRV_SEL(acmp, u32Level) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVCTL_Msk) | ((u32Level)<<ACMP_VREF_CRVCTL_Pos))
sahilmgandhi 18:6a4db94011d3 287
sahilmgandhi 18:6a4db94011d3 288 /**
sahilmgandhi 18:6a4db94011d3 289 * @brief This macro is used to select the source of CRV
sahilmgandhi 18:6a4db94011d3 290 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 291 * @param[in] u32Src is the source of CRV. Including:
sahilmgandhi 18:6a4db94011d3 292 * - \ref ACMP_VREF_CRVSSEL_VDDA
sahilmgandhi 18:6a4db94011d3 293 * - \ref ACMP_VREF_CRVSSEL_INTVREF
sahilmgandhi 18:6a4db94011d3 294 * @return None
sahilmgandhi 18:6a4db94011d3 295 * @details The source of CRV can be VDDA or internal reference voltage. The internal reference voltage level is determined by SYS_VREFCTL register.
sahilmgandhi 18:6a4db94011d3 296 */
sahilmgandhi 18:6a4db94011d3 297 #define ACMP_SELECT_CRV_SRC(acmp, u32Src) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVSSEL_Msk) | (u32Src))
sahilmgandhi 18:6a4db94011d3 298
sahilmgandhi 18:6a4db94011d3 299 /**
sahilmgandhi 18:6a4db94011d3 300 * @brief This macro is used to select ACMP interrupt condition
sahilmgandhi 18:6a4db94011d3 301 * @param[in] acmp The pointer of the specified ACMP module
sahilmgandhi 18:6a4db94011d3 302 * @param[in] u32ChNum The ACMP number
sahilmgandhi 18:6a4db94011d3 303 * @param[in] u32Cond Comparator interrupt condition selection. Including:
sahilmgandhi 18:6a4db94011d3 304 * - \ref ACMP_CTL_INTPOL_RF
sahilmgandhi 18:6a4db94011d3 305 * - \ref ACMP_CTL_INTPOL_R
sahilmgandhi 18:6a4db94011d3 306 * - \ref ACMP_CTL_INTPOL_F
sahilmgandhi 18:6a4db94011d3 307 * @return None
sahilmgandhi 18:6a4db94011d3 308 * @details The ACMP output interrupt condition can be rising edge, falling edge or any edge.
sahilmgandhi 18:6a4db94011d3 309 */
sahilmgandhi 18:6a4db94011d3 310 #define ACMP_SELECT_INT_COND(acmp, u32ChNum, u32Cond) ((acmp)->CTL[(u32ChNum)%2] = ((acmp)->CTL[(u32ChNum)%2] & ~ACMP_CTL_INTPOL_Msk) | (u32Cond))
sahilmgandhi 18:6a4db94011d3 311
sahilmgandhi 18:6a4db94011d3 312
sahilmgandhi 18:6a4db94011d3 313
sahilmgandhi 18:6a4db94011d3 314 /* Function prototype declaration */
sahilmgandhi 18:6a4db94011d3 315 void ACMP_Open(ACMP_T *, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn);
sahilmgandhi 18:6a4db94011d3 316 void ACMP_Close(ACMP_T *, uint32_t u32ChNum);
sahilmgandhi 18:6a4db94011d3 317
sahilmgandhi 18:6a4db94011d3 318
sahilmgandhi 18:6a4db94011d3 319
sahilmgandhi 18:6a4db94011d3 320 /*@}*/ /* end of group ACMP_EXPORTED_FUNCTIONS */
sahilmgandhi 18:6a4db94011d3 321
sahilmgandhi 18:6a4db94011d3 322 /*@}*/ /* end of group ACMP_Driver */
sahilmgandhi 18:6a4db94011d3 323
sahilmgandhi 18:6a4db94011d3 324 /*@}*/ /* end of group Standard_Driver */
sahilmgandhi 18:6a4db94011d3 325
sahilmgandhi 18:6a4db94011d3 326 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 327 }
sahilmgandhi 18:6a4db94011d3 328 #endif
sahilmgandhi 18:6a4db94011d3 329
sahilmgandhi 18:6a4db94011d3 330
sahilmgandhi 18:6a4db94011d3 331 #endif //__ACMP_H__
sahilmgandhi 18:6a4db94011d3 332
sahilmgandhi 18:6a4db94011d3 333 /*** (C) COPYRIGHT 2014~2015 Nuvoton Technology Corp. ***/