Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_acmp.c@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /**************************************************************************//** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file acmp.c |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V1.00 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 3 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 14/05/29 1:13p $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief NUC472/NUC442 Analog Comparator(ACMP) driver source file |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | *****************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 11 | |
sahilmgandhi | 18:6a4db94011d3 | 12 | #include "NUC472_442.h" |
sahilmgandhi | 18:6a4db94011d3 | 13 | |
sahilmgandhi | 18:6a4db94011d3 | 14 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 15 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 16 | { |
sahilmgandhi | 18:6a4db94011d3 | 17 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver |
sahilmgandhi | 18:6a4db94011d3 | 20 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 21 | */ |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | /** @addtogroup NUC472_442_ACMP_Driver ACMP Driver |
sahilmgandhi | 18:6a4db94011d3 | 24 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 25 | */ |
sahilmgandhi | 18:6a4db94011d3 | 26 | |
sahilmgandhi | 18:6a4db94011d3 | 27 | |
sahilmgandhi | 18:6a4db94011d3 | 28 | /** @addtogroup NUC472_442_ACMP_EXPORTED_FUNCTIONS ACMP Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 29 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 30 | */ |
sahilmgandhi | 18:6a4db94011d3 | 31 | |
sahilmgandhi | 18:6a4db94011d3 | 32 | |
sahilmgandhi | 18:6a4db94011d3 | 33 | /** |
sahilmgandhi | 18:6a4db94011d3 | 34 | * @brief Configure the specified ACMP module |
sahilmgandhi | 18:6a4db94011d3 | 35 | * |
sahilmgandhi | 18:6a4db94011d3 | 36 | * @param[in] acmp The base address of ACMP module |
sahilmgandhi | 18:6a4db94011d3 | 37 | * @param[in] u32ChNum comparator number, could be 0, 1, 2 |
sahilmgandhi | 18:6a4db94011d3 | 38 | * @param[in] u32NegSrc is comparator negative input selection. Including: |
sahilmgandhi | 18:6a4db94011d3 | 39 | * - \ref ACMP_VNEG_PIN |
sahilmgandhi | 18:6a4db94011d3 | 40 | * - \ref ACMP_VNEG_BANDGAP |
sahilmgandhi | 18:6a4db94011d3 | 41 | * - \ref ACMP_VNEG_4_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 42 | * - \ref ACMP_VNEG_5_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 43 | * - \ref ACMP_VNEG_6_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 44 | * - \ref ACMP_VNEG_7_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 45 | * - \ref ACMP_VNEG_8_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 46 | * - \ref ACMP_VNEG_9_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 47 | * - \ref ACMP_VNEG_10_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 48 | * - \ref ACMP_VNEG_11_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 49 | * - \ref ACMP_VNEG_12_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 50 | * - \ref ACMP_VNEG_13_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 51 | * - \ref ACMP_VNEG_14_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 52 | * - \ref ACMP_VNEG_15_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 53 | * - \ref ACMP_VNEG_16_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 54 | * - \ref ACMP_VNEG_17_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 55 | * - \ref ACMP_VNEG_18_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 56 | * - \ref ACMP_VNEG_19_OVER_24_VDD |
sahilmgandhi | 18:6a4db94011d3 | 57 | * - \ref ACMP_VNEG_4_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 58 | * - \ref ACMP_VNEG_5_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 59 | * - \ref ACMP_VNEG_6_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 60 | * - \ref ACMP_VNEG_7_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 61 | * - \ref ACMP_VNEG_8_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 62 | * - \ref ACMP_VNEG_9_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 63 | * - \ref ACMP_VNEG_10_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 64 | * - \ref ACMP_VNEG_11_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 65 | * - \ref ACMP_VNEG_12_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 66 | * - \ref ACMP_VNEG_13_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 67 | * - \ref ACMP_VNEG_14_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 68 | * - \ref ACMP_VNEG_15_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 69 | * - \ref ACMP_VNEG_16_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 70 | * - \ref ACMP_VNEG_17_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 71 | * - \ref ACMP_VNEG_18_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 72 | * - \ref ACMP_VNEG_19_OVER_24_IREF |
sahilmgandhi | 18:6a4db94011d3 | 73 | * |
sahilmgandhi | 18:6a4db94011d3 | 74 | * @param[in] u32HysteresisEn is the hysteresis function option. Including: |
sahilmgandhi | 18:6a4db94011d3 | 75 | * - \ref ACMP_HYSTERESIS_ENABLE |
sahilmgandhi | 18:6a4db94011d3 | 76 | * - \ref ACMP_HYSTERESIS_DISABLE |
sahilmgandhi | 18:6a4db94011d3 | 77 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 78 | */ |
sahilmgandhi | 18:6a4db94011d3 | 79 | void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn) |
sahilmgandhi | 18:6a4db94011d3 | 80 | { |
sahilmgandhi | 18:6a4db94011d3 | 81 | if(u32NegSrc != ACMP_VNEG_PIN) |
sahilmgandhi | 18:6a4db94011d3 | 82 | ACMP->VREF = u32NegSrc; |
sahilmgandhi | 18:6a4db94011d3 | 83 | ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & (~(ACMP_CTL_NEGSEL_Msk | ACMP_CTL_HYSEN_Msk))) | |
sahilmgandhi | 18:6a4db94011d3 | 84 | ((u32NegSrc != ACMP_VNEG_PIN ? ACMP_CTL_NEGSEL_Msk : 0) | u32HysteresisEn | ACMP_CTL_ACMPEN_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 85 | } |
sahilmgandhi | 18:6a4db94011d3 | 86 | |
sahilmgandhi | 18:6a4db94011d3 | 87 | /** |
sahilmgandhi | 18:6a4db94011d3 | 88 | * @brief This function close comparator |
sahilmgandhi | 18:6a4db94011d3 | 89 | * |
sahilmgandhi | 18:6a4db94011d3 | 90 | * @param[in] acmp The base address of ACMP module |
sahilmgandhi | 18:6a4db94011d3 | 91 | * @param[in] u32ChNum comparator number. |
sahilmgandhi | 18:6a4db94011d3 | 92 | * |
sahilmgandhi | 18:6a4db94011d3 | 93 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 94 | */ |
sahilmgandhi | 18:6a4db94011d3 | 95 | void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum) |
sahilmgandhi | 18:6a4db94011d3 | 96 | { |
sahilmgandhi | 18:6a4db94011d3 | 97 | ACMP->CTL[u32ChNum] &= (~ACMP_CTL_ACMPEN_Msk); |
sahilmgandhi | 18:6a4db94011d3 | 98 | } |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | |
sahilmgandhi | 18:6a4db94011d3 | 101 | |
sahilmgandhi | 18:6a4db94011d3 | 102 | /*@}*/ /* end of group NUC472_442_ACMP_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 103 | |
sahilmgandhi | 18:6a4db94011d3 | 104 | /*@}*/ /* end of group NUC472_442_ACMP_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 105 | |
sahilmgandhi | 18:6a4db94011d3 | 106 | /*@}*/ /* end of group NUC472_442_Device_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 107 | |
sahilmgandhi | 18:6a4db94011d3 | 108 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 109 | } |
sahilmgandhi | 18:6a4db94011d3 | 110 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 111 | |
sahilmgandhi | 18:6a4db94011d3 | 112 | /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ |
sahilmgandhi | 18:6a4db94011d3 | 113 |