Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_M451/device/StdDriver/m451_tk.h@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 tk.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V1.00 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 6 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 15/08/24 4:52p $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief M451 Series TK 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 __TK_H__ |
sahilmgandhi | 18:6a4db94011d3 | 13 | #define __TK_H__ |
sahilmgandhi | 18:6a4db94011d3 | 14 | |
sahilmgandhi | 18:6a4db94011d3 | 15 | #include "M451Series.h" |
sahilmgandhi | 18:6a4db94011d3 | 16 | |
sahilmgandhi | 18:6a4db94011d3 | 17 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 18 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 19 | { |
sahilmgandhi | 18:6a4db94011d3 | 20 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 21 | |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | /** @addtogroup Standard_Driver Standard Driver |
sahilmgandhi | 18:6a4db94011d3 | 24 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 25 | */ |
sahilmgandhi | 18:6a4db94011d3 | 26 | |
sahilmgandhi | 18:6a4db94011d3 | 27 | /** @addtogroup TK_Driver TK Driver |
sahilmgandhi | 18:6a4db94011d3 | 28 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 29 | */ |
sahilmgandhi | 18:6a4db94011d3 | 30 | |
sahilmgandhi | 18:6a4db94011d3 | 31 | /** @addtogroup TK_EXPORTED_CONSTANTS TK Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 32 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 33 | */ |
sahilmgandhi | 18:6a4db94011d3 | 34 | |
sahilmgandhi | 18:6a4db94011d3 | 35 | #define TK_SCAN_MODE_SINGLE (0UL) /*!< Touch key single scan mode */ |
sahilmgandhi | 18:6a4db94011d3 | 36 | #define TK_SCAN_MODE_PERIODIC (TK_CTL_TMRTRGEN_Msk) /*!< Touch key periodic scan mode */ |
sahilmgandhi | 18:6a4db94011d3 | 37 | #define TK_SCAN_MODE_ALL_KEY (TK_REFCTL_SCANALL_Msk) /*!< Touch key all keys scan mode */ |
sahilmgandhi | 18:6a4db94011d3 | 38 | #define TK_SCAN_MODE_PERIODIC_ALL_KEY (TK_CTL_TMRTRGEN_Msk | TK_REFCTL_SCANALL_Msk) /*!< Touch key periodic with all keys scan mode */ |
sahilmgandhi | 18:6a4db94011d3 | 39 | |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define TK_SENSE_PULSE_1 (0UL << TK_REFCTL_SENPTCTL_Pos) /*!< Touch key sensing pulse width is 1us */ |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define TK_SENSE_PULSE_2 (1UL << TK_REFCTL_SENPTCTL_Pos) /*!< Touch key sensing pulse width is 2us */ |
sahilmgandhi | 18:6a4db94011d3 | 42 | #define TK_SENSE_PULSE_4 (2UL << TK_REFCTL_SENPTCTL_Pos) /*!< Touch key sensing pulse width is 4us */ |
sahilmgandhi | 18:6a4db94011d3 | 43 | #define TK_SENSE_PULSE_8 (3UL << TK_REFCTL_SENPTCTL_Pos) /*!< Touch key sensing pulse width is 8us */ |
sahilmgandhi | 18:6a4db94011d3 | 44 | |
sahilmgandhi | 18:6a4db94011d3 | 45 | #define TK_SENSE_CNT_128 (0UL << TK_REFCTL_SENTCTL_Pos) /*!< Touch key sensing count is 128 */ |
sahilmgandhi | 18:6a4db94011d3 | 46 | #define TK_SENSE_CNT_255 (1UL << TK_REFCTL_SENTCTL_Pos) /*!< Touch key sensing count is 255 */ |
sahilmgandhi | 18:6a4db94011d3 | 47 | #define TK_SENSE_CNT_511 (2UL << TK_REFCTL_SENTCTL_Pos) /*!< Touch key sensing count is 511 */ |
sahilmgandhi | 18:6a4db94011d3 | 48 | #define TK_SENSE_CNT_1023 (3UL << TK_REFCTL_SENTCTL_Pos) /*!< Touch key sensing count is 1023 */ |
sahilmgandhi | 18:6a4db94011d3 | 49 | |
sahilmgandhi | 18:6a4db94011d3 | 50 | #define TK_AVCCH_1_DIV_16 (0UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 1/16 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 51 | #define TK_AVCCH_1_DIV_8 (1UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 1/8 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 52 | #define TK_AVCCH_3_DIV_16 (2UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 3/16 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 53 | #define TK_AVCCH_1_DIV_4 (3UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 1/4 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 54 | #define TK_AVCCH_5_DIV_16 (4UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 5/16 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 55 | #define TK_AVCCH_3_DIV_8 (5UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 3/8 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 56 | #define TK_AVCCH_7_DIV_16 (6UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 7/16 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 57 | #define TK_AVCCH_1_DIV_2 (7UL << TK_CTL_AVCCHSEL_Pos) /*!< Touch key AVCCH voltage is 1/2 VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 58 | |
sahilmgandhi | 18:6a4db94011d3 | 59 | #define TK_CAP_BANK_POL_SEL_GND (0UL << TK_POLCTL_CBPOLSEL_Pos) /*!< Touch key capacitor bank polarity is GND */ |
sahilmgandhi | 18:6a4db94011d3 | 60 | #define TK_CAP_BANK_POL_SEL_AVCCH (1UL << TK_POLCTL_CBPOLSEL_Pos) /*!< Touch key capacitor bank polarity is AVCCH */ |
sahilmgandhi | 18:6a4db94011d3 | 61 | #define TK_CAP_BANK_POL_SEL_VDD (2UL << TK_POLCTL_CBPOLSEL_Pos) /*!< Touch key capacitor bank polarity is VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 62 | |
sahilmgandhi | 18:6a4db94011d3 | 63 | #define TK_TKn_POL_SEL_GND (0UL) /*!< Touch key polarity is GND */ |
sahilmgandhi | 18:6a4db94011d3 | 64 | #define TK_TKn_POL_SEL_AVCCH (1UL) /*!< Touch key polarity is AVCCH */ |
sahilmgandhi | 18:6a4db94011d3 | 65 | #define TK_TKn_POL_SEL_VDD (2UL) /*!< Touch key polarity is VDD */ |
sahilmgandhi | 18:6a4db94011d3 | 66 | |
sahilmgandhi | 18:6a4db94011d3 | 67 | #define TK_INT_EN_SCAN_COMPLETE (TK_INTEN_SCINTEN_Msk) /*!< Touch key enable scan complete interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 68 | #define TK_INT_EN_SCAN_COMPLETE_EDGE_TH (TK_INTEN_SCTHIEN_Msk) /*!< Touch key enable scan complete with threshold interrupt of edge trigger mode */ |
sahilmgandhi | 18:6a4db94011d3 | 69 | #define TK_INT_EN_SCAN_COMPLETE_LEVEL_TH (TK_INTEN_THIMOD_Msk | TK_INTEN_SCTHIEN_Msk) /*!< Touch key enable scan complete with threshold interrupt of level trigger mode */ |
sahilmgandhi | 18:6a4db94011d3 | 70 | |
sahilmgandhi | 18:6a4db94011d3 | 71 | #define TK_INT_SCAN_COMPLETE (TK_STATUS_SCIF_Msk) /*!< Touch key scan complete interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 72 | #define TK_INT_SCAN_COMPLETE_TH_ALL (0x1FFFF02UL) /*!< Touch key scan complete or all touch keys threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 73 | #define TK_INT_SCAN_TH_ALL (0x1FFFF00UL) /*!< ALL Touch key threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 74 | #define TK_INT_SCAN_TH_TK0 (TK_STATUS_TKIF0_Msk) /*!< Touch key 0 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 75 | #define TK_INT_SCAN_TH_TK1 (TK_STATUS_TKIF1_Msk) /*!< Touch key 1 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 76 | #define TK_INT_SCAN_TH_TK2 (TK_STATUS_TKIF2_Msk) /*!< Touch key 2 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 77 | #define TK_INT_SCAN_TH_TK3 (TK_STATUS_TKIF3_Msk) /*!< Touch key 3 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 78 | #define TK_INT_SCAN_TH_TK4 (TK_STATUS_TKIF4_Msk) /*!< Touch key 4 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 79 | #define TK_INT_SCAN_TH_TK5 (TK_STATUS_TKIF5_Msk) /*!< Touch key 5 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 80 | #define TK_INT_SCAN_TH_TK6 (TK_STATUS_TKIF6_Msk) /*!< Touch key 6 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 81 | #define TK_INT_SCAN_TH_TK7 (TK_STATUS_TKIF7_Msk) /*!< Touch key 7 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 82 | #define TK_INT_SCAN_TH_TK8 (TK_STATUS_TKIF8_Msk) /*!< Touch key 8 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 83 | #define TK_INT_SCAN_TH_TK9 (TK_STATUS_TKIF9_Msk) /*!< Touch key 9 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 84 | #define TK_INT_SCAN_TH_TK10 (TK_STATUS_TKIF10_Msk) /*!< Touch key 10 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 85 | #define TK_INT_SCAN_TH_TK11 (TK_STATUS_TKIF11_Msk) /*!< Touch key 11 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 86 | #define TK_INT_SCAN_TH_TK12 (TK_STATUS_TKIF12_Msk) /*!< Touch key 12 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 87 | #define TK_INT_SCAN_TH_TK13 (TK_STATUS_TKIF13_Msk) /*!< Touch key 13 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 88 | #define TK_INT_SCAN_TH_TK14 (TK_STATUS_TKIF14_Msk) /*!< Touch key 14 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 89 | #define TK_INT_SCAN_TH_TK15 (TK_STATUS_TKIF15_Msk) /*!< Touch key 15 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 90 | #define TK_INT_SCAN_TH_TK16 (TK_STATUS_TKIF16_Msk) /*!< Touch key 16 threshold control interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 91 | |
sahilmgandhi | 18:6a4db94011d3 | 92 | |
sahilmgandhi | 18:6a4db94011d3 | 93 | /*@}*/ /* end of group TK_EXPORTED_CONSTANTS */ |
sahilmgandhi | 18:6a4db94011d3 | 94 | |
sahilmgandhi | 18:6a4db94011d3 | 95 | |
sahilmgandhi | 18:6a4db94011d3 | 96 | /** @addtogroup TK_EXPORTED_FUNCTIONS TK Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 97 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | /** |
sahilmgandhi | 18:6a4db94011d3 | 101 | * @brief Enable scan key(s) |
sahilmgandhi | 18:6a4db94011d3 | 102 | * @param[in] u32Mask Combination of enabled scan keys. Each bit corresponds to a touch key. |
sahilmgandhi | 18:6a4db94011d3 | 103 | * Bit 0 represents touch key 0, bit 1 represents touch key 1... |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 105 | * @note Touch key 16 is the default reference key, so touch key 16 is enabled. |
sahilmgandhi | 18:6a4db94011d3 | 106 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 107 | */ |
sahilmgandhi | 18:6a4db94011d3 | 108 | #define TK_ENABLE_SCAN_KEY(u32Mask) (TK->CTL |= (u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 109 | |
sahilmgandhi | 18:6a4db94011d3 | 110 | /** |
sahilmgandhi | 18:6a4db94011d3 | 111 | * @brief Disable scan key(s) |
sahilmgandhi | 18:6a4db94011d3 | 112 | * @param[in] u32Mask Combination of disabled scan keys. Each bit corresponds to a touch key. |
sahilmgandhi | 18:6a4db94011d3 | 113 | * Bit 0 represents touch key 0, bit 1 represents touch key 1... |
sahilmgandhi | 18:6a4db94011d3 | 114 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 115 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 116 | */ |
sahilmgandhi | 18:6a4db94011d3 | 117 | #define TK_DISABLE_SCAN_KEY(u32Mask) (TK->CTL &= ~(u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 118 | |
sahilmgandhi | 18:6a4db94011d3 | 119 | /** |
sahilmgandhi | 18:6a4db94011d3 | 120 | * @brief Enable reference key(s) |
sahilmgandhi | 18:6a4db94011d3 | 121 | * @param[in] u32Mask Combination of enabled reference keys. Each bit corresponds to a touch key. |
sahilmgandhi | 18:6a4db94011d3 | 122 | * Bit 0 represents touch key 0, bit 1 represents touch key 1... |
sahilmgandhi | 18:6a4db94011d3 | 123 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 124 | * @note Touch key 16 is the default reference key, so touch key 16 is enabled. |
sahilmgandhi | 18:6a4db94011d3 | 125 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 126 | */ |
sahilmgandhi | 18:6a4db94011d3 | 127 | #define TK_ENABLE_REF_KEY(u32Mask) (TK->REFCTL |= (u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 128 | |
sahilmgandhi | 18:6a4db94011d3 | 129 | /** |
sahilmgandhi | 18:6a4db94011d3 | 130 | * @brief Disable reference key(s) |
sahilmgandhi | 18:6a4db94011d3 | 131 | * @param[in] u32Mask Combination of disabled reference keys. Each bit corresponds to a touch key. |
sahilmgandhi | 18:6a4db94011d3 | 132 | * Bit 0 represents touch key 0, bit 1 represents touch key 1... |
sahilmgandhi | 18:6a4db94011d3 | 133 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @note It must enable a reference key and touch key 16 is the default reference key. |
sahilmgandhi | 18:6a4db94011d3 | 135 | * If no any one touch key as reference key except touch key 16, then reference Touch key 16 can't be disable. |
sahilmgandhi | 18:6a4db94011d3 | 136 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 137 | */ |
sahilmgandhi | 18:6a4db94011d3 | 138 | #define TK_DISABLE_REF_KEY(u32Mask) (TK->REFCTL &= ~(u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 139 | |
sahilmgandhi | 18:6a4db94011d3 | 140 | /** |
sahilmgandhi | 18:6a4db94011d3 | 141 | * @brief Initiate enabled key(s) scan immediately. |
sahilmgandhi | 18:6a4db94011d3 | 142 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 144 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 145 | */ |
sahilmgandhi | 18:6a4db94011d3 | 146 | #define TK_START_SCAN() (TK->CTL |= TK_CTL_SCAN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 147 | |
sahilmgandhi | 18:6a4db94011d3 | 148 | /** |
sahilmgandhi | 18:6a4db94011d3 | 149 | * @brief Set touch key Sensing pulse width. |
sahilmgandhi | 18:6a4db94011d3 | 150 | * @param[in] u32PulseWidth Sensing pulse width. |
sahilmgandhi | 18:6a4db94011d3 | 151 | * - \ref TK_SENSE_PULSE_1 |
sahilmgandhi | 18:6a4db94011d3 | 152 | * - \ref TK_SENSE_PULSE_2 |
sahilmgandhi | 18:6a4db94011d3 | 153 | * - \ref TK_SENSE_PULSE_4 |
sahilmgandhi | 18:6a4db94011d3 | 154 | * - \ref TK_SENSE_PULSE_8 |
sahilmgandhi | 18:6a4db94011d3 | 155 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 156 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 157 | */ |
sahilmgandhi | 18:6a4db94011d3 | 158 | #define TK_SET_PULSE_WIDTH(u32PulseWidth) (TK->REFCTL = (TK->REFCTL & ~TK_REFCTL_SENPTCTL_Msk) | (u32PulseWidth)) |
sahilmgandhi | 18:6a4db94011d3 | 159 | |
sahilmgandhi | 18:6a4db94011d3 | 160 | /** |
sahilmgandhi | 18:6a4db94011d3 | 161 | * @brief Set touch key Sensing count. |
sahilmgandhi | 18:6a4db94011d3 | 162 | * @param[in] u32SenseCnt Sensing count. |
sahilmgandhi | 18:6a4db94011d3 | 163 | * - \ref TK_SENSE_CNT_128 |
sahilmgandhi | 18:6a4db94011d3 | 164 | * - \ref TK_SENSE_CNT_255 |
sahilmgandhi | 18:6a4db94011d3 | 165 | * - \ref TK_SENSE_CNT_511 |
sahilmgandhi | 18:6a4db94011d3 | 166 | * - \ref TK_SENSE_CNT_1023 |
sahilmgandhi | 18:6a4db94011d3 | 167 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 168 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 169 | */ |
sahilmgandhi | 18:6a4db94011d3 | 170 | #define TK_SET_SENSING_CNT(u32SenseCnt) (TK->REFCTL = (TK->REFCTL & ~TK_REFCTL_SENTCTL_Msk) | (u32SenseCnt)) |
sahilmgandhi | 18:6a4db94011d3 | 171 | |
sahilmgandhi | 18:6a4db94011d3 | 172 | |
sahilmgandhi | 18:6a4db94011d3 | 173 | /** |
sahilmgandhi | 18:6a4db94011d3 | 174 | * @brief Set touch key AVCCH voltage. |
sahilmgandhi | 18:6a4db94011d3 | 175 | * @param[in] u32AVCCHSel voltage selection. |
sahilmgandhi | 18:6a4db94011d3 | 176 | * - \ref TK_AVCCH_1_DIV_16 |
sahilmgandhi | 18:6a4db94011d3 | 177 | * - \ref TK_AVCCH_1_DIV_8 |
sahilmgandhi | 18:6a4db94011d3 | 178 | * - \ref TK_AVCCH_3_DIV_16 |
sahilmgandhi | 18:6a4db94011d3 | 179 | * - \ref TK_AVCCH_1_DIV_4 |
sahilmgandhi | 18:6a4db94011d3 | 180 | * - \ref TK_AVCCH_5_DIV_16 |
sahilmgandhi | 18:6a4db94011d3 | 181 | * - \ref TK_AVCCH_3_DIV_8 |
sahilmgandhi | 18:6a4db94011d3 | 182 | * - \ref TK_AVCCH_7_DIV_16 |
sahilmgandhi | 18:6a4db94011d3 | 183 | * - \ref TK_AVCCH_1_DIV_2 |
sahilmgandhi | 18:6a4db94011d3 | 184 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 185 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 186 | */ |
sahilmgandhi | 18:6a4db94011d3 | 187 | #define TK_SET_AVCCH(u32AVCCHSel) (TK->CTL = (TK->CTL & ~TK_CTL_AVCCHSEL_Msk) | (u32AVCCHSel)) |
sahilmgandhi | 18:6a4db94011d3 | 188 | |
sahilmgandhi | 18:6a4db94011d3 | 189 | /** |
sahilmgandhi | 18:6a4db94011d3 | 190 | * @brief Get touch key complement capacitor bank data. |
sahilmgandhi | 18:6a4db94011d3 | 191 | * @param[in] u32TKNum Touch key number. The valid value is 0~16. |
sahilmgandhi | 18:6a4db94011d3 | 192 | * @return Complement capacitor bank data |
sahilmgandhi | 18:6a4db94011d3 | 193 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 194 | */ |
sahilmgandhi | 18:6a4db94011d3 | 195 | #define TK_GET_COMP_CAP_BANK_DATA(u32TKNum) (((*(__IO uint32_t *) (&(TK->CCBDAT0) + ((u32TKNum) >> 2))) >> ((u32TKNum) % 4 * 8) & TK_CCBDAT0_CCBDAT0_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 196 | |
sahilmgandhi | 18:6a4db94011d3 | 197 | /** |
sahilmgandhi | 18:6a4db94011d3 | 198 | * @brief Get touch key sensing result data. |
sahilmgandhi | 18:6a4db94011d3 | 199 | * @param[in] u32TKNum Touch key number. The valid value is 0~16. |
sahilmgandhi | 18:6a4db94011d3 | 200 | * @return Sensing result data |
sahilmgandhi | 18:6a4db94011d3 | 201 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 202 | */ |
sahilmgandhi | 18:6a4db94011d3 | 203 | #define TK_GET_SENSE_DATA(u32TKNum) (((*(__IO uint32_t *) (&(TK->DAT0) + ((u32TKNum) >> 2))) >> ((u32TKNum) % 4 * 8) & TK_DAT0_TKDAT0_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 204 | |
sahilmgandhi | 18:6a4db94011d3 | 205 | /** |
sahilmgandhi | 18:6a4db94011d3 | 206 | * @brief Get touch key busy status. |
sahilmgandhi | 18:6a4db94011d3 | 207 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 208 | * @retval 0 Touch key is scan completed or stopped. |
sahilmgandhi | 18:6a4db94011d3 | 209 | * @retval 1 Touch key is busy. |
sahilmgandhi | 18:6a4db94011d3 | 210 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 211 | */ |
sahilmgandhi | 18:6a4db94011d3 | 212 | #define TK_IS_BUSY() ((TK->STATUS & TK_STATUS_BUSY_Msk) ? 1: 0) |
sahilmgandhi | 18:6a4db94011d3 | 213 | |
sahilmgandhi | 18:6a4db94011d3 | 214 | /** |
sahilmgandhi | 18:6a4db94011d3 | 215 | * @brief Get touch key interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 216 | * @param[in] u32Mask Interrupt flag type selection. |
sahilmgandhi | 18:6a4db94011d3 | 217 | * - \ref TK_INT_SCAN_COMPLETE |
sahilmgandhi | 18:6a4db94011d3 | 218 | * - \ref TK_INT_SCAN_COMPLETE_TH_ALL |
sahilmgandhi | 18:6a4db94011d3 | 219 | * - \ref TK_INT_SCAN_TH_ALL |
sahilmgandhi | 18:6a4db94011d3 | 220 | * - \ref TK_INT_SCAN_TH_TK0 |
sahilmgandhi | 18:6a4db94011d3 | 221 | * - \ref TK_INT_SCAN_TH_TK1 |
sahilmgandhi | 18:6a4db94011d3 | 222 | * - \ref TK_INT_SCAN_TH_TK2 |
sahilmgandhi | 18:6a4db94011d3 | 223 | * - \ref TK_INT_SCAN_TH_TK3 |
sahilmgandhi | 18:6a4db94011d3 | 224 | * - \ref TK_INT_SCAN_TH_TK4 |
sahilmgandhi | 18:6a4db94011d3 | 225 | * - \ref TK_INT_SCAN_TH_TK5 |
sahilmgandhi | 18:6a4db94011d3 | 226 | * - \ref TK_INT_SCAN_TH_TK6 |
sahilmgandhi | 18:6a4db94011d3 | 227 | * - \ref TK_INT_SCAN_TH_TK7 |
sahilmgandhi | 18:6a4db94011d3 | 228 | * - \ref TK_INT_SCAN_TH_TK8 |
sahilmgandhi | 18:6a4db94011d3 | 229 | * - \ref TK_INT_SCAN_TH_TK9 |
sahilmgandhi | 18:6a4db94011d3 | 230 | * - \ref TK_INT_SCAN_TH_TK10 |
sahilmgandhi | 18:6a4db94011d3 | 231 | * - \ref TK_INT_SCAN_TH_TK11 |
sahilmgandhi | 18:6a4db94011d3 | 232 | * - \ref TK_INT_SCAN_TH_TK12 |
sahilmgandhi | 18:6a4db94011d3 | 233 | * - \ref TK_INT_SCAN_TH_TK13 |
sahilmgandhi | 18:6a4db94011d3 | 234 | * - \ref TK_INT_SCAN_TH_TK14 |
sahilmgandhi | 18:6a4db94011d3 | 235 | * - \ref TK_INT_SCAN_TH_TK15 |
sahilmgandhi | 18:6a4db94011d3 | 236 | * - \ref TK_INT_SCAN_TH_TK16 |
sahilmgandhi | 18:6a4db94011d3 | 237 | * @retval 0 Touch key has no interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 238 | * @retval 1 Touch key is scan completed or threshold control event occurs. |
sahilmgandhi | 18:6a4db94011d3 | 239 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 240 | */ |
sahilmgandhi | 18:6a4db94011d3 | 241 | #define TK_GET_INT_STATUS(u32Mask) ((TK->STATUS & (u32Mask)) ? 1: 0) |
sahilmgandhi | 18:6a4db94011d3 | 242 | |
sahilmgandhi | 18:6a4db94011d3 | 243 | /** |
sahilmgandhi | 18:6a4db94011d3 | 244 | * @brief Clear touch key interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 245 | * @param[in] u32Mask Interrupt flag type selection. |
sahilmgandhi | 18:6a4db94011d3 | 246 | * - \ref TK_INT_SCAN_COMPLETE |
sahilmgandhi | 18:6a4db94011d3 | 247 | * - \ref TK_INT_SCAN_COMPLETE_TH_ALL |
sahilmgandhi | 18:6a4db94011d3 | 248 | * - \ref TK_INT_SCAN_TH_ALL |
sahilmgandhi | 18:6a4db94011d3 | 249 | * - \ref TK_INT_SCAN_TH_TK0 |
sahilmgandhi | 18:6a4db94011d3 | 250 | * - \ref TK_INT_SCAN_TH_TK1 |
sahilmgandhi | 18:6a4db94011d3 | 251 | * - \ref TK_INT_SCAN_TH_TK2 |
sahilmgandhi | 18:6a4db94011d3 | 252 | * - \ref TK_INT_SCAN_TH_TK3 |
sahilmgandhi | 18:6a4db94011d3 | 253 | * - \ref TK_INT_SCAN_TH_TK4 |
sahilmgandhi | 18:6a4db94011d3 | 254 | * - \ref TK_INT_SCAN_TH_TK5 |
sahilmgandhi | 18:6a4db94011d3 | 255 | * - \ref TK_INT_SCAN_TH_TK6 |
sahilmgandhi | 18:6a4db94011d3 | 256 | * - \ref TK_INT_SCAN_TH_TK7 |
sahilmgandhi | 18:6a4db94011d3 | 257 | * - \ref TK_INT_SCAN_TH_TK8 |
sahilmgandhi | 18:6a4db94011d3 | 258 | * - \ref TK_INT_SCAN_TH_TK9 |
sahilmgandhi | 18:6a4db94011d3 | 259 | * - \ref TK_INT_SCAN_TH_TK10 |
sahilmgandhi | 18:6a4db94011d3 | 260 | * - \ref TK_INT_SCAN_TH_TK11 |
sahilmgandhi | 18:6a4db94011d3 | 261 | * - \ref TK_INT_SCAN_TH_TK12 |
sahilmgandhi | 18:6a4db94011d3 | 262 | * - \ref TK_INT_SCAN_TH_TK13 |
sahilmgandhi | 18:6a4db94011d3 | 263 | * - \ref TK_INT_SCAN_TH_TK14 |
sahilmgandhi | 18:6a4db94011d3 | 264 | * - \ref TK_INT_SCAN_TH_TK15 |
sahilmgandhi | 18:6a4db94011d3 | 265 | * - \ref TK_INT_SCAN_TH_TK16 |
sahilmgandhi | 18:6a4db94011d3 | 266 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 267 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 268 | */ |
sahilmgandhi | 18:6a4db94011d3 | 269 | #define TK_CLR_INT_FLAG(u32Mask) (TK->STATUS = (u32Mask)) |
sahilmgandhi | 18:6a4db94011d3 | 270 | |
sahilmgandhi | 18:6a4db94011d3 | 271 | |
sahilmgandhi | 18:6a4db94011d3 | 272 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 273 | /* Define TK functions prototype */ |
sahilmgandhi | 18:6a4db94011d3 | 274 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 275 | void TK_Open(void); |
sahilmgandhi | 18:6a4db94011d3 | 276 | void TK_Close(void); |
sahilmgandhi | 18:6a4db94011d3 | 277 | void TK_SetScanMode(uint32_t u32Mode); |
sahilmgandhi | 18:6a4db94011d3 | 278 | void TK_ConfigSensitivity(uint32_t u32PulseWidth, uint32_t u32SenseCnt, uint32_t u32AVCCHSel); |
sahilmgandhi | 18:6a4db94011d3 | 279 | void TK_SetCapBankPol(uint32_t u32CapBankPolSel); |
sahilmgandhi | 18:6a4db94011d3 | 280 | void TK_EnableTkPolarity(uint32_t u32Mask); |
sahilmgandhi | 18:6a4db94011d3 | 281 | void TK_DisableTkPolarity(uint32_t u32Mask); |
sahilmgandhi | 18:6a4db94011d3 | 282 | void TK_SetCompCapBankData(uint32_t u32TKNum, uint32_t u32CapData); |
sahilmgandhi | 18:6a4db94011d3 | 283 | void TK_SetTkPol(uint32_t u32Mask, uint32_t u32PolSel); |
sahilmgandhi | 18:6a4db94011d3 | 284 | void TK_SetRefKeyCapBankData(uint32_t u32CapData); |
sahilmgandhi | 18:6a4db94011d3 | 285 | void TK_SetScanThreshold(uint32_t u32TKNum, uint32_t u32HighLevel, uint32_t u32LowLevel); |
sahilmgandhi | 18:6a4db94011d3 | 286 | void TK_EnableInt(uint32_t u32Msk); |
sahilmgandhi | 18:6a4db94011d3 | 287 | void TK_DisableInt(uint32_t u32Msk); |
sahilmgandhi | 18:6a4db94011d3 | 288 | |
sahilmgandhi | 18:6a4db94011d3 | 289 | |
sahilmgandhi | 18:6a4db94011d3 | 290 | /*@}*/ /* end of group TK_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 291 | |
sahilmgandhi | 18:6a4db94011d3 | 292 | /*@}*/ /* end of group TK_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 293 | |
sahilmgandhi | 18:6a4db94011d3 | 294 | /*@}*/ /* end of group Standard_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 295 | |
sahilmgandhi | 18:6a4db94011d3 | 296 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 297 | } |
sahilmgandhi | 18:6a4db94011d3 | 298 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 299 | |
sahilmgandhi | 18:6a4db94011d3 | 300 | #endif //__TK_H__ |
sahilmgandhi | 18:6a4db94011d3 | 301 | |
sahilmgandhi | 18:6a4db94011d3 | 302 | /*** (C) COPYRIGHT 2014~2015 Nuvoton Technology Corp. ***/ |