Compare commits
1248 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da192c521f | |||
| 0f5cccca4f | |||
| 3a30d45c2e | |||
| 269ec9f87f | |||
| 3d2b471c1a | |||
| 72912851b8 | |||
| 8d7bfd03d8 | |||
| 3c9e6b7b62 | |||
| 0e760274bd | |||
| b291a422e9 | |||
| 8813978766 | |||
| 7ae548cf34 | |||
| 8f9067faa6 | |||
| addf52fd4a | |||
| e9ddd21aef | |||
| 2d7d43b64c | |||
| 5cfe13f240 | |||
| 9852252bca | |||
| 1c33310363 | |||
| 380c9abf16 | |||
| 501fe97c00 | |||
| c7e2d73039 | |||
| 422a958a34 | |||
| 038fccd7a1 | |||
| 6730335657 | |||
| 1a57644b0c | |||
| 80afded132 | |||
| 028fe129a5 | |||
| d7a2dd676e | |||
| b3f2b30347 | |||
| 4ffecdbf7d | |||
| 2dfdf4b55c | |||
| 358759cb52 | |||
| 93c8b2a40b | |||
| 672f764b4d | |||
| 5a5b95edbf | |||
| f25e793cff | |||
| df17a6a1b4 | |||
| f7e65935fb | |||
| 4e02aff9b5 | |||
| 81363bc441 | |||
| 95f4a55820 | |||
| 21205cc3d8 | |||
| fb0996b5db | |||
| 538231edfd | |||
| 067b509479 | |||
| a19f2f8ae7 | |||
| f24dda9700 | |||
| ec4681ab6b | |||
| dd7e4ee97f | |||
| 2b9722f387 | |||
| 00e4bc9f54 | |||
| 9472bbe51d | |||
| d2b6e62996 | |||
| 30248214c7 | |||
| c5f138ea07 | |||
| efca4afab2 | |||
| 3d9f4ac757 | |||
| 9d57c376db | |||
| 04fb34c7ff | |||
| f8aa5ff771 | |||
| 07b85f8b92 | |||
| be81dfa3de | |||
| b5c6f11e41 | |||
| 206b7f4e92 | |||
| 9d9a2d75ef | |||
| 21cc188272 | |||
| 86cc22d639 | |||
| 3f9707aa33 | |||
| f36fd3ddec | |||
| 912ed155c5 | |||
| b5e50cdd4e | |||
| eed451e034 | |||
| f3209bba34 | |||
| 1f520a5a8c | |||
| b32be2dc64 | |||
| edac64e7d2 | |||
| ecda6cdc0a | |||
| f3e503e725 | |||
| 1d5d853c9a | |||
| 63da6900b0 | |||
| a18b625534 | |||
| 975810fb4a | |||
| ae12ad0d6c | |||
| 80b17ab573 | |||
| 625860f086 | |||
| 6583bb781d | |||
| 2701dd8a17 | |||
| 217186d7bc | |||
| 6b82415c81 | |||
| 692a01b1c7 | |||
| 878b5557a1 | |||
| 2ec2bf1564 | |||
| 6c591a97a1 | |||
| e7db8ee9e5 | |||
| 10e1b6ef8b | |||
| d1f21d1189 | |||
| 449dad71f2 | |||
| a2109cb492 | |||
| 3d1da45f3e | |||
| d02daec08f | |||
| 0268c03a75 | |||
| 991a74b75b | |||
| 2bf6d804c4 | |||
| 9453bb13c2 | |||
| 67fd8f0727 | |||
| 2309c9f43a | |||
| 236db44669 | |||
| e6774fb7d2 | |||
| f4ce235589 | |||
| cb047e9070 | |||
| 5b336a4cdb | |||
| 10ad9f1062 | |||
| f24c5d82e3 | |||
| 053b541de8 | |||
| 8a6f098cc6 | |||
| 78167ce439 | |||
| d1995aec7a | |||
| 4122de9d17 | |||
| d60efc3b5d | |||
| cb12161191 | |||
| c1df713e4d | |||
| ec33df0554 | |||
| a5ed3e96f2 | |||
| 60959f196f | |||
| 95429a4108 | |||
| a0959366af | |||
| b2000b7055 | |||
| 0468f81950 | |||
| 6e42c9e305 | |||
| 0504c02153 | |||
| 3afe66bb0c | |||
| 73b7b08f2c | |||
| 9eb6df17a7 | |||
| c9f60183a9 | |||
| 0d957872a0 | |||
| 9c07d28bd6 | |||
| 23e768dffa | |||
| f7ffd53bac | |||
| 2f467e2797 | |||
| 050ca9ca13 | |||
| cf52c48d19 | |||
| 984177c40c | |||
| c9b8435749 | |||
| f00a202246 | |||
| 6efc4f3abf | |||
| 45336bb6c0 | |||
| 5f555140be | |||
| 7ecb7cbd46 | |||
| 7667949aca | |||
| 529c937943 | |||
| 7250ec4337 | |||
| f05225a271 | |||
| d080027ff4 | |||
| bdf2c94bff | |||
| e83ecec809 | |||
| f80a602783 | |||
| f390b3f314 | |||
| d254651146 | |||
| 7db943b147 | |||
| fe8d8beb7a | |||
| 5f36ed2c4c | |||
| af7fbcc026 | |||
| 203df3533d | |||
| b792b74036 | |||
| dc64175d77 | |||
| a8d8ef7534 | |||
| d74aabf259 | |||
| 60628864ca | |||
| 889d7ba218 | |||
| 5e7bd2dc87 | |||
| 1e865e5df7 | |||
| b086394178 | |||
| 39d28a9bbf | |||
| 6325968a39 | |||
| e99f24ff2f | |||
| ac204028e7 | |||
| 4315c2547a | |||
| f21c65918f | |||
| 58c4473bea | |||
| 825c46024d | |||
| cfe80e1def | |||
| 7464d3c96a | |||
| 81568c3c6d | |||
| 4ebeb14026 | |||
| 03e489aaad | |||
| acc0e75279 | |||
| a5c059dcf5 | |||
| 17de96ace7 | |||
| 7458bfe297 | |||
| 6880e93b75 | |||
| 61d8e40712 | |||
| 3b1f186c0c | |||
| f83d0f2a68 | |||
| bd25e7393b | |||
| d201fe74c6 | |||
| 0e23105e1e | |||
| 72da53c613 | |||
| 174f8d3631 | |||
| e970461adb | |||
| 0c06e97e98 | |||
| a9c334e8bc | |||
| 842da54e68 | |||
| 07c6b5ab71 | |||
| 1857e611d3 | |||
| 63e1665fa9 | |||
| e69313fc2b | |||
| bd22405412 | |||
| 49791949af | |||
| 140ce06692 | |||
| 28c3ad291a | |||
| 0450e83fa5 | |||
| f21cce0b28 | |||
| 39b47ef5b0 | |||
| e4b98011cf | |||
| 60598b4cdd | |||
| f074706d2e | |||
| b726511a3b | |||
| 4d61287807 | |||
| b17b8583af | |||
| 280504e2e0 | |||
| 341c7d080d | |||
| 31ca3de72f | |||
| e83cfc0a62 | |||
| 3ac8bd8de7 | |||
| 0b310ab6c5 | |||
| 91d740e128 | |||
| 00f279376f | |||
| ab355a90d3 | |||
| 4297bcc89f | |||
| d088b5f30f | |||
| 1fad8e6a81 | |||
| 467f0ea6b7 | |||
| 29e854c535 | |||
| 6599adc184 | |||
| a12eec33e2 | |||
| c9486ebb85 | |||
| b6ffea612a | |||
| 8196b36ad9 | |||
| cf749dbeda | |||
| ae081d0fe0 | |||
| 785143a013 | |||
| 0cbbba08bd | |||
| af0549bfd2 | |||
| ae1a698263 | |||
| 600b4f0590 | |||
| 3ebfd29312 | |||
| 2ef0669b19 | |||
| 485ca10bc3 | |||
| 599530902d | |||
| 1ba7c31395 | |||
| 64139f5e5a | |||
| 2f9ed1777d | |||
| edfcf3b527 | |||
| c429a4b3ec | |||
| e5a334b83a | |||
| f05928d886 | |||
| b4e287fe8e | |||
| de725bd408 | |||
| 061c1fcd93 | |||
| 181e487f13 | |||
| ff38d7c293 | |||
| 1977b4490f | |||
| 7562183efc | |||
| 5a8b3a84ae | |||
| 1b7c065055 | |||
| 433ac29d31 | |||
| 2427d0b683 | |||
| 8ebefe6d35 | |||
| 725ba8d01e | |||
| 2b54eeb897 | |||
| 14187dae6c | |||
| 662fe8288b | |||
| aad336eb81 | |||
| 5874852501 | |||
| 12b51d6060 | |||
| d12b24758a | |||
| 3f54c9ba33 | |||
| 92e21d3ee2 | |||
| 5714f64927 | |||
| d407a43ac1 | |||
| eaa788e076 | |||
| 6901445592 | |||
| 0d35b1d0b8 | |||
| 87fc00c182 | |||
| 7681711e7e | |||
| aa4160ba62 | |||
| cd769781a1 | |||
| f40cff59f3 | |||
| 90eb266139 | |||
| d078c7c29f | |||
| 3dc9e478ad | |||
| 0d97dec434 | |||
| 1651ccc0cc | |||
| 3b1ab84536 | |||
| d84934d8c5 | |||
| 4ffdbcbd4e | |||
| 5c8107bcdd | |||
| df7c80335a | |||
| b014fd1ad2 | |||
| 443b648863 | |||
| 377dfb182f | |||
| b81021f475 | |||
| 724197454c | |||
| 058e446531 | |||
| 110c5dcf23 | |||
| 256c25a843 | |||
| ca30aee903 | |||
| 0733825fb1 | |||
| af3e4d7510 | |||
| aaaf8fe8dd | |||
| b360306881 | |||
| ce85515428 | |||
| 764921bdbf | |||
| c40c7b589b | |||
| 0f2e0525df | |||
| 5ae02a361b | |||
| 83037542aa | |||
| fb34265d75 | |||
| 6e343ef2f0 | |||
| 2f6c57eadc | |||
| f989bd5435 | |||
| 6c5a460e65 | |||
| d1e4237e1d | |||
| a664763e6f | |||
| b5dc228a7a | |||
| 3cbb2f56c6 | |||
| c35736a140 | |||
| cb4a6dd2dc | |||
| 5b66810580 | |||
| 01e9b536cb | |||
| 58eabd21fb | |||
| 88d12a762a | |||
| bf0ecedf60 | |||
| 9bc7aec349 | |||
| 40ba644bb4 | |||
| 3b8216bdd1 | |||
| 37799f70ba | |||
| 1632e5e38a | |||
| fe3a09bbcf | |||
| 1d62309d2a | |||
| 1e9dc85148 | |||
| cf325ba240 | |||
| 018b68a5c4 | |||
| dde61d8886 | |||
| 0fbfb1bf82 | |||
| 8340ca6e05 | |||
| 9887555192 | |||
| 105571ec68 | |||
| 68dd5e635e | |||
| 25069ed4e9 | |||
| 8b52eff2c1 | |||
| 75b3a68b65 | |||
| e3c88a5120 | |||
| 62db9848d3 | |||
| 5908fd5cec | |||
| 0adbc79571 | |||
| 0091865583 | |||
| 85649a4549 | |||
| 1d0fe035f3 | |||
| e7707aedbc | |||
| 0a8dc0e96b | |||
| d2fcb3ee56 | |||
| 3cd7dbcc45 | |||
| c13a831ea1 | |||
| 2d22902d08 | |||
| ad3b770c1a | |||
| 2f4a20257c | |||
| 1bd0dd04e3 | |||
| aacff0d361 | |||
| 8bf3139bc8 | |||
| 50b4e86f75 | |||
| 2096188ac3 | |||
| f9f54019ab | |||
| c51a6f94e0 | |||
| 89abf07faa | |||
| 17aa67e4ea | |||
| c7273d521f | |||
| 1fd9a7d476 | |||
| 3f2c771d90 | |||
| bcd039aa81 | |||
| 82606354dd | |||
| 253cf0f427 | |||
| 32a6451ad8 | |||
| b5417be109 | |||
| f244045245 | |||
| ce517df702 | |||
| 2242a84218 | |||
| 6e3406d228 | |||
| 43c298a7a9 | |||
| 4c823224b0 | |||
| d86c3cf43c | |||
| f0cab611db | |||
| 269a068032 | |||
| fae7d08698 | |||
| 512f2a3136 | |||
| cd3220d055 | |||
| 86b4b805d2 | |||
| 1875ab3bd7 | |||
| 6e6e4e2143 | |||
| 9d11b70436 | |||
| ea9bffdc48 | |||
| 0de826160e | |||
| 3c927901a4 | |||
| c8d0ca9337 | |||
| 8a32c5395b | |||
| 29e7639933 | |||
| 5a18324030 | |||
| 07c0eeee99 | |||
| b7aac49995 | |||
| 09b84faa00 | |||
| efb6d61413 | |||
| 38192cb5f3 | |||
| aed5ec008a | |||
| cfb98ef682 | |||
| 88b494678f | |||
| 92e14298b0 | |||
| 9db9842aea | |||
| e541323741 | |||
| 1c9a70cee9 | |||
| 2acd3792fc | |||
| 8b4c4aa5c3 | |||
| ce76843dc3 | |||
| ad5c8cbba9 | |||
| 6460709d92 | |||
| 105bebb466 | |||
| 97ead2eccb | |||
| d85411f13a | |||
| 7c7f2d094e | |||
| e2d703377a | |||
| 2715f6ddbf | |||
| 39e9b133f3 | |||
| da6b536182 | |||
| 3a8e36f19e | |||
| eea3ba5588 | |||
| 1cbcbb0971 | |||
| 2fa514e88a | |||
| b9126ab497 | |||
| a33f099547 | |||
| 21ec6b88c3 | |||
| e4dc80d3d3 | |||
| 6adbdf42e0 | |||
| 5107018414 | |||
| 27d544ac25 | |||
| 013793bbe9 | |||
| a23a5395f9 | |||
| e5b70237c7 | |||
| ed6f4a71c5 | |||
| 3161740df9 | |||
| 086ff1644f | |||
| 3ffc9651b1 | |||
| 357b87b498 | |||
| 95ad6ec9a1 | |||
| 2fa51f8920 | |||
| 27a7cf9fcf | |||
| d3f305332a | |||
| b0aeac117f | |||
| 73b380d8d2 | |||
| fe4930212c | |||
| dca9790f42 | |||
| c23376f2e7 | |||
| dfb98101e4 | |||
| f1501317ca | |||
| 9a5d23d96f | |||
| 303ee67896 | |||
| 8759508319 | |||
| a65564eef6 | |||
| aeaf9b9312 | |||
| 89f78b0b80 | |||
| b0093a1513 | |||
| a3530d1141 | |||
| 990e770e15 | |||
| f643f4d674 | |||
| bbe8fbe13d | |||
| 51c6bd6b72 | |||
| c8cdd1fc6f | |||
| 7395dafc1e | |||
| fad2a60ce6 | |||
| eecda434fb | |||
| 944ced87c5 | |||
| 06709ad60e | |||
| 084134d3c7 | |||
| 3906f27c46 | |||
| 8613a74443 | |||
| a38c90ee84 | |||
| a00cec8b71 | |||
| 1f895844ac | |||
| af8be9013b | |||
| 0ddee3c7db | |||
| 272072fa20 | |||
| aab61e63c3 | |||
| 6cd85e6008 | |||
| 09af1b90b8 | |||
| 765b2da3d4 | |||
| 881e348eed | |||
| 5a332df47e | |||
| 040357fd1b | |||
| 15d1b8d719 | |||
| 7325d7102e | |||
| 7f76a0e064 | |||
| 4f3eb6bec8 | |||
| fcd8524b6e | |||
| 8c98690e1d | |||
| 8ea5665ee2 | |||
| 8c4377dd63 | |||
| 661e378ce9 | |||
| fde8c2c310 | |||
| 1aa10a5f18 | |||
| fdce91192e | |||
| d819c55395 | |||
| fd4542f33a | |||
| e8291ed728 | |||
| 465b654d24 | |||
| 88506a80c3 | |||
| b514d3c87f | |||
| 77df0d689a | |||
| cc5f1d475c | |||
| 91759dede6 | |||
| 557217fc05 | |||
| aee63afccd | |||
| d3fcc28e64 | |||
| 99f6326544 | |||
| ea669cb504 | |||
| b46a1b6360 | |||
| 3cc7626d1f | |||
| 174b8d99d5 | |||
| 3b718b816c | |||
| 34fd59c370 | |||
| 541155ea87 | |||
| 9fa328e5c8 | |||
| 73f0ee9345 | |||
| f308a8af91 | |||
| 357e31270a | |||
| d2d7d186b5 | |||
| 2ccdf4f36d | |||
| c00383f286 | |||
| 60f72a78a9 | |||
| abba7a0003 | |||
| b868d668fa | |||
| 8212d8d543 | |||
| 46bae30573 | |||
| 51ae4881ab | |||
| 498d76fd79 | |||
| af9395ac2e | |||
| fd42f0d226 | |||
| 96217bf36a | |||
| cf5c3b6610 | |||
| d1c64b9dc4 | |||
| 5d50819791 | |||
| 3f455889d0 | |||
| 4ddedb3b27 | |||
| d4ba23bc28 | |||
| bbb424bd2f | |||
| 8f0cee2a14 | |||
| 08263ae66e | |||
| 3b193d1b5f | |||
| 5bd09d26e2 | |||
| b45beeffd6 | |||
| 306588925d | |||
| c43838bb1e | |||
| 99f0e44864 | |||
| 66e3869138 | |||
| 2f2459c0db | |||
| 8c5675c290 | |||
| a466c8ef68 | |||
| 0f7393a13e | |||
| c4fbb44d6d | |||
| ad2c6488c7 | |||
| c9c83a4560 | |||
| ab0d3c4fb3 | |||
| 477b6fa1df | |||
| 831fc2a952 | |||
| 7dcd350941 | |||
| c31bb2b7ad | |||
| 46f5bea19f | |||
| d16a770855 | |||
| 71bb3a8133 | |||
| 9b7d87e885 | |||
| 816f0a678a | |||
| 6e43398509 | |||
| d6c5c503d4 | |||
| 15d6116188 | |||
| 0b9ecf3824 | |||
| b5ba5c1465 | |||
| 78e7654601 | |||
| 3f6d44d40b | |||
| 363dc2f0e8 | |||
| 5f797ca29f | |||
| 1a6d21bb60 | |||
| 0778f5f028 | |||
| 54bab3e0d0 | |||
| b18b40feff | |||
| bdd0211aeb | |||
| c8e5a82d49 | |||
| f64592e362 | |||
| ac74f45dc0 | |||
| 8ebcc9dc3a | |||
| 19530c9945 | |||
| 6f76066ab3 | |||
| 8b67f6f3e8 | |||
| 36086d3ca4 | |||
| 1781031f2d | |||
| d485988bec | |||
| 8a1fd25363 | |||
| 5097c57d3a | |||
| b819fc53ca | |||
| e1ae7952eb | |||
| 1cc9212c05 | |||
| a5f53f0cf3 | |||
| c2b3e88787 | |||
| 8d162e5bd7 | |||
| 430dcb65a7 | |||
| 3ec0d110bd | |||
| f303129fb6 | |||
| b2c11ba980 | |||
| a864d9d4ab | |||
| 28aca76c4d | |||
| 61059385a3 | |||
| 856edfcc0d | |||
| 0d81ae77bc | |||
| 84df13f7d1 | |||
| 4c7e9502ad | |||
| 652a0f6b5a | |||
| 96a0cdc541 | |||
| d24df7af2c | |||
| f0b8d5ba3d | |||
| 50f44d9249 | |||
| f5b5dd8038 | |||
| 76cf07c3f7 | |||
| 476c7193d8 | |||
| adbf226de1 | |||
| 5bf73b86ff | |||
| 9b2576e5de | |||
| f08bb8bb6a | |||
| b1f8f492c6 | |||
| 8a5eaa3c9b | |||
| 61a7256d42 | |||
| c724c762a2 | |||
| fdac8f6cec | |||
| 05932e4458 | |||
| 7216583b8b | |||
| e8e0697e48 | |||
| 75f39fadfc | |||
| df194f75e1 | |||
| 380144c20f | |||
| 89a304fd98 | |||
| 6ae7f7870d | |||
| 17d6d965dc | |||
| 8f195844dd | |||
| ce8b9c4fc5 | |||
| 000b710c5f | |||
| 8e48e24c7f | |||
| 46d2443c7d | |||
| eed053dffb | |||
| 3e568efe67 | |||
| 8349fc89a4 | |||
| da2a6f9a31 | |||
| 532289e851 | |||
| d29615dc0c | |||
| 5bde7fcb28 | |||
| 20faff5935 | |||
| e5d3044801 | |||
| b7eadb9f37 | |||
| e016a720f4 | |||
| e8786bf110 | |||
| cc2925b705 | |||
| b64661070e | |||
| 5c44f6c434 | |||
| b33375d438 | |||
| 35905ea4f9 | |||
| ad588e8990 | |||
| a94e588765 | |||
| 69af392554 | |||
| 48a185d004 | |||
| 24d1f480b6 | |||
| 95b41413e6 | |||
| 59b96e323e | |||
| 2433ee6fc8 | |||
| 3455a2bac2 | |||
| ec1cf6e7f8 | |||
| dc887ef99b | |||
| c244eb860c | |||
| 7b556d2e96 | |||
| a5e8575829 | |||
| cab84e0e5b | |||
| 5b3f60ea2e | |||
| 62d0b79023 | |||
| c184f808f7 | |||
| c886f5cb13 | |||
| b5a964fcc5 | |||
| 4382068f92 | |||
| f941203172 | |||
| 47854ff5ce | |||
| c79e3967b3 | |||
| 5b8b939a1f | |||
| d69822ed51 | |||
| 2fb2a0a119 | |||
| 39d88bcccb | |||
| ab965376ff | |||
| b2cc27e5ea | |||
| 8a08cca0f2 | |||
| 667d278f54 | |||
| bf27e79e74 | |||
| 87e28c0599 | |||
| 24c6b2ab35 | |||
| 6a803ba9c5 | |||
| 457d8a0acb | |||
| 6f85a8c7aa | |||
| dd3086d3f2 | |||
| 7fad13a1e2 | |||
| 73c82e7ad8 | |||
| b832f5b9f6 | |||
| c38b0855c8 | |||
| d147a057ac | |||
| bca353cc12 | |||
| 253dfc4bc1 | |||
| 1bda6bf862 | |||
| c80aac1518 | |||
| 314fd13c39 | |||
| 4f7c6dfe35 | |||
| 57173739a1 | |||
| 0dca49a7c0 | |||
| d8c2c810b4 | |||
| 9bc88f8bab | |||
| 3ca1ca6869 | |||
| 97b0da0c2e | |||
| 61db046b32 | |||
| 77df2ab0e7 | |||
| ed1ab42186 | |||
| f4a59e4ce5 | |||
| 7ee275b620 | |||
| 6a1e980c6d | |||
| 20076a8bd3 | |||
| 3626b5ad8b | |||
| bf7007d02f | |||
| f17506c504 | |||
| 59e36f1d27 | |||
| acd8619809 | |||
| 7c35be7fd8 | |||
| 595580556c | |||
| 88dfeefca3 | |||
| 5350faf2a2 | |||
| 7016cc9511 | |||
| d78db12abd | |||
| 3b315b3da0 | |||
| f26f26b7bd | |||
| a447e76fdf | |||
| f8d173bd0b | |||
| 9aa2229077 | |||
| aa6c58ad37 | |||
| 221286c10a | |||
| 9547fb9dfb | |||
| 62aab66299 | |||
| d7b1a8ba33 | |||
| 53614e5144 | |||
| b42d24e31e | |||
| 07f029c2d5 | |||
| b0c8120fcc | |||
| a54fe2d73c | |||
| 7ea63d08df | |||
| 4187b637a5 | |||
| 07e7de3600 | |||
| c0c4c97db6 | |||
| 2ca983568d | |||
| 3700f688f5 | |||
| a504c88346 | |||
| c6cb93d38c | |||
| 394ed08f88 | |||
| 9bf1cf1b22 | |||
| 4623e78ce0 | |||
| d7f384f680 | |||
| abc8320a68 | |||
| f4c3135c6d | |||
| aae42c68f9 | |||
| 4d435c38a6 | |||
| 6c42a3a339 | |||
| 376d8af2c8 | |||
| 434b6a05c1 | |||
| bdc2621119 | |||
| 6965bd4e15 | |||
| a55b33e613 | |||
| 8b34351537 | |||
| 735e556724 | |||
| d80aecda0a | |||
| be2dea1dc6 | |||
| 55c287a69e | |||
| 1902d339b0 | |||
| eb23a68e92 | |||
| 7ced55b97c | |||
| e019197b32 | |||
| 1561c6df51 | |||
| 374bc99fa3 | |||
| ab624eac2a | |||
| 52f79ffeca | |||
| b9d7ccf1cd | |||
| c323fced9a | |||
| d4d1540727 | |||
| 01ed99143c | |||
| e578f988d3 | |||
| 76841450c8 | |||
| 44f327d738 | |||
| 326d2db025 | |||
| 2cb716f513 | |||
| 34da3a0a3f | |||
| 18199ff960 | |||
| a105e10075 | |||
| fb5334f428 | |||
| c5bf8298d3 | |||
| c3568398b5 | |||
| 96a773fa48 | |||
| 39cd3dbdbe | |||
| fb20ceabce | |||
| d01ee7e7b5 | |||
| d7390e13d9 | |||
| f3aa2a48e7 | |||
| 460751503e | |||
| 5ab872de1f | |||
| 9da94c247a | |||
| 59004023fd | |||
| 461dad6e05 | |||
| c4a2077951 | |||
| 8a2a3ef91d | |||
| 6397b3339c | |||
| cdaaad3df1 | |||
| e3bdefd873 | |||
| a5be0c52c6 | |||
| e73611f5fa | |||
| e509cdbeb0 | |||
| 99b7e926e7 | |||
| 68be33b1fc | |||
| acb3271c9a | |||
| 61fe430d4f | |||
| d77f5ee722 | |||
| fde17d5720 | |||
| aa65c20d1f | |||
| ecf3ab5de4 | |||
| 2daa85918e | |||
| 2015989f84 | |||
| 1c86adc760 | |||
| 648d45cfb2 | |||
| 171719f18c | |||
| b519af4f05 | |||
| 7d03c52511 | |||
| 312b4aa7c2 | |||
| 02dee80fa5 | |||
| 73569d891f | |||
| 47dc70e3ec | |||
| 1d258903bb | |||
| e34c9981ab | |||
| 26a441fc7d | |||
| ac975ed8c2 | |||
| 58d12aad73 | |||
| caa848f943 | |||
| 7ad12be763 | |||
| 408169aef4 | |||
| bd96d22bfb | |||
| 73f21cd5d6 | |||
| 6f4a6e531c | |||
| 01edf22a10 | |||
| ff6fa09ecf | |||
| c8dcc7c208 | |||
| 8b0d82e9db | |||
| 1e05d192ab | |||
| 373f3ecab3 | |||
| e36d31a3b7 | |||
| f295712008 | |||
| 5c70c785f5 | |||
| 69b02031ca | |||
| 2ca6c5fbd7 | |||
| 6a81291c57 | |||
| 15b1b896e8 | |||
| c1cb5977ee | |||
| 8a5bd8a808 | |||
| 3dea417c25 | |||
| c1d7cf939e | |||
| 4c7d1436e9 | |||
| 6588933c04 | |||
| 5dabc95409 | |||
| a733537ddd | |||
| f4f30c9d64 | |||
| 79374f0b93 | |||
| 1520de0093 | |||
| da05b3ba94 | |||
| 4b19c8552e | |||
| 971ec35135 | |||
| 4de419e26e | |||
| a0729f0c3a | |||
| 5090c56651 | |||
| 16b9239a26 | |||
| a964b3cf3d | |||
| 34fb4831a2 | |||
| e8572c5239 | |||
| 7ee70c2248 | |||
| b78fa6bb70 | |||
| 9be61cdc02 | |||
| 7231a20dba | |||
| 7296de34cb | |||
| e2ff536b03 | |||
| df776f36a4 | |||
| 40eb07bad4 | |||
| 440cf2bc10 | |||
| bd33cf4a9f | |||
| 567291e734 | |||
| 68f9f2521e | |||
| 8d80cbbf4c | |||
| 273502a172 | |||
| 98d0d48191 | |||
| bbe67fca5a | |||
| 9eeb711c96 | |||
| 424101110c | |||
| b2eeebd9c3 | |||
| 0d4a9444c4 | |||
| 86cce025f4 | |||
| 1a18a487f9 | |||
| 03141a5ef4 | |||
| 28ada096e2 | |||
| 4121311b9d | |||
| dfa549f268 | |||
| 64360164ad | |||
| 86405cdd11 | |||
| 6c45c3f4e7 | |||
| 96624f0f31 | |||
| dc59f07d24 | |||
| b668cb0516 | |||
| 95dff34b73 | |||
| 4cc6f9f6de | |||
| 61a48cc662 | |||
| 9cc15876be | |||
| c9cf2174dd | |||
| bd2cd4903e | |||
| 37f3199df3 | |||
| fbd899a37d | |||
| 29bb8d7d4f | |||
| 015d0594b0 | |||
| 90664d20a4 | |||
| 2739c26c4f | |||
| 6fb9573157 | |||
| 594193c908 | |||
| 1fa61c297e | |||
| b27a59f41e | |||
| 2c0fa34c9e | |||
| a65a26d6b4 | |||
| db2f157a22 | |||
| a5cd582665 | |||
| e3bc420daa | |||
| fc4ab05157 | |||
| 0ef54f2f85 | |||
| a200521eab | |||
| 727aa2a051 | |||
| 1a397825f9 | |||
| 289c02eda4 | |||
| d5ad7a0814 | |||
| c3cdaceab3 | |||
| 1c127217df | |||
| 7f57f28ccc | |||
| 788d62bcc4 | |||
| 4f96ad5621 | |||
| d71f1e9bf6 | |||
| db5bb8546d | |||
| 4b2ece159b | |||
| d5ee2a5a62 | |||
| 7ac6d7f78e | |||
| 13596e8722 | |||
| 3a6abe1d6e | |||
| 16afbf9bfa | |||
| c83863d5d6 | |||
| 34bca48b98 | |||
| ac52dcc174 | |||
| 84920e9c58 | |||
| 31bb3fb297 | |||
| c80a78bb70 | |||
| 5d5909fc25 | |||
| 93f0463b21 | |||
| 1f74ef4157 | |||
| 4fa2260a59 | |||
| 038d405254 | |||
| 2438b34df9 | |||
| 443aaa30bf | |||
| 7f622467fc | |||
| 86867928ac | |||
| 9a38cad6f0 | |||
| 7a5c474d91 | |||
| 4e448b700a | |||
| fa58be3cb8 | |||
| 9f2862ce48 | |||
| 9fb8bd5685 | |||
| aa816ee81c | |||
| 0d075378d5 | |||
| 9a1c90471f | |||
| 1a0f889803 | |||
| 9322c408c6 | |||
| fd5b7e0cec | |||
| e5a853a3d0 | |||
| 72419f69a9 | |||
| 91bea43332 | |||
| d2b00fe486 | |||
| 6c66cae694 | |||
| f3e0e5184d | |||
| 5d3862f9d1 | |||
| 0b320f75e9 | |||
| 5f1cd70122 | |||
| a49c09a776 | |||
| 26d8863111 | |||
| 4a141a694f | |||
| 83c790a020 | |||
| c28e71a1bf | |||
| ee8feb9dee | |||
| c8e2f44087 | |||
| 7417423691 | |||
| 590225be25 | |||
| a0e41c0970 | |||
| 233df9cca0 | |||
| bb0de75a92 | |||
| 7c47e7162d | |||
| af78d0cbfa | |||
| 9a78f321a4 | |||
| 5de25ccd20 | |||
| d6ce63c49c | |||
| f036be7c4e | |||
| 07e11c7cf5 | |||
| 92782f9252 | |||
| 6a61a3c0b4 | |||
| f0aee4101a | |||
| aba67e2449 | |||
| 6504e96165 | |||
| 86bf911139 | |||
| 7bad72359c | |||
| 1daf2f3256 | |||
| f1263d3f88 | |||
| 140e095c6e | |||
| b2c1c64fb1 | |||
| ceb5ee38af | |||
| 8efd4cfd73 | |||
| b3ebb71704 | |||
| 372e12f83f | |||
| 6beb42cdf6 | |||
| f991bf23b2 | |||
| 5bfba7720e | |||
| a069d30a4b | |||
| 839bef6d5d | |||
| 1292d735ba | |||
| 4eb81a69e6 | |||
| 3e9cd334a4 | |||
| 67710df9f3 | |||
| b6209c86dd | |||
| 2b567d1df5 | |||
| 06272f463d | |||
| 83e33bdd26 | |||
| de3dec7215 | |||
| 73d41c10b9 | |||
| 63da4dc59a | |||
| 7eb9811958 | |||
| 82e28851bd | |||
| aed5965ad8 | |||
| d360846dd4 | |||
| 2f60e324dc | |||
| 5e2abfcdcd | |||
| fa5c45f515 | |||
| a0d4e8e78e | |||
| bbf0cc1379 | |||
| c8f1fbd9d8 | |||
| be91fb9b47 | |||
| 71ddb8dc60 | |||
| d2c547c407 | |||
| 70871715e4 | |||
| 49b2ddc8c1 | |||
| f8876a7958 | |||
| 18fcc367d2 | |||
| 6b78edf7c5 | |||
| 19ce90fe02 | |||
| 00fed0a703 | |||
| e06d820909 | |||
| 01541ee64c | |||
| f24f02e212 | |||
| 12c41423ad | |||
| 0995eaa492 | |||
| 1d06b10962 | |||
| 408b349a84 | |||
| 236bb2c110 | |||
| 9ecb267b63 | |||
| 3cf59f6f9a | |||
| c1730e2b08 | |||
| 86358dd6cd | |||
| 0f3f5d083d | |||
| 6ec56fa923 | |||
| 965baf2683 | |||
| 4fde836d83 | |||
| 3d91bd486c | |||
| 3f2f94ef28 | |||
| 7f30039d2a | |||
| 14e1d495ef | |||
| bbe7d3d0fe | |||
| 7ce509b9a7 | |||
| 9c34c4f05b | |||
| 442ade15a6 | |||
| 5fd4582cc8 | |||
| 8b88e3b386 | |||
| 27843388c6 | |||
| bfa5bb86e4 | |||
| 921273baa0 | |||
| 7d20ec706e | |||
| 437eb3bafc | |||
| f3c1fc70a9 | |||
| dad7691df9 | |||
| 6752cb2d9c | |||
| 0ac452e252 | |||
| 3a1cd30ce1 | |||
| 69582042d7 | |||
| 9e7b5056a0 | |||
| 5f82f03ff3 | |||
| 5e3873c8db | |||
| 01aac2a142 | |||
| b69cb9fbd9 | |||
| 30254e3388 | |||
| 38ee395ac7 | |||
| 5df5e4c4a2 | |||
| a95dcd74e7 | |||
| ab318beaaf | |||
| 8caf5d252d | |||
| 1c2ecddae4 | |||
| 6dfb8a2187 | |||
| 3b2e5027e5 | |||
| b39f5d614a | |||
| ab09fa4bbf | |||
| 83ea7dc5b9 | |||
| 5697451c72 | |||
| 58e806f3fa | |||
| 50a5ce1dc4 | |||
| 6123a00e64 | |||
| 7c21716886 | |||
| ae1bc83350 | |||
| 596a7e1904 | |||
| b264317fa0 | |||
| 673577a31b | |||
| 23022f1a82 | |||
| 96e9db8919 | |||
| 08356361ac | |||
| 047d037f8c | |||
| 0908458381 | |||
| 16fbb455ef | |||
| f30b46b2a8 | |||
| 65c3f1ffcd | |||
| 7577717b59 | |||
| 1a8f54cea1 | |||
| 6731c094ee | |||
| b99a928a80 | |||
| 55ba90ac19 | |||
| 5ff5cee8ce | |||
| 8b58edc70e | |||
| d0319d45af | |||
| ca409e5531 | |||
| 1f45cb0a51 | |||
| 931a0052ea | |||
| 46ec4b648c | |||
| 724f5aa36b | |||
| 6d9dfa96c3 | |||
| 3fb07d9b8d | |||
| 8e2519e88b | |||
| cec7283b21 | |||
| 2292441f0c | |||
| c430906d3b | |||
| 82c8724b33 | |||
| 9b160972a1 | |||
| e036750bdf | |||
| fcd9de72ef | |||
| 32d4373e0f | |||
| b3ddbcee2a | |||
| 29435dfb4b | |||
| 52158dffcc | |||
| ca7acbe6d9 | |||
| 33247733e0 | |||
| 621c24a10f | |||
| 6cba11f087 | |||
| 4d351b4846 | |||
| a30007caa4 | |||
| 6aa87a7b67 | |||
| b1c38d4c82 | |||
| 42e21bb06e | |||
| ce4b5bbeaa | |||
| f413aa33b3 | |||
| 587154c01b | |||
| 1f27870d41 | |||
| c5d4225804 | |||
| 529748894c | |||
| 4e26ecc940 | |||
| c421774422 | |||
| 16078e47d4 | |||
| 6a9bee27cc | |||
| 94ea26ff46 | |||
| 6c51fe5039 | |||
| 34b2de4cd8 | |||
| 57429cb9fe | |||
| 97fa2a9c30 | |||
| c94ca24adc | |||
| 99e9554edd | |||
| dbbf050005 | |||
| f934d0ef5b | |||
| e48dfcc2b3 | |||
| b98fb17fe9 | |||
| bce67ec2c9 | |||
| 9b1d2483a0 | |||
| b1adc567da | |||
| 0807d82af0 | |||
| 5cd7a90b32 | |||
| bb119739b0 | |||
| df8dd5ac21 | |||
| b7c8e5bbcf | |||
| 2b7b1e52b1 | |||
| 2f771b3979 | |||
| 9bebe9b631 | |||
| a2032afa3a | |||
| 6a55ca8370 | |||
| 8f20562f49 | |||
| 43018a48c4 | |||
| 72586eb30a | |||
| 7a02ba361c | |||
| f4a89ec776 | |||
| 57834776ad | |||
| caa2b25b40 | |||
| a27fef8750 | |||
| 789be03b4f | |||
| 40ce057a3e | |||
| 625ac81acc | |||
| ffc69537aa | |||
| 71efcfc648 | |||
| 04be9d6001 | |||
| c17da4b707 | |||
| ccd9fd0dc3 | |||
| 46b9988e26 | |||
| 0f73afb0b0 | |||
| 36b452c7ac | |||
| a394ac9f95 | |||
| 332344bd43 | |||
| e6c1cadea0 | |||
| faea7d72b8 | |||
| 08337e01f7 | |||
| 9606f4d04f | |||
| 3cbaad9288 | |||
| 99692dc99e | |||
| ca811156a0 | |||
| be1e099f1b | |||
| c8ea9b0e58 | |||
| ca7ca4572e | |||
| 8016f058bc | |||
| e5c39b7c2a | |||
| bf2071871c | |||
| fc32e20881 | |||
| 1c1fddc7ac |
@@ -3,3 +3,6 @@ applet/
|
|||||||
*~
|
*~
|
||||||
*.orig
|
*.orig
|
||||||
*.rej
|
*.rej
|
||||||
|
*.bak
|
||||||
|
*.DS_Store
|
||||||
|
*.idea
|
||||||
|
|||||||
+160
@@ -0,0 +1,160 @@
|
|||||||
|
---
|
||||||
|
language: c
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- pwd
|
||||||
|
- wget https://bootstrap.pypa.io/get-pip.py
|
||||||
|
- wget https://bintray.com/artifact/download/olikraus/u8glib/u8glib_arduino_v1.17.zip
|
||||||
|
install:
|
||||||
|
- sudo python get-pip.py
|
||||||
|
- sudo pip install ino
|
||||||
|
# add ppa for newer version of Arduino than available in ubuntu 12.04
|
||||||
|
- sudo add-apt-repository ppa:michael-gruz/elektronik -y
|
||||||
|
- sudo apt-get update -q
|
||||||
|
- sudo apt-get install arduino
|
||||||
|
before_script:
|
||||||
|
# add U8glib, LiquidCrystal_I2C & LiquidTWI2 libraries
|
||||||
|
- sudo unzip u8glib_arduino_v1.17.zip -d /usr/share/arduino/libraries/
|
||||||
|
- cd /usr/share/arduino/libraries/
|
||||||
|
- sudo git clone https://github.com/kiyoshigawa/LiquidCrystal_I2C.git
|
||||||
|
- ls -la
|
||||||
|
- ls -la LiquidCrystal_I2C/
|
||||||
|
- sudo git clone https://github.com/lincomatic/LiquidTWI2.git
|
||||||
|
# remove Robot_Control library to stop compile error!
|
||||||
|
- sudo rm -rf /usr/share/arduino/libraries/Robot_Control
|
||||||
|
# change back to home directory for compiling
|
||||||
|
- cd $TRAVIS_BUILD_DIR
|
||||||
|
# ino needs files in src directory
|
||||||
|
- ln -s Marlin src
|
||||||
|
# remove Marlin.pde as it confuses ino after it finds Marlin.ino
|
||||||
|
- rm Marlin/Marlin.pde
|
||||||
|
script:
|
||||||
|
# build default config
|
||||||
|
- ino build -m mega2560
|
||||||
|
# backup configuration.h
|
||||||
|
- cp Marlin/Configuration.h Marlin/Configuration.h.backup
|
||||||
|
- cp Marlin/Configuration_adv.h Marlin/Configuration_adv.h.backup
|
||||||
|
# change extruder numbers from 1 to 2
|
||||||
|
# commented out for the moment fails build but compiles fine in Arduino
|
||||||
|
#- sed -i 's/#define EXTRUDERS 1/#define EXTRUDERS 2/g' Marlin/Configuration.h
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# change extruder numbers from 2 to 3, needs to be a board with 3 extruders defined in pins.h
|
||||||
|
#- sed -i 's/#define MOTHERBOARD BOARD_ULTIMAKER/#define MOTHERBOARD BOARD_AZTEEG_X3_PRO/g' Marlin/Configuration.h
|
||||||
|
#- sed -i 's/#define EXTRUDERS 2/#define EXTRUDERS 3/g' Marlin/Configuration.h
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# enable PIDTEMPBED
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define PIDTEMPBED/#define PIDTEMPBED/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# enable THERMAL RUNAWAY PROTECTION for extruders & bed
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_PERIOD/#define THERMAL_RUNAWAY_PROTECTION_PERIOD/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS/#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD/#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS/#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# enable AUTO_BED_LEVELING
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define ENABLE_AUTO_BED_LEVELING/#define ENABLE_AUTO_BED_LEVELING/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# enable EEPROM_SETTINGS & EEPROM_CHITCHAT
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define EEPROM_SETTINGS/#define EEPROM_SETTINGS/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define EEPROM_CHITCHAT/#define EEPROM_CHITCHAT/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
### LCDS ###
|
||||||
|
# ULTIMAKERCONTROLLER
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# MAKRPANEL
|
||||||
|
# Needs to use melzi and sanguino hardware
|
||||||
|
#- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
#- sed -i 's/\/\/#define MAKRPANEL/#define MAKRPANEL/g' Marlin/Configuration.h
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# REPRAP_DISCOUNT_SMART_CONTROLLER
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define REPRAP_DISCOUNT_SMART_CONTROLLER/#define REPRAP_DISCOUNT_SMART_CONTROLLER/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# G3D_PANE
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define G3D_PANEL/#define G3D_PANEL/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# REPRAPWORLD_KEYPAD
|
||||||
|
# Cant find configuration details to get it to compile
|
||||||
|
#- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
#- sed -i 's/\/\/#define ULTRA_LCD/#define ULTRA_LCD/g' Marlin/Configuration.h
|
||||||
|
#- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD/#define REPRAPWORLD_KEYPAD/g' Marlin/Configuration.h
|
||||||
|
#- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/g' Marlin/Configuration.h
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# RA_CONTROL_PANEL
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define RA_CONTROL_PANEL/#define RA_CONTROL_PANEL/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
### I2C PANELS ###
|
||||||
|
# LCD_I2C_SAINSMART_YWROBOT
|
||||||
|
# Failing at the moment needs different library
|
||||||
|
#- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
#- sed -i 's/\/\/#define LCD_I2C_SAINSMART_YWROBOT/#define LCD_I2C_SAINSMART_YWROBOT/g' Marlin/Configuration.h
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# LCD_I2C_PANELOLU2
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define LCD_I2C_PANELOLU2/#define LCD_I2C_PANELOLU2/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# LCD_I2C_VIKI
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define LCD_I2C_VIKI/#define LCD_I2C_VIKI/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# Enable filament sensor
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# Enable filament sensor with LCD display
|
||||||
|
- cp Marlin/Configuration.h.backup Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h
|
||||||
|
- sed -i 's/\/\/#define FILAMENT_LCD_DISPLAY/#define FILAMENT_LCD_DISPLAY/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
######## Example Configurations ##############
|
||||||
|
# Delta Config
|
||||||
|
- cp Marlin/example_configurations/delta/Configuration* Marlin/
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# Makibox Config need to check board type for Teensy++ 2.0
|
||||||
|
#- cp Marlin/example_configurations/makibox/Configuration* Marlin/
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
# SCARA Config
|
||||||
|
- cp Marlin/example_configurations/SCARA/Configuration* Marlin/
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m mega2560
|
||||||
|
# tvrrug Config need to check board type for sanguino atmega644p
|
||||||
|
#- cp Marlin/example_configurations/tvrrug/Round2/Configuration* Marlin/
|
||||||
|
#- rm -rf .build/
|
||||||
|
#- ino build -m mega2560
|
||||||
|
######## Board Types #############
|
||||||
|
- sed -i 's/#define MOTHERBOARD BOARD_RAMPS_13_EFB/#define MOTHERBOARD BOARD_DUEMILANOVE_328P/g' Marlin/Configuration.h
|
||||||
|
- rm -rf .build/
|
||||||
|
- ino build -m atmega328
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
##############################################################
|
||||||
|
|
||||||
|
Generation_Series.name=Gen6 & Gen6 Deluxe
|
||||||
|
Generation_Series.upload.protocol=stk500
|
||||||
|
Generation_Series.upload.maximum_size=63488
|
||||||
|
Generation_Series.upload.speed=38400
|
||||||
|
Generation_Series.bootloader.low_fuses=0xFF
|
||||||
|
Generation_Series.bootloader.high_fuses=0xDC
|
||||||
|
Generation_Series.bootloader.extended_fuses=0xFD
|
||||||
|
Generation_Series.bootloader.path=atmega644p
|
||||||
|
Generation_Series.bootloader.file=ATmegaBOOT_644P.hex
|
||||||
|
Generation_Series.bootloader.unlock_bits=0x3F
|
||||||
|
Generation_Series.bootloader.lock_bits=0x0F
|
||||||
|
Generation_Series.build.mcu=atmega644p
|
||||||
|
Generation_Series.build.f_cpu=16000000L
|
||||||
|
Generation_Series.build.core=arduino
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
|
||||||
|
Sanguinololu.name=Sanguinololu 1.2 and above
|
||||||
|
Sanguinololu.upload.protocol=stk500
|
||||||
|
Sanguinololu.upload.maximum_size=63488
|
||||||
|
Sanguinololu.upload.speed=38400
|
||||||
|
Sanguinololu.bootloader.low_fuses=0xFF
|
||||||
|
Sanguinololu.bootloader.high_fuses=0xDC
|
||||||
|
Sanguinololu.bootloader.extended_fuses=0xFD
|
||||||
|
Sanguinololu.bootloader.path=atmega644p
|
||||||
|
Sanguinololu.bootloader.file=ATmegaBOOT_644P.hex
|
||||||
|
Sanguinololu.bootloader.unlock_bits=0x3F
|
||||||
|
Sanguinololu.bootloader.lock_bits=0x0F
|
||||||
|
Sanguinololu.build.mcu=atmega644p
|
||||||
|
Sanguinololu.build.f_cpu=16000000L
|
||||||
|
Sanguinololu.build.core=arduino
|
||||||
@@ -0,0 +1,713 @@
|
|||||||
|
/**********************************************************/
|
||||||
|
/* Serial Bootloader for Atmel megaAVR Controllers */
|
||||||
|
/* */
|
||||||
|
/* tested with ATmega644 and ATmega644P */
|
||||||
|
/* should work with other mega's, see code for details */
|
||||||
|
/* */
|
||||||
|
/* ATmegaBOOT.c */
|
||||||
|
/* */
|
||||||
|
/* 20090131: Added 324P support from Alex Leone */
|
||||||
|
/* Marius Kintel */
|
||||||
|
/* 20080915: applied ADABoot mods for Sanguino 644P */
|
||||||
|
/* Brian Riley */
|
||||||
|
/* 20080711: hacked for Sanguino by Zach Smith */
|
||||||
|
/* and Justin Day */
|
||||||
|
/* 20070626: hacked for Arduino Diecimila (which auto- */
|
||||||
|
/* resets when a USB connection is made to it) */
|
||||||
|
/* by D. Mellis */
|
||||||
|
/* 20060802: hacked for Arduino by D. Cuartielles */
|
||||||
|
/* based on a previous hack by D. Mellis */
|
||||||
|
/* and D. Cuartielles */
|
||||||
|
/* */
|
||||||
|
/* Monitor and debug functions were added to the original */
|
||||||
|
/* code by Dr. Erik Lins, chip45.com. (See below) */
|
||||||
|
/* */
|
||||||
|
/* Thanks to Karl Pitrich for fixing a bootloader pin */
|
||||||
|
/* problem and more informative LED blinking! */
|
||||||
|
/* */
|
||||||
|
/* For the latest version see: */
|
||||||
|
/* http://www.chip45.com/ */
|
||||||
|
/* */
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
/* based on stk500boot.c */
|
||||||
|
/* Copyright (c) 2003, Jason P. Kyle */
|
||||||
|
/* All rights reserved. */
|
||||||
|
/* see avr1.org for original file and information */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it */
|
||||||
|
/* and/or modify it under the terms of the GNU General */
|
||||||
|
/* Public License as published by the Free Software */
|
||||||
|
/* Foundation; either version 2 of the License, or */
|
||||||
|
/* (at your option) any later version. */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will */
|
||||||
|
/* be useful, but WITHOUT ANY WARRANTY; without even the */
|
||||||
|
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
|
||||||
|
/* PARTICULAR PURPOSE. See the GNU General Public */
|
||||||
|
/* License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General */
|
||||||
|
/* Public License along with this program; if not, write */
|
||||||
|
/* to the Free Software Foundation, Inc., */
|
||||||
|
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
/* */
|
||||||
|
/* Licence can be viewed at */
|
||||||
|
/* http://www.fsf.org/licenses/gpl.txt */
|
||||||
|
/* */
|
||||||
|
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
|
||||||
|
/* m8515,m8535. ATmega161 has a very small boot block so */
|
||||||
|
/* isn't supported. */
|
||||||
|
/* */
|
||||||
|
/* Tested with m168 */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
|
/* some includes */
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/boot.h>
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
#define NUM_LED_FLASHES 3
|
||||||
|
#define ADABOOT_VER 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
|
||||||
|
#define MAX_ERROR_COUNT 5
|
||||||
|
|
||||||
|
/* set the UART baud rate */
|
||||||
|
/* 20080711: hack by Zach Hoeken */
|
||||||
|
#define BAUD_RATE 38400
|
||||||
|
|
||||||
|
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
|
||||||
|
/* never allow AVR Studio to do an update !!!! */
|
||||||
|
#define HW_VER 0x02
|
||||||
|
#define SW_MAJOR 0x01
|
||||||
|
#define SW_MINOR 0x10
|
||||||
|
|
||||||
|
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
|
||||||
|
/* if monitor functions are included, LED goes on after monitor was entered */
|
||||||
|
#define LED_DDR DDRB
|
||||||
|
#define LED_PORT PORTB
|
||||||
|
#define LED_PIN PINB
|
||||||
|
#define LED PINB0
|
||||||
|
|
||||||
|
/* define various device id's */
|
||||||
|
/* manufacturer byte is always the same */
|
||||||
|
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :(
|
||||||
|
#if defined(__AVR_ATmega644P__)
|
||||||
|
#define SIG2 0x96
|
||||||
|
#define SIG3 0x0A
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
#define SIG2 0x96
|
||||||
|
#define SIG3 0x09
|
||||||
|
#elif defined(__AVR_ATmega324P__)
|
||||||
|
#define SIG2 0x95
|
||||||
|
#define SIG3 0x08
|
||||||
|
#endif
|
||||||
|
#define PAGE_SIZE 0x080U //128 words
|
||||||
|
#define PAGE_SIZE_BYTES 0x100U //256 bytes
|
||||||
|
|
||||||
|
/* function prototypes */
|
||||||
|
void putch(char);
|
||||||
|
char getch(void);
|
||||||
|
void getNch(uint8_t);
|
||||||
|
void byte_response(uint8_t);
|
||||||
|
void nothing_response(void);
|
||||||
|
char gethex(void);
|
||||||
|
void puthex(char);
|
||||||
|
void flash_led(uint8_t);
|
||||||
|
|
||||||
|
/* some variables */
|
||||||
|
union address_union
|
||||||
|
{
|
||||||
|
uint16_t word;
|
||||||
|
uint8_t byte[2];
|
||||||
|
} address;
|
||||||
|
|
||||||
|
union length_union
|
||||||
|
{
|
||||||
|
uint16_t word;
|
||||||
|
uint8_t byte[2];
|
||||||
|
} length;
|
||||||
|
|
||||||
|
struct flags_struct
|
||||||
|
{
|
||||||
|
unsigned eeprom : 1;
|
||||||
|
unsigned rampz : 1;
|
||||||
|
} flags;
|
||||||
|
|
||||||
|
uint8_t buff[256];
|
||||||
|
|
||||||
|
uint8_t error_count = 0;
|
||||||
|
uint8_t sreg;
|
||||||
|
|
||||||
|
void (*app_start)(void) = 0x0000;
|
||||||
|
|
||||||
|
/* main program starts here */
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint8_t ch,ch2;
|
||||||
|
uint16_t w;
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
|
asm volatile("nop\n\t");
|
||||||
|
|
||||||
|
#ifdef ADABOOT // BBR/LF 10/8/2007 & 9/13/2008
|
||||||
|
ch = MCUSR;
|
||||||
|
MCUSR = 0;
|
||||||
|
|
||||||
|
WDTCSR |= _BV(WDCE) | _BV(WDE);
|
||||||
|
WDTCSR = 0;
|
||||||
|
|
||||||
|
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
|
||||||
|
if (! (ch & _BV(EXTRF))) // if it's a not an external reset...
|
||||||
|
app_start(); // skip bootloader
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//initialize our serial port.
|
||||||
|
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||||
|
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||||
|
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
|
||||||
|
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
|
||||||
|
|
||||||
|
/* Enable internal pull-up resistor on pin D0 (RX), in order
|
||||||
|
to supress line noise that prevents the bootloader from
|
||||||
|
timing out (DAM: 20070509) */
|
||||||
|
DDRD &= ~_BV(PIND0);
|
||||||
|
PORTD |= _BV(PIND0);
|
||||||
|
|
||||||
|
/* set LED pin as output */
|
||||||
|
LED_DDR |= _BV(LED);
|
||||||
|
|
||||||
|
/* flash onboard LED to signal entering of bootloader */
|
||||||
|
/* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT */
|
||||||
|
/* then a pause and another flash series signifying ADABOOT sub-version */
|
||||||
|
|
||||||
|
|
||||||
|
flash_led(NUM_LED_FLASHES);
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
flash_led(ADABOOT_VER); // BBR 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* forever loop */
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
/* get character from UART */
|
||||||
|
ch = getch();
|
||||||
|
|
||||||
|
/* A bunch of if...else if... gives smaller code than switch...case ! */
|
||||||
|
|
||||||
|
/* Hello is anyone home ? */
|
||||||
|
if(ch=='0')
|
||||||
|
nothing_response();
|
||||||
|
|
||||||
|
|
||||||
|
/* Request programmer ID */
|
||||||
|
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */
|
||||||
|
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */
|
||||||
|
else if(ch=='1')
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch('A');
|
||||||
|
putch('V');
|
||||||
|
putch('R');
|
||||||
|
putch(' ');
|
||||||
|
putch('I');
|
||||||
|
putch('S');
|
||||||
|
putch('P');
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */
|
||||||
|
else if(ch=='@')
|
||||||
|
{
|
||||||
|
ch2 = getch();
|
||||||
|
if (ch2 > 0x85)
|
||||||
|
getch();
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AVR ISP/STK500 board requests */
|
||||||
|
else if(ch=='A')
|
||||||
|
{
|
||||||
|
ch2 = getch();
|
||||||
|
if(ch2 == 0x80)
|
||||||
|
byte_response(HW_VER); // Hardware version
|
||||||
|
else if(ch2==0x81)
|
||||||
|
byte_response(SW_MAJOR); // Software major version
|
||||||
|
else if(ch2==0x82)
|
||||||
|
byte_response(SW_MINOR); // Software minor version
|
||||||
|
else if(ch2==0x98)
|
||||||
|
byte_response(0x03); // Unknown but seems to be required by avr studio 3.56
|
||||||
|
else
|
||||||
|
byte_response(0x00); // Covers various unnecessary responses we don't care about
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Device Parameters DON'T CARE, DEVICE IS FIXED */
|
||||||
|
else if(ch=='B')
|
||||||
|
{
|
||||||
|
getNch(20);
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Parallel programming stuff DON'T CARE */
|
||||||
|
else if(ch=='E')
|
||||||
|
{
|
||||||
|
getNch(5);
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Enter programming mode */
|
||||||
|
else if(ch=='P')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Leave programming mode */
|
||||||
|
else if(ch=='Q')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
#ifdef ADABOOT
|
||||||
|
// autoreset via watchdog (sneaky!) BBR/LF 9/13/2008
|
||||||
|
WDTCSR = _BV(WDE);
|
||||||
|
while (1); // 16 ms
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Erase device, don't care as we will erase one page at a time anyway. */
|
||||||
|
else if(ch=='R')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set address, little endian. EEPROM in bytes, FLASH in words */
|
||||||
|
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */
|
||||||
|
/* This might explain why little endian was used here, big endian used everywhere else. */
|
||||||
|
else if(ch=='U')
|
||||||
|
{
|
||||||
|
address.byte[0] = getch();
|
||||||
|
address.byte[1] = getch();
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */
|
||||||
|
else if(ch=='V')
|
||||||
|
{
|
||||||
|
getNch(4);
|
||||||
|
byte_response(0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Write memory, length is big endian and is in bytes */
|
||||||
|
else if(ch=='d')
|
||||||
|
{
|
||||||
|
length.byte[1] = getch();
|
||||||
|
length.byte[0] = getch();
|
||||||
|
|
||||||
|
flags.eeprom = 0;
|
||||||
|
if (getch() == 'E')
|
||||||
|
flags.eeprom = 1;
|
||||||
|
|
||||||
|
for (i=0; i<PAGE_SIZE; i++)
|
||||||
|
buff[i] = 0;
|
||||||
|
|
||||||
|
for (w = 0; w < length.word; w++)
|
||||||
|
{
|
||||||
|
// Store data in buffer, can't keep up with serial data stream whilst programming pages
|
||||||
|
buff[w] = getch();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
if (flags.eeprom)
|
||||||
|
{
|
||||||
|
//Write to EEPROM one byte at a time
|
||||||
|
for(w=0;w<length.word;w++)
|
||||||
|
{
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
|
||||||
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
|
EEDR = buff[w];
|
||||||
|
EECR |= (1<<EEMPE);
|
||||||
|
EECR |= (1<<EEPE);
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//address * 2 -> byte location
|
||||||
|
address.word = address.word << 1;
|
||||||
|
|
||||||
|
//Even up an odd number of bytes
|
||||||
|
if ((length.byte[0] & 0x01))
|
||||||
|
length.word++;
|
||||||
|
|
||||||
|
// HACKME: EEPE used to be EEWE
|
||||||
|
//Wait for previous EEPROM writes to complete
|
||||||
|
//while(bit_is_set(EECR,EEPE));
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
|
||||||
|
asm volatile(
|
||||||
|
"clr r17 \n\t" //page_word_count
|
||||||
|
"lds r30,address \n\t" //Address of FLASH location (in bytes)
|
||||||
|
"lds r31,address+1 \n\t"
|
||||||
|
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM
|
||||||
|
"ldi r29,hi8(buff) \n\t"
|
||||||
|
"lds r24,length \n\t" //Length of data to be written (in bytes)
|
||||||
|
"lds r25,length+1 \n\t"
|
||||||
|
"length_loop: \n\t" //Main loop, repeat for number of words in block
|
||||||
|
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page
|
||||||
|
"brne no_page_erase \n\t"
|
||||||
|
"wait_spm1: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm1 \n\t"
|
||||||
|
"ldi r16,0x03 \n\t" //Erase page pointed to by Z
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"wait_spm2: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm2 \n\t"
|
||||||
|
|
||||||
|
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"no_page_erase: \n\t"
|
||||||
|
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer
|
||||||
|
"ld r1,Y+ \n\t"
|
||||||
|
|
||||||
|
"wait_spm3: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm3 \n\t"
|
||||||
|
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
|
||||||
|
"inc r17 \n\t" //page_word_count++
|
||||||
|
"cpi r17,%1 \n\t"
|
||||||
|
"brlo same_page \n\t" //Still same page in FLASH
|
||||||
|
"write_page: \n\t"
|
||||||
|
"clr r17 \n\t" //New page, write current one first
|
||||||
|
"wait_spm4: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm4 \n\t"
|
||||||
|
"ldi r16,0x05 \n\t" //Write page pointed to by Z
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"wait_spm5: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm5 \n\t"
|
||||||
|
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"same_page: \n\t"
|
||||||
|
"adiw r30,2 \n\t" //Next word in FLASH
|
||||||
|
"sbiw r24,2 \n\t" //length-2
|
||||||
|
"breq final_write \n\t" //Finished
|
||||||
|
"rjmp length_loop \n\t"
|
||||||
|
"final_write: \n\t"
|
||||||
|
"cpi r17,0 \n\t"
|
||||||
|
"breq block_done \n\t"
|
||||||
|
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write
|
||||||
|
"rjmp write_page \n\t"
|
||||||
|
"block_done: \n\t"
|
||||||
|
"clr __zero_reg__ \n\t" //restore zero register
|
||||||
|
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
putch(0x14);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read memory block mode, length is big endian. */
|
||||||
|
else if(ch=='t')
|
||||||
|
{
|
||||||
|
length.byte[1] = getch();
|
||||||
|
length.byte[0] = getch();
|
||||||
|
|
||||||
|
if (getch() == 'E')
|
||||||
|
flags.eeprom = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flags.eeprom = 0;
|
||||||
|
address.word = address.word << 1; // address * 2 -> byte location
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command terminator
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
for (w=0; w<length.word; w++)
|
||||||
|
{
|
||||||
|
// Can handle odd and even lengths okay
|
||||||
|
if (flags.eeprom)
|
||||||
|
{
|
||||||
|
// Byte access EEPROM read
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
|
EECR |= (1<<EERE);
|
||||||
|
putch(EEDR);
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!flags.rampz)
|
||||||
|
putch(pgm_read_byte_near(address.word));
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Get device signature bytes */
|
||||||
|
else if(ch=='u')
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(SIG1);
|
||||||
|
putch(SIG2);
|
||||||
|
putch(SIG3);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Read oscillator calibration byte */
|
||||||
|
else if(ch=='v')
|
||||||
|
byte_response(0x00);
|
||||||
|
|
||||||
|
else if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
|
||||||
|
}
|
||||||
|
/* end of forever loop */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char gethex(void)
|
||||||
|
{
|
||||||
|
char ah,al;
|
||||||
|
|
||||||
|
ah = getch();
|
||||||
|
putch(ah);
|
||||||
|
al = getch();
|
||||||
|
putch(al);
|
||||||
|
|
||||||
|
if(ah >= 'a')
|
||||||
|
ah = ah - 'a' + 0x0a;
|
||||||
|
else if(ah >= '0')
|
||||||
|
ah -= '0';
|
||||||
|
if(al >= 'a')
|
||||||
|
al = al - 'a' + 0x0a;
|
||||||
|
else if(al >= '0')
|
||||||
|
al -= '0';
|
||||||
|
|
||||||
|
return (ah << 4) + al;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void puthex(char ch)
|
||||||
|
{
|
||||||
|
char ah,al;
|
||||||
|
|
||||||
|
ah = (ch & 0xf0) >> 4;
|
||||||
|
if(ah >= 0x0a)
|
||||||
|
ah = ah - 0x0a + 'a';
|
||||||
|
else
|
||||||
|
ah += '0';
|
||||||
|
|
||||||
|
al = (ch & 0x0f);
|
||||||
|
if(al >= 0x0a)
|
||||||
|
al = al - 0x0a + 'a';
|
||||||
|
else
|
||||||
|
al += '0';
|
||||||
|
|
||||||
|
putch(ah);
|
||||||
|
putch(al);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void putch(char ch)
|
||||||
|
{
|
||||||
|
while (!(UCSR0A & _BV(UDRE0)));
|
||||||
|
UDR0 = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char getch(void)
|
||||||
|
{
|
||||||
|
uint32_t count = 0;
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
LED_PORT &= ~_BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while(!(UCSR0A & _BV(RXC0)))
|
||||||
|
{
|
||||||
|
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||||
|
/* HACKME:: here is a good place to count times*/
|
||||||
|
count++;
|
||||||
|
if (count > MAX_TIME_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
LED_PORT |= _BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return UDR0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void getNch(uint8_t count)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for(i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
while(!(UCSR0A & _BV(RXC0)));
|
||||||
|
UDR0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void byte_response(uint8_t val)
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(val);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nothing_response(void)
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
|
||||||
|
void flash_led(uint8_t count)
|
||||||
|
{
|
||||||
|
/* flash onboard LED count times to signal entering of bootloader */
|
||||||
|
/* l needs to be volatile or the delay loops below might get */
|
||||||
|
/* optimized away if compiling with optimizations (DAM). */
|
||||||
|
|
||||||
|
volatile uint32_t l;
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
count = ADABOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int8_t i;
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
LED_PORT |= _BV(LED); // LED on
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l); // delay NGvalue was 1000 for both loops - BBR
|
||||||
|
LED_PORT &= ~_BV(LED); // LED off
|
||||||
|
for(l = 0; l < (F_CPU / 250); ++l); // delay asymmteric for ADA BOOT BBR
|
||||||
|
}
|
||||||
|
|
||||||
|
for(l = 0; l < (F_CPU / 100); ++l); // pause ADA BOOT BBR
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void flash_led(uint8_t count)
|
||||||
|
{
|
||||||
|
/* flash onboard LED three times to signal entering of bootloader */
|
||||||
|
/* l needs to be volatile or the delay loops below might get
|
||||||
|
optimized away if compiling with optimizations (DAM). */
|
||||||
|
volatile uint32_t l;
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
count = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t i;
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
LED_PORT |= _BV(LED);
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l);
|
||||||
|
LED_PORT &= ~_BV(LED);
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* end of file ATmegaBOOT.c */
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "WProgram.h"
|
||||||
+21
-6
@@ -172,13 +172,28 @@ void HardwareSerial::flush()
|
|||||||
_rx_buffer->head = _rx_buffer->tail;
|
_rx_buffer->head = _rx_buffer->tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareSerial::write(uint8_t c)
|
//
|
||||||
{
|
// Drakelive 2012-09-04
|
||||||
while (!((*_ucsra) & (1 << _udre)))
|
//
|
||||||
;
|
#if ARDUINO >= 100
|
||||||
|
size_t HardwareSerial::write(uint8_t c)
|
||||||
|
{
|
||||||
|
while (!((*_ucsra) & (1 << _udre)))
|
||||||
|
;
|
||||||
|
|
||||||
*_udr = c;
|
*_udr = c;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void HardwareSerial::write(uint8_t c)
|
||||||
|
{
|
||||||
|
while (!((*_ucsra) & (1 << _udre)))
|
||||||
|
;
|
||||||
|
|
||||||
|
*_udr = c;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Drakelive 2012-09-04
|
||||||
|
|
||||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||||
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial.h - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HardwareSerial_h
|
||||||
|
#define HardwareSerial_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "Stream.h"
|
||||||
|
|
||||||
|
struct ring_buffer;
|
||||||
|
|
||||||
|
class HardwareSerial : public Stream
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ring_buffer *_rx_buffer;
|
||||||
|
volatile uint8_t *_ubrrh;
|
||||||
|
volatile uint8_t *_ubrrl;
|
||||||
|
volatile uint8_t *_ucsra;
|
||||||
|
volatile uint8_t *_ucsrb;
|
||||||
|
volatile uint8_t *_udr;
|
||||||
|
uint8_t _rxen;
|
||||||
|
uint8_t _txen;
|
||||||
|
uint8_t _rxcie;
|
||||||
|
uint8_t _udre;
|
||||||
|
uint8_t _u2x;
|
||||||
|
public:
|
||||||
|
HardwareSerial(ring_buffer *rx_buffer,
|
||||||
|
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||||
|
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||||
|
volatile uint8_t *udr,
|
||||||
|
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
|
||||||
|
void begin(long);
|
||||||
|
void end();
|
||||||
|
virtual int available(void);
|
||||||
|
virtual int peek(void);
|
||||||
|
virtual int read(void);
|
||||||
|
virtual void flush(void);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drakelive 2012-09-04
|
||||||
|
//
|
||||||
|
#if ARDUINO >= 100
|
||||||
|
virtual size_t write(uint8_t);
|
||||||
|
#else
|
||||||
|
virtual void write(uint8_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Drakelive 2012-09-04
|
||||||
|
|
||||||
|
using Print::write; // pull in write(str) and write(buf, size) from Print
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(UBRRH) || defined(UBRR0H)
|
||||||
|
extern HardwareSerial Serial;
|
||||||
|
#elif defined(USBCON)
|
||||||
|
#include "usb_api.h"
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR1H)
|
||||||
|
extern HardwareSerial Serial1;
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR2H)
|
||||||
|
extern HardwareSerial Serial2;
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR3H)
|
||||||
|
extern HardwareSerial Serial3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
Print.h - Base class that provides print() and println()
|
||||||
|
Copyright (c) 2008 David A. Mellis. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Print_h
|
||||||
|
#define Print_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h> // for size_t
|
||||||
|
|
||||||
|
#include "WString.h"
|
||||||
|
|
||||||
|
#define DEC 10
|
||||||
|
#define HEX 16
|
||||||
|
#define OCT 8
|
||||||
|
#define BIN 2
|
||||||
|
#define BYTE 0
|
||||||
|
|
||||||
|
class Print
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
void printNumber(unsigned long, uint8_t);
|
||||||
|
void printFloat(double, uint8_t);
|
||||||
|
public:
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drakelive 2012-09-04
|
||||||
|
//
|
||||||
|
#if ARDUINO >= 100
|
||||||
|
virtual size_t write(uint8_t) = 0;
|
||||||
|
#else
|
||||||
|
virtual void write(uint8_t) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Drakelive 2012-09-04
|
||||||
|
|
||||||
|
virtual void write(const char *str);
|
||||||
|
virtual void write(const uint8_t *buffer, size_t size);
|
||||||
|
|
||||||
|
void print(const String &);
|
||||||
|
void print(const char[]);
|
||||||
|
void print(char, int = BYTE);
|
||||||
|
void print(unsigned char, int = BYTE);
|
||||||
|
void print(int, int = DEC);
|
||||||
|
void print(unsigned int, int = DEC);
|
||||||
|
void print(long, int = DEC);
|
||||||
|
void print(unsigned long, int = DEC);
|
||||||
|
void print(double, int = 2);
|
||||||
|
|
||||||
|
void println(const String &s);
|
||||||
|
void println(const char[]);
|
||||||
|
void println(char, int = BYTE);
|
||||||
|
void println(unsigned char, int = BYTE);
|
||||||
|
void println(int, int = DEC);
|
||||||
|
void println(unsigned int, int = DEC);
|
||||||
|
void println(long, int = DEC);
|
||||||
|
void println(unsigned long, int = DEC);
|
||||||
|
void println(double, int = 2);
|
||||||
|
void println(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
@@ -70,7 +70,9 @@ extern "C"{
|
|||||||
#define max(a,b) ((a)>(b)?(a):(b))
|
#define max(a,b) ((a)>(b)?(a):(b))
|
||||||
#define abs(x) ((x)>0?(x):-(x))
|
#define abs(x) ((x)>0?(x):-(x))
|
||||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||||
|
#if __AVR_LIBC_VERSION__ < 10701UL
|
||||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||||
|
#endif
|
||||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||||
#define sq(x) ((x)*(x))
|
#define sq(x) ((x)*(x))
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
##############################################################
|
||||||
|
|
||||||
|
sanguino.name=Sanguino
|
||||||
|
sanguino.upload.protocol=stk500
|
||||||
|
sanguino.upload.maximum_size=63488
|
||||||
|
sanguino.upload.speed=38400
|
||||||
|
sanguino.bootloader.low_fuses=0xFF
|
||||||
|
sanguino.bootloader.high_fuses=0xDC
|
||||||
|
sanguino.bootloader.extended_fuses=0xFD
|
||||||
|
sanguino.bootloader.path=atmega644p
|
||||||
|
sanguino.bootloader.file=ATmegaBOOT_644P.hex
|
||||||
|
sanguino.bootloader.unlock_bits=0x3F
|
||||||
|
sanguino.bootloader.lock_bits=0x0F
|
||||||
|
sanguino.build.mcu=atmega644p
|
||||||
|
sanguino.build.f_cpu=16000000L
|
||||||
|
sanguino.build.core=arduino
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
atmega644.name=Sanguino W/ ATmega644P
|
||||||
|
|
||||||
|
atmega644.upload.protocol=stk500
|
||||||
|
atmega644.upload.maximum_size=63488
|
||||||
|
atmega644.upload.speed=57600
|
||||||
|
|
||||||
|
atmega644.bootloader.low_fuses=0xFF
|
||||||
|
atmega644.bootloader.high_fuses=0x9A
|
||||||
|
atmega644.bootloader.extended_fuses=0xFF
|
||||||
|
atmega644.bootloader.path=atmega
|
||||||
|
atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
|
||||||
|
#atmega644.bootloader.file=ATmegaBOOT_644P.hex
|
||||||
|
atmega644.bootloader.unlock_bits=0x3F
|
||||||
|
atmega644.bootloader.lock_bits=0x0F
|
||||||
|
|
||||||
|
atmega644.build.mcu=atmega644p
|
||||||
|
atmega644.build.f_cpu=16000000L
|
||||||
|
atmega644.build.core=arduino
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
atmega12848m.name=Sanguino W/ ATmega1284p 8mhz
|
||||||
|
|
||||||
|
atmega12848m.upload.protocol=stk500
|
||||||
|
atmega12848m.upload.maximum_size=131072
|
||||||
|
atmega12848m.upload.speed=19200
|
||||||
|
|
||||||
|
atmega12848m.bootloader.low_fuses=0xD6
|
||||||
|
atmega12848m.bootloader.high_fuses=0xDA
|
||||||
|
atmega12848m.bootloader.extended_fuses=0xFD
|
||||||
|
atmega12848m.bootloader.path=atmega
|
||||||
|
atmega12848m.bootloader.file=ATmegaBOOT_168_atmega1284p_8m.hex
|
||||||
|
atmega12848m.bootloader.unlock_bits=0x3F
|
||||||
|
atmega12848m.bootloader.lock_bits=0x0F
|
||||||
|
|
||||||
|
atmega12848m.build.mcu=atmega1284p
|
||||||
|
atmega12848m.build.f_cpu=8000000L
|
||||||
|
atmega12848m.build.core=arduino
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
atmega1284.name=Sanguino W/ ATmega1284p 16mhz
|
||||||
|
|
||||||
|
atmega1284.upload.protocol=stk500
|
||||||
|
atmega1284.upload.maximum_size=131072
|
||||||
|
atmega1284.upload.speed=57600
|
||||||
|
|
||||||
|
atmega1284.bootloader.low_fuses=0xD6
|
||||||
|
atmega1284.bootloader.high_fuses=0xDA
|
||||||
|
atmega1284.bootloader.extended_fuses=0xFD
|
||||||
|
atmega1284.bootloader.path=atmega
|
||||||
|
atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
|
||||||
|
atmega1284.bootloader.unlock_bits=0x3F
|
||||||
|
atmega1284.bootloader.lock_bits=0x0F
|
||||||
|
|
||||||
|
atmega1284.build.mcu=atmega1284p
|
||||||
|
atmega1284.build.f_cpu=16000000L
|
||||||
|
atmega1284.build.core=arduino
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
atmega1284s.name=Sanguino W/ ATmega1284p 20mhz
|
||||||
|
|
||||||
|
atmega1284s.upload.protocol=stk500
|
||||||
|
atmega1284s.upload.maximum_size=131072
|
||||||
|
atmega1284s.upload.speed=57600
|
||||||
|
|
||||||
|
atmega1284s.bootloader.low_fuses=0xD6
|
||||||
|
atmega1284s.bootloader.high_fuses=0xDA
|
||||||
|
atmega1284s.bootloader.extended_fuses=0xFD
|
||||||
|
atmega1284s.bootloader.path=atmega
|
||||||
|
atmega1284s.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
|
||||||
|
atmega1284s.bootloader.unlock_bits=0x3F
|
||||||
|
atmega1284s.bootloader.lock_bits=0x0F
|
||||||
|
|
||||||
|
atmega1284s.build.mcu=atmega1284p
|
||||||
|
atmega1284s.build.f_cpu=20000000L
|
||||||
|
atmega1284s.build.core=arduino
|
||||||
|
#
|
||||||
@@ -0,0 +1,470 @@
|
|||||||
|
# Makefile for ATmegaBOOT
|
||||||
|
# E.Lins, 18.7.2005
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Instructions
|
||||||
|
#
|
||||||
|
# To make bootloader .hex file:
|
||||||
|
# make diecimila
|
||||||
|
# make lilypad
|
||||||
|
# make ng
|
||||||
|
# etc...
|
||||||
|
#
|
||||||
|
# To burn bootloader .hex file:
|
||||||
|
# make diecimila_isp
|
||||||
|
# make lilypad_isp
|
||||||
|
# make ng_isp
|
||||||
|
# etc...
|
||||||
|
|
||||||
|
# program name should not be changed...
|
||||||
|
PROGRAM = optiboot
|
||||||
|
|
||||||
|
# The default behavior is to build using tools that are in the users
|
||||||
|
# current path variables, but we can also build using an installed
|
||||||
|
# Arduino user IDE setup, or the Arduino source tree.
|
||||||
|
# Uncomment this next lines to build within the arduino environment,
|
||||||
|
# using the arduino-included avrgcc toolset (mac and pc)
|
||||||
|
# ENV ?= arduino
|
||||||
|
# ENV ?= arduinodev
|
||||||
|
# OS ?= macosx
|
||||||
|
# OS ?= windows
|
||||||
|
|
||||||
|
|
||||||
|
# enter the parameters for the avrdude isp tool
|
||||||
|
ISPTOOL = stk500v2
|
||||||
|
ISPPORT = usb
|
||||||
|
ISPSPEED = -b 115200
|
||||||
|
|
||||||
|
MCU_TARGET = atmega168
|
||||||
|
LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
|
||||||
|
|
||||||
|
# Build environments
|
||||||
|
# Start of some ugly makefile-isms to allow optiboot to be built
|
||||||
|
# in several different environments. See the README.TXT file for
|
||||||
|
# details.
|
||||||
|
|
||||||
|
# default
|
||||||
|
fixpath = $(1)
|
||||||
|
|
||||||
|
ifeq ($(ENV), arduino)
|
||||||
|
# For Arduino, we assume that we're connected to the optiboot directory
|
||||||
|
# included with the arduino distribution, which means that the full set
|
||||||
|
# of avr-tools are "right up there" in standard places.
|
||||||
|
TOOLROOT = ../../../tools
|
||||||
|
GCCROOT = $(TOOLROOT)/avr/bin/
|
||||||
|
AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
|
||||||
|
|
||||||
|
ifeq ($(OS), windows)
|
||||||
|
# On windows, SOME of the tool paths will need to have backslashes instead
|
||||||
|
# of forward slashes (because they use windows cmd.exe for execution instead
|
||||||
|
# of a unix/mingw shell?) We also have to ensure that a consistent shell
|
||||||
|
# is used even if a unix shell is installed (ie as part of WINAVR)
|
||||||
|
fixpath = $(subst /,\,$1)
|
||||||
|
SHELL = cmd.exe
|
||||||
|
endif
|
||||||
|
|
||||||
|
else ifeq ($(ENV), arduinodev)
|
||||||
|
# Arduino IDE source code environment. Use the unpacked compilers created
|
||||||
|
# by the build (you'll need to do "ant build" first.)
|
||||||
|
ifeq ($(OS), macosx)
|
||||||
|
TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
|
||||||
|
endif
|
||||||
|
ifeq ($(OS), windows)
|
||||||
|
TOOLROOT = ../../../../build/windows/work/hardware/tools
|
||||||
|
endif
|
||||||
|
|
||||||
|
GCCROOT = $(TOOLROOT)/avr/bin/
|
||||||
|
AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
|
||||||
|
|
||||||
|
else
|
||||||
|
GCCROOT =
|
||||||
|
AVRDUDE_CONF =
|
||||||
|
endif
|
||||||
|
#
|
||||||
|
# End of build environment code.
|
||||||
|
|
||||||
|
|
||||||
|
# the efuse should really be 0xf8; since, however, only the lower
|
||||||
|
# three bits of that byte are used on the atmega168, avrdude gets
|
||||||
|
# confused if you specify 1's for the higher bits, see:
|
||||||
|
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
|
||||||
|
#
|
||||||
|
# similarly, the lock bits should be 0xff instead of 0x3f (to
|
||||||
|
# unlock the bootloader section) and 0xcf instead of 0x2f (to
|
||||||
|
# lock it), but since the high two bits of the lock byte are
|
||||||
|
# unused, avrdude would get confused.
|
||||||
|
|
||||||
|
ISPFUSES = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
|
||||||
|
-p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
|
||||||
|
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
|
||||||
|
-U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
|
||||||
|
ISPFLASH = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
|
||||||
|
-p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
|
||||||
|
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
|
||||||
|
|
||||||
|
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
|
||||||
|
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
|
||||||
|
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
|
||||||
|
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
|
||||||
|
|
||||||
|
OBJ = $(PROGRAM).o
|
||||||
|
OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
|
||||||
|
|
||||||
|
DEFS =
|
||||||
|
LIBS =
|
||||||
|
|
||||||
|
CC = $(GCCROOT)avr-gcc
|
||||||
|
|
||||||
|
# Override is only needed by avr-lib build system.
|
||||||
|
|
||||||
|
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
|
||||||
|
override LDFLAGS = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
|
||||||
|
|
||||||
|
OBJCOPY = $(GCCROOT)avr-objcopy
|
||||||
|
OBJDUMP = $(call fixpath,$(GCCROOT)avr-objdump)
|
||||||
|
|
||||||
|
SIZE = $(GCCROOT)avr-size
|
||||||
|
|
||||||
|
# Test platforms
|
||||||
|
# Virtual boot block test
|
||||||
|
virboot328: TARGET = atmega328
|
||||||
|
virboot328: MCU_TARGET = atmega328p
|
||||||
|
virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
|
||||||
|
virboot328: AVR_FREQ = 16000000L
|
||||||
|
virboot328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
|
||||||
|
virboot328: $(PROGRAM)_atmega328.hex
|
||||||
|
virboot328: $(PROGRAM)_atmega328.lst
|
||||||
|
|
||||||
|
# 20MHz clocked platforms
|
||||||
|
#
|
||||||
|
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
|
||||||
|
#
|
||||||
|
|
||||||
|
pro20: TARGET = pro_20mhz
|
||||||
|
pro20: MCU_TARGET = atmega168
|
||||||
|
pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
pro20: AVR_FREQ = 20000000L
|
||||||
|
pro20: $(PROGRAM)_pro_20mhz.hex
|
||||||
|
pro20: $(PROGRAM)_pro_20mhz.lst
|
||||||
|
|
||||||
|
pro20_isp: pro20
|
||||||
|
pro20_isp: TARGET = pro_20mhz
|
||||||
|
# 2.7V brownout
|
||||||
|
pro20_isp: HFUSE = DD
|
||||||
|
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
|
||||||
|
pro20_isp: LFUSE = C6
|
||||||
|
# 512 byte boot
|
||||||
|
pro20_isp: EFUSE = 04
|
||||||
|
pro20_isp: isp
|
||||||
|
|
||||||
|
# 16MHz clocked platforms
|
||||||
|
#
|
||||||
|
# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
|
||||||
|
#
|
||||||
|
|
||||||
|
pro16: TARGET = pro_16MHz
|
||||||
|
pro16: MCU_TARGET = atmega168
|
||||||
|
pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
pro16: AVR_FREQ = 16000000L
|
||||||
|
pro16: $(PROGRAM)_pro_16MHz.hex
|
||||||
|
pro16: $(PROGRAM)_pro_16MHz.lst
|
||||||
|
|
||||||
|
pro16_isp: pro16
|
||||||
|
pro16_isp: TARGET = pro_16MHz
|
||||||
|
# 2.7V brownout
|
||||||
|
pro16_isp: HFUSE = DD
|
||||||
|
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
|
||||||
|
pro16_isp: LFUSE = C6
|
||||||
|
# 512 byte boot
|
||||||
|
pro16_isp: EFUSE = 04
|
||||||
|
pro16_isp: isp
|
||||||
|
|
||||||
|
# Diecimila, Duemilanove with m168, and NG use identical bootloaders
|
||||||
|
# Call it "atmega168" for generality and clarity, keep "diecimila" for
|
||||||
|
# backward compatibility of makefile
|
||||||
|
#
|
||||||
|
atmega168: TARGET = atmega168
|
||||||
|
atmega168: MCU_TARGET = atmega168
|
||||||
|
atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
atmega168: AVR_FREQ = 16000000L
|
||||||
|
atmega168: $(PROGRAM)_atmega168.hex
|
||||||
|
atmega168: $(PROGRAM)_atmega168.lst
|
||||||
|
|
||||||
|
atmega168_isp: atmega168
|
||||||
|
atmega168_isp: TARGET = atmega168
|
||||||
|
# 2.7V brownout
|
||||||
|
atmega168_isp: HFUSE = DD
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atmega168_isp: LFUSE = FF
|
||||||
|
# 512 byte boot
|
||||||
|
atmega168_isp: EFUSE = 04
|
||||||
|
atmega168_isp: isp
|
||||||
|
|
||||||
|
diecimila: TARGET = diecimila
|
||||||
|
diecimila: MCU_TARGET = atmega168
|
||||||
|
diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
diecimila: AVR_FREQ = 16000000L
|
||||||
|
diecimila: $(PROGRAM)_diecimila.hex
|
||||||
|
diecimila: $(PROGRAM)_diecimila.lst
|
||||||
|
|
||||||
|
diecimila_isp: diecimila
|
||||||
|
diecimila_isp: TARGET = diecimila
|
||||||
|
# 2.7V brownout
|
||||||
|
diecimila_isp: HFUSE = DD
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
diecimila_isp: LFUSE = FF
|
||||||
|
# 512 byte boot
|
||||||
|
diecimila_isp: EFUSE = 04
|
||||||
|
diecimila_isp: isp
|
||||||
|
|
||||||
|
atmega328: TARGET = atmega328
|
||||||
|
atmega328: MCU_TARGET = atmega328p
|
||||||
|
atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
atmega328: AVR_FREQ = 16000000L
|
||||||
|
atmega328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
|
||||||
|
atmega328: $(PROGRAM)_atmega328.hex
|
||||||
|
atmega328: $(PROGRAM)_atmega328.lst
|
||||||
|
|
||||||
|
atmega328_isp: atmega328
|
||||||
|
atmega328_isp: TARGET = atmega328
|
||||||
|
atmega328_isp: MCU_TARGET = atmega328p
|
||||||
|
# 512 byte boot, SPIEN
|
||||||
|
atmega328_isp: HFUSE = DE
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atmega328_isp: LFUSE = FF
|
||||||
|
# 2.7V brownout
|
||||||
|
atmega328_isp: EFUSE = 05
|
||||||
|
atmega328_isp: isp
|
||||||
|
|
||||||
|
atmega1284: TARGET = atmega1284p
|
||||||
|
atmega1284: MCU_TARGET = atmega1284p
|
||||||
|
atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
|
||||||
|
atmega1284: AVR_FREQ = 16000000L
|
||||||
|
atmega1284: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
|
||||||
|
atmega1284: $(PROGRAM)_atmega1284p.hex
|
||||||
|
atmega1284: $(PROGRAM)_atmega1284p.lst
|
||||||
|
|
||||||
|
atmega1284_isp: atmega1284
|
||||||
|
atmega1284_isp: TARGET = atmega1284p
|
||||||
|
atmega1284_isp: MCU_TARGET = atmega1284p
|
||||||
|
# 1024 byte boot
|
||||||
|
atmega1284_isp: HFUSE = DE
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atmega1284_isp: LFUSE = FF
|
||||||
|
# 2.7V brownout
|
||||||
|
atmega1284_isp: EFUSE = FD
|
||||||
|
atmega1284_isp: isp
|
||||||
|
|
||||||
|
# Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
|
||||||
|
#
|
||||||
|
sanguino: TARGET = atmega644p
|
||||||
|
sanguino: MCU_TARGET = atmega644p
|
||||||
|
sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
|
||||||
|
sanguino: AVR_FREQ = 16000000L
|
||||||
|
sanguino: LDSECTIONS = -Wl,--section-start=.text=0xfc00
|
||||||
|
sanguino: $(PROGRAM)_atmega644p.hex
|
||||||
|
sanguino: $(PROGRAM)_atmega644p.lst
|
||||||
|
|
||||||
|
sanguino_isp: sanguino
|
||||||
|
sanguino_isp: TARGET = atmega644p
|
||||||
|
sanguino_isp: MCU_TARGET = atmega644p
|
||||||
|
# 1024 byte boot
|
||||||
|
sanguino_isp: HFUSE = DE
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
sanguino_isp: LFUSE = FF
|
||||||
|
# 2.7V brownout
|
||||||
|
sanguino_isp: EFUSE = 05
|
||||||
|
sanguino_isp: isp
|
||||||
|
|
||||||
|
# Mega has a minimum boot size of 1024 bytes, so enable extra functions
|
||||||
|
#mega: TARGET = atmega1280
|
||||||
|
mega: MCU_TARGET = atmega1280
|
||||||
|
mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
|
||||||
|
mega: AVR_FREQ = 16000000L
|
||||||
|
mega: LDSECTIONS = -Wl,--section-start=.text=0x1fc00
|
||||||
|
mega: $(PROGRAM)_atmega1280.hex
|
||||||
|
mega: $(PROGRAM)_atmega1280.lst
|
||||||
|
|
||||||
|
mega_isp: mega
|
||||||
|
mega_isp: TARGET = atmega1280
|
||||||
|
mega_isp: MCU_TARGET = atmega1280
|
||||||
|
# 1024 byte boot
|
||||||
|
mega_isp: HFUSE = DE
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
mega_isp: LFUSE = FF
|
||||||
|
# 2.7V brownout
|
||||||
|
mega_isp: EFUSE = 05
|
||||||
|
mega_isp: isp
|
||||||
|
|
||||||
|
# ATmega8
|
||||||
|
#
|
||||||
|
atmega8: TARGET = atmega8
|
||||||
|
atmega8: MCU_TARGET = atmega8
|
||||||
|
atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
atmega8: AVR_FREQ = 16000000L
|
||||||
|
atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
|
||||||
|
atmega8: $(PROGRAM)_atmega8.hex
|
||||||
|
atmega8: $(PROGRAM)_atmega8.lst
|
||||||
|
|
||||||
|
atmega8_isp: atmega8
|
||||||
|
atmega8_isp: TARGET = atmega8
|
||||||
|
atmega8_isp: MCU_TARGET = atmega8
|
||||||
|
# SPIEN, CKOPT, Bootsize=512B
|
||||||
|
atmega8_isp: HFUSE = CC
|
||||||
|
# 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atmega8_isp: LFUSE = BF
|
||||||
|
atmega8_isp: isp
|
||||||
|
|
||||||
|
# ATmega88
|
||||||
|
#
|
||||||
|
atmega88: TARGET = atmega88
|
||||||
|
atmega88: MCU_TARGET = atmega88
|
||||||
|
atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
atmega88: AVR_FREQ = 16000000L
|
||||||
|
atmega88: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
|
||||||
|
atmega88: $(PROGRAM)_atmega88.hex
|
||||||
|
atmega88: $(PROGRAM)_atmega88.lst
|
||||||
|
|
||||||
|
atmega88_isp: atmega88
|
||||||
|
atmega88_isp: TARGET = atmega88
|
||||||
|
atmega88_isp: MCU_TARGET = atmega88
|
||||||
|
# 2.7V brownout
|
||||||
|
atmega88_isp: HFUSE = DD
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atemga88_isp: LFUSE = FF
|
||||||
|
# 512 byte boot
|
||||||
|
atmega88_isp: EFUSE = 04
|
||||||
|
atmega88_isp: isp
|
||||||
|
|
||||||
|
|
||||||
|
# 8MHz clocked platforms
|
||||||
|
#
|
||||||
|
# These are capable of 115200 baud
|
||||||
|
#
|
||||||
|
|
||||||
|
lilypad: TARGET = lilypad
|
||||||
|
lilypad: MCU_TARGET = atmega168
|
||||||
|
lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
lilypad: AVR_FREQ = 8000000L
|
||||||
|
lilypad: $(PROGRAM)_lilypad.hex
|
||||||
|
lilypad: $(PROGRAM)_lilypad.lst
|
||||||
|
|
||||||
|
lilypad_isp: lilypad
|
||||||
|
lilypad_isp: TARGET = lilypad
|
||||||
|
# 2.7V brownout
|
||||||
|
lilypad_isp: HFUSE = DD
|
||||||
|
# Internal 8MHz osc (8MHz) Slow rising power
|
||||||
|
lilypad_isp: LFUSE = E2
|
||||||
|
# 512 byte boot
|
||||||
|
lilypad_isp: EFUSE = 04
|
||||||
|
lilypad_isp: isp
|
||||||
|
|
||||||
|
lilypad_resonator: TARGET = lilypad_resonator
|
||||||
|
lilypad_resonator: MCU_TARGET = atmega168
|
||||||
|
lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
lilypad_resonator: AVR_FREQ = 8000000L
|
||||||
|
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
|
||||||
|
lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
|
||||||
|
|
||||||
|
lilypad_resonator_isp: lilypad_resonator
|
||||||
|
lilypad_resonator_isp: TARGET = lilypad_resonator
|
||||||
|
# 2.7V brownout
|
||||||
|
lilypad_resonator_isp: HFUSE = DD
|
||||||
|
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
|
||||||
|
lilypad_resonator_isp: LFUSE = C6
|
||||||
|
# 512 byte boot
|
||||||
|
lilypad_resonator_isp: EFUSE = 04
|
||||||
|
lilypad_resonator_isp: isp
|
||||||
|
|
||||||
|
pro8: TARGET = pro_8MHz
|
||||||
|
pro8: MCU_TARGET = atmega168
|
||||||
|
pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
pro8: AVR_FREQ = 8000000L
|
||||||
|
pro8: $(PROGRAM)_pro_8MHz.hex
|
||||||
|
pro8: $(PROGRAM)_pro_8MHz.lst
|
||||||
|
|
||||||
|
pro8_isp: pro8
|
||||||
|
pro8_isp: TARGET = pro_8MHz
|
||||||
|
# 2.7V brownout
|
||||||
|
pro8_isp: HFUSE = DD
|
||||||
|
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
|
||||||
|
pro8_isp: LFUSE = C6
|
||||||
|
# 512 byte boot
|
||||||
|
pro8_isp: EFUSE = 04
|
||||||
|
pro8_isp: isp
|
||||||
|
|
||||||
|
atmega328_pro8: TARGET = atmega328_pro_8MHz
|
||||||
|
atmega328_pro8: MCU_TARGET = atmega328p
|
||||||
|
atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
|
||||||
|
atmega328_pro8: AVR_FREQ = 8000000L
|
||||||
|
atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
|
||||||
|
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
|
||||||
|
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
|
||||||
|
|
||||||
|
atmega328_pro8_isp: atmega328_pro8
|
||||||
|
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
|
||||||
|
atmega328_pro8_isp: MCU_TARGET = atmega328p
|
||||||
|
# 512 byte boot, SPIEN
|
||||||
|
atmega328_pro8_isp: HFUSE = DE
|
||||||
|
# Low power xtal (16MHz) 16KCK/14CK+65ms
|
||||||
|
atmega328_pro8_isp: LFUSE = FF
|
||||||
|
# 2.7V brownout
|
||||||
|
atmega328_pro8_isp: EFUSE = 05
|
||||||
|
atmega328_pro8_isp: isp
|
||||||
|
|
||||||
|
# 1MHz clocked platforms
|
||||||
|
#
|
||||||
|
# These are capable of 9600 baud
|
||||||
|
#
|
||||||
|
|
||||||
|
luminet: TARGET = luminet
|
||||||
|
luminet: MCU_TARGET = attiny84
|
||||||
|
luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
|
||||||
|
luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
|
||||||
|
luminet: AVR_FREQ = 1000000L
|
||||||
|
luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
|
||||||
|
luminet: $(PROGRAM)_luminet.hex
|
||||||
|
luminet: $(PROGRAM)_luminet.lst
|
||||||
|
|
||||||
|
luminet_isp: luminet
|
||||||
|
luminet_isp: TARGET = luminet
|
||||||
|
luminet_isp: MCU_TARGET = attiny84
|
||||||
|
# Brownout disabled
|
||||||
|
luminet_isp: HFUSE = DF
|
||||||
|
# 1MHz internal oscillator, slowly rising power
|
||||||
|
luminet_isp: LFUSE = 62
|
||||||
|
# Self-programming enable
|
||||||
|
luminet_isp: EFUSE = FE
|
||||||
|
luminet_isp: isp
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic build instructions
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
isp: $(TARGET)
|
||||||
|
$(ISPFUSES)
|
||||||
|
$(ISPFLASH)
|
||||||
|
|
||||||
|
isp-stk500: $(PROGRAM)_$(TARGET).hex
|
||||||
|
$(STK500-1)
|
||||||
|
$(STK500-2)
|
||||||
|
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
$(SIZE) $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
|
||||||
|
|
||||||
|
%.lst: %.elf
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
%.hex: %.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
|
||||||
|
|
||||||
|
%.srec: %.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
|
||||||
|
|
||||||
|
%.bin: %.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@
|
||||||
@@ -0,0 +1,848 @@
|
|||||||
|
/* Modified to use out for SPM access
|
||||||
|
** Peter Knight, Optiboot project http://optiboot.googlecode.com
|
||||||
|
**
|
||||||
|
** Todo: Tidy up
|
||||||
|
**
|
||||||
|
** "_short" routines execute 1 cycle faster and use 1 less word of flash
|
||||||
|
** by using "out" instruction instead of "sts".
|
||||||
|
**
|
||||||
|
** Additional elpm variants that trust the value of RAMPZ
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007 Eric B. Weddington
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of the copyright holders nor the names of
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE. */
|
||||||
|
|
||||||
|
/* $Id: boot.h,v 1.27.2.3 2008/09/30 13:58:48 arcanum Exp $ */
|
||||||
|
|
||||||
|
#ifndef _AVR_BOOT_H_
|
||||||
|
#define _AVR_BOOT_H_ 1
|
||||||
|
|
||||||
|
/** \file */
|
||||||
|
/** \defgroup avr_boot <avr/boot.h>: Bootloader Support Utilities
|
||||||
|
\code
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/boot.h>
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
The macros in this module provide a C language interface to the
|
||||||
|
bootloader support functionality of certain AVR processors. These
|
||||||
|
macros are designed to work with all sizes of flash memory.
|
||||||
|
|
||||||
|
Global interrupts are not automatically disabled for these macros. It
|
||||||
|
is left up to the programmer to do this. See the code example below.
|
||||||
|
Also see the processor datasheet for caveats on having global interrupts
|
||||||
|
enabled during writing of the Flash.
|
||||||
|
|
||||||
|
\note Not all AVR processors provide bootloader support. See your
|
||||||
|
processor datasheet to see if it provides bootloader support.
|
||||||
|
|
||||||
|
\todo From email with Marek: On smaller devices (all except ATmega64/128),
|
||||||
|
__SPM_REG is in the I/O space, accessible with the shorter "in" and "out"
|
||||||
|
instructions - since the boot loader has a limited size, this could be an
|
||||||
|
important optimization.
|
||||||
|
|
||||||
|
\par API Usage Example
|
||||||
|
The following code shows typical usage of the boot API.
|
||||||
|
|
||||||
|
\code
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
void boot_program_page (uint32_t page, uint8_t *buf)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
uint8_t sreg;
|
||||||
|
|
||||||
|
// Disable interrupts.
|
||||||
|
|
||||||
|
sreg = SREG;
|
||||||
|
cli();
|
||||||
|
|
||||||
|
eeprom_busy_wait ();
|
||||||
|
|
||||||
|
boot_page_erase (page);
|
||||||
|
boot_spm_busy_wait (); // Wait until the memory is erased.
|
||||||
|
|
||||||
|
for (i=0; i<SPM_PAGESIZE; i+=2)
|
||||||
|
{
|
||||||
|
// Set up little-endian word.
|
||||||
|
|
||||||
|
uint16_t w = *buf++;
|
||||||
|
w += (*buf++) << 8;
|
||||||
|
|
||||||
|
boot_page_fill (page + i, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
boot_page_write (page); // Store buffer in flash page.
|
||||||
|
boot_spm_busy_wait(); // Wait until the memory is written.
|
||||||
|
|
||||||
|
// Reenable RWW-section again. We need this if we want to jump back
|
||||||
|
// to the application after bootloading.
|
||||||
|
|
||||||
|
boot_rww_enable ();
|
||||||
|
|
||||||
|
// Re-enable interrupts (if they were ever enabled).
|
||||||
|
|
||||||
|
SREG = sreg;
|
||||||
|
}\endcode */
|
||||||
|
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
/* Check for SPM Control Register in processor. */
|
||||||
|
#if defined (SPMCSR)
|
||||||
|
# define __SPM_REG SPMCSR
|
||||||
|
#elif defined (SPMCR)
|
||||||
|
# define __SPM_REG SPMCR
|
||||||
|
#else
|
||||||
|
# error AVR processor does not provide bootloader support!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Check for SPM Enable bit. */
|
||||||
|
#if defined(SPMEN)
|
||||||
|
# define __SPM_ENABLE SPMEN
|
||||||
|
#elif defined(SELFPRGEN)
|
||||||
|
# define __SPM_ENABLE SELFPRGEN
|
||||||
|
#else
|
||||||
|
# error Cannot find SPM Enable bit definition!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def BOOTLOADER_SECTION
|
||||||
|
|
||||||
|
Used to declare a function or variable to be placed into a
|
||||||
|
new section called .bootloader. This section and its contents
|
||||||
|
can then be relocated to any address (such as the bootloader
|
||||||
|
NRWW area) at link-time. */
|
||||||
|
|
||||||
|
#define BOOTLOADER_SECTION __attribute__ ((section (".bootloader")))
|
||||||
|
|
||||||
|
/* Create common bit definitions. */
|
||||||
|
#ifdef ASB
|
||||||
|
#define __COMMON_ASB ASB
|
||||||
|
#else
|
||||||
|
#define __COMMON_ASB RWWSB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ASRE
|
||||||
|
#define __COMMON_ASRE ASRE
|
||||||
|
#else
|
||||||
|
#define __COMMON_ASRE RWWSRE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define the bit positions of the Boot Lock Bits. */
|
||||||
|
|
||||||
|
#define BLB12 5
|
||||||
|
#define BLB11 4
|
||||||
|
#define BLB02 3
|
||||||
|
#define BLB01 2
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_spm_interrupt_enable()
|
||||||
|
Enable the SPM interrupt. */
|
||||||
|
|
||||||
|
#define boot_spm_interrupt_enable() (__SPM_REG |= (uint8_t)_BV(SPMIE))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_spm_interrupt_disable()
|
||||||
|
Disable the SPM interrupt. */
|
||||||
|
|
||||||
|
#define boot_spm_interrupt_disable() (__SPM_REG &= (uint8_t)~_BV(SPMIE))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_is_spm_interrupt()
|
||||||
|
Check if the SPM interrupt is enabled. */
|
||||||
|
|
||||||
|
#define boot_is_spm_interrupt() (__SPM_REG & (uint8_t)_BV(SPMIE))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_rww_busy()
|
||||||
|
Check if the RWW section is busy. */
|
||||||
|
|
||||||
|
#define boot_rww_busy() (__SPM_REG & (uint8_t)_BV(__COMMON_ASB))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_spm_busy()
|
||||||
|
Check if the SPM instruction is busy. */
|
||||||
|
|
||||||
|
#define boot_spm_busy() (__SPM_REG & (uint8_t)_BV(__SPM_ENABLE))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_spm_busy_wait()
|
||||||
|
Wait while the SPM instruction is busy. */
|
||||||
|
|
||||||
|
#define boot_spm_busy_wait() do{}while(boot_spm_busy())
|
||||||
|
|
||||||
|
#define __BOOT_PAGE_ERASE (_BV(__SPM_ENABLE) | _BV(PGERS))
|
||||||
|
#define __BOOT_PAGE_WRITE (_BV(__SPM_ENABLE) | _BV(PGWRT))
|
||||||
|
#define __BOOT_PAGE_FILL _BV(__SPM_ENABLE)
|
||||||
|
#define __BOOT_RWW_ENABLE (_BV(__SPM_ENABLE) | _BV(__COMMON_ASRE))
|
||||||
|
#define __BOOT_LOCK_BITS_SET (_BV(__SPM_ENABLE) | _BV(BLBSET))
|
||||||
|
|
||||||
|
#define __boot_page_fill_short(address, data) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r0, %3\n\t" \
|
||||||
|
"out %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
"clr r1\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||||
|
"z" ((uint16_t)address), \
|
||||||
|
"r" ((uint16_t)data) \
|
||||||
|
: "r0" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_fill_normal(address, data) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r0, %3\n\t" \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
"clr r1\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||||
|
"z" ((uint16_t)address), \
|
||||||
|
"r" ((uint16_t)data) \
|
||||||
|
: "r0" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_fill_alternate(address, data)\
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r0, %3\n\t" \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
".word 0xffff\n\t" \
|
||||||
|
"nop\n\t" \
|
||||||
|
"clr r1\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||||
|
"z" ((uint16_t)address), \
|
||||||
|
"r" ((uint16_t)data) \
|
||||||
|
: "r0" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_fill_extended(address, data) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r0, %4\n\t" \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"sts %1, %C3\n\t" \
|
||||||
|
"sts %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
"clr r1\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_MEM_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||||
|
"r" ((uint32_t)address), \
|
||||||
|
"r" ((uint16_t)data) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_fill_extended_short(address, data) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r0, %4\n\t" \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"out %1, %C3\n\t" \
|
||||||
|
"out %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
"clr r1\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_IO_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_FILL), \
|
||||||
|
"r" ((uint32_t)address), \
|
||||||
|
"r" ((uint16_t)data) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_erase_short(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"out %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
#define __boot_page_erase_normal(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_erase_alternate(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
".word 0xffff\n\t" \
|
||||||
|
"nop\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_erase_extended(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"sts %1, %C3\n\t" \
|
||||||
|
"sts %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_MEM_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||||
|
"r" ((uint32_t)address) \
|
||||||
|
: "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
#define __boot_page_erase_extended_short(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"out %1, %C3\n\t" \
|
||||||
|
"out %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_IO_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_ERASE), \
|
||||||
|
"r" ((uint32_t)address) \
|
||||||
|
: "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_write_short(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"out %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_write_normal(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_write_alternate(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
".word 0xffff\n\t" \
|
||||||
|
"nop\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||||
|
"z" ((uint16_t)address) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_page_write_extended(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"sts %1, %C3\n\t" \
|
||||||
|
"sts %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_MEM_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||||
|
"r" ((uint32_t)address) \
|
||||||
|
: "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
#define __boot_page_write_extended_short(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"movw r30, %A3\n\t" \
|
||||||
|
"out %1, %C3\n\t" \
|
||||||
|
"out %0, %2\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"i" (_SFR_IO_ADDR(RAMPZ)), \
|
||||||
|
"r" ((uint8_t)__BOOT_PAGE_WRITE), \
|
||||||
|
"r" ((uint32_t)address) \
|
||||||
|
: "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_rww_enable_short() \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"out %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_RWW_ENABLE) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_rww_enable() \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_RWW_ENABLE) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_rww_enable_alternate() \
|
||||||
|
(__extension__({ \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
".word 0xffff\n\t" \
|
||||||
|
"nop\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_RWW_ENABLE) \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
/* From the mega16/mega128 data sheets (maybe others):
|
||||||
|
|
||||||
|
Bits by SPM To set the Boot Loader Lock bits, write the desired data to
|
||||||
|
R0, write "X0001001" to SPMCR and execute SPM within four clock cycles
|
||||||
|
after writing SPMCR. The only accessible Lock bits are the Boot Lock bits
|
||||||
|
that may prevent the Application and Boot Loader section from any
|
||||||
|
software update by the MCU.
|
||||||
|
|
||||||
|
If bits 5..2 in R0 are cleared (zero), the corresponding Boot Lock bit
|
||||||
|
will be programmed if an SPM instruction is executed within four cycles
|
||||||
|
after BLBSET and SPMEN (or SELFPRGEN) are set in SPMCR. The Z-pointer is
|
||||||
|
don't care during this operation, but for future compatibility it is
|
||||||
|
recommended to load the Z-pointer with $0001 (same as used for reading the
|
||||||
|
Lock bits). For future compatibility It is also recommended to set bits 7,
|
||||||
|
6, 1, and 0 in R0 to 1 when writing the Lock bits. When programming the
|
||||||
|
Lock bits the entire Flash can be read during the operation. */
|
||||||
|
|
||||||
|
#define __boot_lock_bits_set_short(lock_bits) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint8_t value = (uint8_t)(~(lock_bits)); \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"ldi r30, 1\n\t" \
|
||||||
|
"ldi r31, 0\n\t" \
|
||||||
|
"mov r0, %2\n\t" \
|
||||||
|
"out %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||||
|
"r" (value) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_lock_bits_set(lock_bits) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint8_t value = (uint8_t)(~(lock_bits)); \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"ldi r30, 1\n\t" \
|
||||||
|
"ldi r31, 0\n\t" \
|
||||||
|
"mov r0, %2\n\t" \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||||
|
"r" (value) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define __boot_lock_bits_set_alternate(lock_bits) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint8_t value = (uint8_t)(~(lock_bits)); \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"ldi r30, 1\n\t" \
|
||||||
|
"ldi r31, 0\n\t" \
|
||||||
|
"mov r0, %2\n\t" \
|
||||||
|
"sts %0, %1\n\t" \
|
||||||
|
"spm\n\t" \
|
||||||
|
".word 0xffff\n\t" \
|
||||||
|
"nop\n\t" \
|
||||||
|
: \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||||
|
"r" (value) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
}))
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reading lock and fuse bits:
|
||||||
|
|
||||||
|
Similarly to writing the lock bits above, set BLBSET and SPMEN (or
|
||||||
|
SELFPRGEN) bits in __SPMREG, and then (within four clock cycles) issue an
|
||||||
|
LPM instruction.
|
||||||
|
|
||||||
|
Z address: contents:
|
||||||
|
0x0000 low fuse bits
|
||||||
|
0x0001 lock bits
|
||||||
|
0x0002 extended fuse bits
|
||||||
|
0x0003 high fuse bits
|
||||||
|
|
||||||
|
Sounds confusing, doesn't it?
|
||||||
|
|
||||||
|
Unlike the macros in pgmspace.h, no need to care for non-enhanced
|
||||||
|
cores here as these old cores do not provide SPM support anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def GET_LOW_FUSE_BITS
|
||||||
|
address to read the low fuse bits, using boot_lock_fuse_bits_get
|
||||||
|
*/
|
||||||
|
#define GET_LOW_FUSE_BITS (0x0000)
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def GET_LOCK_BITS
|
||||||
|
address to read the lock bits, using boot_lock_fuse_bits_get
|
||||||
|
*/
|
||||||
|
#define GET_LOCK_BITS (0x0001)
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def GET_EXTENDED_FUSE_BITS
|
||||||
|
address to read the extended fuse bits, using boot_lock_fuse_bits_get
|
||||||
|
*/
|
||||||
|
#define GET_EXTENDED_FUSE_BITS (0x0002)
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def GET_HIGH_FUSE_BITS
|
||||||
|
address to read the high fuse bits, using boot_lock_fuse_bits_get
|
||||||
|
*/
|
||||||
|
#define GET_HIGH_FUSE_BITS (0x0003)
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_lock_fuse_bits_get(address)
|
||||||
|
|
||||||
|
Read the lock or fuse bits at \c address.
|
||||||
|
|
||||||
|
Parameter \c address can be any of GET_LOW_FUSE_BITS,
|
||||||
|
GET_LOCK_BITS, GET_EXTENDED_FUSE_BITS, or GET_HIGH_FUSE_BITS.
|
||||||
|
|
||||||
|
\note The lock and fuse bits returned are the physical values,
|
||||||
|
i.e. a bit returned as 0 means the corresponding fuse or lock bit
|
||||||
|
is programmed.
|
||||||
|
*/
|
||||||
|
#define boot_lock_fuse_bits_get_short(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint8_t __result; \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"ldi r30, %3\n\t" \
|
||||||
|
"ldi r31, 0\n\t" \
|
||||||
|
"out %1, %2\n\t" \
|
||||||
|
"lpm %0, Z\n\t" \
|
||||||
|
: "=r" (__result) \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||||
|
"M" (address) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
__result; \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define boot_lock_fuse_bits_get(address) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint8_t __result; \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"ldi r30, %3\n\t" \
|
||||||
|
"ldi r31, 0\n\t" \
|
||||||
|
"sts %1, %2\n\t" \
|
||||||
|
"lpm %0, Z\n\t" \
|
||||||
|
: "=r" (__result) \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t)__BOOT_LOCK_BITS_SET), \
|
||||||
|
"M" (address) \
|
||||||
|
: "r0", "r30", "r31" \
|
||||||
|
); \
|
||||||
|
__result; \
|
||||||
|
}))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_signature_byte_get(address)
|
||||||
|
|
||||||
|
Read the Signature Row byte at \c address. For some MCU types,
|
||||||
|
this function can also retrieve the factory-stored oscillator
|
||||||
|
calibration bytes.
|
||||||
|
|
||||||
|
Parameter \c address can be 0-0x1f as documented by the datasheet.
|
||||||
|
\note The values are MCU type dependent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define __BOOT_SIGROW_READ (_BV(__SPM_ENABLE) | _BV(SIGRD))
|
||||||
|
|
||||||
|
#define boot_signature_byte_get_short(addr) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint16_t __addr16 = (uint16_t)(addr); \
|
||||||
|
uint8_t __result; \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"out %1, %2\n\t" \
|
||||||
|
"lpm %0, Z" "\n\t" \
|
||||||
|
: "=r" (__result) \
|
||||||
|
: "i" (_SFR_IO_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t) __BOOT_SIGROW_READ), \
|
||||||
|
"z" (__addr16) \
|
||||||
|
); \
|
||||||
|
__result; \
|
||||||
|
}))
|
||||||
|
|
||||||
|
#define boot_signature_byte_get(addr) \
|
||||||
|
(__extension__({ \
|
||||||
|
uint16_t __addr16 = (uint16_t)(addr); \
|
||||||
|
uint8_t __result; \
|
||||||
|
__asm__ __volatile__ \
|
||||||
|
( \
|
||||||
|
"sts %1, %2\n\t" \
|
||||||
|
"lpm %0, Z" "\n\t" \
|
||||||
|
: "=r" (__result) \
|
||||||
|
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
|
||||||
|
"r" ((uint8_t) __BOOT_SIGROW_READ), \
|
||||||
|
"z" (__addr16) \
|
||||||
|
); \
|
||||||
|
__result; \
|
||||||
|
}))
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_page_fill(address, data)
|
||||||
|
|
||||||
|
Fill the bootloader temporary page buffer for flash
|
||||||
|
address with data word.
|
||||||
|
|
||||||
|
\note The address is a byte address. The data is a word. The AVR
|
||||||
|
writes data to the buffer a word at a time, but addresses the buffer
|
||||||
|
per byte! So, increment your address by 2 between calls, and send 2
|
||||||
|
data bytes in a word format! The LSB of the data is written to the lower
|
||||||
|
address; the MSB of the data is written to the higher address.*/
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_page_erase(address)
|
||||||
|
|
||||||
|
Erase the flash page that contains address.
|
||||||
|
|
||||||
|
\note address is a byte address in flash, not a word address. */
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_page_write(address)
|
||||||
|
|
||||||
|
Write the bootloader temporary page buffer
|
||||||
|
to flash page that contains address.
|
||||||
|
|
||||||
|
\note address is a byte address in flash, not a word address. */
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_rww_enable()
|
||||||
|
|
||||||
|
Enable the Read-While-Write memory section. */
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
\def boot_lock_bits_set(lock_bits)
|
||||||
|
|
||||||
|
Set the bootloader lock bits.
|
||||||
|
|
||||||
|
\param lock_bits A mask of which Boot Loader Lock Bits to set.
|
||||||
|
|
||||||
|
\note In this context, a 'set bit' will be written to a zero value.
|
||||||
|
Note also that only BLBxx bits can be programmed by this command.
|
||||||
|
|
||||||
|
For example, to disallow the SPM instruction from writing to the Boot
|
||||||
|
Loader memory section of flash, you would use this macro as such:
|
||||||
|
|
||||||
|
\code
|
||||||
|
boot_lock_bits_set (_BV (BLB11));
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\note Like any lock bits, the Boot Loader Lock Bits, once set,
|
||||||
|
cannot be cleared again except by a chip erase which will in turn
|
||||||
|
also erase the boot loader itself. */
|
||||||
|
|
||||||
|
/* Normal versions of the macros use 16-bit addresses.
|
||||||
|
Extended versions of the macros use 32-bit addresses.
|
||||||
|
Alternate versions of the macros use 16-bit addresses and require special
|
||||||
|
instruction sequences after LPM.
|
||||||
|
|
||||||
|
FLASHEND is defined in the ioXXXX.h file.
|
||||||
|
USHRT_MAX is defined in <limits.h>. */
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
|
||||||
|
/* Alternate: ATmega161/163/323 and 16 bit address */
|
||||||
|
#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data)
|
||||||
|
#define boot_page_erase(address) __boot_page_erase_alternate(address)
|
||||||
|
#define boot_page_write(address) __boot_page_write_alternate(address)
|
||||||
|
#define boot_rww_enable() __boot_rww_enable_alternate()
|
||||||
|
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits)
|
||||||
|
|
||||||
|
#elif (FLASHEND > USHRT_MAX)
|
||||||
|
|
||||||
|
/* Extended: >16 bit address */
|
||||||
|
#define boot_page_fill(address, data) __boot_page_fill_extended_short(address, data)
|
||||||
|
#define boot_page_erase(address) __boot_page_erase_extended_short(address)
|
||||||
|
#define boot_page_write(address) __boot_page_write_extended_short(address)
|
||||||
|
#define boot_rww_enable() __boot_rww_enable_short()
|
||||||
|
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Normal: 16 bit address */
|
||||||
|
#define boot_page_fill(address, data) __boot_page_fill_short(address, data)
|
||||||
|
#define boot_page_erase(address) __boot_page_erase_short(address)
|
||||||
|
#define boot_page_write(address) __boot_page_write_short(address)
|
||||||
|
#define boot_rww_enable() __boot_rww_enable_short()
|
||||||
|
#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
|
||||||
|
Same as boot_page_fill() except it waits for eeprom and spm operations to
|
||||||
|
complete before filling the page. */
|
||||||
|
|
||||||
|
#define boot_page_fill_safe(address, data) \
|
||||||
|
do { \
|
||||||
|
boot_spm_busy_wait(); \
|
||||||
|
eeprom_busy_wait(); \
|
||||||
|
boot_page_fill(address, data); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
|
||||||
|
Same as boot_page_erase() except it waits for eeprom and spm operations to
|
||||||
|
complete before erasing the page. */
|
||||||
|
|
||||||
|
#define boot_page_erase_safe(address) \
|
||||||
|
do { \
|
||||||
|
boot_spm_busy_wait(); \
|
||||||
|
eeprom_busy_wait(); \
|
||||||
|
boot_page_erase (address); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
|
||||||
|
Same as boot_page_write() except it waits for eeprom and spm operations to
|
||||||
|
complete before writing the page. */
|
||||||
|
|
||||||
|
#define boot_page_write_safe(address) \
|
||||||
|
do { \
|
||||||
|
boot_spm_busy_wait(); \
|
||||||
|
eeprom_busy_wait(); \
|
||||||
|
boot_page_write (address); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
|
||||||
|
Same as boot_rww_enable() except waits for eeprom and spm operations to
|
||||||
|
complete before enabling the RWW mameory. */
|
||||||
|
|
||||||
|
#define boot_rww_enable_safe() \
|
||||||
|
do { \
|
||||||
|
boot_spm_busy_wait(); \
|
||||||
|
eeprom_busy_wait(); \
|
||||||
|
boot_rww_enable(); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/** \ingroup avr_boot
|
||||||
|
|
||||||
|
Same as boot_lock_bits_set() except waits for eeprom and spm operations to
|
||||||
|
complete before setting the lock bits. */
|
||||||
|
|
||||||
|
#define boot_lock_bits_set_safe(lock_bits) \
|
||||||
|
do { \
|
||||||
|
boot_spm_busy_wait(); \
|
||||||
|
eeprom_busy_wait(); \
|
||||||
|
boot_lock_bits_set (lock_bits); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* _AVR_BOOT_H_ */
|
||||||
@@ -0,0 +1,724 @@
|
|||||||
|
/**********************************************************/
|
||||||
|
/* -Wl,-section-start=bootloader=0x1fc00 */
|
||||||
|
/* Optiboot bootloader for Arduino */
|
||||||
|
/* */
|
||||||
|
/* http://optiboot.googlecode.com */
|
||||||
|
/* */
|
||||||
|
/* Arduino-maintained version : See README.TXT */
|
||||||
|
/* http://code.google.com/p/arduino/ */
|
||||||
|
/* */
|
||||||
|
/* Heavily optimised bootloader that is faster and */
|
||||||
|
/* smaller than the Arduino standard bootloader */
|
||||||
|
/* */
|
||||||
|
/* Enhancements: */
|
||||||
|
/* Fits in 512 bytes, saving 1.5K of code space */
|
||||||
|
/* Background page erasing speeds up programming */
|
||||||
|
/* Higher baud rate speeds up programming */
|
||||||
|
/* Written almost entirely in C */
|
||||||
|
/* Customisable timeout with accurate timeconstant */
|
||||||
|
/* Optional virtual UART. No hardware UART required. */
|
||||||
|
/* Optional virtual boot partition for devices without. */
|
||||||
|
/* */
|
||||||
|
/* What you lose: */
|
||||||
|
/* Implements a skeleton STK500 protocol which is */
|
||||||
|
/* missing several features including EEPROM */
|
||||||
|
/* programming and non-page-aligned writes */
|
||||||
|
/* High baud rate breaks compatibility with standard */
|
||||||
|
/* Arduino flash settings */
|
||||||
|
/* */
|
||||||
|
/* Fully supported: */
|
||||||
|
/* ATmega168 based devices (Diecimila etc) */
|
||||||
|
/* ATmega328P based devices (Duemilanove etc) */
|
||||||
|
/* */
|
||||||
|
/* Alpha test */
|
||||||
|
/* ATmega1280 based devices (Arduino Mega) */
|
||||||
|
/* */
|
||||||
|
/* Work in progress: */
|
||||||
|
/* ATmega644P based devices (Sanguino) */
|
||||||
|
/* ATtiny84 based devices (Luminet) */
|
||||||
|
/* */
|
||||||
|
/* Does not support: */
|
||||||
|
/* USB based devices (eg. Teensy) */
|
||||||
|
/* */
|
||||||
|
/* Assumptions: */
|
||||||
|
/* The code makes several assumptions that reduce the */
|
||||||
|
/* code size. They are all true after a hardware reset, */
|
||||||
|
/* but may not be true if the bootloader is called by */
|
||||||
|
/* other means or on other hardware. */
|
||||||
|
/* No interrupts can occur */
|
||||||
|
/* UART and Timer 1 are set to their reset state */
|
||||||
|
/* SP points to RAMEND */
|
||||||
|
/* */
|
||||||
|
/* Code builds on code, libraries and optimisations from: */
|
||||||
|
/* stk500boot.c by Jason P. Kyle */
|
||||||
|
/* Arduino bootloader http://arduino.cc */
|
||||||
|
/* Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */
|
||||||
|
/* avr-libc project http://nongnu.org/avr-libc */
|
||||||
|
/* Adaboot http://www.ladyada.net/library/arduino/bootloader.html */
|
||||||
|
/* AVR305 Atmel Application Note */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it */
|
||||||
|
/* and/or modify it under the terms of the GNU General */
|
||||||
|
/* Public License as published by the Free Software */
|
||||||
|
/* Foundation; either version 2 of the License, or */
|
||||||
|
/* (at your option) any later version. */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will */
|
||||||
|
/* be useful, but WITHOUT ANY WARRANTY; without even the */
|
||||||
|
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
|
||||||
|
/* PARTICULAR PURPOSE. See the GNU General Public */
|
||||||
|
/* License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General */
|
||||||
|
/* Public License along with this program; if not, write */
|
||||||
|
/* to the Free Software Foundation, Inc., */
|
||||||
|
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
/* */
|
||||||
|
/* Licence can be viewed at */
|
||||||
|
/* http://www.fsf.org/licenses/gpl.txt */
|
||||||
|
/* */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************/
|
||||||
|
/* */
|
||||||
|
/* Optional defines: */
|
||||||
|
/* */
|
||||||
|
/**********************************************************/
|
||||||
|
/* */
|
||||||
|
/* BIG_BOOT: */
|
||||||
|
/* Build a 1k bootloader, not 512 bytes. This turns on */
|
||||||
|
/* extra functionality. */
|
||||||
|
/* */
|
||||||
|
/* BAUD_RATE: */
|
||||||
|
/* Set bootloader baud rate. */
|
||||||
|
/* */
|
||||||
|
/* LUDICROUS_SPEED: */
|
||||||
|
/* 230400 baud :-) */
|
||||||
|
/* */
|
||||||
|
/* SOFT_UART: */
|
||||||
|
/* Use AVR305 soft-UART instead of hardware UART. */
|
||||||
|
/* */
|
||||||
|
/* LED_START_FLASHES: */
|
||||||
|
/* Number of LED flashes on bootup. */
|
||||||
|
/* */
|
||||||
|
/* LED_DATA_FLASH: */
|
||||||
|
/* Flash LED when transferring data. For boards without */
|
||||||
|
/* TX or RX LEDs, or for people who like blinky lights. */
|
||||||
|
/* */
|
||||||
|
/* SUPPORT_EEPROM: */
|
||||||
|
/* Support reading and writing from EEPROM. This is not */
|
||||||
|
/* used by Arduino, so off by default. */
|
||||||
|
/* */
|
||||||
|
/* TIMEOUT_MS: */
|
||||||
|
/* Bootloader timeout period, in milliseconds. */
|
||||||
|
/* 500,1000,2000,4000,8000 supported. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
/**********************************************************/
|
||||||
|
/* Version Numbers! */
|
||||||
|
/* */
|
||||||
|
/* Arduino Optiboot now includes this Version number in */
|
||||||
|
/* the source and object code. */
|
||||||
|
/* */
|
||||||
|
/* Version 3 was released as zip from the optiboot */
|
||||||
|
/* repository and was distributed with Arduino 0022. */
|
||||||
|
/* Version 4 starts with the arduino repository commit */
|
||||||
|
/* that brought the arduino repository up-to-date with */
|
||||||
|
/* the optiboot source tree changes since v3. */
|
||||||
|
/* */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
/**********************************************************/
|
||||||
|
/* Edit History: */
|
||||||
|
/* */
|
||||||
|
/* Jan 2012: */
|
||||||
|
/* 4.5 WestfW: fix NRWW value for m1284. */
|
||||||
|
/* 4.4 WestfW: use attribute OS_main instead of naked for */
|
||||||
|
/* main(). This allows optimizations that we */
|
||||||
|
/* count on, which are prohibited in naked */
|
||||||
|
/* functions due to PR42240. (keeps us less */
|
||||||
|
/* than 512 bytes when compiler is gcc4.5 */
|
||||||
|
/* (code from 4.3.2 remains the same.) */
|
||||||
|
/* 4.4 WestfW and Maniacbug: Add m1284 support. This */
|
||||||
|
/* does not change the 328 binary, so the */
|
||||||
|
/* version number didn't change either. (?) */
|
||||||
|
/* June 2011: */
|
||||||
|
/* 4.4 WestfW: remove automatic soft_uart detect (didn't */
|
||||||
|
/* know what it was doing or why.) Added a */
|
||||||
|
/* check of the calculated BRG value instead. */
|
||||||
|
/* Version stays 4.4; existing binaries are */
|
||||||
|
/* not changed. */
|
||||||
|
/* 4.4 WestfW: add initialization of address to keep */
|
||||||
|
/* the compiler happy. Change SC'ed targets. */
|
||||||
|
/* Return the SW version via READ PARAM */
|
||||||
|
/* 4.3 WestfW: catch framing errors in getch(), so that */
|
||||||
|
/* AVRISP works without HW kludges. */
|
||||||
|
/* http://code.google.com/p/arduino/issues/detail?id=368n*/
|
||||||
|
/* 4.2 WestfW: reduce code size, fix timeouts, change */
|
||||||
|
/* verifySpace to use WDT instead of appstart */
|
||||||
|
/* 4.1 WestfW: put version number in binary. */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
#define OPTIBOOT_MAJVER 4
|
||||||
|
#define OPTIBOOT_MINVER 5
|
||||||
|
|
||||||
|
#define MAKESTR(a) #a
|
||||||
|
#define MAKEVER(a, b) MAKESTR(a*256+b)
|
||||||
|
|
||||||
|
asm(" .section .version\n"
|
||||||
|
"optiboot_version: .word " MAKEVER(OPTIBOOT_MAJVER, OPTIBOOT_MINVER) "\n"
|
||||||
|
" .section .text\n");
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
// <avr/boot.h> uses sts instructions, but this version uses out instructions
|
||||||
|
// This saves cycles and program memory.
|
||||||
|
#include "boot.h"
|
||||||
|
|
||||||
|
|
||||||
|
// We don't use <avr/wdt.h> as those routines have interrupt overhead we don't need.
|
||||||
|
|
||||||
|
#include "pin_defs.h"
|
||||||
|
#include "stk500.h"
|
||||||
|
|
||||||
|
#ifndef LED_START_FLASHES
|
||||||
|
#define LED_START_FLASHES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LUDICROUS_SPEED
|
||||||
|
#define BAUD_RATE 230400L
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set the UART baud rate defaults */
|
||||||
|
#ifndef BAUD_RATE
|
||||||
|
#if F_CPU >= 8000000L
|
||||||
|
#define BAUD_RATE 115200L // Highest rate Avrdude win32 will support
|
||||||
|
#elsif F_CPU >= 1000000L
|
||||||
|
#define BAUD_RATE 9600L // 19200 also supported, but with significant error
|
||||||
|
#elsif F_CPU >= 128000L
|
||||||
|
#define BAUD_RATE 4800L // Good for 128kHz internal RC
|
||||||
|
#else
|
||||||
|
#define BAUD_RATE 1200L // Good even at 32768Hz
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Switch in soft UART for hard baud rates */
|
||||||
|
/*
|
||||||
|
* I don't understand what this was supposed to accomplish, where the
|
||||||
|
* constant "280" came from, or why automatically (and perhaps unexpectedly)
|
||||||
|
* switching to a soft uart is a good thing, so I'm undoing this in favor
|
||||||
|
* of a range check using the same calc used to config the BRG...
|
||||||
|
*/
|
||||||
|
#if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz
|
||||||
|
#ifndef SOFT_UART
|
||||||
|
#define SOFT_UART
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else // 0
|
||||||
|
#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250
|
||||||
|
#error Unachievable baud rate (too slow) BAUD_RATE
|
||||||
|
#endif // baud rate slow check
|
||||||
|
#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3
|
||||||
|
#error Unachievable baud rate (too fast) BAUD_RATE
|
||||||
|
#endif // baud rate fastn check
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Watchdog settings */
|
||||||
|
#define WATCHDOG_OFF (0)
|
||||||
|
#define WATCHDOG_16MS (_BV(WDE))
|
||||||
|
#define WATCHDOG_32MS (_BV(WDP0) | _BV(WDE))
|
||||||
|
#define WATCHDOG_64MS (_BV(WDP1) | _BV(WDE))
|
||||||
|
#define WATCHDOG_125MS (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
|
||||||
|
#define WATCHDOG_250MS (_BV(WDP2) | _BV(WDE))
|
||||||
|
#define WATCHDOG_500MS (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
|
||||||
|
#define WATCHDOG_1S (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
|
||||||
|
#define WATCHDOG_2S (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
|
||||||
|
#ifndef __AVR_ATmega8__
|
||||||
|
#define WATCHDOG_4S (_BV(WDP3) | _BV(WDE))
|
||||||
|
#define WATCHDOG_8S (_BV(WDP3) | _BV(WDP0) | _BV(WDE))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Function Prototypes */
|
||||||
|
/* The main function is in init9, which removes the interrupt vector table */
|
||||||
|
/* we don't need. It is also 'naked', which means the compiler does not */
|
||||||
|
/* generate any entry or exit code itself. */
|
||||||
|
int main(void) __attribute__ ((OS_main)) __attribute__ ((section (".init9")));
|
||||||
|
void putch(char);
|
||||||
|
uint8_t getch(void);
|
||||||
|
static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */
|
||||||
|
void verifySpace();
|
||||||
|
static inline void flash_led(uint8_t);
|
||||||
|
uint8_t getLen();
|
||||||
|
static inline void watchdogReset();
|
||||||
|
void watchdogConfig(uint8_t x);
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
void uartDelay() __attribute__ ((naked));
|
||||||
|
#endif
|
||||||
|
void appStart() __attribute__ ((naked));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NRWW memory
|
||||||
|
* Addresses below NRWW (Non-Read-While-Write) can be programmed while
|
||||||
|
* continuing to run code from flash, slightly speeding up programming
|
||||||
|
* time. Beware that Atmel data sheets specify this as a WORD address,
|
||||||
|
* while optiboot will be comparing against a 16-bit byte address. This
|
||||||
|
* means that on a part with 128kB of memory, the upper part of the lower
|
||||||
|
* 64k will get NRWW processing as well, even though it doesn't need it.
|
||||||
|
* That's OK. In fact, you can disable the overlapping processing for
|
||||||
|
* a part entirely by setting NRWWSTART to zero. This reduces code
|
||||||
|
* space a bit, at the expense of being slightly slower, overall.
|
||||||
|
*
|
||||||
|
* RAMSTART should be self-explanatory. It's bigger on parts with a
|
||||||
|
* lot of peripheral registers.
|
||||||
|
*/
|
||||||
|
#if defined(__AVR_ATmega168__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0x3800)
|
||||||
|
#elif defined(__AVR_ATmega328P__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0x7000)
|
||||||
|
#elif defined (__AVR_ATmega644P__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0xE000)
|
||||||
|
#elif defined (__AVR_ATmega1284P__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0xE000)
|
||||||
|
#elif defined(__AVR_ATtiny84__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0x0000)
|
||||||
|
#elif defined(__AVR_ATmega1280__)
|
||||||
|
#define RAMSTART (0x200)
|
||||||
|
#define NRWWSTART (0xE000)
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||||
|
#define RAMSTART (0x100)
|
||||||
|
#define NRWWSTART (0x1800)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* C zero initialises all global variables. However, that requires */
|
||||||
|
/* These definitions are NOT zero initialised, but that doesn't matter */
|
||||||
|
/* This allows us to drop the zero init code, saving us memory */
|
||||||
|
#define buff ((uint8_t*)(RAMSTART))
|
||||||
|
#ifdef VIRTUAL_BOOT_PARTITION
|
||||||
|
#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
|
||||||
|
#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* main program starts here */
|
||||||
|
int main(void) {
|
||||||
|
uint8_t ch;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Making these local and in registers prevents the need for initializing
|
||||||
|
* them, and also saves space because code no longer stores to memory.
|
||||||
|
* (initializing address keeps the compiler happy, but isn't really
|
||||||
|
* necessary, and uses 4 bytes of flash.)
|
||||||
|
*/
|
||||||
|
register uint16_t address = 0;
|
||||||
|
register uint8_t length;
|
||||||
|
|
||||||
|
// After the zero init loop, this is the first code to run.
|
||||||
|
//
|
||||||
|
// This code makes the following assumptions:
|
||||||
|
// No interrupts will execute
|
||||||
|
// SP points to RAMEND
|
||||||
|
// r1 contains zero
|
||||||
|
//
|
||||||
|
// If not, uncomment the following instructions:
|
||||||
|
// cli();
|
||||||
|
asm volatile ("clr __zero_reg__");
|
||||||
|
#ifdef __AVR_ATmega8__
|
||||||
|
SP=RAMEND; // This is done by hardware reset
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Adaboot no-wait mod
|
||||||
|
ch = MCUSR;
|
||||||
|
MCUSR = 0;
|
||||||
|
if (!(ch & _BV(EXTRF))) appStart();
|
||||||
|
|
||||||
|
#if LED_START_FLASHES > 0
|
||||||
|
// Set up Timer 1 for timeout counter
|
||||||
|
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
|
||||||
|
#endif
|
||||||
|
#ifndef SOFT_UART
|
||||||
|
#ifdef __AVR_ATmega8__
|
||||||
|
UCSRA = _BV(U2X); //Double speed mode USART
|
||||||
|
UCSRB = _BV(RXEN) | _BV(TXEN); // enable Rx & Tx
|
||||||
|
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0); // config USART; 8N1
|
||||||
|
UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
|
||||||
|
#else
|
||||||
|
UCSR0A = _BV(U2X0); //Double speed mode USART0
|
||||||
|
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
|
||||||
|
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
|
||||||
|
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set up watchdog to trigger after 500ms
|
||||||
|
watchdogConfig(WATCHDOG_1S);
|
||||||
|
|
||||||
|
/* Set LED pin as output */
|
||||||
|
LED_DDR |= _BV(LED);
|
||||||
|
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
/* Set TX pin as output */
|
||||||
|
UART_DDR |= _BV(UART_TX_BIT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LED_START_FLASHES > 0
|
||||||
|
/* Flash onboard LED to signal entering of bootloader */
|
||||||
|
flash_led(LED_START_FLASHES * 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Forever loop */
|
||||||
|
for (;;) {
|
||||||
|
/* get character from UART */
|
||||||
|
ch = getch();
|
||||||
|
|
||||||
|
if(ch == STK_GET_PARAMETER) {
|
||||||
|
unsigned char which = getch();
|
||||||
|
verifySpace();
|
||||||
|
if (which == 0x82) {
|
||||||
|
/*
|
||||||
|
* Send optiboot version as "minor SW version"
|
||||||
|
*/
|
||||||
|
putch(OPTIBOOT_MINVER);
|
||||||
|
} else if (which == 0x81) {
|
||||||
|
putch(OPTIBOOT_MAJVER);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* GET PARAMETER returns a generic 0x03 reply for
|
||||||
|
* other parameters - enough to keep Avrdude happy
|
||||||
|
*/
|
||||||
|
putch(0x03);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ch == STK_SET_DEVICE) {
|
||||||
|
// SET DEVICE is ignored
|
||||||
|
getNch(20);
|
||||||
|
}
|
||||||
|
else if(ch == STK_SET_DEVICE_EXT) {
|
||||||
|
// SET DEVICE EXT is ignored
|
||||||
|
getNch(5);
|
||||||
|
}
|
||||||
|
else if(ch == STK_LOAD_ADDRESS) {
|
||||||
|
// LOAD ADDRESS
|
||||||
|
uint16_t newAddress;
|
||||||
|
newAddress = getch();
|
||||||
|
newAddress = (newAddress & 0xff) | (getch() << 8);
|
||||||
|
#ifdef RAMPZ
|
||||||
|
// Transfer top bit to RAMPZ
|
||||||
|
RAMPZ = (newAddress & 0x8000) ? 1 : 0;
|
||||||
|
#endif
|
||||||
|
newAddress += newAddress; // Convert from word address to byte address
|
||||||
|
address = newAddress;
|
||||||
|
verifySpace();
|
||||||
|
}
|
||||||
|
else if(ch == STK_UNIVERSAL) {
|
||||||
|
// UNIVERSAL command is ignored
|
||||||
|
getNch(4);
|
||||||
|
putch(0x00);
|
||||||
|
}
|
||||||
|
/* Write memory, length is big endian and is in bytes */
|
||||||
|
else if(ch == STK_PROG_PAGE) {
|
||||||
|
// PROGRAM PAGE - we support flash programming only, not EEPROM
|
||||||
|
uint8_t *bufPtr;
|
||||||
|
uint16_t addrPtr;
|
||||||
|
|
||||||
|
getch(); /* getlen() */
|
||||||
|
length = getch();
|
||||||
|
getch();
|
||||||
|
|
||||||
|
// If we are in RWW section, immediately start page erase
|
||||||
|
if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
|
||||||
|
|
||||||
|
// While that is going on, read in page contents
|
||||||
|
bufPtr = buff;
|
||||||
|
do *bufPtr++ = getch();
|
||||||
|
while (--length);
|
||||||
|
|
||||||
|
// If we are in NRWW section, page erase has to be delayed until now.
|
||||||
|
// Todo: Take RAMPZ into account
|
||||||
|
if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
|
||||||
|
|
||||||
|
// Read command terminator, start reply
|
||||||
|
verifySpace();
|
||||||
|
|
||||||
|
// If only a partial page is to be programmed, the erase might not be complete.
|
||||||
|
// So check that here
|
||||||
|
boot_spm_busy_wait();
|
||||||
|
|
||||||
|
#ifdef VIRTUAL_BOOT_PARTITION
|
||||||
|
if ((uint16_t)(void*)address == 0) {
|
||||||
|
// This is the reset vector page. We need to live-patch the code so the
|
||||||
|
// bootloader runs.
|
||||||
|
//
|
||||||
|
// Move RESET vector to WDT vector
|
||||||
|
uint16_t vect = buff[0] | (buff[1]<<8);
|
||||||
|
rstVect = vect;
|
||||||
|
wdtVect = buff[8] | (buff[9]<<8);
|
||||||
|
vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
|
||||||
|
buff[8] = vect & 0xff;
|
||||||
|
buff[9] = vect >> 8;
|
||||||
|
|
||||||
|
// Add jump to bootloader at RESET vector
|
||||||
|
buff[0] = 0x7f;
|
||||||
|
buff[1] = 0xce; // rjmp 0x1d00 instruction
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Copy buffer into programming buffer
|
||||||
|
bufPtr = buff;
|
||||||
|
addrPtr = (uint16_t)(void*)address;
|
||||||
|
ch = SPM_PAGESIZE / 2;
|
||||||
|
do {
|
||||||
|
uint16_t a;
|
||||||
|
a = *bufPtr++;
|
||||||
|
a |= (*bufPtr++) << 8;
|
||||||
|
__boot_page_fill_short((uint16_t)(void*)addrPtr,a);
|
||||||
|
addrPtr += 2;
|
||||||
|
} while (--ch);
|
||||||
|
|
||||||
|
// Write from programming buffer
|
||||||
|
__boot_page_write_short((uint16_t)(void*)address);
|
||||||
|
boot_spm_busy_wait();
|
||||||
|
|
||||||
|
#if defined(RWWSRE)
|
||||||
|
// Reenable read access to flash
|
||||||
|
boot_rww_enable();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Read memory block mode, length is big endian. */
|
||||||
|
else if(ch == STK_READ_PAGE) {
|
||||||
|
// READ PAGE - we only read flash
|
||||||
|
getch(); /* getlen() */
|
||||||
|
length = getch();
|
||||||
|
getch();
|
||||||
|
|
||||||
|
verifySpace();
|
||||||
|
#ifdef VIRTUAL_BOOT_PARTITION
|
||||||
|
do {
|
||||||
|
// Undo vector patch in bottom page so verify passes
|
||||||
|
if (address == 0) ch=rstVect & 0xff;
|
||||||
|
else if (address == 1) ch=rstVect >> 8;
|
||||||
|
else if (address == 8) ch=wdtVect & 0xff;
|
||||||
|
else if (address == 9) ch=wdtVect >> 8;
|
||||||
|
else ch = pgm_read_byte_near(address);
|
||||||
|
address++;
|
||||||
|
putch(ch);
|
||||||
|
} while (--length);
|
||||||
|
#else
|
||||||
|
#ifdef RAMPZ
|
||||||
|
// Since RAMPZ should already be set, we need to use EPLM directly.
|
||||||
|
// do putch(pgm_read_byte_near(address++));
|
||||||
|
// while (--length);
|
||||||
|
do {
|
||||||
|
uint8_t result;
|
||||||
|
__asm__ ("elpm %0,Z\n":"=r"(result):"z"(address));
|
||||||
|
putch(result);
|
||||||
|
address++;
|
||||||
|
}
|
||||||
|
while (--length);
|
||||||
|
#else
|
||||||
|
do putch(pgm_read_byte_near(address++));
|
||||||
|
while (--length);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get device signature bytes */
|
||||||
|
else if(ch == STK_READ_SIGN) {
|
||||||
|
// READ SIGN - return what Avrdude wants to hear
|
||||||
|
verifySpace();
|
||||||
|
putch(SIGNATURE_0);
|
||||||
|
putch(SIGNATURE_1);
|
||||||
|
putch(SIGNATURE_2);
|
||||||
|
}
|
||||||
|
else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
|
||||||
|
// Adaboot no-wait mod
|
||||||
|
watchdogConfig(WATCHDOG_16MS);
|
||||||
|
verifySpace();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This covers the response to commands like STK_ENTER_PROGMODE
|
||||||
|
verifySpace();
|
||||||
|
}
|
||||||
|
putch(STK_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void putch(char ch) {
|
||||||
|
#ifndef SOFT_UART
|
||||||
|
while (!(UCSR0A & _BV(UDRE0)));
|
||||||
|
UDR0 = ch;
|
||||||
|
#else
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
" com %[ch]\n" // ones complement, carry set
|
||||||
|
" sec\n"
|
||||||
|
"1: brcc 2f\n"
|
||||||
|
" cbi %[uartPort],%[uartBit]\n"
|
||||||
|
" rjmp 3f\n"
|
||||||
|
"2: sbi %[uartPort],%[uartBit]\n"
|
||||||
|
" nop\n"
|
||||||
|
"3: rcall uartDelay\n"
|
||||||
|
" rcall uartDelay\n"
|
||||||
|
" lsr %[ch]\n"
|
||||||
|
" dec %[bitcnt]\n"
|
||||||
|
" brne 1b\n"
|
||||||
|
:
|
||||||
|
:
|
||||||
|
[bitcnt] "d" (10),
|
||||||
|
[ch] "r" (ch),
|
||||||
|
[uartPort] "I" (_SFR_IO_ADDR(UART_PORT)),
|
||||||
|
[uartBit] "I" (UART_TX_BIT)
|
||||||
|
:
|
||||||
|
"r25"
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getch(void) {
|
||||||
|
uint8_t ch;
|
||||||
|
|
||||||
|
#ifdef LED_DATA_FLASH
|
||||||
|
#ifdef __AVR_ATmega8__
|
||||||
|
LED_PORT ^= _BV(LED);
|
||||||
|
#else
|
||||||
|
LED_PIN |= _BV(LED);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"1: sbic %[uartPin],%[uartBit]\n" // Wait for start edge
|
||||||
|
" rjmp 1b\n"
|
||||||
|
" rcall uartDelay\n" // Get to middle of start bit
|
||||||
|
"2: rcall uartDelay\n" // Wait 1 bit period
|
||||||
|
" rcall uartDelay\n" // Wait 1 bit period
|
||||||
|
" clc\n"
|
||||||
|
" sbic %[uartPin],%[uartBit]\n"
|
||||||
|
" sec\n"
|
||||||
|
" dec %[bitCnt]\n"
|
||||||
|
" breq 3f\n"
|
||||||
|
" ror %[ch]\n"
|
||||||
|
" rjmp 2b\n"
|
||||||
|
"3:\n"
|
||||||
|
:
|
||||||
|
[ch] "=r" (ch)
|
||||||
|
:
|
||||||
|
[bitCnt] "d" (9),
|
||||||
|
[uartPin] "I" (_SFR_IO_ADDR(UART_PIN)),
|
||||||
|
[uartBit] "I" (UART_RX_BIT)
|
||||||
|
:
|
||||||
|
"r25"
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
while(!(UCSR0A & _BV(RXC0)))
|
||||||
|
;
|
||||||
|
if (!(UCSR0A & _BV(FE0))) {
|
||||||
|
/*
|
||||||
|
* A Framing Error indicates (probably) that something is talking
|
||||||
|
* to us at the wrong bit rate. Assume that this is because it
|
||||||
|
* expects to be talking to the application, and DON'T reset the
|
||||||
|
* watchdog. This should cause the bootloader to abort and run
|
||||||
|
* the application "soon", if it keeps happening. (Note that we
|
||||||
|
* don't care that an invalid char is returned...)
|
||||||
|
*/
|
||||||
|
watchdogReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = UDR0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_DATA_FLASH
|
||||||
|
#ifdef __AVR_ATmega8__
|
||||||
|
LED_PORT ^= _BV(LED);
|
||||||
|
#else
|
||||||
|
LED_PIN |= _BV(LED);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
// AVR305 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
|
||||||
|
// Adding 3 to numerator simulates nearest rounding for more accurate baud rates
|
||||||
|
#define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6)
|
||||||
|
#if UART_B_VALUE > 255
|
||||||
|
#error Baud rate too slow for soft UART
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void uartDelay() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"ldi r25,%[count]\n"
|
||||||
|
"1:dec r25\n"
|
||||||
|
"brne 1b\n"
|
||||||
|
"ret\n"
|
||||||
|
::[count] "M" (UART_B_VALUE)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void getNch(uint8_t count) {
|
||||||
|
do getch(); while (--count);
|
||||||
|
verifySpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
void verifySpace() {
|
||||||
|
if (getch() != CRC_EOP) {
|
||||||
|
watchdogConfig(WATCHDOG_16MS); // shorten WD timeout
|
||||||
|
while (1) // and busy-loop so that WD causes
|
||||||
|
; // a reset and app start.
|
||||||
|
}
|
||||||
|
putch(STK_INSYNC);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LED_START_FLASHES > 0
|
||||||
|
void flash_led(uint8_t count) {
|
||||||
|
do {
|
||||||
|
TCNT1 = -(F_CPU/(1024*16));
|
||||||
|
TIFR1 = _BV(TOV1);
|
||||||
|
while(!(TIFR1 & _BV(TOV1)));
|
||||||
|
#ifdef __AVR_ATmega8__
|
||||||
|
LED_PORT ^= _BV(LED);
|
||||||
|
#else
|
||||||
|
LED_PIN |= _BV(LED);
|
||||||
|
#endif
|
||||||
|
watchdogReset();
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Watchdog functions. These are only safe with interrupts turned off.
|
||||||
|
void watchdogReset() {
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"wdr\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void watchdogConfig(uint8_t x) {
|
||||||
|
WDTCSR = _BV(WDCE) | _BV(WDE);
|
||||||
|
WDTCSR = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void appStart() {
|
||||||
|
watchdogConfig(WATCHDOG_OFF);
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
#ifdef VIRTUAL_BOOT_PARTITION
|
||||||
|
// Jump to WDT vector
|
||||||
|
"ldi r30,4\n"
|
||||||
|
"clr r31\n"
|
||||||
|
#else
|
||||||
|
// Jump to RST vector
|
||||||
|
"clr r30\n"
|
||||||
|
"clr r31\n"
|
||||||
|
#endif
|
||||||
|
"ijmp\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
:020000021000EC
|
||||||
|
:10FE00000F92CDB7DEB7112484B714BE81FFDFD0C7
|
||||||
|
:10FE100082E08093C00088E18093C10086E08093F7
|
||||||
|
:10FE2000C2008AE28093C4008EE0BBD0209A00E03A
|
||||||
|
:10FE300010E0EE24E394E1E1DE2EF3E0FF2EA5D006
|
||||||
|
:10FE4000813471F4A2D08983B2D08981823809F4D7
|
||||||
|
:10FE50008BC0813811F484E001C083E08FD08BC067
|
||||||
|
:10FE6000823411F484E103C0853419F485E0A7D00D
|
||||||
|
:10FE700082C0853591F489D0A82EBB2486D0082F66
|
||||||
|
:10FE800010E0102F00270A291B29812F881F88279F
|
||||||
|
:10FE9000881F8BBF000F111F6DC0863521F484E0D1
|
||||||
|
:10FEA0008ED080E0DBCF843609F040C06ED06DD0BC
|
||||||
|
:10FEB000C82E6BD080EE0030180718F4F801F7BE9A
|
||||||
|
:10FEC000E895A12C51E0B52E60D0F50181935F013A
|
||||||
|
:10FED000CE16D1F7F0EE00301F0718F0F801F7BE8C
|
||||||
|
:10FEE000E89565D007B600FCFDCFF801A0E0B1E0D1
|
||||||
|
:10FEF0002C9130E011968C91119790E0982F8827E3
|
||||||
|
:10FF0000822B932B12960C01E7BEE89511243296B2
|
||||||
|
:10FF100082E0A030B80761F785E0F80187BFE89577
|
||||||
|
:10FF200007B600FCFDCFD7BEE89525C08437A9F4FD
|
||||||
|
:10FF30002CD02BD0B82E29D03AD0CB2C4801F401AC
|
||||||
|
:10FF400086911CD00894811C911CCA94C1F70F5F44
|
||||||
|
:10FF50001F4FBA940B0D111D0EC0853739F427D0F1
|
||||||
|
:10FF60008EE10CD087E90AD085E078CF813511F495
|
||||||
|
:10FF700088E017D01CD080E101D061CF9091C00003
|
||||||
|
:10FF800095FFFCCF8093C60008958091C00087FF45
|
||||||
|
:10FF9000FCCF8091C00084FD01C0A8958091C6006F
|
||||||
|
:10FFA0000895E0E6F0E098E1908380830895EDDF26
|
||||||
|
:10FFB000803219F088E0F5DFFFCF84E1DFCFCF9307
|
||||||
|
:10FFC000C82FE3DFC150E9F7F2DFCF91089580E059
|
||||||
|
:08FFD000E8DFEE27FF2709948A
|
||||||
|
:040000031000FE00EB
|
||||||
|
:00000001FF
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
|
||||||
|
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
|
||||||
|
#define LED_DDR DDRB
|
||||||
|
#define LED_PORT PORTB
|
||||||
|
#define LED_PIN PINB
|
||||||
|
#define LED PINB5
|
||||||
|
|
||||||
|
/* Ports for soft UART */
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
#define UART_PORT PORTD
|
||||||
|
#define UART_PIN PIND
|
||||||
|
#define UART_DDR DDRD
|
||||||
|
#define UART_TX_BIT 1
|
||||||
|
#define UART_RX_BIT 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega8__)
|
||||||
|
//Name conversion R.Wiersma
|
||||||
|
#define UCSR0A UCSRA
|
||||||
|
#define UDR0 UDR
|
||||||
|
#define UDRE0 UDRE
|
||||||
|
#define RXC0 RXC
|
||||||
|
#define FE0 FE
|
||||||
|
#define TIFR1 TIFR
|
||||||
|
#define WDTCSR WDTCR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Luminet support */
|
||||||
|
#if defined(__AVR_ATtiny84__)
|
||||||
|
/* Red LED is connected to pin PA4 */
|
||||||
|
#define LED_DDR DDRA
|
||||||
|
#define LED_PORT PORTA
|
||||||
|
#define LED_PIN PINA
|
||||||
|
#define LED PINA4
|
||||||
|
/* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
#define UART_PORT PORTA
|
||||||
|
#define UART_PIN PINA
|
||||||
|
#define UART_DDR DDRA
|
||||||
|
#define UART_TX_BIT 2
|
||||||
|
#define UART_RX_BIT 3
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Sanguino support */
|
||||||
|
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||||
|
/* Onboard LED is connected to pin PB0 on Sanguino */
|
||||||
|
#define LED_DDR DDRB
|
||||||
|
#define LED_PORT PORTB
|
||||||
|
#define LED_PIN PINB
|
||||||
|
#define LED PINB0
|
||||||
|
|
||||||
|
/* Ports for soft UART */
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
#define UART_PORT PORTD
|
||||||
|
#define UART_PIN PIND
|
||||||
|
#define UART_DDR DDRD
|
||||||
|
#define UART_TX_BIT 1
|
||||||
|
#define UART_RX_BIT 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Mega support */
|
||||||
|
#if defined(__AVR_ATmega1280__)
|
||||||
|
/* Onboard LED is connected to pin PB7 on Arduino Mega */
|
||||||
|
#define LED_DDR DDRB
|
||||||
|
#define LED_PORT PORTB
|
||||||
|
#define LED_PIN PINB
|
||||||
|
#define LED PINB7
|
||||||
|
|
||||||
|
/* Ports for soft UART */
|
||||||
|
#ifdef SOFT_UART
|
||||||
|
#define UART_PORT PORTE
|
||||||
|
#define UART_PIN PINE
|
||||||
|
#define UART_DDR DDRE
|
||||||
|
#define UART_TX_BIT 1
|
||||||
|
#define UART_RX_BIT 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/* STK500 constants list, from AVRDUDE */
|
||||||
|
#define STK_OK 0x10
|
||||||
|
#define STK_FAILED 0x11 // Not used
|
||||||
|
#define STK_UNKNOWN 0x12 // Not used
|
||||||
|
#define STK_NODEVICE 0x13 // Not used
|
||||||
|
#define STK_INSYNC 0x14 // ' '
|
||||||
|
#define STK_NOSYNC 0x15 // Not used
|
||||||
|
#define ADC_CHANNEL_ERROR 0x16 // Not used
|
||||||
|
#define ADC_MEASURE_OK 0x17 // Not used
|
||||||
|
#define PWM_CHANNEL_ERROR 0x18 // Not used
|
||||||
|
#define PWM_ADJUST_OK 0x19 // Not used
|
||||||
|
#define CRC_EOP 0x20 // 'SPACE'
|
||||||
|
#define STK_GET_SYNC 0x30 // '0'
|
||||||
|
#define STK_GET_SIGN_ON 0x31 // '1'
|
||||||
|
#define STK_SET_PARAMETER 0x40 // '@'
|
||||||
|
#define STK_GET_PARAMETER 0x41 // 'A'
|
||||||
|
#define STK_SET_DEVICE 0x42 // 'B'
|
||||||
|
#define STK_SET_DEVICE_EXT 0x45 // 'E'
|
||||||
|
#define STK_ENTER_PROGMODE 0x50 // 'P'
|
||||||
|
#define STK_LEAVE_PROGMODE 0x51 // 'Q'
|
||||||
|
#define STK_CHIP_ERASE 0x52 // 'R'
|
||||||
|
#define STK_CHECK_AUTOINC 0x53 // 'S'
|
||||||
|
#define STK_LOAD_ADDRESS 0x55 // 'U'
|
||||||
|
#define STK_UNIVERSAL 0x56 // 'V'
|
||||||
|
#define STK_PROG_FLASH 0x60 // '`'
|
||||||
|
#define STK_PROG_DATA 0x61 // 'a'
|
||||||
|
#define STK_PROG_FUSE 0x62 // 'b'
|
||||||
|
#define STK_PROG_LOCK 0x63 // 'c'
|
||||||
|
#define STK_PROG_PAGE 0x64 // 'd'
|
||||||
|
#define STK_PROG_FUSE_EXT 0x65 // 'e'
|
||||||
|
#define STK_READ_FLASH 0x70 // 'p'
|
||||||
|
#define STK_READ_DATA 0x71 // 'q'
|
||||||
|
#define STK_READ_FUSE 0x72 // 'r'
|
||||||
|
#define STK_READ_LOCK 0x73 // 's'
|
||||||
|
#define STK_READ_PAGE 0x74 // 't'
|
||||||
|
#define STK_READ_SIGN 0x75 // 'u'
|
||||||
|
#define STK_READ_OSCCAL 0x76 // 'v'
|
||||||
|
#define STK_READ_FUSE_EXT 0x77 // 'w'
|
||||||
|
#define STK_READ_OSCCAL_EXT 0x78 // 'x'
|
||||||
@@ -0,0 +1,713 @@
|
|||||||
|
/**********************************************************/
|
||||||
|
/* Serial Bootloader for Atmel megaAVR Controllers */
|
||||||
|
/* */
|
||||||
|
/* tested with ATmega644 and ATmega644P */
|
||||||
|
/* should work with other mega's, see code for details */
|
||||||
|
/* */
|
||||||
|
/* ATmegaBOOT.c */
|
||||||
|
/* */
|
||||||
|
/* 20090131: Added 324P support from Alex Leone */
|
||||||
|
/* Marius Kintel */
|
||||||
|
/* 20080915: applied ADABoot mods for Sanguino 644P */
|
||||||
|
/* Brian Riley */
|
||||||
|
/* 20080711: hacked for Sanguino by Zach Smith */
|
||||||
|
/* and Justin Day */
|
||||||
|
/* 20070626: hacked for Arduino Diecimila (which auto- */
|
||||||
|
/* resets when a USB connection is made to it) */
|
||||||
|
/* by D. Mellis */
|
||||||
|
/* 20060802: hacked for Arduino by D. Cuartielles */
|
||||||
|
/* based on a previous hack by D. Mellis */
|
||||||
|
/* and D. Cuartielles */
|
||||||
|
/* */
|
||||||
|
/* Monitor and debug functions were added to the original */
|
||||||
|
/* code by Dr. Erik Lins, chip45.com. (See below) */
|
||||||
|
/* */
|
||||||
|
/* Thanks to Karl Pitrich for fixing a bootloader pin */
|
||||||
|
/* problem and more informative LED blinking! */
|
||||||
|
/* */
|
||||||
|
/* For the latest version see: */
|
||||||
|
/* http://www.chip45.com/ */
|
||||||
|
/* */
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
/* */
|
||||||
|
/* based on stk500boot.c */
|
||||||
|
/* Copyright (c) 2003, Jason P. Kyle */
|
||||||
|
/* All rights reserved. */
|
||||||
|
/* see avr1.org for original file and information */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it */
|
||||||
|
/* and/or modify it under the terms of the GNU General */
|
||||||
|
/* Public License as published by the Free Software */
|
||||||
|
/* Foundation; either version 2 of the License, or */
|
||||||
|
/* (at your option) any later version. */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will */
|
||||||
|
/* be useful, but WITHOUT ANY WARRANTY; without even the */
|
||||||
|
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
|
||||||
|
/* PARTICULAR PURPOSE. See the GNU General Public */
|
||||||
|
/* License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General */
|
||||||
|
/* Public License along with this program; if not, write */
|
||||||
|
/* to the Free Software Foundation, Inc., */
|
||||||
|
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
/* */
|
||||||
|
/* Licence can be viewed at */
|
||||||
|
/* http://www.fsf.org/licenses/gpl.txt */
|
||||||
|
/* */
|
||||||
|
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
|
||||||
|
/* m8515,m8535. ATmega161 has a very small boot block so */
|
||||||
|
/* isn't supported. */
|
||||||
|
/* */
|
||||||
|
/* Tested with m168 */
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
|
/* some includes */
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/boot.h>
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
#define NUM_LED_FLASHES 3
|
||||||
|
#define ADABOOT_VER 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
|
||||||
|
#define MAX_ERROR_COUNT 5
|
||||||
|
|
||||||
|
/* set the UART baud rate */
|
||||||
|
/* 20080711: hack by Zach Hoeken */
|
||||||
|
#define BAUD_RATE 38400
|
||||||
|
|
||||||
|
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
|
||||||
|
/* never allow AVR Studio to do an update !!!! */
|
||||||
|
#define HW_VER 0x02
|
||||||
|
#define SW_MAJOR 0x01
|
||||||
|
#define SW_MINOR 0x10
|
||||||
|
|
||||||
|
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
|
||||||
|
/* if monitor functions are included, LED goes on after monitor was entered */
|
||||||
|
#define LED_DDR DDRB
|
||||||
|
#define LED_PORT PORTB
|
||||||
|
#define LED_PIN PINB
|
||||||
|
#define LED PINB0
|
||||||
|
|
||||||
|
/* define various device id's */
|
||||||
|
/* manufacturer byte is always the same */
|
||||||
|
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :(
|
||||||
|
#if defined(__AVR_ATmega644P__)
|
||||||
|
#define SIG2 0x96
|
||||||
|
#define SIG3 0x0A
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
#define SIG2 0x96
|
||||||
|
#define SIG3 0x09
|
||||||
|
#elif defined(__AVR_ATmega324P__)
|
||||||
|
#define SIG2 0x95
|
||||||
|
#define SIG3 0x08
|
||||||
|
#endif
|
||||||
|
#define PAGE_SIZE 0x080U //128 words
|
||||||
|
#define PAGE_SIZE_BYTES 0x100U //256 bytes
|
||||||
|
|
||||||
|
/* function prototypes */
|
||||||
|
void putch(char);
|
||||||
|
char getch(void);
|
||||||
|
void getNch(uint8_t);
|
||||||
|
void byte_response(uint8_t);
|
||||||
|
void nothing_response(void);
|
||||||
|
char gethex(void);
|
||||||
|
void puthex(char);
|
||||||
|
void flash_led(uint8_t);
|
||||||
|
|
||||||
|
/* some variables */
|
||||||
|
union address_union
|
||||||
|
{
|
||||||
|
uint16_t word;
|
||||||
|
uint8_t byte[2];
|
||||||
|
} address;
|
||||||
|
|
||||||
|
union length_union
|
||||||
|
{
|
||||||
|
uint16_t word;
|
||||||
|
uint8_t byte[2];
|
||||||
|
} length;
|
||||||
|
|
||||||
|
struct flags_struct
|
||||||
|
{
|
||||||
|
unsigned eeprom : 1;
|
||||||
|
unsigned rampz : 1;
|
||||||
|
} flags;
|
||||||
|
|
||||||
|
uint8_t buff[256];
|
||||||
|
|
||||||
|
uint8_t error_count = 0;
|
||||||
|
uint8_t sreg;
|
||||||
|
|
||||||
|
void (*app_start)(void) = 0x0000;
|
||||||
|
|
||||||
|
/* main program starts here */
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint8_t ch,ch2;
|
||||||
|
uint16_t w;
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
|
asm volatile("nop\n\t");
|
||||||
|
|
||||||
|
#ifdef ADABOOT // BBR/LF 10/8/2007 & 9/13/2008
|
||||||
|
ch = MCUSR;
|
||||||
|
MCUSR = 0;
|
||||||
|
|
||||||
|
WDTCSR |= _BV(WDCE) | _BV(WDE);
|
||||||
|
WDTCSR = 0;
|
||||||
|
|
||||||
|
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
|
||||||
|
if (! (ch & _BV(EXTRF))) // if it's a not an external reset...
|
||||||
|
app_start(); // skip bootloader
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//initialize our serial port.
|
||||||
|
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||||
|
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||||
|
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
|
||||||
|
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
|
||||||
|
|
||||||
|
/* Enable internal pull-up resistor on pin D0 (RX), in order
|
||||||
|
to supress line noise that prevents the bootloader from
|
||||||
|
timing out (DAM: 20070509) */
|
||||||
|
DDRD &= ~_BV(PIND0);
|
||||||
|
PORTD |= _BV(PIND0);
|
||||||
|
|
||||||
|
/* set LED pin as output */
|
||||||
|
LED_DDR |= _BV(LED);
|
||||||
|
|
||||||
|
/* flash onboard LED to signal entering of bootloader */
|
||||||
|
/* ADABOOT will do two series of flashes. first 4 - signifying ADABOOT */
|
||||||
|
/* then a pause and another flash series signifying ADABOOT sub-version */
|
||||||
|
|
||||||
|
|
||||||
|
flash_led(NUM_LED_FLASHES);
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
flash_led(ADABOOT_VER); // BBR 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* forever loop */
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
/* get character from UART */
|
||||||
|
ch = getch();
|
||||||
|
|
||||||
|
/* A bunch of if...else if... gives smaller code than switch...case ! */
|
||||||
|
|
||||||
|
/* Hello is anyone home ? */
|
||||||
|
if(ch=='0')
|
||||||
|
nothing_response();
|
||||||
|
|
||||||
|
|
||||||
|
/* Request programmer ID */
|
||||||
|
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */
|
||||||
|
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */
|
||||||
|
else if(ch=='1')
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch('A');
|
||||||
|
putch('V');
|
||||||
|
putch('R');
|
||||||
|
putch(' ');
|
||||||
|
putch('I');
|
||||||
|
putch('S');
|
||||||
|
putch('P');
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */
|
||||||
|
else if(ch=='@')
|
||||||
|
{
|
||||||
|
ch2 = getch();
|
||||||
|
if (ch2 > 0x85)
|
||||||
|
getch();
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* AVR ISP/STK500 board requests */
|
||||||
|
else if(ch=='A')
|
||||||
|
{
|
||||||
|
ch2 = getch();
|
||||||
|
if(ch2 == 0x80)
|
||||||
|
byte_response(HW_VER); // Hardware version
|
||||||
|
else if(ch2==0x81)
|
||||||
|
byte_response(SW_MAJOR); // Software major version
|
||||||
|
else if(ch2==0x82)
|
||||||
|
byte_response(SW_MINOR); // Software minor version
|
||||||
|
else if(ch2==0x98)
|
||||||
|
byte_response(0x03); // Unknown but seems to be required by avr studio 3.56
|
||||||
|
else
|
||||||
|
byte_response(0x00); // Covers various unnecessary responses we don't care about
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Device Parameters DON'T CARE, DEVICE IS FIXED */
|
||||||
|
else if(ch=='B')
|
||||||
|
{
|
||||||
|
getNch(20);
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Parallel programming stuff DON'T CARE */
|
||||||
|
else if(ch=='E')
|
||||||
|
{
|
||||||
|
getNch(5);
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Enter programming mode */
|
||||||
|
else if(ch=='P')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Leave programming mode */
|
||||||
|
else if(ch=='Q')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
#ifdef ADABOOT
|
||||||
|
// autoreset via watchdog (sneaky!) BBR/LF 9/13/2008
|
||||||
|
WDTCSR = _BV(WDE);
|
||||||
|
while (1); // 16 ms
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Erase device, don't care as we will erase one page at a time anyway. */
|
||||||
|
else if(ch=='R')
|
||||||
|
{
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set address, little endian. EEPROM in bytes, FLASH in words */
|
||||||
|
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */
|
||||||
|
/* This might explain why little endian was used here, big endian used everywhere else. */
|
||||||
|
else if(ch=='U')
|
||||||
|
{
|
||||||
|
address.byte[0] = getch();
|
||||||
|
address.byte[1] = getch();
|
||||||
|
nothing_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */
|
||||||
|
else if(ch=='V')
|
||||||
|
{
|
||||||
|
getNch(4);
|
||||||
|
byte_response(0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Write memory, length is big endian and is in bytes */
|
||||||
|
else if(ch=='d')
|
||||||
|
{
|
||||||
|
length.byte[1] = getch();
|
||||||
|
length.byte[0] = getch();
|
||||||
|
|
||||||
|
flags.eeprom = 0;
|
||||||
|
if (getch() == 'E')
|
||||||
|
flags.eeprom = 1;
|
||||||
|
|
||||||
|
for (i=0; i<PAGE_SIZE; i++)
|
||||||
|
buff[i] = 0;
|
||||||
|
|
||||||
|
for (w = 0; w < length.word; w++)
|
||||||
|
{
|
||||||
|
// Store data in buffer, can't keep up with serial data stream whilst programming pages
|
||||||
|
buff[w] = getch();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
if (flags.eeprom)
|
||||||
|
{
|
||||||
|
//Write to EEPROM one byte at a time
|
||||||
|
for(w=0;w<length.word;w++)
|
||||||
|
{
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
|
||||||
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
|
EEDR = buff[w];
|
||||||
|
EECR |= (1<<EEMPE);
|
||||||
|
EECR |= (1<<EEPE);
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//address * 2 -> byte location
|
||||||
|
address.word = address.word << 1;
|
||||||
|
|
||||||
|
//Even up an odd number of bytes
|
||||||
|
if ((length.byte[0] & 0x01))
|
||||||
|
length.word++;
|
||||||
|
|
||||||
|
// HACKME: EEPE used to be EEWE
|
||||||
|
//Wait for previous EEPROM writes to complete
|
||||||
|
//while(bit_is_set(EECR,EEPE));
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
|
||||||
|
asm volatile(
|
||||||
|
"clr r17 \n\t" //page_word_count
|
||||||
|
"lds r30,address \n\t" //Address of FLASH location (in bytes)
|
||||||
|
"lds r31,address+1 \n\t"
|
||||||
|
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM
|
||||||
|
"ldi r29,hi8(buff) \n\t"
|
||||||
|
"lds r24,length \n\t" //Length of data to be written (in bytes)
|
||||||
|
"lds r25,length+1 \n\t"
|
||||||
|
"length_loop: \n\t" //Main loop, repeat for number of words in block
|
||||||
|
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page
|
||||||
|
"brne no_page_erase \n\t"
|
||||||
|
"wait_spm1: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm1 \n\t"
|
||||||
|
"ldi r16,0x03 \n\t" //Erase page pointed to by Z
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"wait_spm2: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm2 \n\t"
|
||||||
|
|
||||||
|
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"no_page_erase: \n\t"
|
||||||
|
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer
|
||||||
|
"ld r1,Y+ \n\t"
|
||||||
|
|
||||||
|
"wait_spm3: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm3 \n\t"
|
||||||
|
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
|
||||||
|
"inc r17 \n\t" //page_word_count++
|
||||||
|
"cpi r17,%1 \n\t"
|
||||||
|
"brlo same_page \n\t" //Still same page in FLASH
|
||||||
|
"write_page: \n\t"
|
||||||
|
"clr r17 \n\t" //New page, write current one first
|
||||||
|
"wait_spm4: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm4 \n\t"
|
||||||
|
"ldi r16,0x05 \n\t" //Write page pointed to by Z
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"wait_spm5: \n\t"
|
||||||
|
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||||
|
"andi r16,1 \n\t"
|
||||||
|
"cpi r16,1 \n\t"
|
||||||
|
"breq wait_spm5 \n\t"
|
||||||
|
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||||
|
"sts %0,r16 \n\t"
|
||||||
|
"spm \n\t"
|
||||||
|
"same_page: \n\t"
|
||||||
|
"adiw r30,2 \n\t" //Next word in FLASH
|
||||||
|
"sbiw r24,2 \n\t" //length-2
|
||||||
|
"breq final_write \n\t" //Finished
|
||||||
|
"rjmp length_loop \n\t"
|
||||||
|
"final_write: \n\t"
|
||||||
|
"cpi r17,0 \n\t"
|
||||||
|
"breq block_done \n\t"
|
||||||
|
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write
|
||||||
|
"rjmp write_page \n\t"
|
||||||
|
"block_done: \n\t"
|
||||||
|
"clr __zero_reg__ \n\t" //restore zero register
|
||||||
|
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
putch(0x14);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read memory block mode, length is big endian. */
|
||||||
|
else if(ch=='t')
|
||||||
|
{
|
||||||
|
length.byte[1] = getch();
|
||||||
|
length.byte[0] = getch();
|
||||||
|
|
||||||
|
if (getch() == 'E')
|
||||||
|
flags.eeprom = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flags.eeprom = 0;
|
||||||
|
address.word = address.word << 1; // address * 2 -> byte location
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command terminator
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
for (w=0; w<length.word; w++)
|
||||||
|
{
|
||||||
|
// Can handle odd and even lengths okay
|
||||||
|
if (flags.eeprom)
|
||||||
|
{
|
||||||
|
// Byte access EEPROM read
|
||||||
|
while(EECR & (1<<EEPE));
|
||||||
|
EEAR = (uint16_t)(void *)address.word;
|
||||||
|
EECR |= (1<<EERE);
|
||||||
|
putch(EEDR);
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!flags.rampz)
|
||||||
|
putch(pgm_read_byte_near(address.word));
|
||||||
|
|
||||||
|
address.word++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Get device signature bytes */
|
||||||
|
else if(ch=='u')
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(SIG1);
|
||||||
|
putch(SIG2);
|
||||||
|
putch(SIG3);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Read oscillator calibration byte */
|
||||||
|
else if(ch=='v')
|
||||||
|
byte_response(0x00);
|
||||||
|
|
||||||
|
else if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
|
||||||
|
}
|
||||||
|
/* end of forever loop */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char gethex(void)
|
||||||
|
{
|
||||||
|
char ah,al;
|
||||||
|
|
||||||
|
ah = getch();
|
||||||
|
putch(ah);
|
||||||
|
al = getch();
|
||||||
|
putch(al);
|
||||||
|
|
||||||
|
if(ah >= 'a')
|
||||||
|
ah = ah - 'a' + 0x0a;
|
||||||
|
else if(ah >= '0')
|
||||||
|
ah -= '0';
|
||||||
|
if(al >= 'a')
|
||||||
|
al = al - 'a' + 0x0a;
|
||||||
|
else if(al >= '0')
|
||||||
|
al -= '0';
|
||||||
|
|
||||||
|
return (ah << 4) + al;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void puthex(char ch)
|
||||||
|
{
|
||||||
|
char ah,al;
|
||||||
|
|
||||||
|
ah = (ch & 0xf0) >> 4;
|
||||||
|
if(ah >= 0x0a)
|
||||||
|
ah = ah - 0x0a + 'a';
|
||||||
|
else
|
||||||
|
ah += '0';
|
||||||
|
|
||||||
|
al = (ch & 0x0f);
|
||||||
|
if(al >= 0x0a)
|
||||||
|
al = al - 0x0a + 'a';
|
||||||
|
else
|
||||||
|
al += '0';
|
||||||
|
|
||||||
|
putch(ah);
|
||||||
|
putch(al);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void putch(char ch)
|
||||||
|
{
|
||||||
|
while (!(UCSR0A & _BV(UDRE0)));
|
||||||
|
UDR0 = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char getch(void)
|
||||||
|
{
|
||||||
|
uint32_t count = 0;
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
LED_PORT &= ~_BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while(!(UCSR0A & _BV(RXC0)))
|
||||||
|
{
|
||||||
|
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||||
|
/* HACKME:: here is a good place to count times*/
|
||||||
|
count++;
|
||||||
|
if (count > MAX_TIME_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
LED_PORT |= _BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return UDR0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void getNch(uint8_t count)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for(i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
while(!(UCSR0A & _BV(RXC0)));
|
||||||
|
UDR0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void byte_response(uint8_t val)
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(val);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nothing_response(void)
|
||||||
|
{
|
||||||
|
if (getch() == ' ')
|
||||||
|
{
|
||||||
|
putch(0x14);
|
||||||
|
putch(0x10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (++error_count == MAX_ERROR_COUNT)
|
||||||
|
app_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ADABOOT
|
||||||
|
|
||||||
|
void flash_led(uint8_t count)
|
||||||
|
{
|
||||||
|
/* flash onboard LED count times to signal entering of bootloader */
|
||||||
|
/* l needs to be volatile or the delay loops below might get */
|
||||||
|
/* optimized away if compiling with optimizations (DAM). */
|
||||||
|
|
||||||
|
volatile uint32_t l;
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
count = ADABOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int8_t i;
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
LED_PORT |= _BV(LED); // LED on
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l); // delay NGvalue was 1000 for both loops - BBR
|
||||||
|
LED_PORT &= ~_BV(LED); // LED off
|
||||||
|
for(l = 0; l < (F_CPU / 250); ++l); // delay asymmteric for ADA BOOT BBR
|
||||||
|
}
|
||||||
|
|
||||||
|
for(l = 0; l < (F_CPU / 100); ++l); // pause ADA BOOT BBR
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void flash_led(uint8_t count)
|
||||||
|
{
|
||||||
|
/* flash onboard LED three times to signal entering of bootloader */
|
||||||
|
/* l needs to be volatile or the delay loops below might get
|
||||||
|
optimized away if compiling with optimizations (DAM). */
|
||||||
|
volatile uint32_t l;
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
count = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t i;
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
LED_PORT |= _BV(LED);
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l);
|
||||||
|
LED_PORT &= ~_BV(LED);
|
||||||
|
for(l = 0; l < (F_CPU / 1000); ++l);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* end of file ATmegaBOOT.c */
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
|
||||||
|
:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
|
||||||
|
:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
|
||||||
|
:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
|
||||||
|
:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
|
||||||
|
:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
|
||||||
|
:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
|
||||||
|
:10F870000C945B7C0C945B7C0C945B7C11241FBE11
|
||||||
|
:10F88000CFEFD8E0DEBFCDBF11E0A0E0B1E0E6E60B
|
||||||
|
:10F89000FFEF02C005900D92A030B107D9F712E03A
|
||||||
|
:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
|
||||||
|
:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
|
||||||
|
:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
|
||||||
|
:10F8D00009F481E020E0482F55274115510509F42E
|
||||||
|
:10F8E0003DC0289A19821A821B821C820BC0898112
|
||||||
|
:10F8F0009A81AB81BC810196A11DB11D89839A8338
|
||||||
|
:10F90000AB83BC8389819A81AB81BC8180589E4343
|
||||||
|
:10F91000A040B04060F3289819821A821B821C8292
|
||||||
|
:10F920000BC089819A81AB81BC810196A11DB11D5B
|
||||||
|
:10F9300089839A83AB83BC8389819A81AB81BC81A3
|
||||||
|
:10F9400080509A4FA040B04060F32F5F822F9927DC
|
||||||
|
:10F9500087FD9095841795070CF4C3CF19821A82FE
|
||||||
|
:10F960001B821C8289819A81AB81BC818050914726
|
||||||
|
:10F97000A240B040A0F489819A81AB81BC810196FC
|
||||||
|
:10F98000A11DB11D89839A83AB83BC8389819A8130
|
||||||
|
:10F99000AB81BC8180509147A240B04060F3249677
|
||||||
|
:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
|
||||||
|
:10F9B000EF92FF920F931F93EE24FF248701289864
|
||||||
|
:10F9C0008091C00087FD17C00894E11CF11C011D47
|
||||||
|
:10F9D000111D81E0E81689E0F8068DE3080780E054
|
||||||
|
:10F9E000180770F3E0910001F091010109958091F1
|
||||||
|
:10F9F000C00087FFE9CF289A8091C600992787FD2C
|
||||||
|
:10FA000090951F910F91FF90EF900895982F8091FE
|
||||||
|
:10FA1000C00085FFFCCF9093C60008950E94D87C5B
|
||||||
|
:10FA2000803271F0809102018F5F809302018530F6
|
||||||
|
:10FA300009F00895E0910001F09101010995089500
|
||||||
|
:10FA400084E10E94067D80E10E94067D0895CF93A7
|
||||||
|
:10FA5000C82F0E94D87C803241F0809102018F5FD4
|
||||||
|
:10FA600080930201853081F40AC084E10E94067D02
|
||||||
|
:10FA70008C2F0E94067D80E10E94067D05C0E091EA
|
||||||
|
:10FA80000001F09101010995CF910895282F90E090
|
||||||
|
:10FA900007C08091C0008823E4F78091C6009F5F73
|
||||||
|
:10FAA0009217B8F30895CFEFD8E0DEBFCDBF0000C6
|
||||||
|
:10FAB00094B714BE809160008861809360001092BA
|
||||||
|
:10FAC000600091FF74C189E18093C4001092C50069
|
||||||
|
:10FAD00088E18093C10086E08093C2005098589AD4
|
||||||
|
:10FAE000209A83E00E945D7C81E00E945D7C0E9400
|
||||||
|
:10FAF000D87C8033B9F18133C1F1803409F456C028
|
||||||
|
:10FB0000813409F45CC0823409F46EC0853409F490
|
||||||
|
:10FB100071C0803539F1813509F4F3C0823511F1B6
|
||||||
|
:10FB2000853509F4D3C0863509F4CBC0843609F491
|
||||||
|
:10FB300065C0843709F4EBC0853709F4D2C0863735
|
||||||
|
:10FB400009F44AC0809102018F5F809302018530E1
|
||||||
|
:10FB500071F6E0910001F091010109950E94D87CB5
|
||||||
|
:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
|
||||||
|
:10FB7000803241F784E10E94067D81E40E94067D87
|
||||||
|
:10FB800086E50E94067D82E50E94067D8C2F0E94FC
|
||||||
|
:10FB9000067D89E40E94067D83E50E94067D80E55E
|
||||||
|
:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
|
||||||
|
:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
|
||||||
|
:10FBC000D87C803809F407C1813809F400C1823833
|
||||||
|
:10FBD00009F4F9C0883921F080E00E94277D87CFA1
|
||||||
|
:10FBE00083E00E94277D83CF84E10E94467D0E94AE
|
||||||
|
:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
|
||||||
|
:10FC0000809306020E94D87C8093050280910802AE
|
||||||
|
:10FC10008E7F809308020E94D87C853409F44BC003
|
||||||
|
:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
|
||||||
|
:10FC3000C0E0D0E0809105029091060218161906E6
|
||||||
|
:10FC400078F405E011E00E94D87CF80181938F01DF
|
||||||
|
:10FC500021968091050290910602C817D90798F362
|
||||||
|
:10FC60000E94D87C803209F06DCF8091080280FF1D
|
||||||
|
:10FC7000B6C0C0E0D0E02091050230910602121615
|
||||||
|
:10FC80001306B8F4E0910301F0910401A5E0B1E09E
|
||||||
|
:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
|
||||||
|
:10FCA00031962196C217D30798F3F0930401E0939D
|
||||||
|
:10FCB000030184E175CF809108028160809308027E
|
||||||
|
:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
|
||||||
|
:10FCD000809303010E94D87C809304010E940E7DD2
|
||||||
|
:10FCE00006CF0E94D87C803209F02CCF84E10E949C
|
||||||
|
:10FCF000067D8EE10E94067D85E90E94067D88E0F2
|
||||||
|
:10FD00004FCF0E940E7D88E080936000FFCF0E945D
|
||||||
|
:10FD1000D87C809306020E94D87C809305020E94C2
|
||||||
|
:10FD2000D87C853409F449C0809108028E7F809385
|
||||||
|
:10FD300008028091030190910401880F991F90930C
|
||||||
|
:10FD40000401809303010E94D87C803209F0CFCE59
|
||||||
|
:10FD500084E10E94067DC0E0D0E020910502309150
|
||||||
|
:10FD600006021216130608F01DCFE0910301F09170
|
||||||
|
:10FD700004018091080280FF96C0F999FECFF2BD80
|
||||||
|
:10FD8000E1BDF89A80B50E94067DE0910301F091F3
|
||||||
|
:10FD900004013196F0930401E093030120910502E0
|
||||||
|
:10FDA000309106022196C217D30718F3FBCEE091DB
|
||||||
|
:10FDB0000001F0910101099586CE809108028160D1
|
||||||
|
:10FDC00080930802C0CF80E10E94277D90CE81E021
|
||||||
|
:10FDD0000E94277D8CCE82E00E94277D88CE809174
|
||||||
|
:10FDE000030190910401880F991F9093040180935F
|
||||||
|
:10FDF00003018091050280FF09C080910502909166
|
||||||
|
:10FE0000060201969093060280930502F999FECFAF
|
||||||
|
:10FE10001127E0910301F0910401C5E0D1E0809148
|
||||||
|
:10FE2000050290910602103091F400915700017084
|
||||||
|
:10FE30000130D9F303E000935700E8950091570093
|
||||||
|
:10FE400001700130D9F301E100935700E895099062
|
||||||
|
:10FE500019900091570001700130D9F301E000932F
|
||||||
|
:10FE60005700E8951395103898F011270091570026
|
||||||
|
:10FE700001700130D9F305E000935700E895009137
|
||||||
|
:10FE8000570001700130D9F301E100935700E89564
|
||||||
|
:10FE90003296029709F0C7CF103011F00296E5CFE5
|
||||||
|
:10FEA000112484E17DCE869580FF06C03196F093C3
|
||||||
|
:10FEB0000401E093030176CF84910E94067D209196
|
||||||
|
:10FEC000050230910602E0910301F0910401EECFAA
|
||||||
|
:10FED0001F93CF930E94D87CC82F0E94067D0E945A
|
||||||
|
:10FEE000D87C182F0E94067DC1362CF0C7551136DC
|
||||||
|
:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
|
||||||
|
:10FF000010330CF01053C295C07FC10F8C2F99276E
|
||||||
|
:10FF100087FD9095CF911F910895CF93282F992712
|
||||||
|
:10FF200087FD9095807F907095958795959587959D
|
||||||
|
:10FF300095958795959587958A303CF0895AC22F7B
|
||||||
|
:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
|
||||||
|
:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
|
||||||
|
:06FF6000CF910895FFCFD0
|
||||||
|
:040000030000F80001
|
||||||
|
:00000001FF
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
:10F800000C94387C0C94557C0C94557C0C94557C51
|
||||||
|
:10F810000C94557C0C94557C0C94557C0C94557C24
|
||||||
|
:10F820000C94557C0C94557C0C94557C0C94557C14
|
||||||
|
:10F830000C94557C0C94557C0C94557C0C94557C04
|
||||||
|
:10F840000C94557C0C94557C0C94557C0C94557CF4
|
||||||
|
:10F850000C94557C0C94557C0C94557C0C94557CE4
|
||||||
|
:10F860000C94557C0C94557C0C94557C0C94557CD4
|
||||||
|
:10F8700011241FBECFEFD0E1DEBFCDBF11E0A0E06D
|
||||||
|
:10F88000B1E0EAE5FFEF02C005900D92A030B107AC
|
||||||
|
:10F89000D9F712E0A0E0B1E001C01D92A930B10794
|
||||||
|
:10F8A000E1F70E944D7D0C94AC7F0C94007CCF93CB
|
||||||
|
:10F8B000DF93CDB7DEB724970FB6F894DEBF0FBE47
|
||||||
|
:10F8C000CDBF882309F481E020E0482F552741155A
|
||||||
|
:10F8D000510509F43DC0289A19821A821B821C82A4
|
||||||
|
:10F8E0000BC089819A81AB81BC810196A11DB11D9C
|
||||||
|
:10F8F00089839A83AB83BC8389819A81AB81BC81E4
|
||||||
|
:10F9000080589E43A040B04060F3289819821A8224
|
||||||
|
:10F910001B821C820BC089819A81AB81BC810196BC
|
||||||
|
:10F92000A11DB11D89839A83AB83BC8389819A8190
|
||||||
|
:10F93000AB81BC8180509A4FA040B04060F32F5FF4
|
||||||
|
:10F94000822F992787FD9095841795070CF4C3CFD4
|
||||||
|
:10F9500019821A821B821C8289819A81AB81BC81A7
|
||||||
|
:10F9600080509147A240B040A0F489819A81AB8138
|
||||||
|
:10F97000BC810196A11DB11D89839A83AB83BC8391
|
||||||
|
:10F9800089819A81AB81BC8180509147A240B0406F
|
||||||
|
:10F9900060F324960FB6F894DEBF0FBECDBFDF91A3
|
||||||
|
:10F9A000CF910895EF92FF920F931F93EE24FF24BF
|
||||||
|
:10F9B000870128988091C00087FD17C00894E11C3A
|
||||||
|
:10F9C000F11C011D111D81E0E81689E0F8068DE3A8
|
||||||
|
:10F9D000080780E0180770F3E0910001F091010141
|
||||||
|
:10F9E00009958091C00087FFE9CF289A8091C600D1
|
||||||
|
:10F9F000992787FD90951F910F91FF90EF900895A3
|
||||||
|
:10FA0000982F8091C00085FFFCCF9093C600089589
|
||||||
|
:10FA10000E94D27C803271F0809102018F5F8093CE
|
||||||
|
:10FA20000201853009F00895E0910001F091010193
|
||||||
|
:10FA30000995089584E10E94007D80E10E94007D87
|
||||||
|
:10FA40000895CF93C82F0E94D27C803241F08091DC
|
||||||
|
:10FA500002018F5F80930201853081F40AC084E146
|
||||||
|
:10FA60000E94007D8C2F0E94007D80E10E94007D1D
|
||||||
|
:10FA700005C0E0910001F09101010995CF91089531
|
||||||
|
:10FA8000282F90E007C08091C0008823E4F7809180
|
||||||
|
:10FA9000C6009F5F9217B8F30895CFEFD0E1DEBFA5
|
||||||
|
:10FAA000CDBF000094B714BE809160008861809340
|
||||||
|
:10FAB00060001092600091FF74C189E18093C400DE
|
||||||
|
:10FAC0001092C50088E18093C10086E08093C20057
|
||||||
|
:10FAD0005098589A209A83E00E94577C81E00E94B7
|
||||||
|
:10FAE000577C0E94D27C8033B9F18133C1F18034DC
|
||||||
|
:10FAF00009F456C0813409F45CC0823409F46EC044
|
||||||
|
:10FB0000853409F471C0803539F1813509F4F3C0C9
|
||||||
|
:10FB1000823511F1853509F4D3C0863509F4CBC09F
|
||||||
|
:10FB2000843609F465C0843709F4EBC0853709F4DD
|
||||||
|
:10FB3000D2C0863709F44AC0809102018F5F80935A
|
||||||
|
:10FB40000201853071F6E0910001F0910101099503
|
||||||
|
:10FB50000E94D27C803349F60E94087DC2CF0E9469
|
||||||
|
:10FB6000D27CC82F803241F784E10E94007D81E47D
|
||||||
|
:10FB70000E94007D86E50E94007D82E50E94007D56
|
||||||
|
:10FB80008C2F0E94007D89E40E94007D83E50E9405
|
||||||
|
:10FB9000007D80E50E94007D80E10E94007DA1CF74
|
||||||
|
:10FBA0000E94D27C8638C0F20E94D27C0E94087DDE
|
||||||
|
:10FBB00098CF0E94D27C803809F407C1813809F4BB
|
||||||
|
:10FBC00000C1823809F4F9C0883921F080E00E9430
|
||||||
|
:10FBD000217D87CF83E00E94217D83CF84E10E9435
|
||||||
|
:10FBE000407D0E94087D7DCF85E00E94407DF9CF59
|
||||||
|
:10FBF0000E94D27C809306020E94D27C80930502F0
|
||||||
|
:10FC0000809108028E7F809308020E94D27C853406
|
||||||
|
:10FC100009F44BC0E5E0F1E0119281E0E438F80727
|
||||||
|
:10FC2000D9F3D0F3C0E0D0E08091050290910602B4
|
||||||
|
:10FC30001816190678F405E011E00E94D27CF8014C
|
||||||
|
:10FC400081938F0121968091050290910602C81739
|
||||||
|
:10FC5000D90798F30E94D27C803209F06DCF809151
|
||||||
|
:10FC6000080280FFB6C0C0E0D0E0209105023091CC
|
||||||
|
:10FC7000060212161306B8F4E0910301F091040194
|
||||||
|
:10FC8000A5E0B1E0F999FECFF2BDE1BD8D9180BD57
|
||||||
|
:10FC9000FA9AF99A31962196C217D30798F3F093FE
|
||||||
|
:10FCA0000401E093030184E175CF80910802816033
|
||||||
|
:10FCB00080930802AFCF84E00E94407D80E087CF30
|
||||||
|
:10FCC0000E94D27C809303010E94D27C8093040125
|
||||||
|
:10FCD0000E94087D06CF0E94D27C803209F02CCF92
|
||||||
|
:10FCE00084E10E94007D8EE10E94007D86E90E94F1
|
||||||
|
:10FCF000007D89E04FCF0E94087D88E080936000FE
|
||||||
|
:10FD0000FFCF0E94D27C809306020E94D27C809317
|
||||||
|
:10FD100005020E94D27C853409F449C08091080212
|
||||||
|
:10FD20008E7F809308028091030190910401880FD7
|
||||||
|
:10FD3000991F90930401809303010E94D27C80322A
|
||||||
|
:10FD400009F0CFCE84E10E94007DC0E0D0E0209198
|
||||||
|
:10FD50000502309106021216130608F01DCFE0913D
|
||||||
|
:10FD60000301F09104018091080280FF96C0F99987
|
||||||
|
:10FD7000FECFF2BDE1BDF89A80B50E94007DE09112
|
||||||
|
:10FD80000301F09104013196F0930401E093030123
|
||||||
|
:10FD900020910502309106022196C217D30718F36D
|
||||||
|
:10FDA000FBCEE0910001F0910101099586CE809192
|
||||||
|
:10FDB0000802816080930802C0CF80E10E94217D0B
|
||||||
|
:10FDC00090CE81E00E94217D8CCE82E00E94217D38
|
||||||
|
:10FDD00088CE8091030190910401880F991F909320
|
||||||
|
:10FDE0000401809303018091050280FF09C0809186
|
||||||
|
:10FDF00005029091060201969093060280930502F7
|
||||||
|
:10FE0000F999FECF1127E0910301F0910401C5E0BB
|
||||||
|
:10FE1000D1E08091050290910602103091F400919A
|
||||||
|
:10FE2000570001700130D9F303E000935700E895C3
|
||||||
|
:10FE30000091570001700130D9F301E100935700A0
|
||||||
|
:10FE4000E895099019900091570001700130D9F39D
|
||||||
|
:10FE500001E000935700E8951395103898F01127AA
|
||||||
|
:10FE60000091570001700130D9F305E0009357006D
|
||||||
|
:10FE7000E8950091570001700130D9F301E100933A
|
||||||
|
:10FE80005700E8953296029709F0C7CF103011F06D
|
||||||
|
:10FE90000296E5CF112484E17DCE869580FF06C0D1
|
||||||
|
:10FEA0003196F0930401E093030176CF84910E9490
|
||||||
|
:10FEB000007D2091050230910602E0910301F0914E
|
||||||
|
:10FEC0000401EECF1F93CF930E94D27CC82F0E94D3
|
||||||
|
:10FED000007D0E94D27C182F0E94007DC1362CF03C
|
||||||
|
:10FEE000C75511363CF0175508C0C033D4F3C05382
|
||||||
|
:10FEF0001136CCF710330CF01053C295C07FC10FF0
|
||||||
|
:10FF00008C2F992787FD9095CF911F910895CF93BE
|
||||||
|
:10FF1000282F992787FD9095807F907095958795DC
|
||||||
|
:10FF20009595879595958795959587958A303CF019
|
||||||
|
:10FF3000895AC22FCF70CA303CF0C95A06C0805DC2
|
||||||
|
:10FF4000C22FCF70CA30CCF7C05D0E94007D8C2FCD
|
||||||
|
:0AFF50000E94007DCF910895FFCFBD
|
||||||
|
:040000030000F80001
|
||||||
|
:00000001FF
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
|
||||||
|
:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
|
||||||
|
:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
|
||||||
|
:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
|
||||||
|
:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
|
||||||
|
:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
|
||||||
|
:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
|
||||||
|
:10F870000C945B7C0C945B7C0C945B7C11241FBE11
|
||||||
|
:10F88000CFEFD0E1DEBFCDBF11E0A0E0B1E0E6E612
|
||||||
|
:10F89000FFEF02C005900D92A030B107D9F712E03A
|
||||||
|
:10F8A000A0E0B1E001C01D92A930B107E1F70E94CC
|
||||||
|
:10F8B000537D0C94B27F0C94007CCF93DF93CDB733
|
||||||
|
:10F8C000DEB724970FB6F894DEBF0FBECDBF8823F6
|
||||||
|
:10F8D00009F481E020E0482F55274115510509F42E
|
||||||
|
:10F8E0003DC0289A19821A821B821C820BC0898112
|
||||||
|
:10F8F0009A81AB81BC810196A11DB11D89839A8338
|
||||||
|
:10F90000AB83BC8389819A81AB81BC8180589E4343
|
||||||
|
:10F91000A040B04060F3289819821A821B821C8292
|
||||||
|
:10F920000BC089819A81AB81BC810196A11DB11D5B
|
||||||
|
:10F9300089839A83AB83BC8389819A81AB81BC81A3
|
||||||
|
:10F9400080509A4FA040B04060F32F5F822F9927DC
|
||||||
|
:10F9500087FD9095841795070CF4C3CF19821A82FE
|
||||||
|
:10F960001B821C8289819A81AB81BC818050914726
|
||||||
|
:10F97000A240B040A0F489819A81AB81BC810196FC
|
||||||
|
:10F98000A11DB11D89839A83AB83BC8389819A8130
|
||||||
|
:10F99000AB81BC8180509147A240B04060F3249677
|
||||||
|
:10F9A0000FB6F894DEBF0FBECDBFDF91CF910895A3
|
||||||
|
:10F9B000EF92FF920F931F93EE24FF248701289864
|
||||||
|
:10F9C0008091C00087FD17C00894E11CF11C011D47
|
||||||
|
:10F9D000111D81E0E81689E0F8068DE3080780E054
|
||||||
|
:10F9E000180770F3E0910001F091010109958091F1
|
||||||
|
:10F9F000C00087FFE9CF289A8091C600992787FD2C
|
||||||
|
:10FA000090951F910F91FF90EF900895982F8091FE
|
||||||
|
:10FA1000C00085FFFCCF9093C60008950E94D87C5B
|
||||||
|
:10FA2000803271F0809102018F5F809302018530F6
|
||||||
|
:10FA300009F00895E0910001F09101010995089500
|
||||||
|
:10FA400084E10E94067D80E10E94067D0895CF93A7
|
||||||
|
:10FA5000C82F0E94D87C803241F0809102018F5FD4
|
||||||
|
:10FA600080930201853081F40AC084E10E94067D02
|
||||||
|
:10FA70008C2F0E94067D80E10E94067D05C0E091EA
|
||||||
|
:10FA80000001F09101010995CF910895282F90E090
|
||||||
|
:10FA900007C08091C0008823E4F78091C6009F5F73
|
||||||
|
:10FAA0009217B8F30895CFEFD0E1DEBFCDBF0000CD
|
||||||
|
:10FAB00094B714BE809160008861809360001092BA
|
||||||
|
:10FAC000600091FF74C189E18093C4001092C50069
|
||||||
|
:10FAD00088E18093C10086E08093C2005098589AD4
|
||||||
|
:10FAE000209A83E00E945D7C81E00E945D7C0E9400
|
||||||
|
:10FAF000D87C8033B9F18133C1F1803409F456C028
|
||||||
|
:10FB0000813409F45CC0823409F46EC0853409F490
|
||||||
|
:10FB100071C0803539F1813509F4F3C0823511F1B6
|
||||||
|
:10FB2000853509F4D3C0863509F4CBC0843609F491
|
||||||
|
:10FB300065C0843709F4EBC0853709F4D2C0863735
|
||||||
|
:10FB400009F44AC0809102018F5F809302018530E1
|
||||||
|
:10FB500071F6E0910001F091010109950E94D87CB5
|
||||||
|
:10FB6000803349F60E940E7DC2CF0E94D87CC82FF8
|
||||||
|
:10FB7000803241F784E10E94067D81E40E94067D87
|
||||||
|
:10FB800086E50E94067D82E50E94067D8C2F0E94FC
|
||||||
|
:10FB9000067D89E40E94067D83E50E94067D80E55E
|
||||||
|
:10FBA0000E94067D80E10E94067DA1CF0E94D87C44
|
||||||
|
:10FBB0008638C0F20E94D87C0E940E7D98CF0E94A9
|
||||||
|
:10FBC000D87C803809F407C1813809F400C1823833
|
||||||
|
:10FBD00009F4F9C0883921F080E00E94277D87CFA1
|
||||||
|
:10FBE00083E00E94277D83CF84E10E94467D0E94AE
|
||||||
|
:10FBF0000E7D7DCF85E00E94467DF9CF0E94D87CA6
|
||||||
|
:10FC0000809306020E94D87C8093050280910802AE
|
||||||
|
:10FC10008E7F809308020E94D87C853409F44BC003
|
||||||
|
:10FC2000E5E0F1E0119281E0E438F807D9F3D0F390
|
||||||
|
:10FC3000C0E0D0E0809105029091060218161906E6
|
||||||
|
:10FC400078F405E011E00E94D87CF80181938F01DF
|
||||||
|
:10FC500021968091050290910602C817D90798F362
|
||||||
|
:10FC60000E94D87C803209F06DCF8091080280FF1D
|
||||||
|
:10FC7000B6C0C0E0D0E02091050230910602121615
|
||||||
|
:10FC80001306B8F4E0910301F0910401A5E0B1E09E
|
||||||
|
:10FC9000F999FECFF2BDE1BD8D9180BDFA9AF99A36
|
||||||
|
:10FCA00031962196C217D30798F3F0930401E0939D
|
||||||
|
:10FCB000030184E175CF809108028160809308027E
|
||||||
|
:10FCC000AFCF84E00E94467D80E087CF0E94D87C41
|
||||||
|
:10FCD000809303010E94D87C809304010E940E7DD2
|
||||||
|
:10FCE00006CF0E94D87C803209F02CCF84E10E949C
|
||||||
|
:10FCF000067D8EE10E94067D86E90E94067D8AE0EF
|
||||||
|
:10FD00004FCF0E940E7D88E080936000FFCF0E945D
|
||||||
|
:10FD1000D87C809306020E94D87C809305020E94C2
|
||||||
|
:10FD2000D87C853409F449C0809108028E7F809385
|
||||||
|
:10FD300008028091030190910401880F991F90930C
|
||||||
|
:10FD40000401809303010E94D87C803209F0CFCE59
|
||||||
|
:10FD500084E10E94067DC0E0D0E020910502309150
|
||||||
|
:10FD600006021216130608F01DCFE0910301F09170
|
||||||
|
:10FD700004018091080280FF96C0F999FECFF2BD80
|
||||||
|
:10FD8000E1BDF89A80B50E94067DE0910301F091F3
|
||||||
|
:10FD900004013196F0930401E093030120910502E0
|
||||||
|
:10FDA000309106022196C217D30718F3FBCEE091DB
|
||||||
|
:10FDB0000001F0910101099586CE809108028160D1
|
||||||
|
:10FDC00080930802C0CF80E10E94277D90CE81E021
|
||||||
|
:10FDD0000E94277D8CCE82E00E94277D88CE809174
|
||||||
|
:10FDE000030190910401880F991F9093040180935F
|
||||||
|
:10FDF00003018091050280FF09C080910502909166
|
||||||
|
:10FE0000060201969093060280930502F999FECFAF
|
||||||
|
:10FE10001127E0910301F0910401C5E0D1E0809148
|
||||||
|
:10FE2000050290910602103091F400915700017084
|
||||||
|
:10FE30000130D9F303E000935700E8950091570093
|
||||||
|
:10FE400001700130D9F301E100935700E895099062
|
||||||
|
:10FE500019900091570001700130D9F301E000932F
|
||||||
|
:10FE60005700E8951395103898F011270091570026
|
||||||
|
:10FE700001700130D9F305E000935700E895009137
|
||||||
|
:10FE8000570001700130D9F301E100935700E89564
|
||||||
|
:10FE90003296029709F0C7CF103011F00296E5CFE5
|
||||||
|
:10FEA000112484E17DCE869580FF06C03196F093C3
|
||||||
|
:10FEB0000401E093030176CF84910E94067D209196
|
||||||
|
:10FEC000050230910602E0910301F0910401EECFAA
|
||||||
|
:10FED0001F93CF930E94D87CC82F0E94067D0E945A
|
||||||
|
:10FEE000D87C182F0E94067DC1362CF0C7551136DC
|
||||||
|
:10FEF0003CF0175508C0C033D4F3C0531136CCF7CB
|
||||||
|
:10FF000010330CF01053C295C07FC10F8C2F99276E
|
||||||
|
:10FF100087FD9095CF911F910895CF93282F992712
|
||||||
|
:10FF200087FD9095807F907095958795959587959D
|
||||||
|
:10FF300095958795959587958A303CF0895AC22F7B
|
||||||
|
:10FF4000CF70CA303CF0C95A06C0805DC22FCF7056
|
||||||
|
:10FF5000CA30CCF7C05D0E94067D8C2F0E94067DC2
|
||||||
|
:06FF6000CF910895FFCFD0
|
||||||
|
:040000030000F80001
|
||||||
|
:00000001FF
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Makefile for ATmegaBOOT
|
||||||
|
# E.Lins, 18.7.2005
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
|
||||||
|
# program name should not be changed...
|
||||||
|
PROGRAM = ATmegaBOOT_644P
|
||||||
|
|
||||||
|
# enter the target CPU frequency
|
||||||
|
AVR_FREQ = 16000000L
|
||||||
|
|
||||||
|
MCU_TARGET = atmega644p
|
||||||
|
LDSECTION = --section-start=.text=0xF800
|
||||||
|
|
||||||
|
OBJ = $(PROGRAM).o
|
||||||
|
OPTIMIZE = -O2
|
||||||
|
|
||||||
|
DEFS =
|
||||||
|
LIBS =
|
||||||
|
|
||||||
|
CC = avr-gcc
|
||||||
|
|
||||||
|
|
||||||
|
# Override is only needed by avr-lib build system.
|
||||||
|
|
||||||
|
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
|
||||||
|
override LDFLAGS = -Wl,$(LDSECTION)
|
||||||
|
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
|
||||||
|
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
|
||||||
|
all: CFLAGS += '-DMAX_TIME_COUNT=8000000L>>1' -DADABOOT
|
||||||
|
all: $(PROGRAM).hex
|
||||||
|
|
||||||
|
$(PROGRAM).hex: $(PROGRAM).elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||||
|
|
||||||
|
$(PROGRAM).elf: $(OBJ)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
|
$(OBJ): ATmegaBOOT.c
|
||||||
|
avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o
|
||||||
|
|
||||||
|
%.lst: %.elf
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
%.srec: %.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -O srec $< $@
|
||||||
|
|
||||||
|
%.bin: %.elf
|
||||||
|
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Note: This bootloader support ATmega644, ATmega644P and ATmega324P.
|
||||||
|
To build, set PROGRAM and MCU_TARGET in the Makefile according to your target device.
|
||||||
|
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "wiring.h"
|
||||||
|
#include "wiring_private.h"
|
||||||
|
|
||||||
|
// this next line disables the entire HardwareSerial.cpp,
|
||||||
|
// this is so I can support Attiny series and any other chip without a uart
|
||||||
|
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
||||||
|
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
|
||||||
|
// Define constants and variables for buffering incoming serial data. We're
|
||||||
|
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||||
|
// location to which to write the next incoming character and rx_buffer_tail
|
||||||
|
// is the index of the location from which to read.
|
||||||
|
#if (RAMEND < 1000)
|
||||||
|
#define RX_BUFFER_SIZE 32
|
||||||
|
#else
|
||||||
|
#define RX_BUFFER_SIZE 128
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct ring_buffer
|
||||||
|
{
|
||||||
|
unsigned char buffer[RX_BUFFER_SIZE];
|
||||||
|
int head;
|
||||||
|
int tail;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(UBRRH) || defined(UBRR0H)
|
||||||
|
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR1H)
|
||||||
|
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR2H)
|
||||||
|
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR3H)
|
||||||
|
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline void store_char(unsigned char c, ring_buffer *rx_buffer)
|
||||||
|
{
|
||||||
|
int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
// if we should be storing the received character into the location
|
||||||
|
// just before the tail (meaning that the head would advance to the
|
||||||
|
// current location of the tail), we're about to overflow the buffer
|
||||||
|
// and so we don't write the character or advance the head.
|
||||||
|
if (i != rx_buffer->tail) {
|
||||||
|
rx_buffer->buffer[rx_buffer->head] = c;
|
||||||
|
rx_buffer->head = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(USART_RX_vect)
|
||||||
|
SIGNAL(USART_RX_vect)
|
||||||
|
{
|
||||||
|
#if defined(UDR0)
|
||||||
|
unsigned char c = UDR0;
|
||||||
|
#elif defined(UDR)
|
||||||
|
unsigned char c = UDR; // atmega8535
|
||||||
|
#else
|
||||||
|
#error UDR not defined
|
||||||
|
#endif
|
||||||
|
store_char(c, &rx_buffer);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_USART0_RECV) && defined(UDR0)
|
||||||
|
SIGNAL(SIG_USART0_RECV)
|
||||||
|
{
|
||||||
|
unsigned char c = UDR0;
|
||||||
|
store_char(c, &rx_buffer);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_UART0_RECV) && defined(UDR0)
|
||||||
|
SIGNAL(SIG_UART0_RECV)
|
||||||
|
{
|
||||||
|
unsigned char c = UDR0;
|
||||||
|
store_char(c, &rx_buffer);
|
||||||
|
}
|
||||||
|
//#elif defined(SIG_USART_RECV)
|
||||||
|
#elif defined(USART0_RX_vect)
|
||||||
|
// fixed by Mark Sproul this is on the 644/644p
|
||||||
|
//SIGNAL(SIG_USART_RECV)
|
||||||
|
SIGNAL(USART0_RX_vect)
|
||||||
|
{
|
||||||
|
#if defined(UDR0)
|
||||||
|
unsigned char c = UDR0;
|
||||||
|
#elif defined(UDR)
|
||||||
|
unsigned char c = UDR; // atmega8, atmega32
|
||||||
|
#else
|
||||||
|
#error UDR not defined
|
||||||
|
#endif
|
||||||
|
store_char(c, &rx_buffer);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_UART_RECV)
|
||||||
|
// this is for atmega8
|
||||||
|
SIGNAL(SIG_UART_RECV)
|
||||||
|
{
|
||||||
|
#if defined(UDR0)
|
||||||
|
unsigned char c = UDR0; // atmega645
|
||||||
|
#elif defined(UDR)
|
||||||
|
unsigned char c = UDR; // atmega8
|
||||||
|
#endif
|
||||||
|
store_char(c, &rx_buffer);
|
||||||
|
}
|
||||||
|
#elif defined(USBCON)
|
||||||
|
#warning No interrupt handler for usart 0
|
||||||
|
#warning Serial(0) is on USB interface
|
||||||
|
#else
|
||||||
|
#error No interrupt handler for usart 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#if defined(SIG_USART1_RECV)
|
||||||
|
#if defined(USART1_RX_vect)
|
||||||
|
//SIGNAL(SIG_USART1_RECV)
|
||||||
|
SIGNAL(USART1_RX_vect)
|
||||||
|
{
|
||||||
|
unsigned char c = UDR1;
|
||||||
|
store_char(c, &rx_buffer1);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_USART1_RECV)
|
||||||
|
#error SIG_USART1_RECV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USART2_RX_vect) && defined(UDR2)
|
||||||
|
SIGNAL(USART2_RX_vect)
|
||||||
|
{
|
||||||
|
unsigned char c = UDR2;
|
||||||
|
store_char(c, &rx_buffer2);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_USART2_RECV)
|
||||||
|
#error SIG_USART2_RECV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USART3_RX_vect) && defined(UDR3)
|
||||||
|
SIGNAL(USART3_RX_vect)
|
||||||
|
{
|
||||||
|
unsigned char c = UDR3;
|
||||||
|
store_char(c, &rx_buffer3);
|
||||||
|
}
|
||||||
|
#elif defined(SIG_USART3_RECV)
|
||||||
|
#error SIG_USART3_RECV
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors ////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
|
||||||
|
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||||
|
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||||
|
volatile uint8_t *udr,
|
||||||
|
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
|
||||||
|
{
|
||||||
|
_rx_buffer = rx_buffer;
|
||||||
|
_ubrrh = ubrrh;
|
||||||
|
_ubrrl = ubrrl;
|
||||||
|
_ucsra = ucsra;
|
||||||
|
_ucsrb = ucsrb;
|
||||||
|
_udr = udr;
|
||||||
|
_rxen = rxen;
|
||||||
|
_txen = txen;
|
||||||
|
_rxcie = rxcie;
|
||||||
|
_udre = udre;
|
||||||
|
_u2x = u2x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void HardwareSerial::begin(long baud)
|
||||||
|
{
|
||||||
|
uint16_t baud_setting;
|
||||||
|
bool use_u2x = true;
|
||||||
|
|
||||||
|
#if F_CPU == 16000000UL
|
||||||
|
// hardcoded exception for compatibility with the bootloader shipped
|
||||||
|
// with the Duemilanove and previous boards and the firmware on the 8U2
|
||||||
|
// on the Uno and Mega 2560.
|
||||||
|
if (baud == 57600) {
|
||||||
|
use_u2x = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (use_u2x) {
|
||||||
|
*_ucsra = 1 << _u2x;
|
||||||
|
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||||
|
} else {
|
||||||
|
*_ucsra = 0;
|
||||||
|
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
||||||
|
*_ubrrh = baud_setting >> 8;
|
||||||
|
*_ubrrl = baud_setting;
|
||||||
|
|
||||||
|
sbi(*_ucsrb, _rxen);
|
||||||
|
sbi(*_ucsrb, _txen);
|
||||||
|
sbi(*_ucsrb, _rxcie);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::end()
|
||||||
|
{
|
||||||
|
cbi(*_ucsrb, _rxen);
|
||||||
|
cbi(*_ucsrb, _txen);
|
||||||
|
cbi(*_ucsrb, _rxcie);
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::available(void)
|
||||||
|
{
|
||||||
|
return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::peek(void)
|
||||||
|
{
|
||||||
|
if (_rx_buffer->head == _rx_buffer->tail) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return _rx_buffer->buffer[_rx_buffer->tail];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::read(void)
|
||||||
|
{
|
||||||
|
// if the head isn't ahead of the tail, we don't have any characters
|
||||||
|
if (_rx_buffer->head == _rx_buffer->tail) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
|
||||||
|
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::flush()
|
||||||
|
{
|
||||||
|
// don't reverse this or there may be problems if the RX interrupt
|
||||||
|
// occurs after reading the value of rx_buffer_head but before writing
|
||||||
|
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||||
|
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||||
|
// don't reverse this or there may be problems if the RX interrupt
|
||||||
|
// occurs after reading the value of rx_buffer_head but before writing
|
||||||
|
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||||
|
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||||
|
// were full, not empty.
|
||||||
|
_rx_buffer->head = _rx_buffer->tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::write(uint8_t c)
|
||||||
|
{
|
||||||
|
while (!((*_ucsra) & (1 << _udre)))
|
||||||
|
;
|
||||||
|
|
||||||
|
*_udr = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if defined(UBRRH) && defined(UBRRL)
|
||||||
|
HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
|
||||||
|
#elif defined(UBRR0H) && defined(UBRR0L)
|
||||||
|
HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
|
||||||
|
#elif defined(USBCON)
|
||||||
|
#warning no serial port defined (port 0)
|
||||||
|
#else
|
||||||
|
#error no serial port defined (port 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(UBRR1H)
|
||||||
|
HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR2H)
|
||||||
|
HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
|
||||||
|
#endif
|
||||||
|
#if defined(UBRR3H)
|
||||||
|
HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // whole file
|
||||||
|
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
/*
|
||||||
|
Print.cpp - Base class that provides print() and println()
|
||||||
|
Copyright (c) 2008 David A. Mellis. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "wiring.h"
|
||||||
|
|
||||||
|
#include "Print.h"
|
||||||
|
|
||||||
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/* default implementation: may be overridden */
|
||||||
|
void Print::write(const char *str)
|
||||||
|
{
|
||||||
|
while (*str)
|
||||||
|
write(*str++);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* default implementation: may be overridden */
|
||||||
|
void Print::write(const uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
while (size--)
|
||||||
|
write(*buffer++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(const String &s)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
write(s[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(const char str[])
|
||||||
|
{
|
||||||
|
write(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(char c, int base)
|
||||||
|
{
|
||||||
|
print((long) c, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(unsigned char b, int base)
|
||||||
|
{
|
||||||
|
print((unsigned long) b, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(int n, int base)
|
||||||
|
{
|
||||||
|
print((long) n, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(unsigned int n, int base)
|
||||||
|
{
|
||||||
|
print((unsigned long) n, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(long n, int base)
|
||||||
|
{
|
||||||
|
if (base == 0) {
|
||||||
|
write(n);
|
||||||
|
} else if (base == 10) {
|
||||||
|
if (n < 0) {
|
||||||
|
print('-');
|
||||||
|
n = -n;
|
||||||
|
}
|
||||||
|
printNumber(n, 10);
|
||||||
|
} else {
|
||||||
|
printNumber(n, base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(unsigned long n, int base)
|
||||||
|
{
|
||||||
|
if (base == 0) write(n);
|
||||||
|
else printNumber(n, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::print(double n, int digits)
|
||||||
|
{
|
||||||
|
printFloat(n, digits);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(void)
|
||||||
|
{
|
||||||
|
print('\r');
|
||||||
|
print('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(const String &s)
|
||||||
|
{
|
||||||
|
print(s);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(const char c[])
|
||||||
|
{
|
||||||
|
print(c);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(char c, int base)
|
||||||
|
{
|
||||||
|
print(c, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(unsigned char b, int base)
|
||||||
|
{
|
||||||
|
print(b, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(int n, int base)
|
||||||
|
{
|
||||||
|
print(n, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(unsigned int n, int base)
|
||||||
|
{
|
||||||
|
print(n, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(long n, int base)
|
||||||
|
{
|
||||||
|
print(n, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(unsigned long n, int base)
|
||||||
|
{
|
||||||
|
print(n, base);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::println(double n, int digits)
|
||||||
|
{
|
||||||
|
print(n, digits);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Private Methods /////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void Print::printNumber(unsigned long n, uint8_t base)
|
||||||
|
{
|
||||||
|
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||||
|
unsigned long i = 0;
|
||||||
|
|
||||||
|
if (n == 0) {
|
||||||
|
print('0');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (n > 0) {
|
||||||
|
buf[i++] = n % base;
|
||||||
|
n /= base;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; i > 0; i--)
|
||||||
|
print((char) (buf[i - 1] < 10 ?
|
||||||
|
'0' + buf[i - 1] :
|
||||||
|
'A' + buf[i - 1] - 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print::printFloat(double number, uint8_t digits)
|
||||||
|
{
|
||||||
|
// Handle negative numbers
|
||||||
|
if (number < 0.0)
|
||||||
|
{
|
||||||
|
print('-');
|
||||||
|
number = -number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||||
|
double rounding = 0.5;
|
||||||
|
for (uint8_t i=0; i<digits; ++i)
|
||||||
|
rounding /= 10.0;
|
||||||
|
|
||||||
|
number += rounding;
|
||||||
|
|
||||||
|
// Extract the integer part of the number and print it
|
||||||
|
unsigned long int_part = (unsigned long)number;
|
||||||
|
double remainder = number - (double)int_part;
|
||||||
|
print(int_part);
|
||||||
|
|
||||||
|
// Print the decimal point, but only if there are digits beyond
|
||||||
|
if (digits > 0)
|
||||||
|
print(".");
|
||||||
|
|
||||||
|
// Extract digits from the remainder one at a time
|
||||||
|
while (digits-- > 0)
|
||||||
|
{
|
||||||
|
remainder *= 10.0;
|
||||||
|
int toPrint = int(remainder);
|
||||||
|
print(toPrint);
|
||||||
|
remainder -= toPrint;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
Stream.h - base class for character-based streams.
|
||||||
|
Copyright (c) 2010 David A. Mellis. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Stream_h
|
||||||
|
#define Stream_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "Print.h"
|
||||||
|
|
||||||
|
class Stream : public Print
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual int available() = 0;
|
||||||
|
virtual int read() = 0;
|
||||||
|
virtual int peek() = 0;
|
||||||
|
virtual void flush() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,601 @@
|
|||||||
|
/* Tone.cpp
|
||||||
|
|
||||||
|
A Tone Generator Library
|
||||||
|
|
||||||
|
Written by Brett Hagman
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Version Modified By Date Comments
|
||||||
|
------- ----------- -------- --------
|
||||||
|
0001 B Hagman 09/08/02 Initial coding
|
||||||
|
0002 B Hagman 09/08/18 Multiple pins
|
||||||
|
0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
|
||||||
|
0004 B Hagman 09/09/26 Fixed problems with ATmega8
|
||||||
|
0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
|
||||||
|
09/11/25 Changed pin toggle method to XOR
|
||||||
|
09/11/25 Fixed timer0 from being excluded
|
||||||
|
0006 D Mellis 09/12/29 Replaced objects with functions
|
||||||
|
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "wiring.h"
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
|
||||||
|
#define TCCR2A TCCR2
|
||||||
|
#define TCCR2B TCCR2
|
||||||
|
#define COM2A1 COM21
|
||||||
|
#define COM2A0 COM20
|
||||||
|
#define OCR2A OCR2
|
||||||
|
#define TIMSK2 TIMSK
|
||||||
|
#define OCIE2A OCIE2
|
||||||
|
#define TIMER2_COMPA_vect TIMER2_COMP_vect
|
||||||
|
#define TIMSK1 TIMSK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// timerx_toggle_count:
|
||||||
|
// > 0 - duration specified
|
||||||
|
// = 0 - stopped
|
||||||
|
// < 0 - infinitely (until stop() method called, or new play() called)
|
||||||
|
|
||||||
|
#if !defined(__AVR_ATmega8__)
|
||||||
|
volatile long timer0_toggle_count;
|
||||||
|
volatile uint8_t *timer0_pin_port;
|
||||||
|
volatile uint8_t timer0_pin_mask;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
volatile long timer1_toggle_count;
|
||||||
|
volatile uint8_t *timer1_pin_port;
|
||||||
|
volatile uint8_t timer1_pin_mask;
|
||||||
|
volatile long timer2_toggle_count;
|
||||||
|
volatile uint8_t *timer2_pin_port;
|
||||||
|
volatile uint8_t timer2_pin_mask;
|
||||||
|
|
||||||
|
#if defined(TIMSK3)
|
||||||
|
volatile long timer3_toggle_count;
|
||||||
|
volatile uint8_t *timer3_pin_port;
|
||||||
|
volatile uint8_t timer3_pin_mask;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK4)
|
||||||
|
volatile long timer4_toggle_count;
|
||||||
|
volatile uint8_t *timer4_pin_port;
|
||||||
|
volatile uint8_t timer4_pin_mask;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK5)
|
||||||
|
volatile long timer5_toggle_count;
|
||||||
|
volatile uint8_t *timer5_pin_port;
|
||||||
|
volatile uint8_t timer5_pin_mask;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// MLS: This does not make sense, the 3 options are the same
|
||||||
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
|
||||||
|
#define AVAILABLE_TONE_PINS 1
|
||||||
|
|
||||||
|
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
|
||||||
|
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
|
||||||
|
|
||||||
|
#elif defined(__AVR_ATmega8__)
|
||||||
|
|
||||||
|
#define AVAILABLE_TONE_PINS 1
|
||||||
|
|
||||||
|
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
|
||||||
|
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define AVAILABLE_TONE_PINS 1
|
||||||
|
|
||||||
|
// Leave timer 0 to last.
|
||||||
|
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
|
||||||
|
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int8_t toneBegin(uint8_t _pin)
|
||||||
|
{
|
||||||
|
int8_t _timer = -1;
|
||||||
|
|
||||||
|
// if we're already using the pin, the timer should be configured.
|
||||||
|
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||||
|
if (tone_pins[i] == _pin) {
|
||||||
|
return pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// search for an unused timer.
|
||||||
|
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||||
|
if (tone_pins[i] == 255) {
|
||||||
|
tone_pins[i] = _pin;
|
||||||
|
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_timer != -1)
|
||||||
|
{
|
||||||
|
// Set timer specific stuff
|
||||||
|
// All timers in CTC mode
|
||||||
|
// 8 bit timers will require changing prescalar values,
|
||||||
|
// whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
|
||||||
|
switch (_timer)
|
||||||
|
{
|
||||||
|
#if defined(TCCR0A) && defined(TCCR0B)
|
||||||
|
case 0:
|
||||||
|
// 8 bit timer
|
||||||
|
TCCR0A = 0;
|
||||||
|
TCCR0B = 0;
|
||||||
|
bitWrite(TCCR0A, WGM01, 1);
|
||||||
|
bitWrite(TCCR0B, CS00, 1);
|
||||||
|
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer0_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12)
|
||||||
|
case 1:
|
||||||
|
// 16 bit timer
|
||||||
|
TCCR1A = 0;
|
||||||
|
TCCR1B = 0;
|
||||||
|
bitWrite(TCCR1B, WGM12, 1);
|
||||||
|
bitWrite(TCCR1B, CS10, 1);
|
||||||
|
timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer1_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR2A) && defined(TCCR2B)
|
||||||
|
case 2:
|
||||||
|
// 8 bit timer
|
||||||
|
TCCR2A = 0;
|
||||||
|
TCCR2B = 0;
|
||||||
|
bitWrite(TCCR2A, WGM21, 1);
|
||||||
|
bitWrite(TCCR2B, CS20, 1);
|
||||||
|
timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer2_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3)
|
||||||
|
case 3:
|
||||||
|
// 16 bit timer
|
||||||
|
TCCR3A = 0;
|
||||||
|
TCCR3B = 0;
|
||||||
|
bitWrite(TCCR3B, WGM32, 1);
|
||||||
|
bitWrite(TCCR3B, CS30, 1);
|
||||||
|
timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer3_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4A) && defined(TCCR4B) && defined(TIMSK4)
|
||||||
|
case 4:
|
||||||
|
// 16 bit timer
|
||||||
|
TCCR4A = 0;
|
||||||
|
TCCR4B = 0;
|
||||||
|
#if defined(WGM42)
|
||||||
|
bitWrite(TCCR4B, WGM42, 1);
|
||||||
|
#elif defined(CS43)
|
||||||
|
#warning this may not be correct
|
||||||
|
// atmega32u4
|
||||||
|
bitWrite(TCCR4B, CS43, 1);
|
||||||
|
#endif
|
||||||
|
bitWrite(TCCR4B, CS40, 1);
|
||||||
|
timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer4_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR5A) && defined(TCCR5B) && defined(TIMSK5)
|
||||||
|
case 5:
|
||||||
|
// 16 bit timer
|
||||||
|
TCCR5A = 0;
|
||||||
|
TCCR5B = 0;
|
||||||
|
bitWrite(TCCR5B, WGM52, 1);
|
||||||
|
bitWrite(TCCR5B, CS50, 1);
|
||||||
|
timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
|
||||||
|
timer5_pin_mask = digitalPinToBitMask(_pin);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// frequency (in hertz) and duration (in milliseconds).
|
||||||
|
|
||||||
|
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
||||||
|
{
|
||||||
|
uint8_t prescalarbits = 0b001;
|
||||||
|
long toggle_count = 0;
|
||||||
|
uint32_t ocr = 0;
|
||||||
|
int8_t _timer;
|
||||||
|
|
||||||
|
_timer = toneBegin(_pin);
|
||||||
|
|
||||||
|
if (_timer >= 0)
|
||||||
|
{
|
||||||
|
// Set the pinMode as OUTPUT
|
||||||
|
pinMode(_pin, OUTPUT);
|
||||||
|
|
||||||
|
// if we are using an 8 bit timer, scan through prescalars to find the best fit
|
||||||
|
if (_timer == 0 || _timer == 2)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 - 1;
|
||||||
|
prescalarbits = 0b001; // ck/1: same for both timers
|
||||||
|
if (ocr > 255)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 8 - 1;
|
||||||
|
prescalarbits = 0b010; // ck/8: same for both timers
|
||||||
|
|
||||||
|
if (_timer == 2 && ocr > 255)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 32 - 1;
|
||||||
|
prescalarbits = 0b011;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ocr > 255)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 64 - 1;
|
||||||
|
prescalarbits = _timer == 0 ? 0b011 : 0b100;
|
||||||
|
|
||||||
|
if (_timer == 2 && ocr > 255)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 128 - 1;
|
||||||
|
prescalarbits = 0b101;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ocr > 255)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 256 - 1;
|
||||||
|
prescalarbits = _timer == 0 ? 0b100 : 0b110;
|
||||||
|
if (ocr > 255)
|
||||||
|
{
|
||||||
|
// can't do any better than /1024
|
||||||
|
ocr = F_CPU / frequency / 2 / 1024 - 1;
|
||||||
|
prescalarbits = _timer == 0 ? 0b101 : 0b111;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(TCCR0B)
|
||||||
|
if (_timer == 0)
|
||||||
|
{
|
||||||
|
TCCR0B = prescalarbits;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2B)
|
||||||
|
{
|
||||||
|
TCCR2B = prescalarbits;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
// dummy place holder to make the above ifdefs work
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// two choices for the 16 bit timers: ck/1 or ck/64
|
||||||
|
ocr = F_CPU / frequency / 2 - 1;
|
||||||
|
|
||||||
|
prescalarbits = 0b001;
|
||||||
|
if (ocr > 0xffff)
|
||||||
|
{
|
||||||
|
ocr = F_CPU / frequency / 2 / 64 - 1;
|
||||||
|
prescalarbits = 0b011;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_timer == 1)
|
||||||
|
{
|
||||||
|
#if defined(TCCR1B)
|
||||||
|
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if defined(TCCR3B)
|
||||||
|
else if (_timer == 3)
|
||||||
|
TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR4B)
|
||||||
|
else if (_timer == 4)
|
||||||
|
TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR5B)
|
||||||
|
else if (_timer == 5)
|
||||||
|
TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate the toggle count
|
||||||
|
if (duration > 0)
|
||||||
|
{
|
||||||
|
toggle_count = 2 * frequency * duration / 1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toggle_count = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the OCR for the given timer,
|
||||||
|
// set the toggle count,
|
||||||
|
// then turn on the interrupts
|
||||||
|
switch (_timer)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A)
|
||||||
|
case 0:
|
||||||
|
OCR0A = ocr;
|
||||||
|
timer0_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK0, OCIE0A, 1);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A)
|
||||||
|
OCR1A = ocr;
|
||||||
|
timer1_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK1, OCIE1A, 1);
|
||||||
|
#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A)
|
||||||
|
// this combination is for at least the ATmega32
|
||||||
|
OCR1A = ocr;
|
||||||
|
timer1_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK, OCIE1A, 1);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A)
|
||||||
|
case 2:
|
||||||
|
OCR2A = ocr;
|
||||||
|
timer2_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK2, OCIE2A, 1);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK3)
|
||||||
|
case 3:
|
||||||
|
OCR3A = ocr;
|
||||||
|
timer3_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK3, OCIE3A, 1);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK4)
|
||||||
|
case 4:
|
||||||
|
OCR4A = ocr;
|
||||||
|
timer4_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK4, OCIE4A, 1);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A)
|
||||||
|
case 5:
|
||||||
|
OCR5A = ocr;
|
||||||
|
timer5_toggle_count = toggle_count;
|
||||||
|
bitWrite(TIMSK5, OCIE5A, 1);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX: this function only works properly for timer 2 (the only one we use
|
||||||
|
// currently). for the others, it should end the tone, but won't restore
|
||||||
|
// proper PWM functionality for the timer.
|
||||||
|
void disableTimer(uint8_t _timer)
|
||||||
|
{
|
||||||
|
switch (_timer)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
#if defined(TIMSK0)
|
||||||
|
TIMSK0 = 0;
|
||||||
|
#elif defined(TIMSK)
|
||||||
|
TIMSK = 0; // atmega32
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(TIMSK1) && defined(OCIE1A)
|
||||||
|
case 1:
|
||||||
|
bitWrite(TIMSK1, OCIE1A, 0);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
#if defined(TIMSK2) && defined(OCIE2A)
|
||||||
|
bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2A) && defined(WGM20)
|
||||||
|
TCCR2A = (1 << WGM20);
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2B) && defined(CS22)
|
||||||
|
TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
|
||||||
|
#endif
|
||||||
|
#if defined(OCR2A)
|
||||||
|
OCR2A = 0;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(TIMSK3)
|
||||||
|
case 3:
|
||||||
|
TIMSK3 = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK4)
|
||||||
|
case 4:
|
||||||
|
TIMSK4 = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMSK5)
|
||||||
|
case 5:
|
||||||
|
TIMSK5 = 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void noTone(uint8_t _pin)
|
||||||
|
{
|
||||||
|
int8_t _timer = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
|
||||||
|
if (tone_pins[i] == _pin) {
|
||||||
|
_timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
|
||||||
|
tone_pins[i] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disableTimer(_timer);
|
||||||
|
|
||||||
|
digitalWrite(_pin, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#if !defined(__AVR_ATmega8__)
|
||||||
|
ISR(TIMER0_COMPA_vect)
|
||||||
|
{
|
||||||
|
if (timer0_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer0_pin_port ^= timer0_pin_mask;
|
||||||
|
|
||||||
|
if (timer0_toggle_count > 0)
|
||||||
|
timer0_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableTimer(0);
|
||||||
|
*timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ISR(TIMER1_COMPA_vect)
|
||||||
|
{
|
||||||
|
if (timer1_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer1_pin_port ^= timer1_pin_mask;
|
||||||
|
|
||||||
|
if (timer1_toggle_count > 0)
|
||||||
|
timer1_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableTimer(1);
|
||||||
|
*timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ISR(TIMER2_COMPA_vect)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (timer2_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer2_pin_port ^= timer2_pin_mask;
|
||||||
|
|
||||||
|
if (timer2_toggle_count > 0)
|
||||||
|
timer2_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// need to call noTone() so that the tone_pins[] entry is reset, so the
|
||||||
|
// timer gets initialized next time we call tone().
|
||||||
|
// XXX: this assumes timer 2 is always the first one used.
|
||||||
|
noTone(tone_pins[0]);
|
||||||
|
// disableTimer(2);
|
||||||
|
// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
ISR(TIMER3_COMPA_vect)
|
||||||
|
{
|
||||||
|
if (timer3_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer3_pin_port ^= timer3_pin_mask;
|
||||||
|
|
||||||
|
if (timer3_toggle_count > 0)
|
||||||
|
timer3_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableTimer(3);
|
||||||
|
*timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER4_COMPA_vect)
|
||||||
|
{
|
||||||
|
if (timer4_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer4_pin_port ^= timer4_pin_mask;
|
||||||
|
|
||||||
|
if (timer4_toggle_count > 0)
|
||||||
|
timer4_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableTimer(4);
|
||||||
|
*timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER5_COMPA_vect)
|
||||||
|
{
|
||||||
|
if (timer5_toggle_count != 0)
|
||||||
|
{
|
||||||
|
// toggle the pin
|
||||||
|
*timer5_pin_port ^= timer5_pin_mask;
|
||||||
|
|
||||||
|
if (timer5_toggle_count > 0)
|
||||||
|
timer5_toggle_count--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableTimer(5);
|
||||||
|
*timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
WCharacter.h - Character utility functions for Wiring & Arduino
|
||||||
|
Copyright (c) 2010 Hernando Barragan. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Character_h
|
||||||
|
#define Character_h
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
// WCharacter.h prototypes
|
||||||
|
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isAlpha(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isAscii(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isWhitespace(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isControl(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isDigit(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isGraph(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isLowerCase(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isPrintable(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isPunct(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isSpace(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isUpperCase(int c) __attribute__((always_inline));
|
||||||
|
inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
|
||||||
|
inline int toAscii(int c) __attribute__((always_inline));
|
||||||
|
inline int toLowerCase(int c) __attribute__((always_inline));
|
||||||
|
inline int toUpperCase(int c)__attribute__((always_inline));
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for an alphanumeric character.
|
||||||
|
// It is equivalent to (isalpha(c) || isdigit(c)).
|
||||||
|
inline boolean isAlphaNumeric(int c)
|
||||||
|
{
|
||||||
|
return ( isalnum(c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for an alphabetic character.
|
||||||
|
// It is equivalent to (isupper(c) || islower(c)).
|
||||||
|
inline boolean isAlpha(int c)
|
||||||
|
{
|
||||||
|
return ( isalpha(c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks whether c is a 7-bit unsigned char value
|
||||||
|
// that fits into the ASCII character set.
|
||||||
|
inline boolean isAscii(int c)
|
||||||
|
{
|
||||||
|
return ( isascii (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for a blank character, that is, a space or a tab.
|
||||||
|
inline boolean isWhitespace(int c)
|
||||||
|
{
|
||||||
|
return ( isblank (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for a control character.
|
||||||
|
inline boolean isControl(int c)
|
||||||
|
{
|
||||||
|
return ( iscntrl (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for a digit (0 through 9).
|
||||||
|
inline boolean isDigit(int c)
|
||||||
|
{
|
||||||
|
return ( isdigit (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for any printable character except space.
|
||||||
|
inline boolean isGraph(int c)
|
||||||
|
{
|
||||||
|
return ( isgraph (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for a lower-case character.
|
||||||
|
inline boolean isLowerCase(int c)
|
||||||
|
{
|
||||||
|
return (islower (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for any printable character including space.
|
||||||
|
inline boolean isPrintable(int c)
|
||||||
|
{
|
||||||
|
return ( isprint (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for any printable character which is not a space
|
||||||
|
// or an alphanumeric character.
|
||||||
|
inline boolean isPunct(int c)
|
||||||
|
{
|
||||||
|
return ( ispunct (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for white-space characters. For the avr-libc library,
|
||||||
|
// these are: space, formfeed ('\f'), newline ('\n'), carriage
|
||||||
|
// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
|
||||||
|
inline boolean isSpace(int c)
|
||||||
|
{
|
||||||
|
return ( isspace (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for an uppercase letter.
|
||||||
|
inline boolean isUpperCase(int c)
|
||||||
|
{
|
||||||
|
return ( isupper (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
|
||||||
|
// 8 9 a b c d e f A B C D E F.
|
||||||
|
inline boolean isHexadecimalDigit(int c)
|
||||||
|
{
|
||||||
|
return ( isxdigit (c) == 0 ? false : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Converts c to a 7-bit unsigned char value that fits into the
|
||||||
|
// ASCII character set, by clearing the high-order bits.
|
||||||
|
inline int toAscii(int c)
|
||||||
|
{
|
||||||
|
return toascii (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Warning:
|
||||||
|
// Many people will be unhappy if you use this function.
|
||||||
|
// This function will convert accented letters into random
|
||||||
|
// characters.
|
||||||
|
|
||||||
|
// Converts the letter c to lower case, if possible.
|
||||||
|
inline int toLowerCase(int c)
|
||||||
|
{
|
||||||
|
return tolower (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Converts the letter c to upper case, if possible.
|
||||||
|
inline int toUpperCase(int c)
|
||||||
|
{
|
||||||
|
return toupper (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "wiring.h"
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Part of the Wiring project - http://wiring.uniandes.edu.co
|
||||||
|
|
||||||
|
Copyright (c) 2004-05 Hernando Barragan
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Modified 24 November 2006 by David A. Mellis
|
||||||
|
Modified 1 August 2010 by Mark Sproul
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "WConstants.h"
|
||||||
|
#include "wiring_private.h"
|
||||||
|
|
||||||
|
volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
|
||||||
|
// volatile static voidFuncPtr twiIntFunc;
|
||||||
|
|
||||||
|
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
|
||||||
|
if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
|
||||||
|
intFunc[interruptNum] = userFunc;
|
||||||
|
|
||||||
|
// Configure the interrupt mode (trigger on low input, any change, rising
|
||||||
|
// edge, or falling edge). The mode constants were chosen to correspond
|
||||||
|
// to the configuration bits in the hardware register, so we simply shift
|
||||||
|
// the mode into place.
|
||||||
|
|
||||||
|
// Enable the interrupt.
|
||||||
|
switch (interruptNum) {
|
||||||
|
#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
|
||||||
|
case 2:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
|
EIMSK |= (1 << INT0);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
|
||||||
|
EIMSK |= (1 << INT1);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
|
||||||
|
EIMSK |= (1 << INT2);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
|
||||||
|
EIMSK |= (1 << INT3);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
|
||||||
|
EIMSK |= (1 << INT4);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
|
||||||
|
EIMSK |= (1 << INT5);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
|
||||||
|
EIMSK |= (1 << INT6);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
|
||||||
|
EIMSK |= (1 << INT7);
|
||||||
|
break;
|
||||||
|
#elif defined(EICRA) && defined(EIMSK)
|
||||||
|
case 0:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
|
EIMSK |= (1 << INT0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
|
||||||
|
EIMSK |= (1 << INT1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
|
||||||
|
EIMSK |= (1 << INT2);
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
case 0:
|
||||||
|
#if defined(EICRA) && defined(ISC00) && defined(EIMSK)
|
||||||
|
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
|
EIMSK |= (1 << INT0);
|
||||||
|
#elif defined(MCUCR) && defined(ISC00) && defined(GICR)
|
||||||
|
MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
|
GICR |= (1 << INT0);
|
||||||
|
#elif defined(MCUCR) && defined(ISC00) && defined(GIMSK)
|
||||||
|
MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
|
||||||
|
GIMSK |= (1 << INT0);
|
||||||
|
#else
|
||||||
|
#error attachInterrupt not finished for this CPU (case 0)
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
#if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK)
|
||||||
|
EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
|
||||||
|
EIMSK |= (1 << INT1);
|
||||||
|
#elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR)
|
||||||
|
MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
|
||||||
|
GICR |= (1 << INT1);
|
||||||
|
#elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK)
|
||||||
|
MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
|
||||||
|
GIMSK |= (1 << INT1);
|
||||||
|
#else
|
||||||
|
#warning attachInterrupt may need some more work for this cpu (case 1)
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void detachInterrupt(uint8_t interruptNum) {
|
||||||
|
if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
|
||||||
|
// Disable the interrupt. (We can't assume that interruptNum is equal
|
||||||
|
// to the number of the EIMSK bit to clear, as this isn't true on the
|
||||||
|
// ATmega8. There, INT0 is 6 and INT1 is 7.)
|
||||||
|
switch (interruptNum) {
|
||||||
|
#if defined(EICRA) && defined(EICRB) && defined(EIMSK)
|
||||||
|
case 5:
|
||||||
|
EIMSK &= ~(1 << INT3);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
EIMSK &= ~(1 << INT4);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
EIMSK &= ~(1 << INT5);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
EIMSK &= ~(1 << INT6);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
EIMSK &= ~(1 << INT7);
|
||||||
|
break;
|
||||||
|
#elif defined(EICRA) && defined(EIMSK)
|
||||||
|
case 0:
|
||||||
|
EIMSK &= ~(1 << INT0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
EIMSK &= ~(1 << INT1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
EIMSK &= ~(1 << INT2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
#else
|
||||||
|
case 0:
|
||||||
|
#if defined(EIMSK) && defined(INT0)
|
||||||
|
EIMSK &= ~(1 << INT0);
|
||||||
|
#elif defined(GICR) && defined(ISC00)
|
||||||
|
GICR &= ~(1 << INT0); // atmega32
|
||||||
|
#elif defined(GIMSK) && defined(INT0)
|
||||||
|
GIMSK &= ~(1 << INT0);
|
||||||
|
#else
|
||||||
|
#error detachInterrupt not finished for this cpu
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
#if defined(EIMSK) && defined(INT1)
|
||||||
|
EIMSK &= ~(1 << INT1);
|
||||||
|
#elif defined(GICR) && defined(INT1)
|
||||||
|
GICR &= ~(1 << INT1); // atmega32
|
||||||
|
#elif defined(GIMSK) && defined(INT1)
|
||||||
|
GIMSK &= ~(1 << INT1);
|
||||||
|
#else
|
||||||
|
#warning detachInterrupt may need some more work for this cpu (case 1)
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
intFunc[interruptNum] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void attachInterruptTwi(void (*userFunc)(void) ) {
|
||||||
|
twiIntFunc = userFunc;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(EICRA) && defined(EICRB)
|
||||||
|
SIGNAL(INT0_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_2])
|
||||||
|
intFunc[EXTERNAL_INT_2]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT1_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_3])
|
||||||
|
intFunc[EXTERNAL_INT_3]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT2_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_4])
|
||||||
|
intFunc[EXTERNAL_INT_4]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT3_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_5])
|
||||||
|
intFunc[EXTERNAL_INT_5]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT4_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_0])
|
||||||
|
intFunc[EXTERNAL_INT_0]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT5_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_1])
|
||||||
|
intFunc[EXTERNAL_INT_1]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT6_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_6])
|
||||||
|
intFunc[EXTERNAL_INT_6]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT7_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_7])
|
||||||
|
intFunc[EXTERNAL_INT_7]();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(EICRA)
|
||||||
|
|
||||||
|
SIGNAL(INT0_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_0])
|
||||||
|
intFunc[EXTERNAL_INT_0]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT1_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_1])
|
||||||
|
intFunc[EXTERNAL_INT_1]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT2_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_2])
|
||||||
|
intFunc[EXTERNAL_INT_2]();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
SIGNAL(INT0_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_0])
|
||||||
|
intFunc[EXTERNAL_INT_0]();
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(INT1_vect) {
|
||||||
|
if(intFunc[EXTERNAL_INT_1])
|
||||||
|
intFunc[EXTERNAL_INT_1]();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
SIGNAL(SIG_2WIRE_SERIAL) {
|
||||||
|
if(twiIntFunc)
|
||||||
|
twiIntFunc();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Part of the Wiring project - http://wiring.org.co
|
||||||
|
Copyright (c) 2004-06 Hernando Barragan
|
||||||
|
Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "stdlib.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
void randomSeed(unsigned int seed)
|
||||||
|
{
|
||||||
|
if (seed != 0) {
|
||||||
|
srandom(seed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long random(long howbig)
|
||||||
|
{
|
||||||
|
if (howbig == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return random() % howbig;
|
||||||
|
}
|
||||||
|
|
||||||
|
long random(long howsmall, long howbig)
|
||||||
|
{
|
||||||
|
if (howsmall >= howbig) {
|
||||||
|
return howsmall;
|
||||||
|
}
|
||||||
|
long diff = howbig - howsmall;
|
||||||
|
return random(diff) + howsmall;
|
||||||
|
}
|
||||||
|
|
||||||
|
long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||||
|
{
|
||||||
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int makeWord(unsigned int w) { return w; }
|
||||||
|
unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#ifndef WProgram_h
|
||||||
|
#define WProgram_h
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
#include "wiring.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include "WCharacter.h"
|
||||||
|
#include "WString.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
|
||||||
|
uint16_t makeWord(uint16_t w);
|
||||||
|
uint16_t makeWord(byte h, byte l);
|
||||||
|
|
||||||
|
#define word(...) makeWord(__VA_ARGS__)
|
||||||
|
|
||||||
|
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
|
||||||
|
|
||||||
|
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
|
||||||
|
void noTone(uint8_t _pin);
|
||||||
|
|
||||||
|
// WMath prototypes
|
||||||
|
long random(long);
|
||||||
|
long random(long, long);
|
||||||
|
void randomSeed(unsigned int);
|
||||||
|
long map(long, long, long, long, long);
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
const static uint8_t A0 = 54;
|
||||||
|
const static uint8_t A1 = 55;
|
||||||
|
const static uint8_t A2 = 56;
|
||||||
|
const static uint8_t A3 = 57;
|
||||||
|
const static uint8_t A4 = 58;
|
||||||
|
const static uint8_t A5 = 59;
|
||||||
|
const static uint8_t A6 = 60;
|
||||||
|
const static uint8_t A7 = 61;
|
||||||
|
const static uint8_t A8 = 62;
|
||||||
|
const static uint8_t A9 = 63;
|
||||||
|
const static uint8_t A10 = 64;
|
||||||
|
const static uint8_t A11 = 65;
|
||||||
|
const static uint8_t A12 = 66;
|
||||||
|
const static uint8_t A13 = 67;
|
||||||
|
const static uint8_t A14 = 68;
|
||||||
|
const static uint8_t A15 = 69;
|
||||||
|
#else
|
||||||
|
const static uint8_t A0 = 14;
|
||||||
|
const static uint8_t A1 = 15;
|
||||||
|
const static uint8_t A2 = 16;
|
||||||
|
const static uint8_t A3 = 17;
|
||||||
|
const static uint8_t A4 = 18;
|
||||||
|
const static uint8_t A5 = 19;
|
||||||
|
const static uint8_t A6 = 20;
|
||||||
|
const static uint8_t A7 = 21;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,443 @@
|
|||||||
|
/*
|
||||||
|
WString.cpp - String library for Wiring & Arduino
|
||||||
|
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "WProgram.h"
|
||||||
|
#include "WString.h"
|
||||||
|
|
||||||
|
|
||||||
|
String::String( const char *value )
|
||||||
|
{
|
||||||
|
if ( value == NULL )
|
||||||
|
value = "";
|
||||||
|
getBuffer( _length = strlen( value ) );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const String &value )
|
||||||
|
{
|
||||||
|
getBuffer( _length = value._length );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, value._buffer );
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const char value )
|
||||||
|
{
|
||||||
|
_length = 1;
|
||||||
|
getBuffer(1);
|
||||||
|
if ( _buffer != NULL ) {
|
||||||
|
_buffer[0] = value;
|
||||||
|
_buffer[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const unsigned char value )
|
||||||
|
{
|
||||||
|
_length = 1;
|
||||||
|
getBuffer(1);
|
||||||
|
if ( _buffer != NULL) {
|
||||||
|
_buffer[0] = value;
|
||||||
|
_buffer[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const int value, const int base )
|
||||||
|
{
|
||||||
|
char buf[33];
|
||||||
|
itoa((signed long)value, buf, base);
|
||||||
|
getBuffer( _length = strlen(buf) );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const unsigned int value, const int base )
|
||||||
|
{
|
||||||
|
char buf[33];
|
||||||
|
ultoa((unsigned long)value, buf, base);
|
||||||
|
getBuffer( _length = strlen(buf) );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const long value, const int base )
|
||||||
|
{
|
||||||
|
char buf[33];
|
||||||
|
ltoa(value, buf, base);
|
||||||
|
getBuffer( _length = strlen(buf) );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
String::String( const unsigned long value, const int base )
|
||||||
|
{
|
||||||
|
char buf[33];
|
||||||
|
ultoa(value, buf, 10);
|
||||||
|
getBuffer( _length = strlen(buf) );
|
||||||
|
if ( _buffer != NULL )
|
||||||
|
strcpy( _buffer, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
char String::charAt( unsigned int loc ) const
|
||||||
|
{
|
||||||
|
return operator[]( loc );
|
||||||
|
}
|
||||||
|
|
||||||
|
void String::setCharAt( unsigned int loc, const char aChar )
|
||||||
|
{
|
||||||
|
if(_buffer == NULL) return;
|
||||||
|
if(_length > loc) {
|
||||||
|
_buffer[loc] = aChar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::compareTo( const String &s2 ) const
|
||||||
|
{
|
||||||
|
return strcmp( _buffer, s2._buffer );
|
||||||
|
}
|
||||||
|
|
||||||
|
const String & String::concat( const String &s2 )
|
||||||
|
{
|
||||||
|
return (*this) += s2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const String & String::operator=( const String &rhs )
|
||||||
|
{
|
||||||
|
if ( this == &rhs )
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
if ( rhs._length > _length )
|
||||||
|
{
|
||||||
|
free(_buffer);
|
||||||
|
getBuffer( rhs._length );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _buffer != NULL ) {
|
||||||
|
_length = rhs._length;
|
||||||
|
strcpy( _buffer, rhs._buffer );
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//const String & String::operator+=( const char aChar )
|
||||||
|
//{
|
||||||
|
// if ( _length == _capacity )
|
||||||
|
// doubleBuffer();
|
||||||
|
//
|
||||||
|
// _buffer[ _length++ ] = aChar;
|
||||||
|
// _buffer[ _length ] = '\0';
|
||||||
|
// return *this;
|
||||||
|
//}
|
||||||
|
|
||||||
|
const String & String::operator+=( const String &other )
|
||||||
|
{
|
||||||
|
_length += other._length;
|
||||||
|
if ( _length > _capacity )
|
||||||
|
{
|
||||||
|
char *temp = (char *)realloc(_buffer, _length + 1);
|
||||||
|
if ( temp != NULL ) {
|
||||||
|
_buffer = temp;
|
||||||
|
_capacity = _length;
|
||||||
|
} else {
|
||||||
|
_length -= other._length;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strcat( _buffer, other._buffer );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int String::operator==( const String &rhs ) const
|
||||||
|
{
|
||||||
|
return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::operator!=( const String &rhs ) const
|
||||||
|
{
|
||||||
|
return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::operator<( const String &rhs ) const
|
||||||
|
{
|
||||||
|
return strcmp( _buffer, rhs._buffer ) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::operator>( const String &rhs ) const
|
||||||
|
{
|
||||||
|
return strcmp( _buffer, rhs._buffer ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::operator<=( const String &rhs ) const
|
||||||
|
{
|
||||||
|
return strcmp( _buffer, rhs._buffer ) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::operator>=( const String & rhs ) const
|
||||||
|
{
|
||||||
|
return strcmp( _buffer, rhs._buffer ) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char & String::operator[]( unsigned int index )
|
||||||
|
{
|
||||||
|
static char dummy_writable_char;
|
||||||
|
if (index >= _length || !_buffer) {
|
||||||
|
dummy_writable_char = 0;
|
||||||
|
return dummy_writable_char;
|
||||||
|
}
|
||||||
|
return _buffer[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
char String::operator[]( unsigned int index ) const
|
||||||
|
{
|
||||||
|
// need to check for valid index, to do later
|
||||||
|
return _buffer[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean String::endsWith( const String &s2 ) const
|
||||||
|
{
|
||||||
|
if ( _length < s2._length )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean String::equals( const String &s2 ) const
|
||||||
|
{
|
||||||
|
return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean String::equalsIgnoreCase( const String &s2 ) const
|
||||||
|
{
|
||||||
|
if ( this == &s2 )
|
||||||
|
return true; //1;
|
||||||
|
else if ( _length != s2._length )
|
||||||
|
return false; //0;
|
||||||
|
|
||||||
|
return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::replace( char findChar, char replaceChar )
|
||||||
|
{
|
||||||
|
if ( _buffer == NULL ) return *this;
|
||||||
|
String theReturn = _buffer;
|
||||||
|
char* temp = theReturn._buffer;
|
||||||
|
while( (temp = strchr( temp, findChar )) != 0 )
|
||||||
|
*temp = replaceChar;
|
||||||
|
|
||||||
|
return theReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::replace( const String& match, const String& replace )
|
||||||
|
{
|
||||||
|
if ( _buffer == NULL ) return *this;
|
||||||
|
String temp = _buffer, newString;
|
||||||
|
|
||||||
|
int loc;
|
||||||
|
while ( (loc = temp.indexOf( match )) != -1 )
|
||||||
|
{
|
||||||
|
newString += temp.substring( 0, loc );
|
||||||
|
newString += replace;
|
||||||
|
temp = temp.substring( loc + match._length );
|
||||||
|
}
|
||||||
|
newString += temp;
|
||||||
|
return newString;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::indexOf( char temp ) const
|
||||||
|
{
|
||||||
|
return indexOf( temp, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::indexOf( char ch, unsigned int fromIndex ) const
|
||||||
|
{
|
||||||
|
if ( fromIndex >= _length )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
const char* temp = strchr( &_buffer[fromIndex], ch );
|
||||||
|
if ( temp == NULL )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return temp - _buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::indexOf( const String &s2 ) const
|
||||||
|
{
|
||||||
|
return indexOf( s2, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::indexOf( const String &s2, unsigned int fromIndex ) const
|
||||||
|
{
|
||||||
|
if ( fromIndex >= _length )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
|
||||||
|
|
||||||
|
if ( theFind == NULL )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return theFind - _buffer; // pointer subtraction
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::lastIndexOf( char theChar ) const
|
||||||
|
{
|
||||||
|
return lastIndexOf( theChar, _length - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::lastIndexOf( char ch, unsigned int fromIndex ) const
|
||||||
|
{
|
||||||
|
if ( fromIndex >= _length )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
char tempchar = _buffer[fromIndex + 1];
|
||||||
|
_buffer[fromIndex + 1] = '\0';
|
||||||
|
char* temp = strrchr( _buffer, ch );
|
||||||
|
_buffer[fromIndex + 1] = tempchar;
|
||||||
|
|
||||||
|
if ( temp == NULL )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return temp - _buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::lastIndexOf( const String &s2 ) const
|
||||||
|
{
|
||||||
|
return lastIndexOf( s2, _length - s2._length );
|
||||||
|
}
|
||||||
|
|
||||||
|
int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
|
||||||
|
{
|
||||||
|
// check for empty strings
|
||||||
|
if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// matching first character
|
||||||
|
char temp = s2[ 0 ];
|
||||||
|
|
||||||
|
for ( int i = fromIndex; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean String::startsWith( const String &s2 ) const
|
||||||
|
{
|
||||||
|
if ( _length < s2._length )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return startsWith( s2, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean String::startsWith( const String &s2, unsigned int offset ) const
|
||||||
|
{
|
||||||
|
if ( offset > _length - s2._length )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::substring( unsigned int left ) const
|
||||||
|
{
|
||||||
|
return substring( left, _length );
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::substring( unsigned int left, unsigned int right ) const
|
||||||
|
{
|
||||||
|
if ( left > right )
|
||||||
|
{
|
||||||
|
int temp = right;
|
||||||
|
right = left;
|
||||||
|
left = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( right > _length )
|
||||||
|
{
|
||||||
|
right = _length;
|
||||||
|
}
|
||||||
|
|
||||||
|
char temp = _buffer[ right ]; // save the replaced character
|
||||||
|
_buffer[ right ] = '\0';
|
||||||
|
String outPut = ( _buffer + left ); // pointer arithmetic
|
||||||
|
_buffer[ right ] = temp; //restore character
|
||||||
|
return outPut;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::toLowerCase() const
|
||||||
|
{
|
||||||
|
String temp = _buffer;
|
||||||
|
|
||||||
|
for ( unsigned int i = 0; i < _length; i++ )
|
||||||
|
temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::toUpperCase() const
|
||||||
|
{
|
||||||
|
String temp = _buffer;
|
||||||
|
|
||||||
|
for ( unsigned int i = 0; i < _length; i++ )
|
||||||
|
temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String String::trim() const
|
||||||
|
{
|
||||||
|
if ( _buffer == NULL ) return *this;
|
||||||
|
String temp = _buffer;
|
||||||
|
unsigned int i,j;
|
||||||
|
|
||||||
|
for ( i = 0; i < _length; i++ )
|
||||||
|
{
|
||||||
|
if ( !isspace(_buffer[i]) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( j = temp._length - 1; j > i; j-- )
|
||||||
|
{
|
||||||
|
if ( !isspace(_buffer[j]) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp.substring( i, j + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void String::getBytes(unsigned char *buf, unsigned int bufsize)
|
||||||
|
{
|
||||||
|
if (!bufsize || !buf) return;
|
||||||
|
unsigned int len = bufsize - 1;
|
||||||
|
if (len > _length) len = _length;
|
||||||
|
strncpy((char *)buf, _buffer, len);
|
||||||
|
buf[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void String::toCharArray(char *buf, unsigned int bufsize)
|
||||||
|
{
|
||||||
|
if (!bufsize || !buf) return;
|
||||||
|
unsigned int len = bufsize - 1;
|
||||||
|
if (len > _length) len = _length;
|
||||||
|
strncpy(buf, _buffer, len);
|
||||||
|
buf[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long String::toInt() {
|
||||||
|
return atol(_buffer);
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
WString.h - String library for Wiring & Arduino
|
||||||
|
Copyright (c) 2009-10 Hernando Barragan. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef String_h
|
||||||
|
#define String_h
|
||||||
|
|
||||||
|
//#include "WProgram.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
class String
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructors
|
||||||
|
String( const char *value = "" );
|
||||||
|
String( const String &value );
|
||||||
|
String( const char );
|
||||||
|
String( const unsigned char );
|
||||||
|
String( const int, const int base=10);
|
||||||
|
String( const unsigned int, const int base=10 );
|
||||||
|
String( const long, const int base=10 );
|
||||||
|
String( const unsigned long, const int base=10 );
|
||||||
|
~String() { free(_buffer); _length = _capacity = 0;} //added _length = _capacity = 0;
|
||||||
|
|
||||||
|
// operators
|
||||||
|
const String & operator = ( const String &rhs );
|
||||||
|
const String & operator +=( const String &rhs );
|
||||||
|
//const String & operator +=( const char );
|
||||||
|
int operator ==( const String &rhs ) const;
|
||||||
|
int operator !=( const String &rhs ) const;
|
||||||
|
int operator < ( const String &rhs ) const;
|
||||||
|
int operator > ( const String &rhs ) const;
|
||||||
|
int operator <=( const String &rhs ) const;
|
||||||
|
int operator >=( const String &rhs ) const;
|
||||||
|
char operator []( unsigned int index ) const;
|
||||||
|
char& operator []( unsigned int index );
|
||||||
|
//operator const char *() const { return _buffer; }
|
||||||
|
|
||||||
|
// general methods
|
||||||
|
char charAt( unsigned int index ) const;
|
||||||
|
int compareTo( const String &anotherString ) const;
|
||||||
|
unsigned char endsWith( const String &suffix ) const;
|
||||||
|
unsigned char equals( const String &anObject ) const;
|
||||||
|
unsigned char equalsIgnoreCase( const String &anotherString ) const;
|
||||||
|
int indexOf( char ch ) const;
|
||||||
|
int indexOf( char ch, unsigned int fromIndex ) const;
|
||||||
|
int indexOf( const String &str ) const;
|
||||||
|
int indexOf( const String &str, unsigned int fromIndex ) const;
|
||||||
|
int lastIndexOf( char ch ) const;
|
||||||
|
int lastIndexOf( char ch, unsigned int fromIndex ) const;
|
||||||
|
int lastIndexOf( const String &str ) const;
|
||||||
|
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
|
||||||
|
const unsigned int length( ) const { return _length; }
|
||||||
|
void setCharAt(unsigned int index, const char ch);
|
||||||
|
unsigned char startsWith( const String &prefix ) const;
|
||||||
|
unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
|
||||||
|
String substring( unsigned int beginIndex ) const;
|
||||||
|
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
|
||||||
|
String toLowerCase( ) const;
|
||||||
|
String toUpperCase( ) const;
|
||||||
|
String trim( ) const;
|
||||||
|
void getBytes(unsigned char *buf, unsigned int bufsize);
|
||||||
|
void toCharArray(char *buf, unsigned int bufsize);
|
||||||
|
long toInt( );
|
||||||
|
const String& concat( const String &str );
|
||||||
|
String replace( char oldChar, char newChar );
|
||||||
|
String replace( const String& match, const String& replace );
|
||||||
|
friend String operator + ( String lhs, const String &rhs );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
char *_buffer; // the actual char array
|
||||||
|
unsigned int _capacity; // the array length minus one (for the '\0')
|
||||||
|
unsigned int _length; // the String length (not counting the '\0')
|
||||||
|
|
||||||
|
void getBuffer(unsigned int maxStrLen);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// allocate buffer space
|
||||||
|
inline void String::getBuffer(unsigned int maxStrLen)
|
||||||
|
{
|
||||||
|
_capacity = maxStrLen;
|
||||||
|
_buffer = (char *) malloc(_capacity + 1);
|
||||||
|
if (_buffer == NULL) _length = _capacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String operator+( String lhs, const String &rhs )
|
||||||
|
{
|
||||||
|
return lhs += rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,515 @@
|
|||||||
|
#ifndef Binary_h
|
||||||
|
#define Binary_h
|
||||||
|
|
||||||
|
#define B0 0
|
||||||
|
#define B00 0
|
||||||
|
#define B000 0
|
||||||
|
#define B0000 0
|
||||||
|
#define B00000 0
|
||||||
|
#define B000000 0
|
||||||
|
#define B0000000 0
|
||||||
|
#define B00000000 0
|
||||||
|
#define B1 1
|
||||||
|
#define B01 1
|
||||||
|
#define B001 1
|
||||||
|
#define B0001 1
|
||||||
|
#define B00001 1
|
||||||
|
#define B000001 1
|
||||||
|
#define B0000001 1
|
||||||
|
#define B00000001 1
|
||||||
|
#define B10 2
|
||||||
|
#define B010 2
|
||||||
|
#define B0010 2
|
||||||
|
#define B00010 2
|
||||||
|
#define B000010 2
|
||||||
|
#define B0000010 2
|
||||||
|
#define B00000010 2
|
||||||
|
#define B11 3
|
||||||
|
#define B011 3
|
||||||
|
#define B0011 3
|
||||||
|
#define B00011 3
|
||||||
|
#define B000011 3
|
||||||
|
#define B0000011 3
|
||||||
|
#define B00000011 3
|
||||||
|
#define B100 4
|
||||||
|
#define B0100 4
|
||||||
|
#define B00100 4
|
||||||
|
#define B000100 4
|
||||||
|
#define B0000100 4
|
||||||
|
#define B00000100 4
|
||||||
|
#define B101 5
|
||||||
|
#define B0101 5
|
||||||
|
#define B00101 5
|
||||||
|
#define B000101 5
|
||||||
|
#define B0000101 5
|
||||||
|
#define B00000101 5
|
||||||
|
#define B110 6
|
||||||
|
#define B0110 6
|
||||||
|
#define B00110 6
|
||||||
|
#define B000110 6
|
||||||
|
#define B0000110 6
|
||||||
|
#define B00000110 6
|
||||||
|
#define B111 7
|
||||||
|
#define B0111 7
|
||||||
|
#define B00111 7
|
||||||
|
#define B000111 7
|
||||||
|
#define B0000111 7
|
||||||
|
#define B00000111 7
|
||||||
|
#define B1000 8
|
||||||
|
#define B01000 8
|
||||||
|
#define B001000 8
|
||||||
|
#define B0001000 8
|
||||||
|
#define B00001000 8
|
||||||
|
#define B1001 9
|
||||||
|
#define B01001 9
|
||||||
|
#define B001001 9
|
||||||
|
#define B0001001 9
|
||||||
|
#define B00001001 9
|
||||||
|
#define B1010 10
|
||||||
|
#define B01010 10
|
||||||
|
#define B001010 10
|
||||||
|
#define B0001010 10
|
||||||
|
#define B00001010 10
|
||||||
|
#define B1011 11
|
||||||
|
#define B01011 11
|
||||||
|
#define B001011 11
|
||||||
|
#define B0001011 11
|
||||||
|
#define B00001011 11
|
||||||
|
#define B1100 12
|
||||||
|
#define B01100 12
|
||||||
|
#define B001100 12
|
||||||
|
#define B0001100 12
|
||||||
|
#define B00001100 12
|
||||||
|
#define B1101 13
|
||||||
|
#define B01101 13
|
||||||
|
#define B001101 13
|
||||||
|
#define B0001101 13
|
||||||
|
#define B00001101 13
|
||||||
|
#define B1110 14
|
||||||
|
#define B01110 14
|
||||||
|
#define B001110 14
|
||||||
|
#define B0001110 14
|
||||||
|
#define B00001110 14
|
||||||
|
#define B1111 15
|
||||||
|
#define B01111 15
|
||||||
|
#define B001111 15
|
||||||
|
#define B0001111 15
|
||||||
|
#define B00001111 15
|
||||||
|
#define B10000 16
|
||||||
|
#define B010000 16
|
||||||
|
#define B0010000 16
|
||||||
|
#define B00010000 16
|
||||||
|
#define B10001 17
|
||||||
|
#define B010001 17
|
||||||
|
#define B0010001 17
|
||||||
|
#define B00010001 17
|
||||||
|
#define B10010 18
|
||||||
|
#define B010010 18
|
||||||
|
#define B0010010 18
|
||||||
|
#define B00010010 18
|
||||||
|
#define B10011 19
|
||||||
|
#define B010011 19
|
||||||
|
#define B0010011 19
|
||||||
|
#define B00010011 19
|
||||||
|
#define B10100 20
|
||||||
|
#define B010100 20
|
||||||
|
#define B0010100 20
|
||||||
|
#define B00010100 20
|
||||||
|
#define B10101 21
|
||||||
|
#define B010101 21
|
||||||
|
#define B0010101 21
|
||||||
|
#define B00010101 21
|
||||||
|
#define B10110 22
|
||||||
|
#define B010110 22
|
||||||
|
#define B0010110 22
|
||||||
|
#define B00010110 22
|
||||||
|
#define B10111 23
|
||||||
|
#define B010111 23
|
||||||
|
#define B0010111 23
|
||||||
|
#define B00010111 23
|
||||||
|
#define B11000 24
|
||||||
|
#define B011000 24
|
||||||
|
#define B0011000 24
|
||||||
|
#define B00011000 24
|
||||||
|
#define B11001 25
|
||||||
|
#define B011001 25
|
||||||
|
#define B0011001 25
|
||||||
|
#define B00011001 25
|
||||||
|
#define B11010 26
|
||||||
|
#define B011010 26
|
||||||
|
#define B0011010 26
|
||||||
|
#define B00011010 26
|
||||||
|
#define B11011 27
|
||||||
|
#define B011011 27
|
||||||
|
#define B0011011 27
|
||||||
|
#define B00011011 27
|
||||||
|
#define B11100 28
|
||||||
|
#define B011100 28
|
||||||
|
#define B0011100 28
|
||||||
|
#define B00011100 28
|
||||||
|
#define B11101 29
|
||||||
|
#define B011101 29
|
||||||
|
#define B0011101 29
|
||||||
|
#define B00011101 29
|
||||||
|
#define B11110 30
|
||||||
|
#define B011110 30
|
||||||
|
#define B0011110 30
|
||||||
|
#define B00011110 30
|
||||||
|
#define B11111 31
|
||||||
|
#define B011111 31
|
||||||
|
#define B0011111 31
|
||||||
|
#define B00011111 31
|
||||||
|
#define B100000 32
|
||||||
|
#define B0100000 32
|
||||||
|
#define B00100000 32
|
||||||
|
#define B100001 33
|
||||||
|
#define B0100001 33
|
||||||
|
#define B00100001 33
|
||||||
|
#define B100010 34
|
||||||
|
#define B0100010 34
|
||||||
|
#define B00100010 34
|
||||||
|
#define B100011 35
|
||||||
|
#define B0100011 35
|
||||||
|
#define B00100011 35
|
||||||
|
#define B100100 36
|
||||||
|
#define B0100100 36
|
||||||
|
#define B00100100 36
|
||||||
|
#define B100101 37
|
||||||
|
#define B0100101 37
|
||||||
|
#define B00100101 37
|
||||||
|
#define B100110 38
|
||||||
|
#define B0100110 38
|
||||||
|
#define B00100110 38
|
||||||
|
#define B100111 39
|
||||||
|
#define B0100111 39
|
||||||
|
#define B00100111 39
|
||||||
|
#define B101000 40
|
||||||
|
#define B0101000 40
|
||||||
|
#define B00101000 40
|
||||||
|
#define B101001 41
|
||||||
|
#define B0101001 41
|
||||||
|
#define B00101001 41
|
||||||
|
#define B101010 42
|
||||||
|
#define B0101010 42
|
||||||
|
#define B00101010 42
|
||||||
|
#define B101011 43
|
||||||
|
#define B0101011 43
|
||||||
|
#define B00101011 43
|
||||||
|
#define B101100 44
|
||||||
|
#define B0101100 44
|
||||||
|
#define B00101100 44
|
||||||
|
#define B101101 45
|
||||||
|
#define B0101101 45
|
||||||
|
#define B00101101 45
|
||||||
|
#define B101110 46
|
||||||
|
#define B0101110 46
|
||||||
|
#define B00101110 46
|
||||||
|
#define B101111 47
|
||||||
|
#define B0101111 47
|
||||||
|
#define B00101111 47
|
||||||
|
#define B110000 48
|
||||||
|
#define B0110000 48
|
||||||
|
#define B00110000 48
|
||||||
|
#define B110001 49
|
||||||
|
#define B0110001 49
|
||||||
|
#define B00110001 49
|
||||||
|
#define B110010 50
|
||||||
|
#define B0110010 50
|
||||||
|
#define B00110010 50
|
||||||
|
#define B110011 51
|
||||||
|
#define B0110011 51
|
||||||
|
#define B00110011 51
|
||||||
|
#define B110100 52
|
||||||
|
#define B0110100 52
|
||||||
|
#define B00110100 52
|
||||||
|
#define B110101 53
|
||||||
|
#define B0110101 53
|
||||||
|
#define B00110101 53
|
||||||
|
#define B110110 54
|
||||||
|
#define B0110110 54
|
||||||
|
#define B00110110 54
|
||||||
|
#define B110111 55
|
||||||
|
#define B0110111 55
|
||||||
|
#define B00110111 55
|
||||||
|
#define B111000 56
|
||||||
|
#define B0111000 56
|
||||||
|
#define B00111000 56
|
||||||
|
#define B111001 57
|
||||||
|
#define B0111001 57
|
||||||
|
#define B00111001 57
|
||||||
|
#define B111010 58
|
||||||
|
#define B0111010 58
|
||||||
|
#define B00111010 58
|
||||||
|
#define B111011 59
|
||||||
|
#define B0111011 59
|
||||||
|
#define B00111011 59
|
||||||
|
#define B111100 60
|
||||||
|
#define B0111100 60
|
||||||
|
#define B00111100 60
|
||||||
|
#define B111101 61
|
||||||
|
#define B0111101 61
|
||||||
|
#define B00111101 61
|
||||||
|
#define B111110 62
|
||||||
|
#define B0111110 62
|
||||||
|
#define B00111110 62
|
||||||
|
#define B111111 63
|
||||||
|
#define B0111111 63
|
||||||
|
#define B00111111 63
|
||||||
|
#define B1000000 64
|
||||||
|
#define B01000000 64
|
||||||
|
#define B1000001 65
|
||||||
|
#define B01000001 65
|
||||||
|
#define B1000010 66
|
||||||
|
#define B01000010 66
|
||||||
|
#define B1000011 67
|
||||||
|
#define B01000011 67
|
||||||
|
#define B1000100 68
|
||||||
|
#define B01000100 68
|
||||||
|
#define B1000101 69
|
||||||
|
#define B01000101 69
|
||||||
|
#define B1000110 70
|
||||||
|
#define B01000110 70
|
||||||
|
#define B1000111 71
|
||||||
|
#define B01000111 71
|
||||||
|
#define B1001000 72
|
||||||
|
#define B01001000 72
|
||||||
|
#define B1001001 73
|
||||||
|
#define B01001001 73
|
||||||
|
#define B1001010 74
|
||||||
|
#define B01001010 74
|
||||||
|
#define B1001011 75
|
||||||
|
#define B01001011 75
|
||||||
|
#define B1001100 76
|
||||||
|
#define B01001100 76
|
||||||
|
#define B1001101 77
|
||||||
|
#define B01001101 77
|
||||||
|
#define B1001110 78
|
||||||
|
#define B01001110 78
|
||||||
|
#define B1001111 79
|
||||||
|
#define B01001111 79
|
||||||
|
#define B1010000 80
|
||||||
|
#define B01010000 80
|
||||||
|
#define B1010001 81
|
||||||
|
#define B01010001 81
|
||||||
|
#define B1010010 82
|
||||||
|
#define B01010010 82
|
||||||
|
#define B1010011 83
|
||||||
|
#define B01010011 83
|
||||||
|
#define B1010100 84
|
||||||
|
#define B01010100 84
|
||||||
|
#define B1010101 85
|
||||||
|
#define B01010101 85
|
||||||
|
#define B1010110 86
|
||||||
|
#define B01010110 86
|
||||||
|
#define B1010111 87
|
||||||
|
#define B01010111 87
|
||||||
|
#define B1011000 88
|
||||||
|
#define B01011000 88
|
||||||
|
#define B1011001 89
|
||||||
|
#define B01011001 89
|
||||||
|
#define B1011010 90
|
||||||
|
#define B01011010 90
|
||||||
|
#define B1011011 91
|
||||||
|
#define B01011011 91
|
||||||
|
#define B1011100 92
|
||||||
|
#define B01011100 92
|
||||||
|
#define B1011101 93
|
||||||
|
#define B01011101 93
|
||||||
|
#define B1011110 94
|
||||||
|
#define B01011110 94
|
||||||
|
#define B1011111 95
|
||||||
|
#define B01011111 95
|
||||||
|
#define B1100000 96
|
||||||
|
#define B01100000 96
|
||||||
|
#define B1100001 97
|
||||||
|
#define B01100001 97
|
||||||
|
#define B1100010 98
|
||||||
|
#define B01100010 98
|
||||||
|
#define B1100011 99
|
||||||
|
#define B01100011 99
|
||||||
|
#define B1100100 100
|
||||||
|
#define B01100100 100
|
||||||
|
#define B1100101 101
|
||||||
|
#define B01100101 101
|
||||||
|
#define B1100110 102
|
||||||
|
#define B01100110 102
|
||||||
|
#define B1100111 103
|
||||||
|
#define B01100111 103
|
||||||
|
#define B1101000 104
|
||||||
|
#define B01101000 104
|
||||||
|
#define B1101001 105
|
||||||
|
#define B01101001 105
|
||||||
|
#define B1101010 106
|
||||||
|
#define B01101010 106
|
||||||
|
#define B1101011 107
|
||||||
|
#define B01101011 107
|
||||||
|
#define B1101100 108
|
||||||
|
#define B01101100 108
|
||||||
|
#define B1101101 109
|
||||||
|
#define B01101101 109
|
||||||
|
#define B1101110 110
|
||||||
|
#define B01101110 110
|
||||||
|
#define B1101111 111
|
||||||
|
#define B01101111 111
|
||||||
|
#define B1110000 112
|
||||||
|
#define B01110000 112
|
||||||
|
#define B1110001 113
|
||||||
|
#define B01110001 113
|
||||||
|
#define B1110010 114
|
||||||
|
#define B01110010 114
|
||||||
|
#define B1110011 115
|
||||||
|
#define B01110011 115
|
||||||
|
#define B1110100 116
|
||||||
|
#define B01110100 116
|
||||||
|
#define B1110101 117
|
||||||
|
#define B01110101 117
|
||||||
|
#define B1110110 118
|
||||||
|
#define B01110110 118
|
||||||
|
#define B1110111 119
|
||||||
|
#define B01110111 119
|
||||||
|
#define B1111000 120
|
||||||
|
#define B01111000 120
|
||||||
|
#define B1111001 121
|
||||||
|
#define B01111001 121
|
||||||
|
#define B1111010 122
|
||||||
|
#define B01111010 122
|
||||||
|
#define B1111011 123
|
||||||
|
#define B01111011 123
|
||||||
|
#define B1111100 124
|
||||||
|
#define B01111100 124
|
||||||
|
#define B1111101 125
|
||||||
|
#define B01111101 125
|
||||||
|
#define B1111110 126
|
||||||
|
#define B01111110 126
|
||||||
|
#define B1111111 127
|
||||||
|
#define B01111111 127
|
||||||
|
#define B10000000 128
|
||||||
|
#define B10000001 129
|
||||||
|
#define B10000010 130
|
||||||
|
#define B10000011 131
|
||||||
|
#define B10000100 132
|
||||||
|
#define B10000101 133
|
||||||
|
#define B10000110 134
|
||||||
|
#define B10000111 135
|
||||||
|
#define B10001000 136
|
||||||
|
#define B10001001 137
|
||||||
|
#define B10001010 138
|
||||||
|
#define B10001011 139
|
||||||
|
#define B10001100 140
|
||||||
|
#define B10001101 141
|
||||||
|
#define B10001110 142
|
||||||
|
#define B10001111 143
|
||||||
|
#define B10010000 144
|
||||||
|
#define B10010001 145
|
||||||
|
#define B10010010 146
|
||||||
|
#define B10010011 147
|
||||||
|
#define B10010100 148
|
||||||
|
#define B10010101 149
|
||||||
|
#define B10010110 150
|
||||||
|
#define B10010111 151
|
||||||
|
#define B10011000 152
|
||||||
|
#define B10011001 153
|
||||||
|
#define B10011010 154
|
||||||
|
#define B10011011 155
|
||||||
|
#define B10011100 156
|
||||||
|
#define B10011101 157
|
||||||
|
#define B10011110 158
|
||||||
|
#define B10011111 159
|
||||||
|
#define B10100000 160
|
||||||
|
#define B10100001 161
|
||||||
|
#define B10100010 162
|
||||||
|
#define B10100011 163
|
||||||
|
#define B10100100 164
|
||||||
|
#define B10100101 165
|
||||||
|
#define B10100110 166
|
||||||
|
#define B10100111 167
|
||||||
|
#define B10101000 168
|
||||||
|
#define B10101001 169
|
||||||
|
#define B10101010 170
|
||||||
|
#define B10101011 171
|
||||||
|
#define B10101100 172
|
||||||
|
#define B10101101 173
|
||||||
|
#define B10101110 174
|
||||||
|
#define B10101111 175
|
||||||
|
#define B10110000 176
|
||||||
|
#define B10110001 177
|
||||||
|
#define B10110010 178
|
||||||
|
#define B10110011 179
|
||||||
|
#define B10110100 180
|
||||||
|
#define B10110101 181
|
||||||
|
#define B10110110 182
|
||||||
|
#define B10110111 183
|
||||||
|
#define B10111000 184
|
||||||
|
#define B10111001 185
|
||||||
|
#define B10111010 186
|
||||||
|
#define B10111011 187
|
||||||
|
#define B10111100 188
|
||||||
|
#define B10111101 189
|
||||||
|
#define B10111110 190
|
||||||
|
#define B10111111 191
|
||||||
|
#define B11000000 192
|
||||||
|
#define B11000001 193
|
||||||
|
#define B11000010 194
|
||||||
|
#define B11000011 195
|
||||||
|
#define B11000100 196
|
||||||
|
#define B11000101 197
|
||||||
|
#define B11000110 198
|
||||||
|
#define B11000111 199
|
||||||
|
#define B11001000 200
|
||||||
|
#define B11001001 201
|
||||||
|
#define B11001010 202
|
||||||
|
#define B11001011 203
|
||||||
|
#define B11001100 204
|
||||||
|
#define B11001101 205
|
||||||
|
#define B11001110 206
|
||||||
|
#define B11001111 207
|
||||||
|
#define B11010000 208
|
||||||
|
#define B11010001 209
|
||||||
|
#define B11010010 210
|
||||||
|
#define B11010011 211
|
||||||
|
#define B11010100 212
|
||||||
|
#define B11010101 213
|
||||||
|
#define B11010110 214
|
||||||
|
#define B11010111 215
|
||||||
|
#define B11011000 216
|
||||||
|
#define B11011001 217
|
||||||
|
#define B11011010 218
|
||||||
|
#define B11011011 219
|
||||||
|
#define B11011100 220
|
||||||
|
#define B11011101 221
|
||||||
|
#define B11011110 222
|
||||||
|
#define B11011111 223
|
||||||
|
#define B11100000 224
|
||||||
|
#define B11100001 225
|
||||||
|
#define B11100010 226
|
||||||
|
#define B11100011 227
|
||||||
|
#define B11100100 228
|
||||||
|
#define B11100101 229
|
||||||
|
#define B11100110 230
|
||||||
|
#define B11100111 231
|
||||||
|
#define B11101000 232
|
||||||
|
#define B11101001 233
|
||||||
|
#define B11101010 234
|
||||||
|
#define B11101011 235
|
||||||
|
#define B11101100 236
|
||||||
|
#define B11101101 237
|
||||||
|
#define B11101110 238
|
||||||
|
#define B11101111 239
|
||||||
|
#define B11110000 240
|
||||||
|
#define B11110001 241
|
||||||
|
#define B11110010 242
|
||||||
|
#define B11110011 243
|
||||||
|
#define B11110100 244
|
||||||
|
#define B11110101 245
|
||||||
|
#define B11110110 246
|
||||||
|
#define B11110111 247
|
||||||
|
#define B11111000 248
|
||||||
|
#define B11111001 249
|
||||||
|
#define B11111010 250
|
||||||
|
#define B11111011 251
|
||||||
|
#define B11111100 252
|
||||||
|
#define B11111101 253
|
||||||
|
#define B11111110 254
|
||||||
|
#define B11111111 255
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <WProgram.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
loop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,627 @@
|
|||||||
|
/*
|
||||||
|
pins_arduino.c - pin definitions for the Arduino board
|
||||||
|
Part of Arduino / Wiring Lite
|
||||||
|
|
||||||
|
Copyright (c) 2005 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
-----------
|
||||||
|
11/25/11 - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "wiring_private.h"
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
|
||||||
|
// On the Arduino board, digital pins are also used
|
||||||
|
// for the analog output (software PWM). Analog input
|
||||||
|
// pins are a separate set.
|
||||||
|
|
||||||
|
// ATMEL ATMEGA8 & 168 / ARDUINO
|
||||||
|
//
|
||||||
|
// +-\/-+
|
||||||
|
// PC6 1| |28 PC5 (AI 5)
|
||||||
|
// (D 0) PD0 2| |27 PC4 (AI 4)
|
||||||
|
// (D 1) PD1 3| |26 PC3 (AI 3)
|
||||||
|
// (D 2) PD2 4| |25 PC2 (AI 2)
|
||||||
|
// PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
|
||||||
|
// (D 4) PD4 6| |23 PC0 (AI 0)
|
||||||
|
// VCC 7| |22 GND
|
||||||
|
// GND 8| |21 AREF
|
||||||
|
// PB6 9| |20 AVCC
|
||||||
|
// PB7 10| |19 PB5 (D 13)
|
||||||
|
// PWM+ (D 5) PD5 11| |18 PB4 (D 12)
|
||||||
|
// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
|
||||||
|
// (D 7) PD7 13| |16 PB2 (D 10) PWM
|
||||||
|
// (D 8) PB0 14| |15 PB1 (D 9) PWM
|
||||||
|
// +----+
|
||||||
|
//
|
||||||
|
// (PWM+ indicates the additional PWM pins on the ATmega168.)
|
||||||
|
|
||||||
|
// ATMEL ATMEGA1280 / ARDUINO
|
||||||
|
//
|
||||||
|
// 0-7 PE0-PE7 works
|
||||||
|
// 8-13 PB0-PB5 works
|
||||||
|
// 14-21 PA0-PA7 works
|
||||||
|
// 22-29 PH0-PH7 works
|
||||||
|
// 30-35 PG5-PG0 works
|
||||||
|
// 36-43 PC7-PC0 works
|
||||||
|
// 44-51 PJ7-PJ0 works
|
||||||
|
// 52-59 PL7-PL0 works
|
||||||
|
// 60-67 PD7-PD0 works
|
||||||
|
// A0-A7 PF0-PF7
|
||||||
|
// A8-A15 PK0-PK7
|
||||||
|
// ATMEL ATMEGA644P / SANGUINO
|
||||||
|
//
|
||||||
|
// +---\/---+
|
||||||
|
// INT0 (D 0) PB0 1| |40 PA0 (AI 0 / D31)
|
||||||
|
// INT1 (D 1) PB1 2| |39 PA1 (AI 1 / D30)
|
||||||
|
// INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
|
||||||
|
// PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
|
||||||
|
// PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
|
||||||
|
// MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
|
||||||
|
// MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
|
||||||
|
// SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
|
||||||
|
// RST 9| |32 AREF
|
||||||
|
// VCC 10| |31 GND
|
||||||
|
// GND 11| |30 AVCC
|
||||||
|
// XTAL2 12| |29 PC7 (D 23)
|
||||||
|
// XTAL1 13| |28 PC6 (D 22)
|
||||||
|
// RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
|
||||||
|
// TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
|
||||||
|
// RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
|
||||||
|
// TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
|
||||||
|
// PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
|
||||||
|
// PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
|
||||||
|
// PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
|
||||||
|
// +--------+
|
||||||
|
//
|
||||||
|
#define PA 1
|
||||||
|
#define PB 2
|
||||||
|
#define PC 3
|
||||||
|
#define PD 4
|
||||||
|
#define PE 5
|
||||||
|
#define PF 6
|
||||||
|
#define PG 7
|
||||||
|
#define PH 8
|
||||||
|
#define PJ 10
|
||||||
|
#define PK 11
|
||||||
|
#define PL 12
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
&DDRA,
|
||||||
|
&DDRB,
|
||||||
|
&DDRC,
|
||||||
|
&DDRD,
|
||||||
|
&DDRE,
|
||||||
|
&DDRF,
|
||||||
|
&DDRG,
|
||||||
|
&DDRH,
|
||||||
|
NOT_A_PORT,
|
||||||
|
&DDRJ,
|
||||||
|
&DDRK,
|
||||||
|
&DDRL,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PORTA,
|
||||||
|
&PORTB,
|
||||||
|
&PORTC,
|
||||||
|
&PORTD,
|
||||||
|
&PORTE,
|
||||||
|
&PORTF,
|
||||||
|
&PORTG,
|
||||||
|
&PORTH,
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PORTJ,
|
||||||
|
&PORTK,
|
||||||
|
&PORTL,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||||
|
NOT_A_PIN,
|
||||||
|
&PINA,
|
||||||
|
&PINB,
|
||||||
|
&PINC,
|
||||||
|
&PIND,
|
||||||
|
&PINE,
|
||||||
|
&PINF,
|
||||||
|
&PING,
|
||||||
|
&PINH,
|
||||||
|
NOT_A_PIN,
|
||||||
|
&PINJ,
|
||||||
|
&PINK,
|
||||||
|
&PINL,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||||
|
// PORTLIST
|
||||||
|
// -------------------------------------------
|
||||||
|
PE , // PE 0 ** 0 ** USART0_RX
|
||||||
|
PE , // PE 1 ** 1 ** USART0_TX
|
||||||
|
PE , // PE 4 ** 2 ** PWM2
|
||||||
|
PE , // PE 5 ** 3 ** PWM3
|
||||||
|
PG , // PG 5 ** 4 ** PWM4
|
||||||
|
PE , // PE 3 ** 5 ** PWM5
|
||||||
|
PH , // PH 3 ** 6 ** PWM6
|
||||||
|
PH , // PH 4 ** 7 ** PWM7
|
||||||
|
PH , // PH 5 ** 8 ** PWM8
|
||||||
|
PH , // PH 6 ** 9 ** PWM9
|
||||||
|
PB , // PB 4 ** 10 ** PWM10
|
||||||
|
PB , // PB 5 ** 11 ** PWM11
|
||||||
|
PB , // PB 6 ** 12 ** PWM12
|
||||||
|
PB , // PB 7 ** 13 ** PWM13
|
||||||
|
PJ , // PJ 1 ** 14 ** USART3_TX
|
||||||
|
PJ , // PJ 0 ** 15 ** USART3_RX
|
||||||
|
PH , // PH 1 ** 16 ** USART2_TX
|
||||||
|
PH , // PH 0 ** 17 ** USART2_RX
|
||||||
|
PD , // PD 3 ** 18 ** USART1_TX
|
||||||
|
PD , // PD 2 ** 19 ** USART1_RX
|
||||||
|
PD , // PD 1 ** 20 ** I2C_SDA
|
||||||
|
PD , // PD 0 ** 21 ** I2C_SCL
|
||||||
|
PA , // PA 0 ** 22 ** D22
|
||||||
|
PA , // PA 1 ** 23 ** D23
|
||||||
|
PA , // PA 2 ** 24 ** D24
|
||||||
|
PA , // PA 3 ** 25 ** D25
|
||||||
|
PA , // PA 4 ** 26 ** D26
|
||||||
|
PA , // PA 5 ** 27 ** D27
|
||||||
|
PA , // PA 6 ** 28 ** D28
|
||||||
|
PA , // PA 7 ** 29 ** D29
|
||||||
|
PC , // PC 7 ** 30 ** D30
|
||||||
|
PC , // PC 6 ** 31 ** D31
|
||||||
|
PC , // PC 5 ** 32 ** D32
|
||||||
|
PC , // PC 4 ** 33 ** D33
|
||||||
|
PC , // PC 3 ** 34 ** D34
|
||||||
|
PC , // PC 2 ** 35 ** D35
|
||||||
|
PC , // PC 1 ** 36 ** D36
|
||||||
|
PC , // PC 0 ** 37 ** D37
|
||||||
|
PD , // PD 7 ** 38 ** D38
|
||||||
|
PG , // PG 2 ** 39 ** D39
|
||||||
|
PG , // PG 1 ** 40 ** D40
|
||||||
|
PG , // PG 0 ** 41 ** D41
|
||||||
|
PL , // PL 7 ** 42 ** D42
|
||||||
|
PL , // PL 6 ** 43 ** D43
|
||||||
|
PL , // PL 5 ** 44 ** D44
|
||||||
|
PL , // PL 4 ** 45 ** D45
|
||||||
|
PL , // PL 3 ** 46 ** D46
|
||||||
|
PL , // PL 2 ** 47 ** D47
|
||||||
|
PL , // PL 1 ** 48 ** D48
|
||||||
|
PL , // PL 0 ** 49 ** D49
|
||||||
|
PB , // PB 3 ** 50 ** SPI_MISO
|
||||||
|
PB , // PB 2 ** 51 ** SPI_MOSI
|
||||||
|
PB , // PB 1 ** 52 ** SPI_SCK
|
||||||
|
PB , // PB 0 ** 53 ** SPI_SS
|
||||||
|
PF , // PF 0 ** 54 ** A0
|
||||||
|
PF , // PF 1 ** 55 ** A1
|
||||||
|
PF , // PF 2 ** 56 ** A2
|
||||||
|
PF , // PF 3 ** 57 ** A3
|
||||||
|
PF , // PF 4 ** 58 ** A4
|
||||||
|
PF , // PF 5 ** 59 ** A5
|
||||||
|
PF , // PF 6 ** 60 ** A6
|
||||||
|
PF , // PF 7 ** 61 ** A7
|
||||||
|
PK , // PK 0 ** 62 ** A8
|
||||||
|
PK , // PK 1 ** 63 ** A9
|
||||||
|
PK , // PK 2 ** 64 ** A10
|
||||||
|
PK , // PK 3 ** 65 ** A11
|
||||||
|
PK , // PK 4 ** 66 ** A12
|
||||||
|
PK , // PK 5 ** 67 ** A13
|
||||||
|
PK , // PK 6 ** 68 ** A14
|
||||||
|
PK , // PK 7 ** 69 ** A15
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||||
|
// PIN IN PORT
|
||||||
|
// -------------------------------------------
|
||||||
|
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
|
||||||
|
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
|
||||||
|
_BV( 4 ) , // PE 4 ** 2 ** PWM2
|
||||||
|
_BV( 5 ) , // PE 5 ** 3 ** PWM3
|
||||||
|
_BV( 5 ) , // PG 5 ** 4 ** PWM4
|
||||||
|
_BV( 3 ) , // PE 3 ** 5 ** PWM5
|
||||||
|
_BV( 3 ) , // PH 3 ** 6 ** PWM6
|
||||||
|
_BV( 4 ) , // PH 4 ** 7 ** PWM7
|
||||||
|
_BV( 5 ) , // PH 5 ** 8 ** PWM8
|
||||||
|
_BV( 6 ) , // PH 6 ** 9 ** PWM9
|
||||||
|
_BV( 4 ) , // PB 4 ** 10 ** PWM10
|
||||||
|
_BV( 5 ) , // PB 5 ** 11 ** PWM11
|
||||||
|
_BV( 6 ) , // PB 6 ** 12 ** PWM12
|
||||||
|
_BV( 7 ) , // PB 7 ** 13 ** PWM13
|
||||||
|
_BV( 1 ) , // PJ 1 ** 14 ** USART3_TX
|
||||||
|
_BV( 0 ) , // PJ 0 ** 15 ** USART3_RX
|
||||||
|
_BV( 1 ) , // PH 1 ** 16 ** USART2_TX
|
||||||
|
_BV( 0 ) , // PH 0 ** 17 ** USART2_RX
|
||||||
|
_BV( 3 ) , // PD 3 ** 18 ** USART1_TX
|
||||||
|
_BV( 2 ) , // PD 2 ** 19 ** USART1_RX
|
||||||
|
_BV( 1 ) , // PD 1 ** 20 ** I2C_SDA
|
||||||
|
_BV( 0 ) , // PD 0 ** 21 ** I2C_SCL
|
||||||
|
_BV( 0 ) , // PA 0 ** 22 ** D22
|
||||||
|
_BV( 1 ) , // PA 1 ** 23 ** D23
|
||||||
|
_BV( 2 ) , // PA 2 ** 24 ** D24
|
||||||
|
_BV( 3 ) , // PA 3 ** 25 ** D25
|
||||||
|
_BV( 4 ) , // PA 4 ** 26 ** D26
|
||||||
|
_BV( 5 ) , // PA 5 ** 27 ** D27
|
||||||
|
_BV( 6 ) , // PA 6 ** 28 ** D28
|
||||||
|
_BV( 7 ) , // PA 7 ** 29 ** D29
|
||||||
|
_BV( 7 ) , // PC 7 ** 30 ** D30
|
||||||
|
_BV( 6 ) , // PC 6 ** 31 ** D31
|
||||||
|
_BV( 5 ) , // PC 5 ** 32 ** D32
|
||||||
|
_BV( 4 ) , // PC 4 ** 33 ** D33
|
||||||
|
_BV( 3 ) , // PC 3 ** 34 ** D34
|
||||||
|
_BV( 2 ) , // PC 2 ** 35 ** D35
|
||||||
|
_BV( 1 ) , // PC 1 ** 36 ** D36
|
||||||
|
_BV( 0 ) , // PC 0 ** 37 ** D37
|
||||||
|
_BV( 7 ) , // PD 7 ** 38 ** D38
|
||||||
|
_BV( 2 ) , // PG 2 ** 39 ** D39
|
||||||
|
_BV( 1 ) , // PG 1 ** 40 ** D40
|
||||||
|
_BV( 0 ) , // PG 0 ** 41 ** D41
|
||||||
|
_BV( 7 ) , // PL 7 ** 42 ** D42
|
||||||
|
_BV( 6 ) , // PL 6 ** 43 ** D43
|
||||||
|
_BV( 5 ) , // PL 5 ** 44 ** D44
|
||||||
|
_BV( 4 ) , // PL 4 ** 45 ** D45
|
||||||
|
_BV( 3 ) , // PL 3 ** 46 ** D46
|
||||||
|
_BV( 2 ) , // PL 2 ** 47 ** D47
|
||||||
|
_BV( 1 ) , // PL 1 ** 48 ** D48
|
||||||
|
_BV( 0 ) , // PL 0 ** 49 ** D49
|
||||||
|
_BV( 3 ) , // PB 3 ** 50 ** SPI_MISO
|
||||||
|
_BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI
|
||||||
|
_BV( 1 ) , // PB 1 ** 52 ** SPI_SCK
|
||||||
|
_BV( 0 ) , // PB 0 ** 53 ** SPI_SS
|
||||||
|
_BV( 0 ) , // PF 0 ** 54 ** A0
|
||||||
|
_BV( 1 ) , // PF 1 ** 55 ** A1
|
||||||
|
_BV( 2 ) , // PF 2 ** 56 ** A2
|
||||||
|
_BV( 3 ) , // PF 3 ** 57 ** A3
|
||||||
|
_BV( 4 ) , // PF 4 ** 58 ** A4
|
||||||
|
_BV( 5 ) , // PF 5 ** 59 ** A5
|
||||||
|
_BV( 6 ) , // PF 6 ** 60 ** A6
|
||||||
|
_BV( 7 ) , // PF 7 ** 61 ** A7
|
||||||
|
_BV( 0 ) , // PK 0 ** 62 ** A8
|
||||||
|
_BV( 1 ) , // PK 1 ** 63 ** A9
|
||||||
|
_BV( 2 ) , // PK 2 ** 64 ** A10
|
||||||
|
_BV( 3 ) , // PK 3 ** 65 ** A11
|
||||||
|
_BV( 4 ) , // PK 4 ** 66 ** A12
|
||||||
|
_BV( 5 ) , // PK 5 ** 67 ** A13
|
||||||
|
_BV( 6 ) , // PK 6 ** 68 ** A14
|
||||||
|
_BV( 7 ) , // PK 7 ** 69 ** A15
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||||
|
// TIMERS
|
||||||
|
// -------------------------------------------
|
||||||
|
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
|
||||||
|
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
|
||||||
|
TIMER3B , // PE 4 ** 2 ** PWM2
|
||||||
|
TIMER3C , // PE 5 ** 3 ** PWM3
|
||||||
|
TIMER0B , // PG 5 ** 4 ** PWM4
|
||||||
|
TIMER3A , // PE 3 ** 5 ** PWM5
|
||||||
|
TIMER4A , // PH 3 ** 6 ** PWM6
|
||||||
|
TIMER4B , // PH 4 ** 7 ** PWM7
|
||||||
|
TIMER4C , // PH 5 ** 8 ** PWM8
|
||||||
|
TIMER2B , // PH 6 ** 9 ** PWM9
|
||||||
|
TIMER2A , // PB 4 ** 10 ** PWM10
|
||||||
|
TIMER1A , // PB 5 ** 11 ** PWM11
|
||||||
|
TIMER1B , // PB 6 ** 12 ** PWM12
|
||||||
|
TIMER0A , // PB 7 ** 13 ** PWM13
|
||||||
|
NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX
|
||||||
|
NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX
|
||||||
|
NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX
|
||||||
|
NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX
|
||||||
|
NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX
|
||||||
|
NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX
|
||||||
|
NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA
|
||||||
|
NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL
|
||||||
|
NOT_ON_TIMER , // PA 0 ** 22 ** D22
|
||||||
|
NOT_ON_TIMER , // PA 1 ** 23 ** D23
|
||||||
|
NOT_ON_TIMER , // PA 2 ** 24 ** D24
|
||||||
|
NOT_ON_TIMER , // PA 3 ** 25 ** D25
|
||||||
|
NOT_ON_TIMER , // PA 4 ** 26 ** D26
|
||||||
|
NOT_ON_TIMER , // PA 5 ** 27 ** D27
|
||||||
|
NOT_ON_TIMER , // PA 6 ** 28 ** D28
|
||||||
|
NOT_ON_TIMER , // PA 7 ** 29 ** D29
|
||||||
|
NOT_ON_TIMER , // PC 7 ** 30 ** D30
|
||||||
|
NOT_ON_TIMER , // PC 6 ** 31 ** D31
|
||||||
|
NOT_ON_TIMER , // PC 5 ** 32 ** D32
|
||||||
|
NOT_ON_TIMER , // PC 4 ** 33 ** D33
|
||||||
|
NOT_ON_TIMER , // PC 3 ** 34 ** D34
|
||||||
|
NOT_ON_TIMER , // PC 2 ** 35 ** D35
|
||||||
|
NOT_ON_TIMER , // PC 1 ** 36 ** D36
|
||||||
|
NOT_ON_TIMER , // PC 0 ** 37 ** D37
|
||||||
|
NOT_ON_TIMER , // PD 7 ** 38 ** D38
|
||||||
|
NOT_ON_TIMER , // PG 2 ** 39 ** D39
|
||||||
|
NOT_ON_TIMER , // PG 1 ** 40 ** D40
|
||||||
|
NOT_ON_TIMER , // PG 0 ** 41 ** D41
|
||||||
|
NOT_ON_TIMER , // PL 7 ** 42 ** D42
|
||||||
|
NOT_ON_TIMER , // PL 6 ** 43 ** D43
|
||||||
|
TIMER5C , // PL 5 ** 44 ** D44
|
||||||
|
TIMER5B , // PL 4 ** 45 ** D45
|
||||||
|
TIMER5A , // PL 3 ** 46 ** D46
|
||||||
|
NOT_ON_TIMER , // PL 2 ** 47 ** D47
|
||||||
|
NOT_ON_TIMER , // PL 1 ** 48 ** D48
|
||||||
|
NOT_ON_TIMER , // PL 0 ** 49 ** D49
|
||||||
|
NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO
|
||||||
|
NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI
|
||||||
|
NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK
|
||||||
|
NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS
|
||||||
|
NOT_ON_TIMER , // PF 0 ** 54 ** A0
|
||||||
|
NOT_ON_TIMER , // PF 1 ** 55 ** A1
|
||||||
|
NOT_ON_TIMER , // PF 2 ** 56 ** A2
|
||||||
|
NOT_ON_TIMER , // PF 3 ** 57 ** A3
|
||||||
|
NOT_ON_TIMER , // PF 4 ** 58 ** A4
|
||||||
|
NOT_ON_TIMER , // PF 5 ** 59 ** A5
|
||||||
|
NOT_ON_TIMER , // PF 6 ** 60 ** A6
|
||||||
|
NOT_ON_TIMER , // PF 7 ** 61 ** A7
|
||||||
|
NOT_ON_TIMER , // PK 0 ** 62 ** A8
|
||||||
|
NOT_ON_TIMER , // PK 1 ** 63 ** A9
|
||||||
|
NOT_ON_TIMER , // PK 2 ** 64 ** A10
|
||||||
|
NOT_ON_TIMER , // PK 3 ** 65 ** A11
|
||||||
|
NOT_ON_TIMER , // PK 4 ** 66 ** A12
|
||||||
|
NOT_ON_TIMER , // PK 5 ** 67 ** A13
|
||||||
|
NOT_ON_TIMER , // PK 6 ** 68 ** A14
|
||||||
|
NOT_ON_TIMER , // PK 7 ** 69 ** A15
|
||||||
|
};
|
||||||
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||||
|
// these arrays map port names (e.g. port B) to the
|
||||||
|
// appropriate addresses for various functions (e.g. reading
|
||||||
|
// and writing)
|
||||||
|
const uint16_t PROGMEM port_to_mode_PGM[] =
|
||||||
|
{
|
||||||
|
NOT_A_PORT,
|
||||||
|
&DDRA,
|
||||||
|
&DDRB,
|
||||||
|
&DDRC,
|
||||||
|
&DDRD,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_output_PGM[] =
|
||||||
|
{
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PORTA,
|
||||||
|
&PORTB,
|
||||||
|
&PORTC,
|
||||||
|
&PORTD,
|
||||||
|
};
|
||||||
|
const uint16_t PROGMEM port_to_input_PGM[] =
|
||||||
|
{
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PINA,
|
||||||
|
&PINB,
|
||||||
|
&PINC,
|
||||||
|
&PIND,
|
||||||
|
};
|
||||||
|
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
||||||
|
{
|
||||||
|
PB, /* 0 */
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PD, /* 8 */
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PC, /* 16 */
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PA, /* 24 */
|
||||||
|
PA,
|
||||||
|
PA,
|
||||||
|
PA,
|
||||||
|
PA,
|
||||||
|
PA,
|
||||||
|
PA,
|
||||||
|
PA /* 31 */
|
||||||
|
};
|
||||||
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||||
|
{
|
||||||
|
_BV(0), /* 0, port B */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
_BV(6),
|
||||||
|
_BV(7),
|
||||||
|
_BV(0), /* 8, port D */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
_BV(6),
|
||||||
|
_BV(7),
|
||||||
|
_BV(0), /* 16, port C */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
_BV(6),
|
||||||
|
_BV(7),
|
||||||
|
_BV(7), /* 24, port A */
|
||||||
|
_BV(6),
|
||||||
|
_BV(5),
|
||||||
|
_BV(4),
|
||||||
|
_BV(3),
|
||||||
|
_BV(2),
|
||||||
|
_BV(1),
|
||||||
|
_BV(0)
|
||||||
|
};
|
||||||
|
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
|
||||||
|
{
|
||||||
|
NOT_ON_TIMER, /* 0 - PB0 */
|
||||||
|
NOT_ON_TIMER, /* 1 - PB1 */
|
||||||
|
NOT_ON_TIMER, /* 2 - PB2 */
|
||||||
|
TIMER0A, /* 3 - PB3 */
|
||||||
|
TIMER0B, /* 4 - PB4 */
|
||||||
|
NOT_ON_TIMER, /* 5 - PB5 */
|
||||||
|
NOT_ON_TIMER, /* 6 - PB6 */
|
||||||
|
NOT_ON_TIMER, /* 7 - PB7 */
|
||||||
|
NOT_ON_TIMER, /* 8 - PD0 */
|
||||||
|
NOT_ON_TIMER, /* 9 - PD1 */
|
||||||
|
NOT_ON_TIMER, /* 10 - PD2 */
|
||||||
|
NOT_ON_TIMER, /* 11 - PD3 */
|
||||||
|
TIMER1B, /* 12 - PD4 */
|
||||||
|
TIMER1A, /* 13 - PD5 */
|
||||||
|
TIMER2B, /* 14 - PD6 */
|
||||||
|
TIMER2A, /* 15 - PD7 */
|
||||||
|
NOT_ON_TIMER, /* 16 - PC0 */
|
||||||
|
NOT_ON_TIMER, /* 17 - PC1 */
|
||||||
|
NOT_ON_TIMER, /* 18 - PC2 */
|
||||||
|
NOT_ON_TIMER, /* 19 - PC3 */
|
||||||
|
NOT_ON_TIMER, /* 20 - PC4 */
|
||||||
|
NOT_ON_TIMER, /* 21 - PC5 */
|
||||||
|
NOT_ON_TIMER, /* 22 - PC6 */
|
||||||
|
NOT_ON_TIMER, /* 23 - PC7 */
|
||||||
|
NOT_ON_TIMER, /* 24 - PA0 */
|
||||||
|
NOT_ON_TIMER, /* 25 - PA1 */
|
||||||
|
NOT_ON_TIMER, /* 26 - PA2 */
|
||||||
|
NOT_ON_TIMER, /* 27 - PA3 */
|
||||||
|
NOT_ON_TIMER, /* 28 - PA4 */
|
||||||
|
NOT_ON_TIMER, /* 29 - PA5 */
|
||||||
|
NOT_ON_TIMER, /* 30 - PA6 */
|
||||||
|
NOT_ON_TIMER /* 31 - PA7 */
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
// these arrays map port names (e.g. port B) to the
|
||||||
|
// appropriate addresses for various functions (e.g. reading
|
||||||
|
// and writing)
|
||||||
|
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
&DDRB,
|
||||||
|
&DDRC,
|
||||||
|
&DDRD,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PORTB,
|
||||||
|
&PORTC,
|
||||||
|
&PORTD,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
&PINB,
|
||||||
|
&PINC,
|
||||||
|
&PIND,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||||
|
PD, /* 0 */
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PD,
|
||||||
|
PB, /* 8 */
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PB,
|
||||||
|
PC, /* 14 */
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
PC,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||||
|
_BV(0), /* 0, port D */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
_BV(6),
|
||||||
|
_BV(7),
|
||||||
|
_BV(0), /* 8, port B */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
_BV(0), /* 14, port C */
|
||||||
|
_BV(1),
|
||||||
|
_BV(2),
|
||||||
|
_BV(3),
|
||||||
|
_BV(4),
|
||||||
|
_BV(5),
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||||
|
NOT_ON_TIMER, /* 0 - port D */
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
// on the ATmega168, digital pin 3 has hardware pwm
|
||||||
|
#if defined(__AVR_ATmega8__)
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
#else
|
||||||
|
TIMER2B,
|
||||||
|
#endif
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
// on the ATmega168, digital pins 5 and 6 have hardware pwm
|
||||||
|
#if defined(__AVR_ATmega8__)
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
#else
|
||||||
|
TIMER0B,
|
||||||
|
TIMER0A,
|
||||||
|
#endif
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER, /* 8 - port B */
|
||||||
|
TIMER1A,
|
||||||
|
TIMER1B,
|
||||||
|
#if defined(__AVR_ATmega8__)
|
||||||
|
TIMER2,
|
||||||
|
#else
|
||||||
|
TIMER2A,
|
||||||
|
#endif
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER, /* 14 - port C */
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
pins_arduino.h - Pin definition functions for Arduino
|
||||||
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2007 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Pins_Arduino_h
|
||||||
|
#define Pins_Arduino_h
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
#define NOT_A_PIN 0
|
||||||
|
#define NOT_A_PORT 0
|
||||||
|
|
||||||
|
#define NOT_ON_TIMER 0
|
||||||
|
#define TIMER0A 1
|
||||||
|
#define TIMER0B 2
|
||||||
|
#define TIMER1A 3
|
||||||
|
#define TIMER1B 4
|
||||||
|
#define TIMER2 5
|
||||||
|
#define TIMER2A 6
|
||||||
|
#define TIMER2B 7
|
||||||
|
|
||||||
|
#define TIMER3A 8
|
||||||
|
#define TIMER3B 9
|
||||||
|
#define TIMER3C 10
|
||||||
|
#define TIMER4A 11
|
||||||
|
#define TIMER4B 12
|
||||||
|
#define TIMER4C 13
|
||||||
|
#define TIMER5A 14
|
||||||
|
#define TIMER5B 15
|
||||||
|
#define TIMER5C 16
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
const static uint8_t SS = 53;
|
||||||
|
const static uint8_t MOSI = 51;
|
||||||
|
const static uint8_t MISO = 50;
|
||||||
|
const static uint8_t SCK = 52;
|
||||||
|
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||||
|
const static uint8_t SS = 4;
|
||||||
|
const static uint8_t MOSI = 5;
|
||||||
|
const static uint8_t MISO = 6;
|
||||||
|
const static uint8_t SCK = 7;
|
||||||
|
|
||||||
|
#else
|
||||||
|
const static uint8_t SS = 10;
|
||||||
|
const static uint8_t MOSI = 11;
|
||||||
|
const static uint8_t MISO = 12;
|
||||||
|
const static uint8_t SCK = 13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// On the ATmega1280, the addresses of some of the port registers are
|
||||||
|
// greater than 255, so we can't store them in uint8_t's.
|
||||||
|
extern const uint16_t PROGMEM port_to_mode_PGM[];
|
||||||
|
extern const uint16_t PROGMEM port_to_input_PGM[];
|
||||||
|
extern const uint16_t PROGMEM port_to_output_PGM[];
|
||||||
|
|
||||||
|
extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
|
||||||
|
// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
|
||||||
|
extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
|
||||||
|
extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
|
||||||
|
|
||||||
|
// Get the bit location within the hardware port of the given virtual pin.
|
||||||
|
// This comes from the pins_*.c file for the active board configuration.
|
||||||
|
//
|
||||||
|
// These perform slightly better as macros compared to inline functions
|
||||||
|
//
|
||||||
|
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
|
||||||
|
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
|
||||||
|
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
|
||||||
|
#define analogInPinToBit(P) (P)
|
||||||
|
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
|
||||||
|
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
|
||||||
|
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
wiring.c - Partial implementation of the Wiring API for the ATmega8.
|
||||||
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2005-2006 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wiring_private.h"
|
||||||
|
|
||||||
|
// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
|
||||||
|
// the overflow handler is called every 256 ticks.
|
||||||
|
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
|
||||||
|
|
||||||
|
// the whole number of milliseconds per timer0 overflow
|
||||||
|
#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
|
||||||
|
|
||||||
|
// the fractional number of milliseconds per timer0 overflow. we shift right
|
||||||
|
// by three to fit these numbers into a byte. (for the clock speeds we care
|
||||||
|
// about - 8 and 16 MHz - this doesn't lose precision.)
|
||||||
|
#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
|
||||||
|
#define FRACT_MAX (1000 >> 3)
|
||||||
|
|
||||||
|
volatile unsigned long timer0_overflow_count = 0;
|
||||||
|
volatile unsigned long timer0_millis = 0;
|
||||||
|
static unsigned char timer0_fract = 0;
|
||||||
|
|
||||||
|
SIGNAL(TIMER0_OVF_vect)
|
||||||
|
{
|
||||||
|
// copy these to local variables so they can be stored in registers
|
||||||
|
// (volatile variables must be read from memory on every access)
|
||||||
|
unsigned long m = timer0_millis;
|
||||||
|
unsigned char f = timer0_fract;
|
||||||
|
|
||||||
|
m += MILLIS_INC;
|
||||||
|
f += FRACT_INC;
|
||||||
|
if (f >= FRACT_MAX) {
|
||||||
|
f -= FRACT_MAX;
|
||||||
|
m += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer0_fract = f;
|
||||||
|
timer0_millis = m;
|
||||||
|
timer0_overflow_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long millis()
|
||||||
|
{
|
||||||
|
unsigned long m;
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
|
||||||
|
// disable interrupts while we read timer0_millis or we might get an
|
||||||
|
// inconsistent value (e.g. in the middle of a write to timer0_millis)
|
||||||
|
cli();
|
||||||
|
m = timer0_millis;
|
||||||
|
SREG = oldSREG;
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long micros() {
|
||||||
|
unsigned long m;
|
||||||
|
uint8_t oldSREG = SREG, t;
|
||||||
|
|
||||||
|
cli();
|
||||||
|
m = timer0_overflow_count;
|
||||||
|
#if defined(TCNT0)
|
||||||
|
t = TCNT0;
|
||||||
|
#elif defined(TCNT0L)
|
||||||
|
t = TCNT0L;
|
||||||
|
#else
|
||||||
|
#error TIMER 0 not defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TIFR0
|
||||||
|
if ((TIFR0 & _BV(TOV0)) && (t < 255))
|
||||||
|
m++;
|
||||||
|
#else
|
||||||
|
if ((TIFR & _BV(TOV0)) && (t < 255))
|
||||||
|
m++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SREG = oldSREG;
|
||||||
|
|
||||||
|
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
void delay(unsigned long ms)
|
||||||
|
{
|
||||||
|
uint16_t start = (uint16_t)micros();
|
||||||
|
|
||||||
|
while (ms > 0) {
|
||||||
|
if (((uint16_t)micros() - start) >= 1000) {
|
||||||
|
ms--;
|
||||||
|
start += 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */
|
||||||
|
void delayMicroseconds(unsigned int us)
|
||||||
|
{
|
||||||
|
// calling avrlib's delay_us() function with low values (e.g. 1 or
|
||||||
|
// 2 microseconds) gives delays longer than desired.
|
||||||
|
//delay_us(us);
|
||||||
|
|
||||||
|
#if F_CPU >= 16000000L
|
||||||
|
// for the 16 MHz clock on most Arduino boards
|
||||||
|
|
||||||
|
// for a one-microsecond delay, simply return. the overhead
|
||||||
|
// of the function call yields a delay of approximately 1 1/8 us.
|
||||||
|
if (--us == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// the following loop takes a quarter of a microsecond (4 cycles)
|
||||||
|
// per iteration, so execute it four times for each microsecond of
|
||||||
|
// delay requested.
|
||||||
|
us <<= 2;
|
||||||
|
|
||||||
|
// account for the time taken in the preceeding commands.
|
||||||
|
us -= 2;
|
||||||
|
#else
|
||||||
|
// for the 8 MHz internal clock on the ATmega168
|
||||||
|
|
||||||
|
// for a one- or two-microsecond delay, simply return. the overhead of
|
||||||
|
// the function calls takes more than two microseconds. can't just
|
||||||
|
// subtract two, since us is unsigned; we'd overflow.
|
||||||
|
if (--us == 0)
|
||||||
|
return;
|
||||||
|
if (--us == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// the following loop takes half of a microsecond (4 cycles)
|
||||||
|
// per iteration, so execute it twice for each microsecond of
|
||||||
|
// delay requested.
|
||||||
|
us <<= 1;
|
||||||
|
|
||||||
|
// partially compensate for the time taken by the preceeding commands.
|
||||||
|
// we can't subtract any more than this or we'd overflow w/ small delays.
|
||||||
|
us--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// busy wait
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"1: sbiw %0,1" "\n\t" // 2 cycles
|
||||||
|
"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
// this needs to be called before setup() or some functions won't
|
||||||
|
// work there
|
||||||
|
sei();
|
||||||
|
|
||||||
|
// on the ATmega168, timer 0 is also used for fast hardware pwm
|
||||||
|
// (using phase-correct PWM would mean that timer 0 overflowed half as often
|
||||||
|
// resulting in different millis() behavior on the ATmega8 and ATmega168)
|
||||||
|
#if defined(TCCR0A) && defined(WGM01)
|
||||||
|
sbi(TCCR0A, WGM01);
|
||||||
|
sbi(TCCR0A, WGM00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// set timer 0 prescale factor to 64
|
||||||
|
#if defined(__AVR_ATmega128__)
|
||||||
|
// CPU specific: different values for the ATmega128
|
||||||
|
sbi(TCCR0, CS02);
|
||||||
|
#elif defined(TCCR0) && defined(CS01) && defined(CS00)
|
||||||
|
// this combination is for the standard atmega8
|
||||||
|
sbi(TCCR0, CS01);
|
||||||
|
sbi(TCCR0, CS00);
|
||||||
|
#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
|
||||||
|
// this combination is for the standard 168/328/1280/2560
|
||||||
|
sbi(TCCR0B, CS01);
|
||||||
|
sbi(TCCR0B, CS00);
|
||||||
|
#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
|
||||||
|
// this combination is for the __AVR_ATmega645__ series
|
||||||
|
sbi(TCCR0A, CS01);
|
||||||
|
sbi(TCCR0A, CS00);
|
||||||
|
#else
|
||||||
|
#error Timer 0 prescale factor 64 not set correctly
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// enable timer 0 overflow interrupt
|
||||||
|
#if defined(TIMSK) && defined(TOIE0)
|
||||||
|
sbi(TIMSK, TOIE0);
|
||||||
|
#elif defined(TIMSK0) && defined(TOIE0)
|
||||||
|
sbi(TIMSK0, TOIE0);
|
||||||
|
#else
|
||||||
|
#error Timer 0 overflow interrupt not set correctly
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// timers 1 and 2 are used for phase-correct hardware pwm
|
||||||
|
// this is better for motors as it ensures an even waveform
|
||||||
|
// note, however, that fast pwm mode can achieve a frequency of up
|
||||||
|
// 8 MHz (with a 16 MHz clock) at 50% duty cycle
|
||||||
|
|
||||||
|
TCCR1B = 0;
|
||||||
|
|
||||||
|
// set timer 1 prescale factor to 64
|
||||||
|
#if defined(TCCR1B) && defined(CS11) && defined(CS10)
|
||||||
|
sbi(TCCR1B, CS11);
|
||||||
|
sbi(TCCR1B, CS10);
|
||||||
|
#elif defined(TCCR1) && defined(CS11) && defined(CS10)
|
||||||
|
sbi(TCCR1, CS11);
|
||||||
|
sbi(TCCR1, CS10);
|
||||||
|
#endif
|
||||||
|
// put timer 1 in 8-bit phase correct pwm mode
|
||||||
|
#if defined(TCCR1A) && defined(WGM10)
|
||||||
|
sbi(TCCR1A, WGM10);
|
||||||
|
#elif defined(TCCR1)
|
||||||
|
#warning this needs to be finished
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// set timer 2 prescale factor to 64
|
||||||
|
#if defined(TCCR2) && defined(CS22)
|
||||||
|
sbi(TCCR2, CS22);
|
||||||
|
#elif defined(TCCR2B) && defined(CS22)
|
||||||
|
sbi(TCCR2B, CS22);
|
||||||
|
#else
|
||||||
|
#warning Timer 2 not finished (may not be present on this CPU)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// configure timer 2 for phase correct pwm (8-bit)
|
||||||
|
#if defined(TCCR2) && defined(WGM20)
|
||||||
|
sbi(TCCR2, WGM20);
|
||||||
|
#elif defined(TCCR2A) && defined(WGM20)
|
||||||
|
sbi(TCCR2A, WGM20);
|
||||||
|
#else
|
||||||
|
#warning Timer 2 not finished (may not be present on this CPU)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
|
||||||
|
sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64
|
||||||
|
sbi(TCCR3B, CS30);
|
||||||
|
sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
|
||||||
|
sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64
|
||||||
|
sbi(TCCR4B, CS40);
|
||||||
|
sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pwm mode
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
|
||||||
|
sbi(TCCR5B, CS51); // set timer 5 prescale factor to 64
|
||||||
|
sbi(TCCR5B, CS50);
|
||||||
|
sbi(TCCR5A, WGM50); // put timer 5 in 8-bit phase correct pwm mode
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ADCSRA)
|
||||||
|
// set a2d prescale factor to 128
|
||||||
|
// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
|
||||||
|
// XXX: this will not work properly for other clock speeds, and
|
||||||
|
// this code should use F_CPU to determine the prescale factor.
|
||||||
|
sbi(ADCSRA, ADPS2);
|
||||||
|
sbi(ADCSRA, ADPS1);
|
||||||
|
sbi(ADCSRA, ADPS0);
|
||||||
|
|
||||||
|
// enable a2d conversions
|
||||||
|
sbi(ADCSRA, ADEN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// the bootloader connects pins 0 and 1 to the USART; disconnect them
|
||||||
|
// here so they can be used as normal digital i/o; they will be
|
||||||
|
// reconnected in Serial.begin()
|
||||||
|
#if defined(UCSRB)
|
||||||
|
UCSRB = 0;
|
||||||
|
#elif defined(UCSR0B)
|
||||||
|
UCSR0B = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+4
-1
@@ -76,7 +76,10 @@ extern "C"{
|
|||||||
#define max(a,b) ((a)>(b)?(a):(b))
|
#define max(a,b) ((a)>(b)?(a):(b))
|
||||||
#define abs(x) ((x)>0?(x):-(x))
|
#define abs(x) ((x)>0?(x):-(x))
|
||||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
|
||||||
|
// Removed to work with newer AVRLIBC
|
||||||
|
//#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||||
|
|
||||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||||
#define sq(x) ((x)*(x))
|
#define sq(x) ((x)*(x))
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
/*
|
||||||
|
wiring_analog.c - analog input and output
|
||||||
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2005-2006 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
|
||||||
|
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wiring_private.h"
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
|
||||||
|
uint8_t analog_reference = DEFAULT;
|
||||||
|
|
||||||
|
void analogReference(uint8_t mode)
|
||||||
|
{
|
||||||
|
// can't actually set the register here because the default setting
|
||||||
|
// will connect AVCC and the AREF pin, which would cause a short if
|
||||||
|
// there's something connected to AREF.
|
||||||
|
analog_reference = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int analogRead(uint8_t pin)
|
||||||
|
{
|
||||||
|
uint8_t low, high;
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
|
||||||
|
#else
|
||||||
|
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ADCSRB) && defined(MUX5)
|
||||||
|
// the MUX5 bit of ADCSRB selects whether we're reading from channels
|
||||||
|
// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
|
||||||
|
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// set the analog reference (high two bits of ADMUX) and select the
|
||||||
|
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
|
||||||
|
// to 0 (the default).
|
||||||
|
#if defined(ADMUX)
|
||||||
|
ADMUX = (analog_reference << 6) | (pin & 0x07);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// without a delay, we seem to read from the wrong channel
|
||||||
|
//delay(1);
|
||||||
|
|
||||||
|
#if defined(ADCSRA) && defined(ADCL)
|
||||||
|
// start the conversion
|
||||||
|
sbi(ADCSRA, ADSC);
|
||||||
|
|
||||||
|
// ADSC is cleared when the conversion finishes
|
||||||
|
while (bit_is_set(ADCSRA, ADSC));
|
||||||
|
|
||||||
|
// we have to read ADCL first; doing so locks both ADCL
|
||||||
|
// and ADCH until ADCH is read. reading ADCL second would
|
||||||
|
// cause the results of each conversion to be discarded,
|
||||||
|
// as ADCL and ADCH would be locked when it completed.
|
||||||
|
low = ADCL;
|
||||||
|
high = ADCH;
|
||||||
|
#else
|
||||||
|
// we dont have an ADC, return 0
|
||||||
|
low = 0;
|
||||||
|
high = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// combine the two bytes
|
||||||
|
return (high << 8) | low;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right now, PWM output only works on the pins with
|
||||||
|
// hardware support. These are defined in the appropriate
|
||||||
|
// pins_*.c file. For the rest of the pins, we default
|
||||||
|
// to digital output.
|
||||||
|
void analogWrite(uint8_t pin, int val)
|
||||||
|
{
|
||||||
|
// We need to make sure the PWM output is enabled for those pins
|
||||||
|
// that support it, as we turn it off when digitally reading or
|
||||||
|
// writing with them. Also, make sure the pin is in output mode
|
||||||
|
// for consistenty with Wiring, which doesn't require a pinMode
|
||||||
|
// call for the analog output pins.
|
||||||
|
pinMode(pin, OUTPUT);
|
||||||
|
if (val == 0)
|
||||||
|
{
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
}
|
||||||
|
else if (val == 255)
|
||||||
|
{
|
||||||
|
digitalWrite(pin, HIGH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch(digitalPinToTimer(pin))
|
||||||
|
{
|
||||||
|
// XXX fix needed for atmega8
|
||||||
|
#if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__)
|
||||||
|
case TIMER0A:
|
||||||
|
// connect pwm to pin on timer 0
|
||||||
|
sbi(TCCR0, COM00);
|
||||||
|
OCR0 = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR0A) && defined(COM0A1)
|
||||||
|
case TIMER0A:
|
||||||
|
// connect pwm to pin on timer 0, channel A
|
||||||
|
sbi(TCCR0A, COM0A1);
|
||||||
|
OCR0A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR0A) && defined(COM0B1)
|
||||||
|
case TIMER0B:
|
||||||
|
// connect pwm to pin on timer 0, channel B
|
||||||
|
sbi(TCCR0A, COM0B1);
|
||||||
|
OCR0B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR1A) && defined(COM1A1)
|
||||||
|
case TIMER1A:
|
||||||
|
// connect pwm to pin on timer 1, channel A
|
||||||
|
sbi(TCCR1A, COM1A1);
|
||||||
|
OCR1A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR1A) && defined(COM1B1)
|
||||||
|
case TIMER1B:
|
||||||
|
// connect pwm to pin on timer 1, channel B
|
||||||
|
sbi(TCCR1A, COM1B1);
|
||||||
|
OCR1B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR2) && defined(COM21)
|
||||||
|
case TIMER2:
|
||||||
|
// connect pwm to pin on timer 2
|
||||||
|
sbi(TCCR2, COM21);
|
||||||
|
OCR2 = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR2A) && defined(COM2A1)
|
||||||
|
case TIMER2A:
|
||||||
|
// connect pwm to pin on timer 2, channel A
|
||||||
|
sbi(TCCR2A, COM2A1);
|
||||||
|
OCR2A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR2A) && defined(COM2B1)
|
||||||
|
case TIMER2B:
|
||||||
|
// connect pwm to pin on timer 2, channel B
|
||||||
|
sbi(TCCR2A, COM2B1);
|
||||||
|
OCR2B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3A) && defined(COM3A1)
|
||||||
|
case TIMER3A:
|
||||||
|
// connect pwm to pin on timer 3, channel A
|
||||||
|
sbi(TCCR3A, COM3A1);
|
||||||
|
OCR3A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3A) && defined(COM3B1)
|
||||||
|
case TIMER3B:
|
||||||
|
// connect pwm to pin on timer 3, channel B
|
||||||
|
sbi(TCCR3A, COM3B1);
|
||||||
|
OCR3B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3A) && defined(COM3C1)
|
||||||
|
case TIMER3C:
|
||||||
|
// connect pwm to pin on timer 3, channel C
|
||||||
|
sbi(TCCR3A, COM3C1);
|
||||||
|
OCR3C = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4A) && defined(COM4A1)
|
||||||
|
case TIMER4A:
|
||||||
|
// connect pwm to pin on timer 4, channel A
|
||||||
|
sbi(TCCR4A, COM4A1);
|
||||||
|
OCR4A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4A) && defined(COM4B1)
|
||||||
|
case TIMER4B:
|
||||||
|
// connect pwm to pin on timer 4, channel B
|
||||||
|
sbi(TCCR4A, COM4B1);
|
||||||
|
OCR4B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4A) && defined(COM4C1)
|
||||||
|
case TIMER4C:
|
||||||
|
// connect pwm to pin on timer 4, channel C
|
||||||
|
sbi(TCCR4A, COM4C1);
|
||||||
|
OCR4C = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR5A) && defined(COM5A1)
|
||||||
|
case TIMER5A:
|
||||||
|
// connect pwm to pin on timer 5, channel A
|
||||||
|
sbi(TCCR5A, COM5A1);
|
||||||
|
OCR5A = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR5A) && defined(COM5B1)
|
||||||
|
case TIMER5B:
|
||||||
|
// connect pwm to pin on timer 5, channel B
|
||||||
|
sbi(TCCR5A, COM5B1);
|
||||||
|
OCR5B = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR5A) && defined(COM5C1)
|
||||||
|
case TIMER5C:
|
||||||
|
// connect pwm to pin on timer 5, channel C
|
||||||
|
sbi(TCCR5A, COM5C1);
|
||||||
|
OCR5C = val; // set pwm duty
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case NOT_ON_TIMER:
|
||||||
|
default:
|
||||||
|
if (val < 128) {
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
} else {
|
||||||
|
digitalWrite(pin, HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
wiring_digital.c - digital input and output functions
|
||||||
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2005-2006 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
|
||||||
|
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wiring_private.h"
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
|
||||||
|
void pinMode(uint8_t pin, uint8_t mode)
|
||||||
|
{
|
||||||
|
uint8_t bit = digitalPinToBitMask(pin);
|
||||||
|
uint8_t port = digitalPinToPort(pin);
|
||||||
|
volatile uint8_t *reg;
|
||||||
|
|
||||||
|
if (port == NOT_A_PIN) return;
|
||||||
|
|
||||||
|
// JWS: can I let the optimizer do this?
|
||||||
|
reg = portModeRegister(port);
|
||||||
|
|
||||||
|
if (mode == INPUT) {
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
cli();
|
||||||
|
*reg &= ~bit;
|
||||||
|
SREG = oldSREG;
|
||||||
|
} else {
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
cli();
|
||||||
|
*reg |= bit;
|
||||||
|
SREG = oldSREG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forcing this inline keeps the callers from having to push their own stuff
|
||||||
|
// on the stack. It is a good performance win and only takes 1 more byte per
|
||||||
|
// user than calling. (It will take more bytes on the 168.)
|
||||||
|
//
|
||||||
|
// But shouldn't this be moved into pinMode? Seems silly to check and do on
|
||||||
|
// each digitalread or write.
|
||||||
|
//
|
||||||
|
// Mark Sproul:
|
||||||
|
// - Removed inline. Save 170 bytes on atmega1280
|
||||||
|
// - changed to a switch statment; added 32 bytes but much easier to read and maintain.
|
||||||
|
// - Added more #ifdefs, now compiles for atmega645
|
||||||
|
//
|
||||||
|
//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
|
||||||
|
//static inline void turnOffPWM(uint8_t timer)
|
||||||
|
static void turnOffPWM(uint8_t timer)
|
||||||
|
{
|
||||||
|
switch (timer)
|
||||||
|
{
|
||||||
|
#if defined(TCCR1A) && defined(COM1A1)
|
||||||
|
case TIMER1A: cbi(TCCR1A, COM1A1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR1A) && defined(COM1B1)
|
||||||
|
case TIMER1B: cbi(TCCR1A, COM1B1); break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR2) && defined(COM21)
|
||||||
|
case TIMER2: cbi(TCCR2, COM21); break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR0A) && defined(COM0A1)
|
||||||
|
case TIMER0A: cbi(TCCR0A, COM0A1); break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TIMER0B) && defined(COM0B1)
|
||||||
|
case TIMER0B: cbi(TCCR0A, COM0B1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2A) && defined(COM2A1)
|
||||||
|
case TIMER2A: cbi(TCCR2A, COM2A1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2A) && defined(COM2B1)
|
||||||
|
case TIMER2B: cbi(TCCR2A, COM2B1); break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR3A) && defined(COM3A1)
|
||||||
|
case TIMER3A: cbi(TCCR3A, COM3A1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR3A) && defined(COM3B1)
|
||||||
|
case TIMER3B: cbi(TCCR3A, COM3B1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR3A) && defined(COM3C1)
|
||||||
|
case TIMER3C: cbi(TCCR3A, COM3C1); break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TCCR4A) && defined(COM4A1)
|
||||||
|
case TIMER4A: cbi(TCCR4A, COM4A1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR4A) && defined(COM4B1)
|
||||||
|
case TIMER4B: cbi(TCCR4A, COM4B1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR4A) && defined(COM4C1)
|
||||||
|
case TIMER4C: cbi(TCCR4A, COM4C1); break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR5A)
|
||||||
|
case TIMER5A: cbi(TCCR5A, COM5A1); break;
|
||||||
|
case TIMER5B: cbi(TCCR5A, COM5B1); break;
|
||||||
|
case TIMER5C: cbi(TCCR5A, COM5C1); break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void digitalWrite(uint8_t pin, uint8_t val)
|
||||||
|
{
|
||||||
|
uint8_t timer = digitalPinToTimer(pin);
|
||||||
|
uint8_t bit = digitalPinToBitMask(pin);
|
||||||
|
uint8_t port = digitalPinToPort(pin);
|
||||||
|
volatile uint8_t *out;
|
||||||
|
|
||||||
|
if (port == NOT_A_PIN) return;
|
||||||
|
|
||||||
|
// If the pin that support PWM output, we need to turn it off
|
||||||
|
// before doing a digital write.
|
||||||
|
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
||||||
|
|
||||||
|
out = portOutputRegister(port);
|
||||||
|
|
||||||
|
if (val == LOW) {
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
cli();
|
||||||
|
*out &= ~bit;
|
||||||
|
SREG = oldSREG;
|
||||||
|
} else {
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
cli();
|
||||||
|
*out |= bit;
|
||||||
|
SREG = oldSREG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int digitalRead(uint8_t pin)
|
||||||
|
{
|
||||||
|
uint8_t timer = digitalPinToTimer(pin);
|
||||||
|
uint8_t bit = digitalPinToBitMask(pin);
|
||||||
|
uint8_t port = digitalPinToPort(pin);
|
||||||
|
|
||||||
|
if (port == NOT_A_PIN) return LOW;
|
||||||
|
|
||||||
|
// If the pin that support PWM output, we need to turn it off
|
||||||
|
// before getting a digital reading.
|
||||||
|
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
||||||
|
|
||||||
|
if (*portInputRegister(port) & bit) return HIGH;
|
||||||
|
return LOW;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user