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
00038 #include "pic24_all.h"
00039 #include "pyFuncsInC.h"
00040 #include "pyToC.h"
00041 #include <pps.h>
00042
00043 #undef __FILE_ID__
00044 #define __FILE_ID__ 0x70
00045
00046
00049 #ifdef UNIT_TEST
00050 #undef _ODCA0
00051 #endif
00052
00053
00054 bool_t
00055 getBit(uint16_t u16_bitfield, uint16_t u16_bit)
00056 {
00057 ASSERT(u16_bit < 16);
00058 return (u16_bitfield & (1 << u16_bit)) ? C_TRUE : C_FALSE;
00059 }
00060
00061
00062 void
00063 setBit(volatile uint16_t* pu16_bitfield, uint16_t u16_bit, bool_t b_val)
00064 {
00065 ASSERT(u16_bit < 16);
00066 if (b_val)
00067 *pu16_bitfield |= 1 << u16_bit;
00068 else
00069 *pu16_bitfield &= ~(1 << u16_bit);
00070 }
00071
00072
00073
00074
00081 static const uint16_t u16_digitalPinPresent[NUM_DIGITAL_PORTS] = {
00082 #if NUM_DIGITAL_PORTS >= 1
00083 #ifdef _RA0
00084 0x0001 |
00085 #endif
00086 #ifdef _RA1
00087 0x0002 |
00088 #endif
00089 #ifdef _RA2
00090 0x0004 |
00091 #endif
00092 #ifdef _RA3
00093 0x0008 |
00094 #endif
00095 #ifdef _RA4
00096 0x0010 |
00097 #endif
00098 #ifdef _RA5
00099 0x0020 |
00100 #endif
00101 #ifdef _RA6
00102 0x0040 |
00103 #endif
00104 #ifdef _RA7
00105 0x0080 |
00106 #endif
00107 #ifdef _RA8
00108 0x0100 |
00109 #endif
00110 #ifdef _RA9
00111 0x0200 |
00112 #endif
00113 #ifdef _RA10
00114 0x0400 |
00115 #endif
00116 #ifdef _RA11
00117 0x0800 |
00118 #endif
00119 #ifdef _RA12
00120 0x1000 |
00121 #endif
00122 #ifdef _RA13
00123 0x2000 |
00124 #endif
00125 #ifdef _RA14
00126 0x4000 |
00127 #endif
00128 #ifdef _RA15
00129 0x8000 |
00130 #endif
00131 0x0000,
00132 #endif
00133
00134 #if NUM_DIGITAL_PORTS >= 2
00135 #ifdef _RB0
00136 0x0001 |
00137 #endif
00138 #ifdef _RB1
00139 0x0002 |
00140 #endif
00141 #ifdef _RB2
00142 0x0004 |
00143 #endif
00144 #ifdef _RB3
00145 0x0008 |
00146 #endif
00147 #ifdef _RB4
00148 0x0010 |
00149 #endif
00150 #ifdef _RB5
00151 0x0020 |
00152 #endif
00153 #ifdef _RB6
00154 0x0040 |
00155 #endif
00156 #ifdef _RB7
00157 0x0080 |
00158 #endif
00159 #ifdef _RB8
00160 0x0100 |
00161 #endif
00162 #ifdef _RB9
00163 0x0200 |
00164 #endif
00165 #ifdef _RB10
00166 0x0400 |
00167 #endif
00168 #ifdef _RB11
00169 0x0800 |
00170 #endif
00171 #ifdef _RB12
00172 0x1000 |
00173 #endif
00174 #ifdef _RB13
00175 0x2000 |
00176 #endif
00177 #ifdef _RB14
00178 0x4000 |
00179 #endif
00180 #ifdef _RB15
00181 0x8000 |
00182 #endif
00183 0x0000,
00184 #endif
00185
00186 #if NUM_DIGITAL_PORTS >= 3
00187 #ifdef _RC0
00188 0x0001 |
00189 #endif
00190 #ifdef _RC1
00191 0x0002 |
00192 #endif
00193 #ifdef _RC2
00194 0x0004 |
00195 #endif
00196 #ifdef _RC3
00197 0x0008 |
00198 #endif
00199 #ifdef _RC4
00200 0x0010 |
00201 #endif
00202 #ifdef _RC5
00203 0x0020 |
00204 #endif
00205 #ifdef _RC6
00206 0x0040 |
00207 #endif
00208 #ifdef _RC7
00209 0x0080 |
00210 #endif
00211 #ifdef _RC8
00212 0x0100 |
00213 #endif
00214 #ifdef _RC9
00215 0x0200 |
00216 #endif
00217 #ifdef _RC10
00218 0x0400 |
00219 #endif
00220 #ifdef _RC11
00221 0x0800 |
00222 #endif
00223 #ifdef _RC12
00224 0x1000 |
00225 #endif
00226 #ifdef _RC13
00227 0x2000 |
00228 #endif
00229 #ifdef _RC14
00230 0x4000 |
00231 #endif
00232 #ifdef _RC15
00233 0x8000 |
00234 #endif
00235 0x0000,
00236 #endif
00237
00238 #if NUM_DIGITAL_PORTS >= 4
00239 #ifdef _RD0
00240 0x0001 |
00241 #endif
00242 #ifdef _RD1
00243 0x0002 |
00244 #endif
00245 #ifdef _RD2
00246 0x0004 |
00247 #endif
00248 #ifdef _RD3
00249 0x0008 |
00250 #endif
00251 #ifdef _RD4
00252 0x0010 |
00253 #endif
00254 #ifdef _RD5
00255 0x0020 |
00256 #endif
00257 #ifdef _RD6
00258 0x0040 |
00259 #endif
00260 #ifdef _RD7
00261 0x0080 |
00262 #endif
00263 #ifdef _RD8
00264 0x0100 |
00265 #endif
00266 #ifdef _RD9
00267 0x0200 |
00268 #endif
00269 #ifdef _RD10
00270 0x0400 |
00271 #endif
00272 #ifdef _RD11
00273 0x0800 |
00274 #endif
00275 #ifdef _RD12
00276 0x1000 |
00277 #endif
00278 #ifdef _RD13
00279 0x2000 |
00280 #endif
00281 #ifdef _RD14
00282 0x4000 |
00283 #endif
00284 #ifdef _RD15
00285 0x8000 |
00286 #endif
00287 0x0000,
00288 #endif
00289
00290 #if NUM_DIGITAL_PORTS >= 5
00291 #ifdef _RE0
00292 0x0001 |
00293 #endif
00294 #ifdef _RE1
00295 0x0002 |
00296 #endif
00297 #ifdef _RE2
00298 0x0004 |
00299 #endif
00300 #ifdef _RE3
00301 0x0008 |
00302 #endif
00303 #ifdef _RE4
00304 0x0010 |
00305 #endif
00306 #ifdef _RE5
00307 0x0020 |
00308 #endif
00309 #ifdef _RE6
00310 0x0040 |
00311 #endif
00312 #ifdef _RE7
00313 0x0080 |
00314 #endif
00315 #ifdef _RE8
00316 0x0100 |
00317 #endif
00318 #ifdef _RE9
00319 0x0200 |
00320 #endif
00321 #ifdef _RE10
00322 0x0400 |
00323 #endif
00324 #ifdef _RE11
00325 0x0800 |
00326 #endif
00327 #ifdef _RE12
00328 0x1000 |
00329 #endif
00330 #ifdef _RE13
00331 0x2000 |
00332 #endif
00333 #ifdef _RE14
00334 0x4000 |
00335 #endif
00336 #ifdef _RE15
00337 0x8000 |
00338 #endif
00339 0x0000,
00340 #endif
00341
00342 #if NUM_DIGITAL_PORTS >= 6
00343 #ifdef _RF0
00344 0x0001 |
00345 #endif
00346 #ifdef _RF1
00347 0x0002 |
00348 #endif
00349 #ifdef _RF2
00350 0x0004 |
00351 #endif
00352 #ifdef _RF3
00353 0x0008 |
00354 #endif
00355 #ifdef _RF4
00356 0x0010 |
00357 #endif
00358 #ifdef _RF5
00359 0x0020 |
00360 #endif
00361 #ifdef _RF6
00362 0x0040 |
00363 #endif
00364 #ifdef _RF7
00365 0x0080 |
00366 #endif
00367 #ifdef _RF8
00368 0x0100 |
00369 #endif
00370 #ifdef _RF9
00371 0x0200 |
00372 #endif
00373 #ifdef _RF10
00374 0x0400 |
00375 #endif
00376 #ifdef _RF11
00377 0x0800 |
00378 #endif
00379 #ifdef _RF12
00380 0x1000 |
00381 #endif
00382 #ifdef _RF13
00383 0x2000 |
00384 #endif
00385 #ifdef _RF14
00386 0x4000 |
00387 #endif
00388 #ifdef _RF15
00389 0x8000 |
00390 #endif
00391 0x0000,
00392 #endif
00393
00394 #if NUM_DIGITAL_PORTS >= 7
00395 #ifdef _RG0
00396 0x0001 |
00397 #endif
00398 #ifdef _RG1
00399 0x0002 |
00400 #endif
00401 #ifdef _RG2
00402 0x0004 |
00403 #endif
00404 #ifdef _RG3
00405 0x0008 |
00406 #endif
00407 #ifdef _RG4
00408 0x0010 |
00409 #endif
00410 #ifdef _RG5
00411 0x0020 |
00412 #endif
00413 #ifdef _RG6
00414 0x0040 |
00415 #endif
00416 #ifdef _RG7
00417 0x0080 |
00418 #endif
00419 #ifdef _RG8
00420 0x0100 |
00421 #endif
00422 #ifdef _RG9
00423 0x0200 |
00424 #endif
00425 #ifdef _RG10
00426 0x0400 |
00427 #endif
00428 #ifdef _RG11
00429 0x0800 |
00430 #endif
00431 #ifdef _RG12
00432 0x1000 |
00433 #endif
00434 #ifdef _RG13
00435 0x2000 |
00436 #endif
00437 #ifdef _RG14
00438 0x4000 |
00439 #endif
00440 #ifdef _RG15
00441 0x8000 |
00442 #endif
00443 0x0000,
00444 #endif
00445 };
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00464 static const uint16_t u16_digitalPinOpenDrainPresent[NUM_DIGITAL_PORTS] = {
00465 #if NUM_DIGITAL_PORTS >= 1
00466 #if defined(_ODCA0) || defined(_ODA0)
00467 0x0001 |
00468 #endif
00469 #if defined(_ODCA1) || defined(_ODA1)
00470 0x0002 |
00471 #endif
00472 #if defined(_ODCA2) || defined(_ODA2)
00473 0x0004 |
00474 #endif
00475 #if defined(_ODCA3) || defined(_ODA3)
00476 0x0008 |
00477 #endif
00478 #if defined(_ODCA4) || defined(_ODA4)
00479 0x0010 |
00480 #endif
00481 #if defined(_ODCA5) || defined(_ODA5)
00482 0x0020 |
00483 #endif
00484 #if defined(_ODCA6) || defined(_ODA6)
00485 0x0040 |
00486 #endif
00487 #if defined(_ODCA7) || defined(_ODA7)
00488 0x0080 |
00489 #endif
00490 #if defined(_ODCA8) || defined(_ODA8)
00491 0x0100 |
00492 #endif
00493 #if defined(_ODCA9) || defined(_ODA9)
00494 0x0200 |
00495 #endif
00496 #if defined(_ODCA10) || defined(_ODA10)
00497 0x0400 |
00498 #endif
00499 #if defined(_ODCA11) || defined(_ODA11)
00500 0x0800 |
00501 #endif
00502 #if defined(_ODCA12) || defined(_ODA12)
00503 0x1000 |
00504 #endif
00505 #if defined(_ODCA13) || defined(_ODA13)
00506 0x2000 |
00507 #endif
00508 #if defined(_ODCA14) || defined(_ODA14)
00509 0x4000 |
00510 #endif
00511 #if defined(_ODCA15) || defined(_ODA15)
00512 0x8000 |
00513 #endif
00514 0x0000,
00515 #endif
00516
00517 #if NUM_DIGITAL_PORTS >= 2
00518 #if defined(_ODCB0) || defined(_ODB0)
00519 0x0001 |
00520 #endif
00521 #if defined(_ODCB1) || defined(_ODB1)
00522 0x0002 |
00523 #endif
00524 #if defined(_ODCB2) || defined(_ODB2)
00525 0x0004 |
00526 #endif
00527 #if defined(_ODCB3) || defined(_ODB3)
00528 0x0008 |
00529 #endif
00530 #if defined(_ODCB4) || defined(_ODB4)
00531 0x0010 |
00532 #endif
00533 #if defined(_ODCB5) || defined(_ODB5)
00534 0x0020 |
00535 #endif
00536 #if defined(_ODCB6) || defined(_ODB6)
00537 0x0040 |
00538 #endif
00539 #if defined(_ODCB7) || defined(_ODB7)
00540 0x0080 |
00541 #endif
00542 #if defined(_ODCB8) || defined(_ODB8)
00543 0x0100 |
00544 #endif
00545 #if defined(_ODCB9) || defined(_ODB9)
00546 0x0200 |
00547 #endif
00548 #if defined(_ODCB10) || defined(_ODB10)
00549 0x0400 |
00550 #endif
00551 #if defined(_ODCB11) || defined(_ODB11)
00552 0x0800 |
00553 #endif
00554 #if defined(_ODCB12) || defined(_ODB12)
00555 0x1000 |
00556 #endif
00557 #if defined(_ODCB13) || defined(_ODB13)
00558 0x2000 |
00559 #endif
00560 #if defined(_ODCB14) || defined(_ODB14)
00561 0x4000 |
00562 #endif
00563 #if defined(_ODCB15) || defined(_ODB15)
00564 0x8000 |
00565 #endif
00566 0x0000,
00567 #endif
00568
00569 #if NUM_DIGITAL_PORTS >= 3
00570 #if defined(_ODCC0) || defined(_ODC0)
00571 0x0001 |
00572 #endif
00573 #if defined(_ODCC1) || defined(_ODC1)
00574 0x0002 |
00575 #endif
00576 #if defined(_ODCC2) || defined(_ODC2)
00577 0x0004 |
00578 #endif
00579 #if defined(_ODCC3) || defined(_ODC3)
00580 0x0008 |
00581 #endif
00582 #if defined(_ODCC4) || defined(_ODC4)
00583 0x0010 |
00584 #endif
00585 #if defined(_ODCC5) || defined(_ODC5)
00586 0x0020 |
00587 #endif
00588 #if defined(_ODCC6) || defined(_ODC6)
00589 0x0040 |
00590 #endif
00591 #if defined(_ODCC7) || defined(_ODC7)
00592 0x0080 |
00593 #endif
00594 #if defined(_ODCC8) || defined(_ODC8)
00595 0x0100 |
00596 #endif
00597 #if defined(_ODCC9) || defined(_ODC9)
00598 0x0200 |
00599 #endif
00600 #if defined(_ODCC10) || defined(_ODC10)
00601 0x0400 |
00602 #endif
00603 #if defined(_ODCC11) || defined(_ODC11)
00604 0x0800 |
00605 #endif
00606 #if defined(_ODCC12) || defined(_ODC12)
00607 0x1000 |
00608 #endif
00609 #if defined(_ODCC13) || defined(_ODC13)
00610 0x2000 |
00611 #endif
00612 #if defined(_ODCC14) || defined(_ODC14)
00613 0x4000 |
00614 #endif
00615 #if defined(_ODCC15) || defined(_ODC15)
00616 0x8000 |
00617 #endif
00618 0x0000,
00619 #endif
00620
00621 #if NUM_DIGITAL_PORTS >= 4
00622 #if defined(_ODCD0) || defined(_ODD0)
00623 0x0001 |
00624 #endif
00625 #if defined(_ODCD1) || defined(_ODD1)
00626 0x0002 |
00627 #endif
00628 #if defined(_ODCD2) || defined(_ODD2)
00629 0x0004 |
00630 #endif
00631 #if defined(_ODCD3) || defined(_ODD3)
00632 0x0008 |
00633 #endif
00634 #if defined(_ODCD4) || defined(_ODD4)
00635 0x0010 |
00636 #endif
00637 #if defined(_ODCD5) || defined(_ODD5)
00638 0x0020 |
00639 #endif
00640 #if defined(_ODCD6) || defined(_ODD6)
00641 0x0040 |
00642 #endif
00643 #if defined(_ODCD7) || defined(_ODD7)
00644 0x0080 |
00645 #endif
00646 #if defined(_ODCD8) || defined(_ODD8)
00647 0x0100 |
00648 #endif
00649 #if defined(_ODCD9) || defined(_ODD9)
00650 0x0200 |
00651 #endif
00652 #if defined(_ODCD10) || defined(_ODD10)
00653 0x0400 |
00654 #endif
00655 #if defined(_ODCD11) || defined(_ODD11)
00656 0x0800 |
00657 #endif
00658 #if defined(_ODCD12) || defined(_ODD12)
00659 0x1000 |
00660 #endif
00661 #if defined(_ODCD13) || defined(_ODD13)
00662 0x2000 |
00663 #endif
00664 #if defined(_ODCD14) || defined(_ODD14)
00665 0x4000 |
00666 #endif
00667 #if defined(_ODCD15) || defined(_ODD15)
00668 0x8000 |
00669 #endif
00670 0x0000,
00671 #endif
00672
00673 #if NUM_DIGITAL_PORTS >= 5
00674 #if defined(_ODCE0) || defined(_ODE0)
00675 0x0001 |
00676 #endif
00677 #if defined(_ODCE1) || defined(_ODE1)
00678 0x0002 |
00679 #endif
00680 #if defined(_ODCE2) || defined(_ODE2)
00681 0x0004 |
00682 #endif
00683 #if defined(_ODCE3) || defined(_ODE3)
00684 0x0008 |
00685 #endif
00686 #if defined(_ODCE4) || defined(_ODE4)
00687 0x0010 |
00688 #endif
00689 #if defined(_ODCE5) || defined(_ODE5)
00690 0x0020 |
00691 #endif
00692 #if defined(_ODCE6) || defined(_ODE6)
00693 0x0040 |
00694 #endif
00695 #if defined(_ODCE7) || defined(_ODE7)
00696 0x0080 |
00697 #endif
00698 #if defined(_ODCE8) || defined(_ODE8)
00699 0x0100 |
00700 #endif
00701 #if defined(_ODCE9) || defined(_ODE9)
00702 0x0200 |
00703 #endif
00704 #if defined(_ODCE10) || defined(_ODE10)
00705 0x0400 |
00706 #endif
00707 #if defined(_ODCE11) || defined(_ODE11)
00708 0x0800 |
00709 #endif
00710 #if defined(_ODCE12) || defined(_ODE12)
00711 0x1000 |
00712 #endif
00713 #if defined(_ODCE13) || defined(_ODE13)
00714 0x2000 |
00715 #endif
00716 #if defined(_ODCE14) || defined(_ODE14)
00717 0x4000 |
00718 #endif
00719 #if defined(_ODCE15) || defined(_ODE15)
00720 0x8000 |
00721 #endif
00722 0x0000,
00723 #endif
00724
00725 #if NUM_DIGITAL_PORTS >= 6
00726 #if defined(_ODCF0) || defined(_ODF0)
00727 0x0001 |
00728 #endif
00729 #if defined(_ODCF1) || defined(_ODF1)
00730 0x0002 |
00731 #endif
00732 #if defined(_ODCF2) || defined(_ODF2)
00733 0x0004 |
00734 #endif
00735 #if defined(_ODCF3) || defined(_ODF3)
00736 0x0008 |
00737 #endif
00738 #if defined(_ODCF4) || defined(_ODF4)
00739 0x0010 |
00740 #endif
00741 #if defined(_ODCF5) || defined(_ODF5)
00742 0x0020 |
00743 #endif
00744 #if defined(_ODCF6) || defined(_ODF6)
00745 0x0040 |
00746 #endif
00747 #if defined(_ODCF7) || defined(_ODF7)
00748 0x0080 |
00749 #endif
00750 #if defined(_ODCF8) || defined(_ODF8)
00751 0x0100 |
00752 #endif
00753 #if defined(_ODCF9) || defined(_ODF9)
00754 0x0200 |
00755 #endif
00756 #if defined(_ODCF10) || defined(_ODF10)
00757 0x0400 |
00758 #endif
00759 #if defined(_ODCF11) || defined(_ODF11)
00760 0x0800 |
00761 #endif
00762 #if defined(_ODCF12) || defined(_ODF12)
00763 0x1000 |
00764 #endif
00765 #if defined(_ODCF13) || defined(_ODF13)
00766 0x2000 |
00767 #endif
00768 #if defined(_ODCF14) || defined(_ODF14)
00769 0x4000 |
00770 #endif
00771 #if defined(_ODCF15) || defined(_ODF15)
00772 0x8000 |
00773 #endif
00774 0x0000,
00775 #endif
00776
00777 #if NUM_DIGITAL_PORTS >= 7
00778 #if defined(_ODCG0) || defined(_ODG0)
00779 0x0001 |
00780 #endif
00781 #if defined(_ODCG1) || defined(_ODG1)
00782 0x0002 |
00783 #endif
00784 #if defined(_ODCG2) || defined(_ODG2)
00785 0x0004 |
00786 #endif
00787 #if defined(_ODCG3) || defined(_ODG3)
00788 0x0008 |
00789 #endif
00790 #if defined(_ODCG4) || defined(_ODG4)
00791 0x0010 |
00792 #endif
00793 #if defined(_ODCG5) || defined(_ODG5)
00794 0x0020 |
00795 #endif
00796 #if defined(_ODCG6) || defined(_ODG6)
00797 0x0040 |
00798 #endif
00799 #if defined(_ODCG7) || defined(_ODG7)
00800 0x0080 |
00801 #endif
00802 #if defined(_ODCG8) || defined(_ODG8)
00803 0x0100 |
00804 #endif
00805 #if defined(_ODCG9) || defined(_ODG9)
00806 0x0200 |
00807 #endif
00808 #if defined(_ODCG10) || defined(_ODG10)
00809 0x0400 |
00810 #endif
00811 #if defined(_ODCG11) || defined(_ODG11)
00812 0x0800 |
00813 #endif
00814 #if defined(_ODCG12) || defined(_ODG12)
00815 0x1000 |
00816 #endif
00817 #if defined(_ODCG13) || defined(_ODG13)
00818 0x2000 |
00819 #endif
00820 #if defined(_ODCG14) || defined(_ODG14)
00821 0x4000 |
00822 #endif
00823 #if defined(_ODCG15) || defined(_ODG15)
00824 0x8000 |
00825 #endif
00826 0x0000,
00827 #endif
00828 };
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839 #if defined(__PIC24HJ128GP202__)
00840
00841 #include "devices/pic24hj128gp202_pyports.h"
00842
00843 #elif defined(__PIC24HJ128GP204__)
00844
00845 #include "devices/pic24hj128gp204_pyports.h"
00846
00847 #elif defined(__PIC24HJ128GP206__)
00848
00849 #include "devices/pic24hj128gp206_pyports.h"
00850
00851 #elif defined(__PIC24HJ128GP210__)
00852
00853 #include "devices/pic24hj128gp210_pyports.h"
00854
00855 #elif defined(__PIC24HJ128GP306__)
00856
00857 #include "devices/pic24hj128gp306_pyports.h"
00858
00859 #elif defined(__PIC24HJ128GP310__)
00860
00861 #include "devices/pic24hj128gp310_pyports.h"
00862
00863 #elif defined(__PIC24HJ128GP502__)
00864
00865 #include "devices/pic24hj128gp502_pyports.h"
00866
00867 #elif defined(__PIC24HJ128GP504__)
00868
00869 #include "devices/pic24hj128gp504_pyports.h"
00870
00871 #elif defined(__PIC24HJ128GP506__)
00872
00873 #include "devices/pic24hj128gp506_pyports.h"
00874
00875 #elif defined(__PIC24HJ128GP510__)
00876
00877 #include "devices/pic24hj128gp510_pyports.h"
00878
00879 #elif defined(__PIC24HJ12GP201__)
00880
00881 #include "devices/pic24hj12gp201_pyports.h"
00882
00883 #elif defined(__PIC24HJ12GP202__)
00884
00885 #include "devices/pic24hj12gp202_pyports.h"
00886
00887 #elif defined(__PIC24HJ16GP304__)
00888
00889 #include "devices/pic24hj16gp304_pyports.h"
00890
00891 #elif defined(__PIC24HJ256GP206__)
00892
00893 #include "devices/pic24hj256gp206_pyports.h"
00894
00895 #elif defined(__PIC24HJ256GP210__)
00896
00897 #include "devices/pic24hj256gp210_pyports.h"
00898
00899 #elif defined(__PIC24HJ256GP610__)
00900
00901 #include "devices/pic24hj256gp610_pyports.h"
00902
00903 #elif defined(__PIC24HJ32GP202__)
00904
00905 #include "devices/pic24hj32gp202_pyports.h"
00906
00907 #elif defined(__PIC24HJ32GP204__)
00908
00909 #include "devices/pic24hj32gp204_pyports.h"
00910
00911 #elif defined(__PIC24HJ32GP302__)
00912
00913 #include "devices/pic24hj32gp302_pyports.h"
00914
00915 #elif defined(__PIC24HJ32GP304__)
00916
00917 #include "devices/pic24hj32gp304_pyports.h"
00918
00919 #elif defined(__PIC24HJ64GP202__)
00920
00921 #include "devices/pic24hj64gp202_pyports.h"
00922
00923 #elif defined(__PIC24HJ64GP204__)
00924
00925 #include "devices/pic24hj64gp204_pyports.h"
00926
00927 #elif defined(__PIC24HJ64GP206__)
00928
00929 #include "devices/pic24hj64gp206_pyports.h"
00930
00931 #elif defined(__PIC24HJ64GP210__)
00932
00933 #include "devices/pic24hj64gp210_pyports.h"
00934
00935 #elif defined(__PIC24HJ64GP502__)
00936
00937 #include "devices/pic24hj64gp502_pyports.h"
00938
00939 #elif defined(__PIC24HJ64GP504__)
00940
00941 #include "devices/pic24hj64gp504_pyports.h"
00942
00943 #elif defined(__PIC24HJ64GP506__)
00944
00945 #include "devices/pic24hj64gp506_pyports.h"
00946
00947 #elif defined(__PIC24HJ64GP510__)
00948
00949 #include "devices/pic24hj64gp510_pyports.h"
00950
00951 #elif defined(__PIC24F04KA200__)
00952
00953 #include "devices/pic24f04ka200_pyports.h"
00954
00955 #elif defined(__PIC24F04KA201__)
00956
00957 #include "devices/pic24f04ka201_pyports.h"
00958
00959 #elif defined(__PIC24F08KA101__)
00960
00961 #include "devices/pic24f08ka101_pyports.h"
00962
00963 #elif defined(__PIC24F08KA102__)
00964
00965 #include "devices/pic24f08ka102_pyports.h"
00966
00967 #elif defined(__PIC24F16KA101__)
00968
00969 #include "devices/pic24f16ka101_pyports.h"
00970
00971 #elif defined(__PIC24F16KA102__)
00972
00973 #include "devices/pic24f16ka102_pyports.h"
00974
00975 #elif defined(__PIC24F32KA101__)
00976
00977 #include "devices/pic24f32ka101_pyports.h"
00978
00979 #elif defined(__PIC24F32KA102__)
00980
00981 #include "devices/pic24f32ka102_pyports.h"
00982
00983 #elif defined(__PIC24FJ128GA006__)
00984
00985 #include "devices/pic24fj128ga006_pyports.h"
00986
00987 #elif defined(__PIC24FJ128GA008__)
00988
00989 #include "devices/pic24fj128ga008_pyports.h"
00990
00991 #elif defined(__PIC24FJ128GA010__)
00992
00993 #include "devices/pic24fj128ga010_pyports.h"
00994
00995 #elif defined(__PIC24FJ128GA106__)
00996
00997 #include "devices/pic24fj128ga106_pyports.h"
00998
00999 #elif defined(__PIC24FJ128GA108__)
01000
01001 #include "devices/pic24fj128ga108_pyports.h"
01002
01003 #elif defined(__PIC24FJ128GA110__)
01004
01005 #include "devices/pic24fj128ga110_pyports.h"
01006
01007 #elif defined(__PIC24FJ128GB106__)
01008
01009 #include "devices/pic24fj128gb106_pyports.h"
01010
01011 #elif defined(__PIC24FJ128GB108__)
01012
01013 #include "devices/pic24fj128gb108_pyports.h"
01014
01015 #elif defined(__PIC24FJ128GB110__)
01016
01017 #include "devices/pic24fj128gb110_pyports.h"
01018
01019 #elif defined(__PIC24FJ16GA002__)
01020
01021 #include "devices/pic24fj16ga002_pyports.h"
01022
01023 #elif defined(__PIC24FJ16GA004__)
01024
01025 #include "devices/pic24fj16ga004_pyports.h"
01026
01027 #elif defined(__PIC24FJ192GA106__)
01028
01029 #include "devices/pic24fj192ga106_pyports.h"
01030
01031 #elif defined(__PIC24FJ192GA108__)
01032
01033 #include "devices/pic24fj192ga108_pyports.h"
01034
01035 #elif defined(__PIC24FJ192GA110__)
01036
01037 #include "devices/pic24fj192ga110_pyports.h"
01038
01039 #elif defined(__PIC24FJ192GB106__)
01040
01041 #include "devices/pic24fj192gb106_pyports.h"
01042
01043 #elif defined(__PIC24FJ192GB108__)
01044
01045 #include "devices/pic24fj192gb108_pyports.h"
01046
01047 #elif defined(__PIC24FJ192GB110__)
01048
01049 #include "devices/pic24fj192gb110_pyports.h"
01050
01051 #elif defined(__PIC24FJ256GA106__)
01052
01053 #include "devices/pic24fj256ga106_pyports.h"
01054
01055 #elif defined(__PIC24FJ256GA108__)
01056
01057 #include "devices/pic24fj256ga108_pyports.h"
01058
01059 #elif defined(__PIC24FJ256GA110__)
01060
01061 #include "devices/pic24fj256ga110_pyports.h"
01062
01063 #elif defined(__PIC24FJ256GB106__)
01064
01065 #include "devices/pic24fj256gb106_pyports.h"
01066
01067 #elif defined(__PIC24FJ256GB108__)
01068
01069 #include "devices/pic24fj256gb108_pyports.h"
01070
01071 #elif defined(__PIC24FJ256GB110__)
01072
01073 #include "devices/pic24fj256gb110_pyports.h"
01074
01075 #elif defined(__PIC24FJ32GA002__)
01076
01077 #include "devices/pic24fj32ga002_pyports.h"
01078
01079 #elif defined(__PIC24FJ32GA004__)
01080
01081 #include "devices/pic24fj32ga004_pyports.h"
01082
01083 #elif defined(__PIC24FJ48GA002__)
01084
01085 #include "devices/pic24fj48ga002_pyports.h"
01086
01087 #elif defined(__PIC24FJ48GA004__)
01088
01089 #include "devices/pic24fj48ga004_pyports.h"
01090
01091 #elif defined(__PIC24FJ64GA002__)
01092
01093 #include "devices/pic24fj64ga002_pyports.h"
01094
01095 #elif defined(__PIC24FJ64GA004__)
01096
01097 #include "devices/pic24fj64ga004_pyports.h"
01098
01099 #elif defined(__PIC24FJ64GA006__)
01100
01101 #include "devices/pic24fj64ga006_pyports.h"
01102
01103 #elif defined(__PIC24FJ64GA008__)
01104
01105 #include "devices/pic24fj64ga008_pyports.h"
01106
01107 #elif defined(__PIC24FJ64GA010__)
01108
01109 #include "devices/pic24fj64ga010_pyports.h"
01110
01111 #elif defined(__PIC24FJ64GA106__)
01112
01113 #include "devices/pic24fj64ga106_pyports.h"
01114
01115 #elif defined(__PIC24FJ64GA108__)
01116
01117 #include "devices/pic24fj64ga108_pyports.h"
01118
01119 #elif defined(__PIC24FJ64GA110__)
01120
01121 #include "devices/pic24fj64ga110_pyports.h"
01122
01123 #elif defined(__PIC24FJ64GB106__)
01124
01125 #include "devices/pic24fj64gb106_pyports.h"
01126
01127 #elif defined(__PIC24FJ64GB108__)
01128
01129 #include "devices/pic24fj64gb108_pyports.h"
01130
01131 #elif defined(__PIC24FJ64GB110__)
01132
01133 #include "devices/pic24fj64gb110_pyports.h"
01134
01135 #elif defined(__PIC24FJ96GA006__)
01136
01137 #include "devices/pic24fj96ga006_pyports.h"
01138
01139 #elif defined(__PIC24FJ96GA008__)
01140
01141 #include "devices/pic24fj96ga008_pyports.h"
01142
01143 #elif defined(__PIC24FJ96GA010__)
01144
01145 #include "devices/pic24fj96ga010_pyports.h"
01146
01147 #elif defined(__dsPIC33FJ06GS101__)
01148
01149 #include "devices/dspic33fj06gs101_pyports.h"
01150
01151 #elif defined(__dsPIC33FJ06GS102__)
01152
01153 #include "devices/dspic33fj06gs102_pyports.h"
01154
01155 #elif defined(__dsPIC33FJ06GS202__)
01156
01157 #include "devices/dspic33fj06gs202_pyports.h"
01158
01159 #elif defined(__dsPIC33FJ128GP202__)
01160
01161 #include "devices/dspic33fj128gp202_pyports.h"
01162
01163 #elif defined(__dsPIC33FJ128GP204__)
01164
01165 #include "devices/dspic33fj128gp204_pyports.h"
01166
01167 #elif defined(__dsPIC33FJ128GP206A__)
01168
01169 #include "devices/dspic33fj128gp206a_pyports.h"
01170
01171 #elif defined(__dsPIC33FJ128GP206__)
01172
01173 #include "devices/dspic33fj128gp206_pyports.h"
01174
01175 #elif defined(__dsPIC33FJ128GP306A__)
01176
01177 #include "devices/dspic33fj128gp306a_pyports.h"
01178
01179 #elif defined(__dsPIC33FJ128GP306__)
01180
01181 #include "devices/dspic33fj128gp306_pyports.h"
01182
01183 #elif defined(__dsPIC33FJ128GP310A__)
01184
01185 #include "devices/dspic33fj128gp310a_pyports.h"
01186
01187 #elif defined(__dsPIC33FJ128GP310__)
01188
01189 #include "devices/dspic33fj128gp310_pyports.h"
01190
01191 #elif defined(__dsPIC33FJ128GP706A__)
01192
01193 #include "devices/dspic33fj128gp706a_pyports.h"
01194
01195 #elif defined(__dsPIC33FJ128GP706__)
01196
01197 #include "devices/dspic33fj128gp706_pyports.h"
01198
01199 #elif defined(__dsPIC33FJ128GP708A__)
01200
01201 #include "devices/dspic33fj128gp708a_pyports.h"
01202
01203 #elif defined(__dsPIC33FJ128GP708__)
01204
01205 #include "devices/dspic33fj128gp708_pyports.h"
01206
01207 #elif defined(__dsPIC33FJ128GP710A__)
01208
01209 #include "devices/dspic33fj128gp710a_pyports.h"
01210
01211 #elif defined(__dsPIC33FJ128GP710__)
01212
01213 #include "devices/dspic33fj128gp710_pyports.h"
01214
01215 #elif defined(__dsPIC33FJ128GP802__)
01216
01217 #include "devices/dspic33fj128gp802_pyports.h"
01218
01219 #elif defined(__dsPIC33FJ128GP804__)
01220
01221 #include "devices/dspic33fj128gp804_pyports.h"
01222
01223 #elif defined(__dsPIC33FJ128MC202__)
01224
01225 #include "devices/dspic33fj128mc202_pyports.h"
01226
01227 #elif defined(__dsPIC33FJ128MC204__)
01228
01229 #include "devices/dspic33fj128mc204_pyports.h"
01230
01231 #elif defined(__dsPIC33FJ128MC506A__)
01232
01233 #include "devices/dspic33fj128mc506a_pyports.h"
01234
01235 #elif defined(__dsPIC33FJ128MC506__)
01236
01237 #include "devices/dspic33fj128mc506_pyports.h"
01238
01239 #elif defined(__dsPIC33FJ128MC510A__)
01240
01241 #include "devices/dspic33fj128mc510a_pyports.h"
01242
01243 #elif defined(__dsPIC33FJ128MC510__)
01244
01245 #include "devices/dspic33fj128mc510_pyports.h"
01246
01247 #elif defined(__dsPIC33FJ128MC706A__)
01248
01249 #include "devices/dspic33fj128mc706a_pyports.h"
01250
01251 #elif defined(__dsPIC33FJ128MC706__)
01252
01253 #include "devices/dspic33fj128mc706_pyports.h"
01254
01255 #elif defined(__dsPIC33FJ128MC708A__)
01256
01257 #include "devices/dspic33fj128mc708a_pyports.h"
01258
01259 #elif defined(__dsPIC33FJ128MC708__)
01260
01261 #include "devices/dspic33fj128mc708_pyports.h"
01262
01263 #elif defined(__dsPIC33FJ128MC710A__)
01264
01265 #include "devices/dspic33fj128mc710a_pyports.h"
01266
01267 #elif defined(__dsPIC33FJ128MC710__)
01268
01269 #include "devices/dspic33fj128mc710_pyports.h"
01270
01271 #elif defined(__dsPIC33FJ128MC802__)
01272
01273 #include "devices/dspic33fj128mc802_pyports.h"
01274
01275 #elif defined(__dsPIC33FJ128MC804__)
01276
01277 #include "devices/dspic33fj128mc804_pyports.h"
01278
01279 #elif defined(__dsPIC33FJ12GP201__)
01280
01281 #include "devices/dspic33fj12gp201_pyports.h"
01282
01283 #elif defined(__dsPIC33FJ12GP202__)
01284
01285 #include "devices/dspic33fj12gp202_pyports.h"
01286
01287 #elif defined(__dsPIC33FJ12MC201__)
01288
01289 #include "devices/dspic33fj12mc201_pyports.h"
01290
01291 #elif defined(__dsPIC33FJ12MC202__)
01292
01293 #include "devices/dspic33fj12mc202_pyports.h"
01294
01295 #elif defined(__dsPIC33FJ16GP304__)
01296
01297 #include "devices/dspic33fj16gp304_pyports.h"
01298
01299 #elif defined(__dsPIC33FJ16GS402__)
01300
01301 #include "devices/dspic33fj16gs402_pyports.h"
01302
01303 #elif defined(__dsPIC33FJ16GS404__)
01304
01305 #include "devices/dspic33fj16gs404_pyports.h"
01306
01307 #elif defined(__dsPIC33FJ16GS502__)
01308
01309 #include "devices/dspic33fj16gs502_pyports.h"
01310
01311 #elif defined(__dsPIC33FJ16GS504__)
01312
01313 #include "devices/dspic33fj16gs504_pyports.h"
01314
01315 #elif defined(__dsPIC33FJ16MC304__)
01316
01317 #include "devices/dspic33fj16mc304_pyports.h"
01318
01319 #elif defined(__dsPIC33FJ256GP506A__)
01320
01321 #include "devices/dspic33fj256gp506a_pyports.h"
01322
01323 #elif defined(__dsPIC33FJ256GP506__)
01324
01325 #include "devices/dspic33fj256gp506_pyports.h"
01326
01327 #elif defined(__dsPIC33FJ256GP510A__)
01328
01329 #include "devices/dspic33fj256gp510a_pyports.h"
01330
01331 #elif defined(__dsPIC33FJ256GP510__)
01332
01333 #include "devices/dspic33fj256gp510_pyports.h"
01334
01335 #elif defined(__dsPIC33FJ256GP710A__)
01336
01337 #include "devices/dspic33fj256gp710a_pyports.h"
01338
01339 #elif defined(__dsPIC33FJ256GP710__)
01340
01341 #include "devices/dspic33fj256gp710_pyports.h"
01342
01343 #elif defined(__dsPIC33FJ256MC510A__)
01344
01345 #include "devices/dspic33fj256mc510a_pyports.h"
01346
01347 #elif defined(__dsPIC33FJ256MC510__)
01348
01349 #include "devices/dspic33fj256mc510_pyports.h"
01350
01351 #elif defined(__dsPIC33FJ256MC710A__)
01352
01353 #include "devices/dspic33fj256mc710a_pyports.h"
01354
01355 #elif defined(__dsPIC33FJ256MC710__)
01356
01357 #include "devices/dspic33fj256mc710_pyports.h"
01358
01359 #elif defined(__dsPIC33FJ32GP202__)
01360
01361 #include "devices/dspic33fj32gp202_pyports.h"
01362
01363 #elif defined(__dsPIC33FJ32GP204__)
01364
01365 #include "devices/dspic33fj32gp204_pyports.h"
01366
01367 #elif defined(__dsPIC33FJ32GP302__)
01368
01369 #include "devices/dspic33fj32gp302_pyports.h"
01370
01371 #elif defined(__dsPIC33FJ32GP304__)
01372
01373 #include "devices/dspic33fj32gp304_pyports.h"
01374
01375 #elif defined(__dsPIC33FJ32GS406__)
01376
01377 #include "devices/dspic33fj32gs406_pyports.h"
01378
01379 #elif defined(__dsPIC33FJ32GS606__)
01380
01381 #include "devices/dspic33fj32gs606_pyports.h"
01382
01383 #elif defined(__dsPIC33FJ32GS608__)
01384
01385 #include "devices/dspic33fj32gs608_pyports.h"
01386
01387 #elif defined(__dsPIC33FJ32GS610__)
01388
01389 #include "devices/dspic33fj32gs610_pyports.h"
01390
01391 #elif defined(__dsPIC33FJ32MC202__)
01392
01393 #include "devices/dspic33fj32mc202_pyports.h"
01394
01395 #elif defined(__dsPIC33FJ32MC204__)
01396
01397 #include "devices/dspic33fj32mc204_pyports.h"
01398
01399 #elif defined(__dsPIC33FJ32MC302__)
01400
01401 #include "devices/dspic33fj32mc302_pyports.h"
01402
01403 #elif defined(__dsPIC33FJ32MC304__)
01404
01405 #include "devices/dspic33fj32mc304_pyports.h"
01406
01407 #elif defined(__dsPIC33FJ64GP202__)
01408
01409 #include "devices/dspic33fj64gp202_pyports.h"
01410
01411 #elif defined(__dsPIC33FJ64GP204__)
01412
01413 #include "devices/dspic33fj64gp204_pyports.h"
01414
01415 #elif defined(__dsPIC33FJ64GP206A__)
01416
01417 #include "devices/dspic33fj64gp206a_pyports.h"
01418
01419 #elif defined(__dsPIC33FJ64GP206__)
01420
01421 #include "devices/dspic33fj64gp206_pyports.h"
01422
01423 #elif defined(__dsPIC33FJ64GP306A__)
01424
01425 #include "devices/dspic33fj64gp306a_pyports.h"
01426
01427 #elif defined(__dsPIC33FJ64GP306__)
01428
01429 #include "devices/dspic33fj64gp306_pyports.h"
01430
01431 #elif defined(__dsPIC33FJ64GP310A__)
01432
01433 #include "devices/dspic33fj64gp310a_pyports.h"
01434
01435 #elif defined(__dsPIC33FJ64GP310__)
01436
01437 #include "devices/dspic33fj64gp310_pyports.h"
01438
01439 #elif defined(__dsPIC33FJ64GP706A__)
01440
01441 #include "devices/dspic33fj64gp706a_pyports.h"
01442
01443 #elif defined(__dsPIC33FJ64GP706__)
01444
01445 #include "devices/dspic33fj64gp706_pyports.h"
01446
01447 #elif defined(__dsPIC33FJ64GP708A__)
01448
01449 #include "devices/dspic33fj64gp708a_pyports.h"
01450
01451 #elif defined(__dsPIC33FJ64GP708__)
01452
01453 #include "devices/dspic33fj64gp708_pyports.h"
01454
01455 #elif defined(__dsPIC33FJ64GP710A__)
01456
01457 #include "devices/dspic33fj64gp710a_pyports.h"
01458
01459 #elif defined(__dsPIC33FJ64GP710__)
01460
01461 #include "devices/dspic33fj64gp710_pyports.h"
01462
01463 #elif defined(__dsPIC33FJ64GP802__)
01464
01465 #include "devices/dspic33fj64gp802_pyports.h"
01466
01467 #elif defined(__dsPIC33FJ64GP804__)
01468
01469 #include "devices/dspic33fj64gp804_pyports.h"
01470
01471 #elif defined(__dsPIC33FJ64GS406__)
01472
01473 #include "devices/dspic33fj64gs406_pyports.h"
01474
01475 #elif defined(__dsPIC33FJ64GS606__)
01476
01477 #include "devices/dspic33fj64gs606_pyports.h"
01478
01479 #elif defined(__dsPIC33FJ64GS608__)
01480
01481 #include "devices/dspic33fj64gs608_pyports.h"
01482
01483 #elif defined(__dsPIC33FJ64GS610__)
01484
01485 #include "devices/dspic33fj64gs610_pyports.h"
01486
01487 #elif defined(__dsPIC33FJ64MC202__)
01488
01489 #include "devices/dspic33fj64mc202_pyports.h"
01490
01491 #elif defined(__dsPIC33FJ64MC204__)
01492
01493 #include "devices/dspic33fj64mc204_pyports.h"
01494
01495 #elif defined(__dsPIC33FJ64MC506A__)
01496
01497 #include "devices/dspic33fj64mc506a_pyports.h"
01498
01499 #elif defined(__dsPIC33FJ64MC506__)
01500
01501 #include "devices/dspic33fj64mc506_pyports.h"
01502
01503 #elif defined(__dsPIC33FJ64MC508A__)
01504
01505 #include "devices/dspic33fj64mc508a_pyports.h"
01506
01507 #elif defined(__dsPIC33FJ64MC508__)
01508
01509 #include "devices/dspic33fj64mc508_pyports.h"
01510
01511 #elif defined(__dsPIC33FJ64MC510A__)
01512
01513 #include "devices/dspic33fj64mc510a_pyports.h"
01514
01515 #elif defined(__dsPIC33FJ64MC510__)
01516
01517 #include "devices/dspic33fj64mc510_pyports.h"
01518
01519 #elif defined(__dsPIC33FJ64MC706A__)
01520
01521 #include "devices/dspic33fj64mc706a_pyports.h"
01522
01523 #elif defined(__dsPIC33FJ64MC706__)
01524
01525 #include "devices/dspic33fj64mc706_pyports.h"
01526
01527 #elif defined(__dsPIC33FJ64MC710A__)
01528
01529 #include "devices/dspic33fj64mc710a_pyports.h"
01530
01531 #elif defined(__dsPIC33FJ64MC710__)
01532
01533 #include "devices/dspic33fj64mc710_pyports.h"
01534
01535 #elif defined(__dsPIC33FJ64MC802__)
01536
01537 #include "devices/dspic33fj64mc802_pyports.h"
01538
01539 #elif defined(__dsPIC33FJ64MC804__)
01540
01541 #include "devices/dspic33fj64mc804_pyports.h"
01542
01543 #else
01544
01545 #error -- processor ID not specified in pic24_pyports.h
01546
01547 #endif
01548
01549
01550 #ifndef _PIC24_PYDIGIO_DEFINED
01551 #warning Digital IO macros not defined for this device!
01552 #warning Edit common\pic24_pyports.h file!
01553 #endif
01554
01555
01556
01557
01558
01559
01560
01561
01565 #define UNDEF_AN_PIN 255
01566
01570 #define UNDEF_CN_PIN 255
01571
01576 typedef struct {
01579 uint8_t u8_anPin;
01582 uint8_t u8_cnPin;
01583 } anCnMap_t;
01584
01585
01586
01590 static const anCnMap_t anCnMap[NUM_DIGITAL_PORTS * 16] = { AN_CN_MAP };
01591
01592 #if defined(HAS_REMAPPABLE_PINS) || defined(__DOXYGEN__)
01593
01597 static const uint32_t u32_isRemappable = {
01598 #ifdef _RP0R
01599 0x00000001 |
01600 #endif
01601 #ifdef _RP1R
01602 0x00000002 |
01603 #endif
01604 #ifdef _RP2R
01605 0x00000004 |
01606 #endif
01607 #ifdef _RP3R
01608 0x00000008 |
01609 #endif
01610 #ifdef _RP4R
01611 0x00000010 |
01612 #endif
01613 #ifdef _RP5R
01614 0x00000020 |
01615 #endif
01616 #ifdef _RP6R
01617 0x00000040 |
01618 #endif
01619 #ifdef _RP7R
01620 0x00000080 |
01621 #endif
01622 #ifdef _RP8R
01623 0x00000100 |
01624 #endif
01625 #ifdef _RP9R
01626 0x00000200 |
01627 #endif
01628 #ifdef _RP10R
01629 0x00000400 |
01630 #endif
01631 #ifdef _RP11R
01632 0x00000800 |
01633 #endif
01634 #ifdef _RP12R
01635 0x00001000 |
01636 #endif
01637 #ifdef _RP13R
01638 0x00002000 |
01639 #endif
01640 #ifdef _RP14R
01641 0x00004000 |
01642 #endif
01643 #ifdef _RP15R
01644 0x00008000 |
01645 #endif
01646 #ifdef _RP16R
01647 0x00010000 |
01648 #endif
01649 #ifdef _RP17R
01650 0x00020000 |
01651 #endif
01652 #ifdef _RP18R
01653 0x00040000 |
01654 #endif
01655 #ifdef _RP19R
01656 0x00080000 |
01657 #endif
01658 #ifdef _RP20R
01659 0x00100000 |
01660 #endif
01661 #ifdef _RP21R
01662 0x00200000 |
01663 #endif
01664 #ifdef _RP22R
01665 0x00400000 |
01666 #endif
01667 #ifdef _RP23R
01668 0x00800000 |
01669 #endif
01670 #ifdef _RP24R
01671 0x01000000 |
01672 #endif
01673 #ifdef _RP25R
01674 0x02000000 |
01675 #endif
01676 #ifdef _RP26R
01677 0x04000000 |
01678 #endif
01679 #ifdef _RP27R
01680 0x08000000 |
01681 #endif
01682 #ifdef _RP28R
01683 0x10000000 |
01684 #endif
01685 #ifdef _RP29R
01686 0x20000000 |
01687 #endif
01688 #ifdef _RP30R
01689 0x40000000 |
01690 #endif
01691
01692
01693 0x00000000
01694 };
01695 #endif
01696
01697
01698
01699
01700
01707 inline __STATIC__ bool_t digitalPinInBounds(uint16_t u16_port, uint16_t u16_pin)
01708 {
01709
01710 if (u16_port >= NUM_DIGITAL_PORTS)
01711 return C_FALSE;
01712
01713 if (u16_pin > 15)
01714 return C_FALSE;
01715 else
01716 return C_TRUE;
01717 }
01718
01719 bool_t
01720 digitalPinExists(uint16_t u16_port, uint16_t u16_pin)
01721 {
01722
01723 if (!digitalPinInBounds(u16_port, u16_pin))
01724 return C_FALSE;
01725
01726 return getBit(u16_digitalPinPresent[u16_port], u16_pin);
01727 }
01728
01729
01736 __STATIC__ bool_t
01737 digitalOpenDrainPinExists(uint16_t u16_port, uint16_t u16_pin)
01738 {
01739
01740 if (!digitalPinInBounds(u16_port, u16_pin))
01741 return C_FALSE;
01742
01743 return getBit(u16_digitalPinOpenDrainPresent[u16_port], u16_pin);
01744 }
01745
01746
01751
01752
01753
01754 #define IO_PORT_CONTROL_OFFSET 4
01755
01756 PmReturn_t
01757 setPinIsInput(uint16_t u16_port, uint16_t u16_pin, bool_t b_isInput)
01758 {
01759 PmReturn_t retval = PM_RET_OK;
01760
01761 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01762 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01763
01764 setBit((&TRISA) + u16_port*IO_PORT_CONTROL_OFFSET, u16_pin, b_isInput);
01765 return retval;
01766 }
01767
01768
01769 PmReturn_t
01770 getPinIsInput(uint16_t u16_port, uint16_t u16_pin, bool_t* pb_isInput)
01771 {
01772 PmReturn_t retval = PM_RET_OK;
01773
01774 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01775 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01776
01777 *pb_isInput = getBit(*((&TRISA) + u16_port*IO_PORT_CONTROL_OFFSET), u16_pin);
01778 return retval;
01779 }
01780
01781
01782 PmReturn_t
01783 setPinIsDigital(uint16_t u16_port, uint16_t u16_pin,
01784 bool_t b_isDigital)
01785 {
01786 PmReturn_t retval = PM_RET_OK;
01787 uint8_t u8_anPin;
01788
01789 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01790 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01791
01792
01793
01794
01795
01796
01797 u8_anPin = anCnMap[u16_port*16 + u16_pin].u8_anPin;
01798 if (u8_anPin != UNDEF_AN_PIN) {
01799
01800
01801
01802 SET_EXTENDED_BIT(&AD1PCFGL, u8_anPin, b_isDigital);
01803 #ifdef _AD2IF
01804 SET_EXTENDED_BIT(&AD2PCFGL, u8_anPin, b_isDigital);
01805 #endif
01806 } else {
01807
01808
01809
01810 EXCEPTION_UNLESS(b_isDigital, PM_RET_EX_VAL,
01811 "Pin %c%d does not support analog functionality.",
01812 (char) (u16_port + 'A'), u16_pin);
01813 }
01814
01815 return retval;
01816 }
01817
01818
01819 PmReturn_t
01820 setPinIsOpenDrain(uint16_t u16_port, uint16_t u16_pin, bool_t b_isOpenDrain)
01821 {
01822 PmReturn_t retval = PM_RET_OK;
01823
01824 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01825 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01826
01827
01828
01829
01830
01831 if (digitalOpenDrainPinExists(u16_port, u16_pin)) {
01832
01833
01834 #if defined (_ODA0) || defined (_ODA1) || defined (_ODA2) || defined (_ODA3) || \
01835 defined (_ODA4) || defined (_ODA5) || defined (_ODA6) || defined (_ODA7) || \
01836 defined (_ODA8) || defined (_ODA9) || defined (_ODA10) || defined (_ODA11) || \
01837 defined (_ODA12) || defined (_ODA12) || defined (_ODA14) || defined (_ODA15)
01838 #define ODCA ODA
01839 #endif
01840 setBit((&ODCA) + u16_port*IO_PORT_CONTROL_OFFSET, u16_pin, b_isOpenDrain);
01841 } else {
01842
01843
01844
01845 EXCEPTION_UNLESS(!b_isOpenDrain, PM_RET_EX_VAL,
01846 "The pin %c%d has no open-drain ability.", (char) (u16_port + 'A'), u16_pin);
01847 }
01848
01849 return retval;
01850 }
01851
01852 PmReturn_t
01853 setPinPullDirection(uint16_t u16_port, uint16_t u16_pin,
01854 int16_t i16_dir)
01855 {
01856 PmReturn_t retval = PM_RET_OK;
01857 uint8_t u8_cnPin;
01858
01859 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01860 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01861
01862
01863 u8_cnPin = anCnMap[u16_port*16 + u16_pin].u8_cnPin;
01864
01865
01866 if (i16_dir == 0) {
01867 if (u8_cnPin != UNDEF_CN_PIN) {
01868 SET_EXTENDED_BIT(&CNPU1, u8_cnPin, C_FALSE);
01869 #ifdef HAS_PULL_DOWNS
01870 SET_EXTENDED_BIT(&CNPD1, u8_cnPin, C_FALSE);
01871 #endif
01872 }
01873
01874
01875 } else if (i16_dir > 0) {
01876 EXCEPTION_UNLESS(u8_cnPin != UNDEF_CN_PIN, PM_RET_EX_VAL,
01877 "Pull-ups do not exist on %c%d.",
01878 (char) (u16_port + 'A'), u16_pin);
01879 SET_EXTENDED_BIT(&CNPU1, u8_cnPin, C_TRUE);
01880 #ifdef HAS_PULL_DOWNS
01881 SET_EXTENDED_BIT(&CNPD1, u8_cnPin, C_FALSE);
01882 #endif
01883
01884
01885 } else {
01886 ASSERT(i16_dir < 0);
01887
01888
01889 #ifdef HAS_PULL_DOWNS
01890 SET_EXTENDED_BIT(&CNPD1, u8_cnPin, C_TRUE);
01891 #else
01892 EXCEPTION_UNLESS(0, PM_RET_EX_VAL,
01893 "Pull-downs do not exist on this chip.");
01894 #endif
01895
01896
01897 EXCEPTION_UNLESS(u8_cnPin != UNDEF_CN_PIN, PM_RET_EX_VAL,
01898 "Pull-ups do not exist on %c%d.",
01899 (char) (u16_port + 'A'), u16_pin);
01900 SET_EXTENDED_BIT(&CNPU1, u8_cnPin, C_FALSE);
01901 }
01902
01903 return retval;
01904 }
01905
01906 #ifdef HAS_REMAPPABLE_PINS
01907
01916 #define UNMAP_PERIPHERAL_INPUT(rpinrBitfield, rpPin) \
01917 if (rpinrBitfield == rpPin) \
01918 rpinrBitfield = IN_PIN_PPS_VSS; \
01919 else \
01920 ((void) 0)
01921
01928 #define UNMAP_PERIPHERAL_OUTPUT(rpPin) \
01929 case rpPin : \
01930 _RP ## rpPin ## R = OUT_FN_PPS_NULL; \
01931 break
01932
01935 #define UNMAP_PIN(u16_port, u16_pin) unmapPin(u16_port, u16_pin)
01936
01937 PmReturn_t
01938 unmapPin(uint16_t u16_port, uint16_t u16_pin)
01939 {
01940 PmReturn_t retval = PM_RET_OK;
01941 uint16_t u16_rp;
01942
01943 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
01944 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
01945
01946
01947
01948 if ( (u16_port != PORT_B_INDEX) && (u16_port != PORT_C_INDEX) )
01949 return retval;
01950
01951
01952
01953 u16_rp = (u16_port - PORT_B_INDEX)*16 + u16_pin;
01954
01955
01956 if (!GET_EXTENDED_BIT(u32_isRemappable, u16_rp))
01957 return retval;
01958
01959
01960
01961
01962
01963
01964 #ifdef _U1CTSR
01965 UNMAP_PERIPHERAL_INPUT(_U1CTSR, u16_rp);
01966 #endif
01967 #ifdef _U1RXR
01968 UNMAP_PERIPHERAL_INPUT(_U1RXR, u16_rp);
01969 #endif
01970
01971
01972 #ifdef _U2CTSR
01973 UNMAP_PERIPHERAL_INPUT(_U2CTSR, u16_rp);
01974 #endif
01975 #ifdef _U2RXR
01976 UNMAP_PERIPHERAL_INPUT(_U2RXR, u16_rp);
01977 #endif
01978
01979
01980 #ifdef _SCK1R
01981 UNMAP_PERIPHERAL_INPUT(_SCK1R, u16_rp);
01982 #endif
01983 #ifdef _SDI1R
01984 UNMAP_PERIPHERAL_INPUT(_SDI1R, u16_rp);
01985 #endif
01986 #ifdef _SS1R
01987 UNMAP_PERIPHERAL_INPUT(_SS1R, u16_rp);
01988 #endif
01989
01990
01991 #ifdef _SCK2R
01992 UNMAP_PERIPHERAL_INPUT(_SCK2R, u16_rp);
01993 #endif
01994 #ifdef _SDI2R
01995 UNMAP_PERIPHERAL_INPUT(_SDI2R, u16_rp);
01996 #endif
01997 #ifdef _SS2R
01998 UNMAP_PERIPHERAL_INPUT(_SS2R, u16_rp);
01999 #endif
02000
02001
02002 #ifdef _C1RXR
02003 UNMAP_PERIPHERAL_INPUT(_C1RXR, u16_rp);
02004 #endif
02005
02006
02007
02008 switch (u16_rp) {
02009 #ifdef _RP0R
02010 UNMAP_PERIPHERAL_OUTPUT(0);
02011 #endif
02012
02013 #ifdef _RP1R
02014 UNMAP_PERIPHERAL_OUTPUT(1);
02015 #endif
02016
02017 #ifdef _RP2R
02018 UNMAP_PERIPHERAL_OUTPUT(2);
02019 #endif
02020
02021 #ifdef _RP3R
02022 UNMAP_PERIPHERAL_OUTPUT(3);
02023 #endif
02024
02025 #ifdef _RP4R
02026 UNMAP_PERIPHERAL_OUTPUT(4);
02027 #endif
02028
02029 #ifdef _RP5R
02030 UNMAP_PERIPHERAL_OUTPUT(5);
02031 #endif
02032
02033 #ifdef _RP6R
02034 UNMAP_PERIPHERAL_OUTPUT(6);
02035 #endif
02036
02037 #ifdef _RP7R
02038 UNMAP_PERIPHERAL_OUTPUT(7);
02039 #endif
02040
02041 #ifdef _RP8R
02042 UNMAP_PERIPHERAL_OUTPUT(8);
02043 #endif
02044
02045 #ifdef _RP9R
02046 UNMAP_PERIPHERAL_OUTPUT(9);
02047 #endif
02048
02049 #ifdef _RP10R
02050 UNMAP_PERIPHERAL_OUTPUT(10);
02051 #endif
02052
02053 #ifdef _RP11R
02054 UNMAP_PERIPHERAL_OUTPUT(11);
02055 #endif
02056
02057 #ifdef _RP12R
02058 UNMAP_PERIPHERAL_OUTPUT(12);
02059 #endif
02060
02061 #ifdef _RP13R
02062 UNMAP_PERIPHERAL_OUTPUT(13);
02063 #endif
02064
02065 #ifdef _RP14R
02066 UNMAP_PERIPHERAL_OUTPUT(14);
02067 #endif
02068
02069 #ifdef _RP15R
02070 UNMAP_PERIPHERAL_OUTPUT(15);
02071 #endif
02072
02073 #ifdef _RP16R
02074 UNMAP_PERIPHERAL_OUTPUT(16);
02075 #endif
02076
02077 #ifdef _RP17R
02078 UNMAP_PERIPHERAL_OUTPUT(17);
02079 #endif
02080
02081 #ifdef _RP18R
02082 UNMAP_PERIPHERAL_OUTPUT(18);
02083 #endif
02084
02085 #ifdef _RP19R
02086 UNMAP_PERIPHERAL_OUTPUT(19);
02087 #endif
02088
02089 #ifdef _RP20R
02090 UNMAP_PERIPHERAL_OUTPUT(20);
02091 #endif
02092
02093 #ifdef _RP21R
02094 UNMAP_PERIPHERAL_OUTPUT(21);
02095 #endif
02096
02097 #ifdef _RP22R
02098 UNMAP_PERIPHERAL_OUTPUT(22);
02099 #endif
02100
02101 #ifdef _RP23R
02102 UNMAP_PERIPHERAL_OUTPUT(23);
02103 #endif
02104
02105 #ifdef _RP24R
02106 UNMAP_PERIPHERAL_OUTPUT(24);
02107 #endif
02108
02109 #ifdef _RP25R
02110 UNMAP_PERIPHERAL_OUTPUT(25);
02111 #endif
02112
02113 #ifdef _RP26R
02114 UNMAP_PERIPHERAL_OUTPUT(26);
02115 #endif
02116
02117 #ifdef _RP27R
02118 UNMAP_PERIPHERAL_OUTPUT(27);
02119 #endif
02120
02121 #ifdef _RP28R
02122 UNMAP_PERIPHERAL_OUTPUT(28);
02123 #endif
02124
02125 #ifdef _RP29R
02126 UNMAP_PERIPHERAL_OUTPUT(29);
02127 #endif
02128
02129 #ifdef _RP30R
02130 UNMAP_PERIPHERAL_OUTPUT(30);
02131 #endif
02132
02133 default :
02134
02135 break;
02136 }
02137
02138 return retval;
02139 }
02140
02141 #else // !defined(HAS_REMAPPABLE_PINS)
02144 #define UNMAP_PIN(u16_port, u16_pin) PM_RET_OK
02145 #endif
02146
02147 PmReturn_t
02148 configDigitalPin(uint16_t u16_port, uint16_t u16_pin, bool_t b_isInput,
02149 bool_t b_isOpenDrain, int16_t i16_pullDir)
02150 {
02151 PmReturn_t retval = PM_RET_OK;
02152
02153
02154 PM_CHECK_FUNCTION( setPinIsDigital(u16_port, u16_pin, C_TRUE) );
02155 PM_CHECK_FUNCTION( setPinIsInput(u16_port, u16_pin, b_isInput) );
02156 PM_CHECK_FUNCTION( setPinIsOpenDrain(u16_port, u16_pin, b_isOpenDrain) );
02157 PM_CHECK_FUNCTION( setPinPullDirection(u16_port, u16_pin, i16_pullDir) );
02158 PM_CHECK_FUNCTION( UNMAP_PIN(u16_port, u16_pin) );
02159
02160 return retval;
02161 }
02162
02163 PmReturn_t
02164 configAnalogPin(uint16_t u16_analogPin)
02165 {
02166 PmReturn_t retval = PM_RET_OK;
02167 uint16_t u16_port;
02168 uint16_t u16_pin;
02169 uint16_t u16_ndx;
02170
02171
02172 for (u16_ndx = 0; u16_ndx < 16*NUM_DIGITAL_PORTS; u16_ndx++)
02173 {
02174 if (anCnMap[u16_ndx].u8_anPin == u16_analogPin)
02175 break;
02176 }
02177 EXCEPTION_UNLESS(anCnMap[u16_ndx].u8_anPin == u16_analogPin, PM_RET_EX_VAL,
02178 "Invalid analog pin %d.", u16_analogPin);
02179 u16_port = u16_ndx >> 4;
02180 u16_pin = u16_ndx & 0xF;
02181
02182
02183 PM_CHECK_FUNCTION( setPinIsDigital(u16_port, u16_pin, C_FALSE) );
02184 PM_CHECK_FUNCTION( setPinIsInput(u16_port, u16_pin, C_TRUE) );
02185 PM_CHECK_FUNCTION( setPinPullDirection(u16_port, u16_pin, 0) );
02186 PM_CHECK_FUNCTION( UNMAP_PIN(u16_port, u16_pin) );
02187
02188 return retval;
02189 }
02190
02191
02192 PmReturn_t
02193 setDigitalPin(uint16_t u16_port, uint16_t u16_pin, bool_t b_isHigh)
02194 {
02195 PmReturn_t retval = PM_RET_OK;
02196
02197 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
02198 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
02199 setBit((&PORTA) + u16_port*IO_PORT_CONTROL_OFFSET, u16_pin, b_isHigh);
02200
02201 return retval;
02202 }
02203
02204 PmReturn_t
02205 readDigitalPin(uint16_t u16_port, uint16_t u16_pin, bool_t* pb_isHigh)
02206 {
02207 PmReturn_t retval = PM_RET_OK;
02208
02209 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
02210 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
02211 *pb_isHigh = getBit(*(&PORTA + u16_port*IO_PORT_CONTROL_OFFSET), u16_pin);
02212
02213 return retval;
02214 }
02215
02216 PmReturn_t
02217 readDigitalLatch(uint16_t u16_port, uint16_t u16_pin, bool_t* pb_isHigh)
02218 {
02219 PmReturn_t retval = PM_RET_OK;
02220
02221 EXCEPTION_UNLESS(digitalPinExists(u16_port, u16_pin), PM_RET_EX_VAL,
02222 "Invalid pin %c%d.", (char) (u16_port + 'A'), u16_pin);
02223 *pb_isHigh = getBit(*(&LATA + u16_port*IO_PORT_CONTROL_OFFSET), u16_pin);
02224
02225 return retval;
02226 }
02227