Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00068 #include "includes/mTouchCVD.h"
00069
00075
00076 unsigned short long CVD_Acq_Filtered_Data [CVD_NUMBER_SENSORS];
00077 bank0 unsigned int last_result;
00078 bank0 unsigned int sample_counter = CVD_SAMPLES_PER_SCAN;
00079
00080 unsigned char mTouchCVD_dataReady;
00081 unsigned int sensor_data [CVD_NUMBER_SENSORS];
00082 unsigned int CVDSensorData [CVD_NUMBER_SENSORS];
00083
00084 #if defined(CVD_JITTER_ENABLE) && (CVD_JITTER_TYPE == 1)
00085 unsigned char mTouchCVD_jitter = 0x55;
00086 #endif
00087 #if CVD_NUMBER_SENSORS > 1
00088 bank0 unsigned char current_sensor;
00089 #endif
00090 #if defined(CVD_DELAY_VARIABLE_REQUIRED)
00091 unsigned char mTouchCVD_delayCount;
00092 #endif
00093
00094 #if defined(_PIC14)
00095
00096 near unsigned char int_w;
00097 near unsigned char int_status;
00098 near unsigned char int_fsr;
00099 near unsigned char int_pclath;
00100
00101 #endif
00102
00103
00104
00117 void interrupt ISR(void)
00118 {
00119 #asm
00120
00121 #if defined(_12F617) && (_HTC_VER_MAJOR_ == 9 && _HTC_VER_MINOR_ == 80)
00122 #include <cas12F617.h>
00123
00124
00125 #else
00126 #include <caspic.h>
00127 #endif
00128
00129 mTouchCVD_ISR:
00130 #endasm
00131
00137 SAVE_STATE();
00138
00143 CHECK_AND_CLEAR_TMR0IF();
00144
00149 JITTER_START_TIME();
00150
00152 WAIT_FOR_GODONE_BIT();
00153
00154
00155
00156
00157
00158
00164 STORE_LAST_RESULT();
00165
00170 #pragma switch rangetable
00171
00172
00173
00174 GENERATE_JUMP_TABLE();
00175
00184 #asm
00185 sensor_0:
00186 #endasm
00187 #if CVD_NUMBER_SENSORS > 0
00188 READ_SENSOR(0, CVD_SENSOR0_REFERENCE);
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 #if CVD_NUMBER_SENSORS > 1 // If there is more than one sensor,
00199 EXIT_SENSOR(current_sensor);
00200 #else // If there is only one sensor,
00201 EXIT_LAST_SENSOR(0);
00202 #endif
00203 #endif
00204 #asm
00205 sensor_1:
00206 #endasm
00207 #if CVD_NUMBER_SENSORS > 1
00208 READ_SENSOR(1, 0);
00209 #if CVD_NUMBER_SENSORS > 2 // If this is not the last sensor,
00210 EXIT_SENSOR(current_sensor);
00211 #else // If this is the last sensor,
00212 EXIT_LAST_SENSOR(current_sensor);
00213 #endif
00214 #endif
00215 #asm
00216 sensor_2:
00217 #endasm
00218 #if CVD_NUMBER_SENSORS > 2
00219 READ_SENSOR(2, 1);
00220 #if CVD_NUMBER_SENSORS > 3
00221 EXIT_SENSOR(current_sensor);
00222 #else
00223 EXIT_LAST_SENSOR(current_sensor);
00224 #endif
00225 #endif
00226 #asm
00227 sensor_3:
00228 #endasm
00229 #if CVD_NUMBER_SENSORS > 3
00230 READ_SENSOR(3, 2);
00231 #if CVD_NUMBER_SENSORS > 4
00232 EXIT_SENSOR(current_sensor);
00233 #else
00234 EXIT_LAST_SENSOR(current_sensor);
00235 #endif
00236 #endif
00237 #asm
00238 sensor_4:
00239 #endasm
00240 #if CVD_NUMBER_SENSORS > 4
00241 READ_SENSOR(4, 3);
00242 #if CVD_NUMBER_SENSORS > 5
00243 EXIT_SENSOR(current_sensor);
00244 #else
00245 EXIT_LAST_SENSOR(current_sensor);
00246 #endif
00247 #endif
00248 #asm
00249 sensor_5:
00250 #endasm
00251 #if CVD_NUMBER_SENSORS > 5
00252 READ_SENSOR(5, 4);
00253 #if CVD_NUMBER_SENSORS > 6
00254 EXIT_SENSOR(current_sensor);
00255 #else
00256 EXIT_LAST_SENSOR(current_sensor);
00257 #endif
00258 #endif
00259 #asm
00260 sensor_6:
00261 #endasm
00262 #if CVD_NUMBER_SENSORS > 6
00263 READ_SENSOR(6, 5);
00264 #if CVD_NUMBER_SENSORS > 7
00265 EXIT_SENSOR(current_sensor);
00266 #else
00267 EXIT_LAST_SENSOR(current_sensor);
00268 #endif
00269 #endif
00270 #asm
00271 sensor_7:
00272 #endasm
00273 #if CVD_NUMBER_SENSORS > 7
00274 READ_SENSOR(7, 6);
00275 #if CVD_NUMBER_SENSORS > 8
00276 EXIT_SENSOR(current_sensor);
00277 #else
00278 EXIT_LAST_SENSOR(current_sensor);
00279 #endif
00280 #endif
00281 #asm
00282 sensor_8:
00283 #endasm
00284 #if CVD_NUMBER_SENSORS > 8
00285 READ_SENSOR(8, 7);
00286 #if CVD_NUMBER_SENSORS > 9
00287 EXIT_SENSOR(current_sensor);
00288 #else
00289 EXIT_LAST_SENSOR(current_sensor);
00290 #endif
00291 #endif
00292 #asm
00293 sensor_9:
00294 #endasm
00295 #if CVD_NUMBER_SENSORS > 9
00296 READ_SENSOR(9, 8);
00297 #if CVD_NUMBER_SENSORS > 10
00298 EXIT_SENSOR(current_sensor);
00299 #else
00300 EXIT_LAST_SENSOR(current_sensor);
00301 #endif
00302 #endif
00303 #asm
00304 sensor_10:
00305 #endasm
00306 #if CVD_NUMBER_SENSORS > 10
00307 READ_SENSOR(10, 9);
00308 #if CVD_NUMBER_SENSORS > 11
00309 EXIT_SENSOR(current_sensor);
00310 #else
00311 EXIT_LAST_SENSOR(current_sensor);
00312 #endif
00313 #endif
00314 #asm
00315 sensor_11:
00316 #endasm
00317 #if CVD_NUMBER_SENSORS > 11
00318 READ_SENSOR(11, 10);
00319 #if CVD_NUMBER_SENSORS > 12
00320 EXIT_SENSOR(current_sensor);
00321 #else
00322 EXIT_LAST_SENSOR(current_sensor);
00323 #endif
00324 #endif
00325 #asm
00326 sensor_12:
00327 #endasm
00328 #if CVD_NUMBER_SENSORS > 12
00329 READ_SENSOR(12, 11);
00330 #if CVD_NUMBER_SENSORS > 13
00331 EXIT_SENSOR(current_sensor);
00332 #else
00333 EXIT_LAST_SENSOR(current_sensor);
00334 #endif
00335 #endif
00336 #asm
00337 sensor_13:
00338 #endasm
00339 #if CVD_NUMBER_SENSORS > 13
00340 READ_SENSOR(13, 12);
00341 #if CVD_NUMBER_SENSORS > 14
00342 EXIT_SENSOR(current_sensor);
00343 #else
00344 EXIT_LAST_SENSOR(current_sensor);
00345 #endif
00346 #endif
00347 #asm
00348 sensor_14:
00349 #endasm
00350 #if CVD_NUMBER_SENSORS > 14
00351 READ_SENSOR(14, 13);
00352 #if CVD_NUMBER_SENSORS > 15
00353 EXIT_SENSOR(current_sensor);
00354 #else
00355 EXIT_LAST_SENSOR(current_sensor);
00356 #endif
00357 #endif
00358 #asm
00359 sensor_15:
00360 #endasm
00361 #if CVD_NUMBER_SENSORS > 15
00362 READ_SENSOR(15, 14);
00363 #if CVD_NUMBER_SENSORS > 16
00364 EXIT_SENSOR(current_sensor);
00365 #else
00366 EXIT_LAST_SENSOR(current_sensor);
00367 #endif
00368 #endif
00369 #asm
00370 sensor_16:
00371 #endasm
00372 #if CVD_NUMBER_SENSORS > 16
00373 READ_SENSOR(16, 15);
00374 #if CVD_NUMBER_SENSORS > 17
00375 EXIT_SENSOR(current_sensor);
00376 #else
00377 EXIT_LAST_SENSOR(current_sensor);
00378 #endif
00379 #endif
00380 #asm
00381 sensor_17:
00382 #endasm
00383 #if CVD_NUMBER_SENSORS > 17
00384 READ_SENSOR(17, 16);
00385 #if CVD_NUMBER_SENSORS > 18
00386 EXIT_SENSOR(current_sensor);
00387 #else
00388 EXIT_LAST_SENSOR(current_sensor);
00389 #endif
00390 #endif
00391 #asm
00392 sensor_18:
00393 #endasm
00394 #if CVD_NUMBER_SENSORS > 18
00395 READ_SENSOR(18, 17);
00396 #if CVD_NUMBER_SENSORS > 19
00397 EXIT_SENSOR(current_sensor);
00398 #else
00399 EXIT_LAST_SENSOR(current_sensor);
00400 #endif
00401 #endif
00402 #asm
00403 sensor_19:
00404 #endasm
00405 #if CVD_NUMBER_SENSORS > 19
00406 READ_SENSOR(19, 18);
00407 #if CVD_NUMBER_SENSORS > 20
00408 EXIT_SENSOR(current_sensor);
00409 #else
00410 EXIT_LAST_SENSOR(current_sensor);
00411 #endif
00412 #endif
00413 #asm
00414 sensor_20:
00415 #endasm
00416 #if CVD_NUMBER_SENSORS > 20
00417 READ_SENSOR(20, 19);
00418 #if CVD_NUMBER_SENSORS > 21
00419 EXIT_SENSOR(current_sensor);
00420 #else
00421 EXIT_LAST_SENSOR(current_sensor);
00422 #endif
00423 #endif
00424 #asm
00425 sensor_21:
00426 #endasm
00427 #if CVD_NUMBER_SENSORS > 21
00428 READ_SENSOR(21, 20);
00429 #if CVD_NUMBER_SENSORS > 22
00430 EXIT_SENSOR(current_sensor);
00431 #else
00432 EXIT_LAST_SENSOR(current_sensor);
00433 #endif
00434 #endif
00435 #asm
00436 sensor_22:
00437 #endasm
00438 #if CVD_NUMBER_SENSORS > 22
00439 READ_SENSOR(22, 21);
00440 #if CVD_NUMBER_SENSORS > 23
00441 EXIT_SENSOR(current_sensor);
00442 #else
00443 EXIT_LAST_SENSOR(current_sensor);
00444 #endif
00445 #endif
00446 #asm
00447 sensor_23:
00448 #endasm
00449 #if CVD_NUMBER_SENSORS > 23
00450 READ_SENSOR(23, 22);
00451 #if CVD_NUMBER_SENSORS > 24
00452 EXIT_SENSOR(current_sensor);
00453 #else
00454 EXIT_LAST_SENSOR(current_sensor);
00455 #endif
00456 #endif
00457 #asm
00458 sensor_24:
00459 #endasm
00460 #if CVD_NUMBER_SENSORS > 24
00461 READ_SENSOR(24, 23);
00462 #if CVD_NUMBER_SENSORS > 25
00463 EXIT_SENSOR(current_sensor);
00464 #else
00465 EXIT_LAST_SENSOR(current_sensor);
00466 #endif
00467 #endif
00468 #asm
00469 sensor_25:
00470 #endasm
00471 #if CVD_NUMBER_SENSORS > 25
00472 READ_SENSOR(25, 24);
00473 #if CVD_NUMBER_SENSORS > 26
00474 EXIT_SENSOR(current_sensor);
00475 #else
00476 EXIT_LAST_SENSOR(current_sensor);
00477 #endif
00478 #endif
00479 #asm
00480 sensor_26:
00481 #endasm
00482 #if CVD_NUMBER_SENSORS > 26
00483 READ_SENSOR(26, 25);
00484 #if CVD_NUMBER_SENSORS > 27
00485 EXIT_SENSOR(current_sensor);
00486 #else
00487 EXIT_LAST_SENSOR(current_sensor);
00488 #endif
00489 #endif
00490 #asm
00491 sensor_27:
00492 #endasm
00493 #if CVD_NUMBER_SENSORS > 27
00494 READ_SENSOR(27, 26);
00495 #if CVD_NUMBER_SENSORS > 28
00496 EXIT_SENSOR(current_sensor);
00497 #else
00498 EXIT_LAST_SENSOR(current_sensor);
00499 #endif
00500 #endif
00501 #asm
00502 sensor_28:
00503 #endasm
00504 #if CVD_NUMBER_SENSORS > 28
00505 READ_SENSOR(28, 27);
00506 #if CVD_NUMBER_SENSORS > 29
00507 EXIT_SENSOR(current_sensor);
00508 #else
00509 EXIT_LAST_SENSOR(current_sensor);
00510 #endif
00511 #endif
00512 #asm
00513 sensor_29:
00514 #endasm
00515 #if CVD_NUMBER_SENSORS > 29
00516 READ_SENSOR(29, 28);
00517 EXIT_LAST_SENSOR(current_sensor);
00518 #endif
00519
00525 GENERATE_STORAGE_FUNCTION();
00526
00531 SET_DATA_READY_FLAG();
00532
00534
00535 #asm
00536 END_ISR:
00537 #endasm
00538
00543 RESTORE_STATE();
00544
00555 #asm
00556 retfie
00557 #endasm
00558
00560
00568
00569 #asm
00570 decimate:
00571 #endasm
00572 CVD_DECIMATE();
00573
00574
00575 #asm
00576 sensor_smaller:
00577 #endasm
00578 CVD_SENSOR_SMALLER();
00579
00580 #asm
00581 decimate_end:
00582 #endasm
00583 CVD_DECIMATE_END();
00584
00585
00586
00587
00588
00589
00590 }