| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | |
| 2 | /***************************************************************************** |
||
| 3 | * FileName: mTouchCap_CtmuAPI.h |
||
| 4 | * Dependencies: |
||
| 5 | * Processor: PIC18, PIC24 |
||
| 6 | * Compiler: C18, C30 |
||
| 7 | * Linker: MPLINK,MPLAB LINK30 |
||
| 8 | * Company: Microchip Technology Incorporated |
||
| 9 | * |
||
| 10 | * Software License Agreement |
||
| 11 | * |
||
| 12 | * Copyright © 2009 Microchip Technology Inc. |
||
| 13 | * Microchip licenses this software to you solely for use with Microchip products, according to the terms of the |
||
| 14 | * accompanying click-wrap software license. Microchip and its licensors retain all right, title and interest in |
||
| 15 | * and to the software. All rights reserved. This software and any accompanying information is for suggestion only. |
||
| 16 | * It shall not be deemed to modify Microchips standard warranty for its products. It is your responsibility to ensure |
||
| 17 | * that this software meets your requirements. |
||
| 18 | |||
| 19 | * SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
||
| 20 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT |
||
| 21 | * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP OR ITS LICENSORS BE LIABLE |
||
| 22 | * FOR ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO INCIDENTAL, |
||
| 23 | * SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, |
||
| 24 | * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, OR ANY CLAIMS BY THIRD PARTIES |
||
| 25 | * (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. |
||
| 26 | * The aggregate and cumulative liability of Microchip and its licensors for damages related to the use of the software |
||
| 27 | * will in no event exceed $1000 or the amount you paid Microchip for the software, whichever is greater. |
||
| 28 | |||
| 29 | * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS AND |
||
| 30 | * THE TERMS OF THE ACCOMPANYING CLICK-WRAP SOFTWARE LICENSE. |
||
| 31 | * |
||
| 32 | * |
||
| 33 | * Author Date Comment |
||
| 34 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 35 | * Naveen. M 14 Apr 2009 Version 1.0 Initial Draft |
||
| 36 | * Sasha. M / Naveen. M 4 May 2009 Version 1.0 Initial Draft |
||
| 37 | * Sasha. M / Naveen. M 11 Nov 2009 Version 1.0 Initial Draft |
||
| 38 | * Sasha. M / Nithin. 10 April 2010 Version 1.20 Release |
||
| 39 | *****************************************************************************/ |
||
| 40 | #ifndef _mTOUCH_CAP_CTMU_API_H |
||
| 41 | #define _mTOUCH_CAP_CTMU_API_H |
||
| 42 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 43 | /* ~~~~~~~~~~~~~~~~~~~~~ Includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 44 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 45 | #include "Config.h" |
||
| 46 | #include "GenericTypeDefs.h" |
||
| 47 | #include "HardwareProfile.h" |
||
| 48 | |||
| 49 | #ifdef __PIC24F__ |
||
| 50 | #include "mTouchCap_PIC24_CTMU_Physical.h" |
||
| 51 | #else |
||
| 52 | #include "mTouchCap_PIC18_CTMU_Physical.h" |
||
| 53 | #endif |
||
| 54 | |||
| 55 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 56 | /* ~~~~~~~~~~~~~~~~~~~~~ Enums ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 57 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 58 | |||
| 59 | enum |
||
| 60 | { |
||
| 61 | NO, |
||
| 62 | YES |
||
| 63 | }; |
||
| 64 | enum |
||
| 65 | { |
||
| 66 | NOT_AN_ACTIVE_CHANNEL = -1, |
||
| 67 | KEY_NOT_PRESSED, |
||
| 68 | KEY_PRESSED |
||
| 69 | }; |
||
| 70 | |||
| 71 | enum |
||
| 72 | { |
||
| 73 | CHANNEL_NOT_DETECT =0, |
||
| 74 | CHANNEL_DETECT |
||
| 75 | }; |
||
| 76 | |||
| 77 | enum |
||
| 78 | { |
||
| 79 | FAILED = -1, |
||
| 80 | PASSED = 1 |
||
| 81 | }; |
||
| 82 | |||
| 83 | enum |
||
| 84 | { |
||
| 85 | NEGATIVE_EDGE_POL=0, |
||
| 86 | POSITIVE_EDGE_POL |
||
| 87 | }; |
||
| 88 | |||
| 89 | enum |
||
| 90 | { |
||
| 91 | CURRENT_SRC_DISABLED=0, |
||
| 92 | CURRENT_RANGE_BASE_CURRENT, |
||
| 93 | CURRENT_RANGE_10XBASE_CURRENT, |
||
| 94 | CURRENT_RANGE_100XBASE_CURRENT |
||
| 95 | }; |
||
| 96 | |||
| 97 | enum |
||
| 98 | { |
||
| 99 | TRIGGER_SOURCE_TIMER1=0, |
||
| 100 | TRIGGER_SOURCE_OC, |
||
| 101 | TRIGGER_SOURCE_EXTERNAL2, |
||
| 102 | TRIGGER_SOURCE_EXTERNAL1 |
||
| 103 | }; |
||
| 104 | |||
| 105 | |||
| 106 | enum |
||
| 107 | { |
||
| 108 | OUTPUT=0, |
||
| 109 | INPUT |
||
| 110 | }; |
||
| 111 | |||
| 112 | enum |
||
| 113 | { |
||
| 114 | LOW=0, |
||
| 115 | HIGH |
||
| 116 | }; |
||
| 117 | |||
| 118 | enum |
||
| 119 | { |
||
| 120 | DISABLE=0, |
||
| 121 | ENABLE |
||
| 122 | }; |
||
| 123 | |||
| 124 | enum |
||
| 125 | { |
||
| 126 | RELEASE=0, |
||
| 127 | PRESS |
||
| 128 | }; |
||
| 129 | |||
| 130 | enum |
||
| 131 | { |
||
| 132 | CHANNEL_AN0 , |
||
| 133 | CHANNEL_AN1 , |
||
| 134 | CHANNEL_AN2 , |
||
| 135 | CHANNEL_AN3 , |
||
| 136 | CHANNEL_AN4 , |
||
| 137 | CHANNEL_AN5 , |
||
| 138 | CHANNEL_AN6 , |
||
| 139 | CHANNEL_AN7 , |
||
| 140 | CHANNEL_AN8 , |
||
| 141 | CHANNEL_AN9 , |
||
| 142 | CHANNEL_AN10 , |
||
| 143 | CHANNEL_AN11 , |
||
| 144 | CHANNEL_AN12 |
||
| 145 | #if defined(__PIC24F__) //NC3 |
||
| 146 | ,CHANNEL_AN13 , // for PIC24. Not available in PIC18 |
||
| 147 | CHANNEL_AN14 , // for PIC24. Not available in PIC18 |
||
| 148 | CHANNEL_AN15 // for PIC24. Not available in PIC18 |
||
| 149 | #if defined(__PIC24FJ_DAXXX__) |
||
| 150 | ,CHANNEL_AN16 , // for DA210 |
||
| 151 | CHANNEL_AN17 , // for DA210 |
||
| 152 | CHANNEL_AN18 , // for DA210 |
||
| 153 | CHANNEL_AN19 , // for DA210 |
||
| 154 | CHANNEL_AN20 , // for DA210 |
||
| 155 | CHANNEL_AN21 , // for DA210 |
||
| 156 | CHANNEL_AN22 , // for DA210 |
||
| 157 | CHANNEL_AN23 // for DA210 |
||
| 158 | #endif |
||
| 159 | #endif |
||
| 160 | |||
| 161 | }; |
||
| 162 | |||
| 163 | |||
| 164 | /* chFilterType[ChannelNum] |
||
| 165 | Filter type methods. If the order is changed here, change the condition in the function "mTouchCapPhy_AverageData" |
||
| 166 | |||
| 167 | FilterType - Filter type selection |
||
| 168 | * 0 - Slow moving average 1/20 |
||
| 169 | * 1 - Gated average (as soon as the press stop averaging) |
||
| 170 | * 2 - Fast average (average every sample) |
||
| 171 | */ |
||
| 172 | |||
| 173 | enum |
||
| 174 | { |
||
| 175 | FILTER_METHOD_SLOWAVERAGE=0, |
||
| 176 | FILTER_METHOD_GATEDAVERAGE, |
||
| 177 | FILTER_METHOD_FASTAVERAGE |
||
| 178 | }; |
||
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | /* |
||
| 183 | - The decoding method used |
||
| 184 | * 0 - most pressed |
||
| 185 | * 1 - multiple presses detected at the same time |
||
| 186 | * 2 - press-and-release asserts the press |
||
| 187 | * 3 - press it self assert the press |
||
| 188 | * 4 - key press freezes the key board, until it is released |
||
| 189 | |||
| 190 | Filter type methods. If the order is changed here, change the condition in the function "mTouchCapPhy_AverageData" |
||
| 191 | */ |
||
| 192 | enum |
||
| 193 | { |
||
| 194 | DECODE_METHOD_MOST_PRESSED, /* Future exapansion pending */ |
||
| 195 | DECODE_METHOD_MULTIPLE_PRESS, /* Future exapansion pending */ |
||
| 196 | DECODE_METHOD_PRESS_AND_RELEASE, /* Future exapansion pending */ |
||
| 197 | DECODE_METHOD_PRESS_ASSERT /* Implemented */ |
||
| 198 | // DECODE_METHOD_KEY_PRESS_FREEZ /* Future exapansion pending */ |
||
| 199 | }; |
||
| 200 | |||
| 201 | /* Return values of the API "mTouchCapAPI_SetUpChannel" */ |
||
| 202 | enum |
||
| 203 | { |
||
| 204 | SETUP_SUCCESS, /* The setup process is successfull */ |
||
| 205 | SETUP_ERROR /* There is some kind of error in Setup */ |
||
| 206 | }; |
||
| 207 | |||
| 208 | enum |
||
| 209 | { |
||
| 210 | TWO_CHANNEL_SLIDER = 2, // A two channel Slider |
||
| 211 | FOUR_CHANNEL_SLIDER =4 // A four channel Slider |
||
| 212 | }; |
||
| 213 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 214 | /* ~~~~~~~~~~~~~~~~~~~~~ Constants / Macros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 215 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 216 | |||
| 217 | #define AUTO_ADJUST_STEP_SIZE 3 //Fix the appropriate value |
||
| 218 | |||
| 219 | |||
| 220 | #define CURRENT_SOURCE_TRIM_BITS_MAX_POSITIVE 0x1F |
||
| 221 | #define CURRENT_SOURCE_TRIM_BITS_MIN_POSITIVE 0x01 |
||
| 222 | #define CURRENT_SOURCE_TRIM_BITS_NOMINAL 0x00 |
||
| 223 | #define CURRENT_SOURCE_TRIM_BITS_MIN_NEGATIVE 0x3F |
||
| 224 | #define CURRENT_SOURCE_TRIM_BITS_MAX_NEGATIVE 0x21 |
||
| 225 | |||
| 226 | #define CURRENT_SOURCE_TRIM_BITS_POSITIVE_RANGE_MASK 0x3F |
||
| 227 | #define CURRENT_SOURCE_TRIM_BITS_NEGATIVE_RANGE_MASK 0x1F |
||
| 228 | |||
| 229 | |||
| 230 | #define ADC_UNTOUCHED_VALUE_10_BIT 0x3FF //Untouched value for a 12-bit ADC |
||
| 231 | |||
| 232 | |||
| 233 | #define MATRIX_SINGLE_KEY_CH 2 // 2 channels are multiplexed to form a single Matrix key |
||
| 234 | #define FOUR_CH_SLIDER 4 // 4 channels are used in a 4 channel slider |
||
| 235 | #define TWO_CH_SLIDER 2 // 2 channels are used in a 2 channel slider |
||
| 236 | |||
| 237 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 238 | /* ~~~~~~~~~~~~~~~~~~~~~ Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 239 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 240 | // Structure which stores the members associated with the Direct Key |
||
| 241 | |||
| 242 | |||
| 243 | typedef struct{ |
||
| 244 | |||
| 245 | BYTE Channel_Num; // Channel Used by the Directkey |
||
| 246 | WORD TripValue; // Trip value for each channel |
||
| 247 | WORD hystValue; // Hystersis value |
||
| 248 | BYTE FilterType; // Stores Filter for each channel |
||
| 249 | BYTE DecodeMethod; // Decode Method for each Channel |
||
| 250 | |||
| 251 | }DirectKey; |
||
| 252 | |||
| 253 | // Structure which stores the members associated with the Matrix key. |
||
| 254 | |||
| 255 | typedef struct{ |
||
| 256 | |||
| 257 | BYTE Channel_Num[MATRIX_SINGLE_KEY_CH]; // Channel Used by the Matrixkey |
||
| 258 | WORD TripValue; // Trip value for each key( includes 2 channels) |
||
| 259 | WORD hystValue; // Hystersis value for each key( includes 2 channels) |
||
| 260 | BYTE FilterType; // Stores Filter for each key( includes 2 channels) |
||
| 261 | BYTE DecodeMethod; // Decode Method for each key( includes 2 channels) |
||
| 262 | |||
| 263 | }MatrixKey; |
||
| 264 | |||
| 265 | // Structure which stores the members associated with the 2 channel sliders. |
||
| 266 | typedef struct{ |
||
| 267 | |||
| 268 | BYTE Channel_Num[TWO_CH_SLIDER]; // Channel sUsed by the Sliders |
||
| 269 | WORD TripValue; // Trip value for each key( includes 2 channels) |
||
| 270 | WORD hystValue; // Hystersis value for each key( includes 2 channels) |
||
| 271 | BYTE FilterType; // Stores Filter for each key( includes 2 channels) |
||
| 272 | BYTE DecodeMethod; // Decode Method for each key( includes 2 channels) |
||
| 273 | |||
| 274 | }Slider2Ch; |
||
| 275 | |||
| 276 | // Structure which stores the members associated with the 4 channel sliders. |
||
| 277 | |||
| 278 | typedef struct{ |
||
| 279 | |||
| 280 | BYTE Channel_Num[FOUR_CH_SLIDER]; // Channel sUsed by the Sliders |
||
| 281 | WORD TripValue; // Trip value for each key( includes 2 channels) |
||
| 282 | WORD hystValue; // Hystersis value for each key( includes 2 channels) |
||
| 283 | BYTE FilterType; // Stores Filter for each key( includes 2 channels) |
||
| 284 | BYTE DecodeMethod; // Decode Method for each key( includes 2 channels) |
||
| 285 | |||
| 286 | }Slider4Ch; |
||
| 287 | |||
| 288 | |||
| 289 | extern WORD ScanChannels[MAX_ADC_CHANNELS]; |
||
| 290 | extern BYTE ScanChannelIndex; // store the index of the channels that has to be scanned |
||
| 291 | |||
| 292 | |||
| 293 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 294 | /* ~~~~~~~~~~~~~~~~~~~~~ Function Prototypes ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 295 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 296 | |||
| 297 | BYTE mTouchCapAPI_SetUpChannel (WORD ChannelNum, BYTE TripThreshold, BYTE DecodeMethod, BYTE FilterType); |
||
| 298 | void mTouchCapAPI_SetUpCTMU_Default(WORD ChannelNum); |
||
| 299 | void mTouchCapAPI_SetUpCSM_Default(WORD ChannelNum); |
||
| 300 | WORD mTouchCapAPI_CTMU_GetChannelReading (WORD ChannelNum); |
||
| 301 | CHAR mTouchCapAPI_AutoAdjustChannel (WORD ChannelNum, WORD AdcValueToAchieve); |
||
| 302 | void mTouchCapAPI_CTMU_SetupCurrentSource (BYTE CurrentSourceRange, BYTE TrimValue); |
||
| 303 | void mTouchCapAPI_CSM_SetCurrentSource (BYTE CurrentSourceRange); |
||
| 304 | WORD mTouchCapAPI_ScanChannelIterative (WORD ChannelNum, BYTE SampleCount); |
||
| 305 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 306 | BYTE mTouchCapAPI_SetUpChannelDirectKey(DirectKey *Button,BYTE Channel_number, WORD Trip_Value, WORD Decode_Method, WORD Filter_Method); |
||
| 307 | BYTE mTouchCapAPI_GetStatusDirectButton (DirectKey *Button); |
||
| 308 | BYTE mTouchCapAPI_SetUpChannelMatrixKey(MatrixKey *Button,BYTE Row_Channel_Number,BYTE Col_Channel_number, WORD Trip_Value, WORD Decode_Method, WORD Filter_Method); |
||
| 309 | BYTE mTouchCapAPI_GetStatusMatrixButton (MatrixKey *Button); |
||
| 310 | BYTE mTouchCapAPI_SetUpChannelSlider2Ch(Slider2Ch *Slider, BYTE Slider_Channel1_Number,BYTE Slider_Channel2_Number, WORD Trip_Value, BYTE Decode_Method, BYTE Filter_Method); |
||
| 311 | SHORT mTouchCapAPI_GetStatusSlider2Ch (Slider2Ch* Slider); |
||
| 312 | BYTE mTouchCapAPI_SetUpChannelSlider4Ch(Slider4Ch *Slider, BYTE Slider_Channel1_Number,BYTE Slider_Channel2_Number, BYTE Slider_Channel3_Number,BYTE Slider_Channel4_Number,WORD Trip_Value, BYTE Decode_Method, BYTE Filter_Method); |
||
| 313 | SHORT mTouchCapAPI_GetStatusSlider4Ch (Slider4Ch* Slider); |
||
| 314 | BYTE mTouchCapAPI_getChannelTouchStatus(WORD ChIndex, BYTE Decode_Method); |
||
| 315 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
||
| 316 | void LoadChannelNumber (BYTE Channel_Number_Passed); |
||
| 317 | void mTouchCap_Init(void); |
||
| 318 | void SetChannelBit(WORD,BYTE); |
||
| 319 | void InitAvgDelay(void); |
||
| 320 | #ifdef USE_STATIC_TRIP_VALUE |
||
| 321 | void mTouchCap_UpdateStaticTripValue(void); |
||
| 322 | #endif |
||
| 323 | |||
| 324 | #ifdef USE_SLIDER_2CHNL |
||
| 325 | extern WORD mTouchCapApp_TwoChannelSliderLogic(Slider2Ch *Slider); |
||
| 326 | #endif |
||
| 327 | |||
| 328 | #ifdef USE_SLIDER_4CHNL |
||
| 329 | extern WORD mTouchCapApp_FourChannelSliderLogic(Slider4Ch *Slider); |
||
| 330 | #endif |
||
| 331 | |||
| 332 | #endif // _mTOUCH_CAP_CTMU_API_H |
||
| 333 | |||
| 334 |
Powered by WebSVN v2.8.3