pic24_util.h
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
00039 #ifndef _PIC24_UTIL_H_
00040 #define _PIC24_UTIL_H_
00041
00053 #define DEV_ID_LOCATION 0xFF0000
00054
00055 #define REVISION_LOCATION 0xFF0002
00056
00057
00058 #if defined(__PIC24HJ12GP201__) || defined(__DOXYGEN__)
00059
00062 #define DEV_ID 0x00080a
00063
00066 #define DEV_ID_STR "PIC24HJ12GP201"
00067
00071 #define EXPECTED_REVISION1 0x003001
00072
00076 #define EXPECTED_REVISION1_STR "A2"
00077
00078 #define EXPECTED_REVISION2 0x003002
00079 #define EXPECTED_REVISION2_STR "A3"
00080 #define EXPECTED_REVISION3 0x003003
00081 #define EXPECTED_REVISION3_STR "A4"
00082 #endif
00083
00084 #ifdef __PIC24HJ12GP202__
00085 #define DEV_ID 0x00080B
00086 #define DEV_ID_STR "PIC24HJ12GP202"
00087 #define EXPECTED_REVISION1 0x003001
00088 #define EXPECTED_REVISION1_STR "A2"
00089 #define EXPECTED_REVISION2 0x003002
00090 #define EXPECTED_REVISION2_STR "A3"
00091 #define EXPECTED_REVISION3 0x003003
00092 #define EXPECTED_REVISION3_STR "A4"
00093 #endif
00094
00095
00096
00097
00098
00099 #ifdef __PIC24HJ16GP304__
00100 #define DEV_ID 0x000F17
00101 #define DEV_ID_STR "PIC24HJ16GP304"
00102 #endif
00103
00104 #ifdef __PIC24HJ32GP202__
00105 #define DEV_ID 0x000F1D
00106 #define DEV_ID_STR "PIC24HJ32GP202"
00107 #endif
00108
00109 #ifdef __PIC24HJ32GP204__
00110 #define DEV_ID 0x000F1F
00111 #define DEV_ID_STR "PIC24HJ32GP204"
00112 #endif
00113
00114 #if (defined(__PIC24HJ16GP304__) || defined(__PIC24HJ32GP202__) || defined(__PIC24HJ32GP204__))
00115 #define EXPECTED_REVISION1 0x003001
00116 #define EXPECTED_REVISION1_STR "A2"
00117 #define EXPECTED_REVISION2 0x003002
00118 #define EXPECTED_REVISION2_STR "A3"
00119 #define EXPECTED_REVISION3 0x003004
00120 #define EXPECTED_REVISION3_STR "A4"
00121 #define EXPECTED_REVISION4 0x003005
00122 #define EXPECTED_REVISION4_STR "A5"
00123 #endif
00124
00125
00126
00127 #ifdef __PIC24HJ32GP302__
00128 #define DEV_ID 0x000645
00129 #define DEV_ID_STR "PIC24HJ32GP302"
00130 #endif
00131
00132 #ifdef __PIC24HJ32GP304__
00133 #define DEV_ID 0x000647
00134 #define DEV_ID_STR "PIC24HJ32GP304"
00135 #endif
00136
00137 #ifdef __PIC24HJ64GP202__
00138 #define DEV_ID 0x000655
00139 #define DEV_ID_STR "PIC24HJ64GP202"
00140 #endif
00141
00142 #ifdef __PIC24HJ64GP204__
00143 #define DEV_ID 0x000657
00144 #define DEV_ID_STR "PIC24HJ64GP204"
00145 #endif
00146
00147 #ifdef __PIC24HJ64GP502__
00148 #define DEV_ID 0x000675
00149 #define DEV_ID_STR "PIC24HJ64GP502"
00150 #endif
00151
00152 #ifdef __PIC24HJ64GP504__
00153 #define DEV_ID 0x000677
00154 #define DEV_ID_STR "PIC24HJ64GP504"
00155 #endif
00156
00157 #ifdef __PIC24HJ128GP202__
00158 #define DEV_ID 0x000665
00159 #define DEV_ID_STR "PIC24HJ128GP202"
00160 #endif
00161
00162
00163 #ifdef __PIC24HJ128GP204__
00164 #define DEV_ID 0x000667
00165 #define DEV_ID_STR "PIC24HJ128GP204"
00166 #endif
00167
00168 #ifdef __PIC24HJ128GP502__
00169 #define DEV_ID 0x00067d
00170 #define DEV_ID_STR "PIC24HJ128GP502"
00171 #endif
00172
00173 #ifdef __PIC24HJ128GP504__
00174 #define DEV_ID 0x00067f
00175 #define DEV_ID_STR "PIC24HJ128GP504"
00176 #endif
00177
00178 #if (defined(__PIC24HJ128GP504__) || defined(__PIC24HJ128GP502__)\
00179 || defined(__PIC24HJ128GP204__) || defined(__PIC24HJ128GP202__)\
00180 || defined(__PIC24HJ64GP504__) || defined(__PIC24HJ64GP502__)\
00181 || defined(__PIC24HJ64GP204__) || defined(__PIC24HJ64GP202__)\
00182 || defined(__PIC24HJ32GP304__) || defined(__PIC24HJ32GP302__))
00183 #define EXPECTED_REVISION1 0x003001
00184 #define EXPECTED_REVISION1_STR "A1"
00185 #define EXPECTED_REVISION2 0x003002
00186 #define EXPECTED_REVISION2_STR "A2"
00187 #define EXPECTED_REVISION3 0x003003
00188 #define EXPECTED_REVISION3_STR "A3"
00189 #endif
00190
00191
00192
00193
00194 #ifdef __PIC24HJ64GP206__
00195 #define DEV_ID 0x000041
00196 #define DEV_ID_STR "PIC24HJ64GP206"
00197 #endif
00198
00199 #ifdef __PIC24HJ64GP210__
00200 #define DEV_ID 0x000047
00201 #define DEV_ID_STR "PIC24HJ64GP210"
00202 #endif
00203
00204 #ifdef __PIC24HJ64GP506__
00205 #define DEV_ID 0x000049
00206 #define DEV_ID_STR "PIC24HJ64GP506"
00207 #endif
00208
00209 #ifdef __PIC24HJ64GP510__
00210 #define DEV_ID 0x00004B
00211 #define DEV_ID_STR "PIC24HJ64GP510"
00212 #endif
00213
00214 #ifdef __PIC24HJ128GP206__
00215 #define DEV_ID 0x00005D
00216 #define DEV_ID_STR "PIC24HJ128GP206"
00217 #endif
00218
00219 #ifdef __PIC24HJ128GP210__
00220 #define DEV_ID 0x00005F
00221 #define DEV_ID_STR "PIC24HJ128GP210"
00222 #endif
00223
00224 #ifdef __PIC24HJ128GP306__
00225 #define DEV_ID 0x000065
00226 #define DEV_ID_STR "PIC24HJ128GP306"
00227 #endif
00228
00229 #ifdef __PIC24HJ128GP310__
00230 #define DEV_ID 0x000067
00231 #define DEV_ID_STR "PIC24HJ128GP310"
00232 #endif
00233
00234
00235 #ifdef __PIC24HJ128GP506__
00236 #define DEV_ID 0x000061
00237 #define DEV_ID_STR "PIC24HJ128GP506"
00238 #endif
00239
00240 #ifdef __PIC24HJ128GP510__
00241 #define DEV_ID 0x000063
00242 #define DEV_ID_STR "PIC24HJ128GP510"
00243 #endif
00244
00245 #ifdef __PIC24HJ256GP206__
00246 #define DEV_ID 0x000071
00247 #define DEV_ID_STR "PIC24HJ256GP206"
00248 #endif
00249
00250 #ifdef __PIC24HJ256GP210__
00251 #define DEV_ID 0x000073
00252 #define DEV_ID_STR "PIC24HJ256GP210"
00253 #endif
00254
00255
00256 #ifdef __PIC24HJ256GP610__
00257 #define DEV_ID 0x00007B
00258 #define DEV_ID_STR "PIC24HJ256GP610"
00259 #endif
00260
00261 #if (defined(__PIC24HJ64GP206__) || defined(__PIC24HJ64GP210__) || defined(__PIC24HJ64GP506__) || defined(__PIC24HJ64GP510__)\
00262 || defined(__PIC24HJ128GP206__) || defined(__PIC24HJ128GP210__) || defined(__PIC24HJ128GP306__)\
00263 || defined(__PIC24HJ128GP310__) || defined(__PIC24HJ128GP506__)|| defined(__PIC24HJ128GP510__)\
00264 || defined(__PIC24HJ256GP206__) || defined(__PIC24HJ256GP210__)|| defined(__PIC24HJ256GP610__))
00265
00266 #define EXPECTED_REVISION1 0x003002
00267 #define EXPECTED_REVISION1_STR "A2"
00268 #define EXPECTED_REVISION2 0x003004
00269 #define EXPECTED_REVISION2_STR "A3"
00270 #define EXPECTED_REVISION3 0x003040
00271 #define EXPECTED_REVISION3_STR "A4"
00272 #endif
00273
00274
00275
00276
00277
00278
00279 #ifdef __PIC24FJ128GA010__
00280 #define DEV_ID 0x00040D
00281 #define DEV_ID_STR "PIC24FJ128GA010"
00282 #endif
00283
00284 #ifdef __PIC24FJ96GA010__
00285 #define DEV_ID 0x00040C
00286 #define DEV_ID_STR "PIC24FJ96GA010"
00287 #endif
00288
00289 #ifdef __PIC24FJ64GA010__
00290 #define DEV_ID 0x00040B
00291 #define DEV_ID_STR "PIC24FJ64GA010"
00292 #endif
00293
00294 #ifdef __PIC24FJ128GA008__
00295 #define DEV_ID 0x00040A
00296 #define DEV_ID_STR "PIC24FJ128GA008"
00297 #endif
00298
00299 #ifdef __PIC24FJ96GA008__
00300 #define DEV_ID 0x000409
00301 #define DEV_ID_STR "PIC24FJ96GA008"
00302 #endif
00303
00304 #ifdef __PIC24FJ64GA008__
00305 #define DEV_ID 0x000408
00306 #define DEV_ID_STR "PIC24FJ64GA008"
00307 #endif
00308
00309 #ifdef __PIC24FJ128GA006__
00310 #define DEV_ID 0x000407
00311 #define DEV_ID_STR "PIC24FJ128GA006"
00312 #endif
00313
00314 #ifdef __PIC24FJ96GA006__
00315 #define DEV_ID 0x000409
00316 #define DEV_ID_STR "PIC24FJ96GA006"
00317 #endif
00318
00319 #ifdef __PIC24FJ64GA006__
00320 #define DEV_ID 0x000408
00321 #define DEV_ID_STR "PIC24FJ64GA006"
00322 #endif
00323
00324 #if (defined(__PIC24FJ128GA010__) || defined(__PIC24FJ96GA010__) || defined(__PIC24FJ64GA010__)\
00325 || defined(__PIC24FJ128GA008__) || defined(__PIC24FJ96GA008__) || defined(__PIC24FJ64GA008__)\
00326 || defined(__PIC24FJ128GA006__) || defined(__PIC24FJ96GA006__) || defined(__PIC24FJ64GA006__))
00327 #define EXPECTED_REVISION1 0x003002
00328 #define EXPECTED_REVISION1_STR "A2"
00329 #define EXPECTED_REVISION2 0x003003
00330 #define EXPECTED_REVISION2_STR "A3"
00331 #define EXPECTED_REVISION3 0x003007
00332 #define EXPECTED_REVISION3_STR "A4"
00333 #define EXPECTED_REVISION4 0x003043
00334 #define EXPECTED_REVISION4_STR "C1"
00335 #define EXPECTED_REVISION5 0x003044
00336 #define EXPECTED_REVISION5_STR "C2"
00337 #endif
00338
00339
00340
00341
00342 #ifdef __PIC24FJ32GA102__
00343 #define DEV_ID 0x004202
00344 #define DEV_ID_STR "PIC24FJ32GA102"
00345 #endif
00346 #ifdef __PIC24FJ32GA104__
00347 #define DEV_ID 0x00420A
00348 #define DEV_ID_STR "PIC24FJ32GA104"
00349 #endif
00350 #ifdef __PIC24FJ64GA102__
00351 #define DEV_ID 0x004206
00352 #define DEV_ID_STR "PIC24FJ64GA102"
00353 #endif
00354 #ifdef __PIC24FJ64GA104__
00355 #define DEV_ID 0x00420E
00356 #define DEV_ID_STR "PIC24FJ64GA104"
00357 #endif
00358
00359
00360 #if (defined(__PIC24FJ32GA102__) || defined(__PIC24FJ32GA104__)\
00361 || defined(__PIC24FJ64GA102__) || defined(__PIC24FJ64GA104__))
00362 #define EXPECTED_REVISION1 0x000002
00363 #define EXPECTED_REVISION1_STR "A2"
00364 #endif
00365
00366
00367
00368 #ifdef __PIC24FJ16GA002__
00369 #define DEV_ID 0x000444
00370 #define DEV_ID_STR "PIC24FJ16GA002"
00371 #endif
00372
00373 #ifdef __PIC24FJ32GA002__
00374 #define DEV_ID 0x000445
00375 #define DEV_ID_STR "PIC24FJ32GA002"
00376 #endif
00377
00378 #ifdef __PIC24FJ48GA002__
00379 #define DEV_ID 0x000446
00380 #define DEV_ID_STR "PIC24FJ48GA002"
00381 #endif
00382
00383 #ifdef __PIC24FJ64GA002__
00384 #define DEV_ID 0x000447
00385 #define DEV_ID_STR "PIC24FJ64GA002"
00386 #endif
00387
00388 #ifdef __PIC24FJ16GA004__
00389 #define DEV_ID 0x00044C
00390 #define DEV_ID_STR "PIC24FJ16GA004"
00391 #endif
00392
00393 #ifdef __PIC24FJ32GA004__
00394 #define DEV_ID 0x00044D
00395 #define DEV_ID_STR "PIC24FJ32GA004"
00396 #endif
00397
00398 #ifdef __PIC24FJ48GA004__
00399 #define DEV_ID 0x00044E
00400 #define DEV_ID_STR "PIC24FJ48GA004"
00401 #endif
00402
00403 #ifdef __PIC24FJ64GA004__
00404 #define DEV_ID 0x00044F
00405 #define DEV_ID_STR "PIC24FJ64GA004"
00406 #endif
00407
00408 #if (defined(__PIC24FJ64GA004__) || defined(__PIC24FJ48GA004__) || defined(__PIC24FJ32GA004__) || defined(__PIC24FJ16GA004__)\
00409 || defined(__PIC24FJ64GA002__) || defined(__PIC24FJ48GA002__) || defined(__PIC24FJ32GA002__) || defined(__PIC24FJ16GA002__))
00410
00411 #define EXPECTED_REVISION1 0x003003
00412 #define EXPECTED_REVISION1_STR "A3/A4"
00413 #define EXPECTED_REVISION2 0x003042
00414 #define EXPECTED_REVISION2_STR "B4"
00415 #define EXPECTED_REVISION3 0x003043
00416 #define EXPECTED_REVISION3_STR "B5"
00417 #endif
00418
00419
00420
00421
00422
00423 #ifdef __PIC24FJ256GA110__
00424 #define DEV_ID 0x00101E
00425 #define DEV_ID_STR "PIC24FJ256GA110"
00426 #endif
00427
00428 #ifdef __PIC24FJ192GA110__
00429 #define DEV_ID 0x001016
00430 #define DEV_ID_STR "PIC24FJ192GA110"
00431 #endif
00432
00433 #ifdef __PIC24FJ128GA110__
00434 #define DEV_ID 0x00100E
00435 #define DEV_ID_STR "PIC24FJ128GA110"
00436 #endif
00437
00438 #ifdef __PIC24FJ256GA108__
00439 #define DEV_ID 0x00101A
00440 #define DEV_ID_STR "PIC24FJ256GA108"
00441 #endif
00442
00443 #ifdef __PIC24FJ192GA108__
00444 #define DEV_ID 0x001012
00445 #define DEV_ID_STR "PIC24FJ192GA108"
00446 #endif
00447
00448 #ifdef __PIC24FJ128GA108__
00449 #define DEV_ID 0x00100A
00450 #define DEV_ID_STR "PIC24FJ128GA108"
00451 #endif
00452
00453 #ifdef __PIC24FJ256GA106__
00454 #define DEV_ID 0x001018
00455 #define DEV_ID_STR "PIC24FJ256GA106"
00456 #endif
00457
00458 #ifdef __PIC24FJ192GA106__
00459 #define DEV_ID 0x001010
00460 #define DEV_ID_STR "PIC24FJ192GA106"
00461 #endif
00462
00463 #ifdef __PIC24FJ128GA106__
00464 #define DEV_ID 0x001008
00465 #define DEV_ID_STR "PIC24FJ128GA106"
00466 #endif
00467
00468 #if (defined(__PIC24FJ256GA110__) || defined(__PIC24FJ192GA110__) || defined(__PIC24FJ128GA110__)\
00469 || defined(__PIC24FJ256GA108__) || defined(__PIC24FJ192GA108__) || defined(__PIC24FJ128GA108__)\
00470 || defined(__PIC24FJ256GA106__) || defined(__PIC24FJ192GA106__) || defined(__PIC24FJ128GA106__))
00471
00472 #define EXPECTED_REVISION1 0x003001
00473 #define EXPECTED_REVISION1_STR "A3"
00474 #define EXPECTED_REVISION2 0x003003
00475 #define EXPECTED_REVISION2_STR "A5"
00476 #endif
00477
00478
00479
00480 #ifdef __PIC24F04KA200__
00481 #define DEV_ID 0x000D02
00482 #define DEV_ID_STR "PIC24F04KA200"
00483 #endif
00484
00485 #ifdef __PIC24F04KA201__
00486 #define DEV_ID 0x000D00
00487 #define DEV_ID_STR "PIC24F04KA201"
00488 #endif
00489
00490 #if (defined(__PIC24F04KA200__) || defined(__PIC24F04KA201__) )
00491 #define EXPECTED_REVISION1 0x000001
00492 #define EXPECTED_REVISION1_STR "A1"
00493 #endif
00494
00495
00496 #ifdef __PIC24F08KA101__
00497 #define DEV_ID 0x000D08
00498 #define DEV_ID_STR "PIC24F08KA101"
00499 #endif
00500
00501 #ifdef __PIC24F08KA102__
00502 #define DEV_ID 0x000D0A
00503 #define DEV_ID_STR "PIC24F08KA102"
00504 #endif
00505
00506 #ifdef __PIC24F16KA101__
00507 #define DEV_ID 0x000D01
00508 #define DEV_ID_STR "PIC24F16KA101"
00509 #endif
00510
00511 #ifdef __PIC24F16KA102__
00512 #define DEV_ID 0x000D03
00513 #define DEV_ID_STR "PIC24F16KA102"
00514 #endif
00515
00516 #if (defined(__PIC24F08KA101__) || defined(__PIC24F08KA102__) || defined(__PIC24F16KA101__)\
00517 || defined(__PIC24F16KA102__))
00518
00519 #define EXPECTED_REVISION1 0x000005
00520 #define EXPECTED_REVISION1_STR "A5"
00521 #define EXPECTED_REVISION2 0x000006
00522 #define EXPECTED_REVISION2_STR "A6"
00523 #endif
00524
00525
00526
00527
00528
00529 #ifdef __PIC24FJ256GB110__
00530 #define DEV_ID 0x00101F
00531 #define DEV_ID_STR "PIC24FJ256GB110"
00532 #endif
00533
00534 #ifdef __PIC24FJ192GB110__
00535 #define DEV_ID 0x001017
00536 #define DEV_ID_STR "PIC24FJ192GB110"
00537 #endif
00538
00539 #ifdef __PIC24FJ128GB110__
00540 #define DEV_ID 0x00100F
00541 #define DEV_ID_STR "PIC24FJ128GB110"
00542 #endif
00543
00544 #ifdef __PIC24FJ64GB110__
00545 #define DEV_ID 0x001007
00546 #define DEV_ID_STR "PIC24FJ64GB110"
00547 #endif
00548
00549 #ifdef __PIC24FJ256GB108__
00550 #define DEV_ID 0x00101B
00551 #define DEV_ID_STR "PIC24FJ256GB108"
00552 #endif
00553
00554 #ifdef __PIC24FJ192GB108__
00555 #define DEV_ID 0x001013
00556 #define DEV_ID_STR "PIC24FJ192GB108"
00557 #endif
00558
00559 #ifdef __PIC24FJ128GB108__
00560 #define DEV_ID 0x00100B
00561 #define DEV_ID_STR "PIC24FJ128GB108"
00562 #endif
00563
00564 #ifdef __PIC24FJ64GB108__
00565 #define DEV_ID 0x001003
00566 #define DEV_ID_STR "PIC24FJ64GB108"
00567 #endif
00568
00569 #ifdef __PIC24FJ256GB106__
00570 #define DEV_ID 0x001018
00571 #define DEV_ID_STR "PIC24FJ256GB106"
00572 #define EXPECTED_REVISION1 0x000001
00573 #define EXPECTED_REVISION1_STR "A3"
00574 #endif
00575
00576 #ifdef __PIC24FJ192GB106__
00577 #define DEV_ID 0x001010
00578 #define DEV_ID_STR "PIC24FJ192GB106"
00579 #endif
00580
00581 #ifdef __PIC24FJ128GB106__
00582 #define DEV_ID 0x001008
00583 #define DEV_ID_STR "PIC24FJ128GB106"
00584 #endif
00585
00586 #ifdef __PIC24FJ64GB106__
00587 #define DEV_ID 0x001001
00588 #define DEV_ID_STR "PIC24FJ64GB106"
00589 #endif
00590
00591 #ifdef __PIC24FJ32GB002__
00592 #define DEV_ID 0x004203
00593 #define DEV_ID_STR "PIC24FJ32GB002"
00594 #endif
00595
00596 #ifdef __PIC24FJ32GB004__
00597 #define DEV_ID 0x00420B
00598 #define DEV_ID_STR "PIC24FJ32GB004"
00599 #endif
00600
00601 #ifdef __PIC24FJ64GB002__
00602 #define DEV_ID 0x004207
00603 #define DEV_ID_STR "PIC24FJ64GB002"
00604 #endif
00605
00606 #ifdef __PIC24FJ64GB004__
00607 #define DEV_ID 0x00420F
00608 #define DEV_ID_STR "PIC24FJ64GB004"
00609 #endif
00610
00611 #if (defined(__PIC24FJ32GB002__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ64GB002__) || defined(__PIC24FJ64GB004__))
00612 #define EXPECTED_REVISION1 0x000002
00613 #define EXPECTED_REVISION1_STR "A2"
00614 #endif
00615
00616
00617 #if (defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__)\
00618 || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__)\
00619 || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__))
00620
00621 #define EXPECTED_REVISION1 0x003001
00622 #define EXPECTED_REVISION1_STR "A3"
00623 #define EXPECTED_REVISION2 0x003003
00624 #define EXPECTED_REVISION2_STR "A5"
00625 #endif
00626
00627
00628
00629
00630 #ifdef __dsPIC33FJ12GP201__
00631 #define DEV_ID 0x000802
00632 #define DEV_ID_STR "dsPIC33FJ12GP201"
00633 #endif
00634
00635 #ifdef __dsPIC33FJ12GP202__
00636 #define DEV_ID 0x000803
00637 #define DEV_ID_STR "dsPIC33FJ12GP202"
00638 #endif
00639
00640 #if (defined(__dsPIC33FJ12GP201__) || defined(__dsPIC33FJ12GP202__))
00641 #define EXPECTED_REVISION1 0x003001
00642 #define EXPECTED_REVISION1_STR "A2"
00643 #define EXPECTED_REVISION2 0x003002
00644 #define EXPECTED_REVISION2_STR "A3"
00645 #define EXPECTED_REVISION3 0x003004
00646 #define EXPECTED_REVISION3_STR "A4"
00647 #endif
00648
00649
00650
00651 #ifdef __dsPIC33FJ32GP202__
00652 #define DEV_ID 0x000F0D
00653 #define DEV_ID_STR "dsPIC24FJ32GP202"
00654 #endif
00655
00656 #ifdef __dsPIC33FJ32GP204__
00657 #define DEV_ID 0x000F0F
00658 #define DEV_ID_STR "dsPIC33FJ32GP204"
00659 #endif
00660
00661 #ifdef __dsPIC33FJ16GP304__
00662 #define DEV_ID 0x000F07
00663 #define DEV_ID_STR "dsPIC33FJ16GP304"
00664 #endif
00665
00666 #if (defined(__dsPIC33FJ32GP202__) || defined(__dsPIC33FJ32GP204___) || defined(__dsPIC33FJ16GP304__))
00667 #define EXPECTED_REVISION1 0x003001
00668 #define EXPECTED_REVISION1_STR "A2"
00669 #define EXPECTED_REVISION2 0x003002
00670 #define EXPECTED_REVISION2_STR "A3"
00671 #define EXPECTED_REVISION3 0x003004
00672 #define EXPECTED_REVISION3_STR "A4"
00673 #endif
00674
00675
00676
00677 #ifdef __dsPIC33FJ32GP302__
00678 #define DEV_ID 0x000605
00679 #define DEV_ID_STR "dsPIC33FJ32GP302"
00680 #endif
00681
00682 #ifdef __dsPIC33FJ32GP304__
00683 #define DEV_ID 0x000607
00684 #define DEV_ID_STR "dsPIC33FJ32GP304"
00685 #endif
00686
00687 #ifdef __dsPIC33FJ64GP202__
00688 #define DEV_ID 0x000615
00689 #define DEV_ID_STR "dsPIC33FJ64GP202"
00690 #endif
00691
00692 #ifdef __dsPIC33FJ64GP204__
00693 #define DEV_ID 0x000617
00694 #define DEV_ID_STR "dsPIC33FJ64GP204"
00695 #endif
00696
00697 #ifdef __dsPIC33FJ64GP802__
00698 #define DEV_ID 0x00061d
00699 #define DEV_ID_STR "dsPIC33FJ64GP802"
00700 #endif
00701
00702 #ifdef __dsPIC33FJ64GP804__
00703 #define DEV_ID 0x00061f
00704 #define DEV_ID_STR "dsPIC33FJ64GP804"
00705 #endif
00706
00707 #ifdef __dsPIC33FJ128GP202__
00708 #define DEV_ID 0x000625
00709 #define DEV_ID_STR "dsPIC33FJ128GP202"
00710 #endif
00711
00712
00713 #ifdef __dsPIC33FJ128GP204__
00714 #define DEV_ID 0x000627
00715 #define DEV_ID_STR "dsPIC33FJ128GP204"
00716 #endif
00717
00718 #ifdef __dsPIC33FJ128GP802__
00719 #define DEV_ID 0x00062d
00720 #define DEV_ID_STR "dsPIC33FJ128GP802"
00721 #endif
00722
00723 #ifdef __dsPIC33FJ128GP804__
00724 #define DEV_ID 0x00062f
00725 #define DEV_ID_STR "dsPIC33FJ128GP804"
00726 #endif
00727
00728 #if (defined(__dsPIC33FJ128GP804__) || defined(__dsPIC33FJ128GP802__)\
00729 || defined(__dsPIC33FJ128GP204__) || defined(__dsPIC33FJ128GP202__)\
00730 || defined(__dsPIC33FJ64GP804__) || defined(__dsPIC33FJ64GP802__)\
00731 || defined(__dsPIC33FJ64GP204__) || defined(__dsPIC33FJ64GP202__)\
00732 || defined(__dsPIC33FJ32GP304__) || defined(__dsPIC33FJ32GP302__))
00733 #define EXPECTED_REVISION1 0x003001
00734 #define EXPECTED_REVISION1_STR "A1"
00735 #define EXPECTED_REVISION2 0x003002
00736 #define EXPECTED_REVISION2_STR "A2"
00737 #define EXPECTED_REVISION3 0x003003
00738 #define EXPECTED_REVISION3_STR "A3"
00739 #endif
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749 #ifndef DEV_ID
00750 #define DEV_ID 0
00751 #define DEV_ID_STR "unknown"
00752 #define EXPECTED_REVISION1 0
00753 #define EXPECTED_REVISION1_STR "unknown"
00754 #warning *********************************************
00755 #warning * Unknown chip type! Define a device ID and *
00756 #warning * revision ID in the lines above for this *
00757 #warning * chip to remove this warning message. *
00758 #warning * These values can be found by *
00759 #warning * executing the checkDeviceAndRevision() *
00760 #warning * function, which is typically called after *
00761 #warning * reset via calling printResetCause(). *
00762 #warning * This check allows you to ensure that the *
00763 #warning * programmed hex file is running on the *
00764 #warning * same device type it was compiled for. *
00765 #warning * This is only a warning. *
00766 #warning *********************************************
00767 #endif
00768
00770
00772
00773
00774
00775
00776
00777
00778
00779 #ifdef _ISR
00780 #undef _ISR
00781
00782 #define _ISR __attribute__((interrupt)) __attribute__ ((auto_psv))
00783 #endif
00784
00785 #ifdef _ISRFAST
00786 #undef _ISRFAST
00787
00788 #define _ISRFAST __attribute__((interrupt)) __attribute__ ((no_auto_psv))
00789 #endif
00790
00791
00792 #define SLEEP() Sleep()
00793 #define IDLE() Idle()
00794 #define CLRWDT() ClrWdt()
00795 #define NOP() Nop()
00796 #define ENABLEWDT() _SWDTEN = 1
00797 #define DISABLEWDT() _SWDTEN = 0
00798
00800
00801
00808 #if defined(_U4RXIF)
00809 #define NUM_UART_MODS 4
00810 #elif defined(_U3RXIF)
00811 #define NUM_UART_MODS 3
00812 #elif defined(_U2RXIF)
00813 #define NUM_UART_MODS 2
00814 #elif defined(_U1RXIF) || defined(__DOXYGEN__)
00815 #define NUM_UART_MODS 1
00816 #else
00817 #error UxRXIF flag not defined!
00818 #endif
00819
00823 #if defined(_SI2C2IF)
00824 #define NUM_I2C_MODS 2
00825 #elif defined(_SI2C1IF) || defined(__DOXYGEN__)
00826 #define NUM_I2C_MODS 1
00827 #else
00828 #error SI2CxIF flag not defined!
00829 #endif
00830
00834 #if defined(_SPI2IF)
00835 #define NUM_SPI_MODS 2
00836 #elif defined(_SPI1IF) || defined(__DOXYGEN__)
00837 #define NUM_SPI_MODS 1
00838 #else
00839 #error SPIxIF flag not defined!
00840 #endif
00841
00845 #if defined(_C2IF)
00846 #define NUM_ECAN_MODS 2
00847 #elif defined(_C1IF) || defined(__DOXYGEN__)
00848 #define NUM_ECAN_MODS 1
00849 #endif
00850
00851
00861
00862 #define BITS2WORD(sfrBitfield) ( *((uint16*) &sfrBitfield) )
00864 #define BITS2BYTEL(sfrBitfield) ( ((uint8*) &sfrBitfield)[0] )
00866 #define BITS2BYTEH(sfrBitfield) ( ((uint8*) &sfrBitfield)[1] )
00867
00868
00875 #define REPORT_ERROR(msg) reportError(ERROR_FILE_LINE(msg))
00876
00877 #ifdef SIM
00878 #define HELLO_MSG "****************************************************\n" \
00879 "* SIMULATION MODE - DO NOT RUN ON A REAL PIC! *\n" \
00880 "****************************************************\n" \
00881 "\n" __FILE__ ", built on " __DATE__ " at " __TIME__ "\n"
00882
00883 #warning ***********************************************
00884 #warning * SIMULATION MODE - DO NOT RUN ON A REAL PIC! *
00885 #warning ***********************************************
00886 #else
00887 #define HELLO_MSG "\n" __FILE__ ", built on " __DATE__ " at " __TIME__ "\n"
00888 #endif
00889
00890
00891
00892 void reportError(const char* szErrorMessage);
00893 uint32 readProgramMemory(uint32 u32_address);
00894 void checkDeviceAndRevision(void);
00895 void checkOscOption(void);
00896 void printResetCause(void);
00897 void configPinsForLowPower(void);
00898 void configBasic(const char* psz_helloMsg);
00899 uint32 roundFloatToUint32(float f_x);
00900 uint16 roundFloatToUint16(float f_x);
00901
00904
00905
00906
00907
00908
00909 #ifndef USE_HEARTBEAT
00910
00913 #define USE_HEARTBEAT 1
00914 #endif
00915
00919 #ifndef HB_LED
00920 #define HB_LED _LATB15
00921
00922 #define CONFIG_HB_LED() CONFIG_RB15_AS_DIG_OD_OUTPUT()
00923 #endif // #ifndef HB_LED
00924
00925 extern _PERSISTENT char* sz_lastTimeoutError;
00926
00927 #if USE_HEARTBEAT
00928 extern uint32 u32_heartbeatCount;
00929 #endif
00930
00931 void configHeartbeat(void);
00932 void doHeartbeat(void);
00933 void toggleHeartbeat(void);
00934
00935
00936 #endif