diff --git a/boards.txt b/boards.txt index 7b55a6d..984b30e 100644 --- a/boards.txt +++ b/boards.txt @@ -841,3 +841,33 @@ gemma.build.board=AVR_GEMMA gemma.upload.tool=avrdude gemma.upload.maximum_size=5310 +############################################################## + +# Adafruit Circuit Playground 32u4 w/Caterina Configuration +circuitplay32u4cat.name=Adafruit Circuit Playground +circuitplay32u4cat.bootloader.low_fuses=0xff +circuitplay32u4cat.bootloader.high_fuses=0xd8 +circuitplay32u4cat.bootloader.extended_fuses=0xcb +circuitplay32u4cat.bootloader.file=caterina/Caterina-Circuitplay32u4.hex +circuitplay32u4cat.bootloader.unlock_bits=0x3F +circuitplay32u4cat.bootloader.lock_bits=0x2F +circuitplay32u4cat.bootloader.tool=arduino:avrdude +circuitplay32u4cat.build.mcu=atmega32u4 +circuitplay32u4cat.build.f_cpu=8000000L +circuitplay32u4cat.build.vid=0x239A +circuitplay32u4cat.build.pid=0x8011 +circuitplay32u4cat.build.core=arduino:arduino +circuitplay32u4cat.build.variant=circuitplay32u4 +circuitplay32u4cat.build.board=AVR_CIRCUITPLAY +circuitplay32u4cat.build.usb_product="Circuit Playground" +circuitplay32u4cat.build.usb_manufacturer="Adafruit" +circuitplay32u4cat.build.extra_flags={build.usb_flags} +circuitplay32u4cat.upload.protocol=avr109 +circuitplay32u4cat.upload.maximum_size=28672 +circuitplay32u4cat.upload.speed=57600 +circuitplay32u4cat.upload.disable_flushing=true +circuitplay32u4cat.upload.use_1200bps_touch=true +circuitplay32u4cat.upload.wait_for_upload_port=true +circuitplay32u4cat.upload.tool=arduino:avrdude +circuitplay32u4cat.vid.0=0x239A +circuitplay32u4cat.pid.0=0x8011 diff --git a/bootloaders/caterina/Caterina-Circuitplay32u4.hex b/bootloaders/caterina/Caterina-Circuitplay32u4.hex new file mode 100644 index 0000000..fe6d762 --- /dev/null +++ b/bootloaders/caterina/Caterina-Circuitplay32u4.hex @@ -0,0 +1,251 @@ +:1070000055C000006EC000006CC000006AC00000E7 +:1070100068C0000066C0000064C0000062C00000DC +:1070200060C000005EC00000B2C400005AC0000092 +:1070300058C0000056C0000054C0000052C00000FC +:1070400050C00000D7C000004CC000004AC0000083 +:1070500048C0000046C0000044C0000042C000001C +:1070600040C000003EC000003CC000003AC000002C +:1070700038C0000036C0000034C0000032C000003C +:1070800030C000002EC000002CC000002AC000004C +:1070900028C0000026C0000024C0000022C000005C +:1070A00020C000001EC000001CC0000011241FBE34 +:1070B000CFEFDAE0DEBFCDBF11E0A0E0B1E0E0EB62 +:1070C000FEE702C005900D92A43DB107D9F711E08B +:1070D000A4EDB1E001C01D92AA3EB107E1F755D37E +:1070E000E5C68ECF84E08093E9000DC08091E80072 +:1070F0008B778093E80003C08EB3882359F080918A +:10710000E80082FFF9CF8091E80085FFEFCF809102 +:10711000F100089580E0089593E09093E900909144 +:10712000E80095FF09C08093F10084E690E0909319 +:10713000D9018093D80108959091E8009E779093AB +:10714000E80003C09EB3992329F09091E80090FFD6 +:10715000F9CFE9CF0895F89410926F001092810052 +:10716000109285001092840081E085BF15BE47987B +:107170000C94000008958091DE019091DF0101964A +:107180009093DF018093DE01292F97FF03C03EEF2C +:10719000391B232F220F281710F447980895479A78 +:1071A000089584B7877F84BF88E10FB6F8948093F1 +:1071B0006000109260000FBE90E880E00FB6F89477 +:1071C00090936100809361000FBE81E085BF82E0F3 +:1071D00085BF3F9AE1E6F0E09083108247981092D5 +:1071E00089009DE79093880080936F0083E08093EF +:1071F0008100B5C31F920F920FB60F9211242F93E7 +:107200008F939F93EF93FF931092850010928400C9 +:107210008091D8019091D901009729F0019790931E +:10722000D9018093D8018091D6019091D701009720 +:1072300029F001979093D7018093D601E0E0F0E028 +:1072400085919491019649F08091D4019091D50156 +:1072500001969093D5018093D401FF91EF919F9176 +:107260008F912F910F900FBE0F901F90189542E0B5 +:1072700061EC82E007D342E161E883E003D342E1BD +:1072800060E884E0FFC28091E201982F9F779132FD +:1072900039F59091E301903291F0913209F5813AFC +:1072A000F9F48091E800877F8093E80067E070E060 +:1072B00083E091E01AD48091E8008B770FC081328F +:1072C00079F48091E800877F8093E80067E070E0C0 +:1072D00083E091E067D48091E8008E778093E800A6 +:1072E00008954F925F926F927F928F929F92AF928A +:1072F000BF92CF92DF92EF92FF920F931F93CF93A3 +:10730000DF9384E08093E9008091E80082FF2CC243 +:1073100084E690E09093D7018093D601E3DE082FB6 +:10732000853481F48CE195E29093D5018093D4016A +:1073300007B600FCFDCFF999FECF81E1809357009D +:10734000E89503C0843521F4CDDE8DE0E5DEE3C1B0 +:107350008C34D9F3803509F4F8CF843721F484E4F0 +:10736000DBDE80E0F3CF813611F489E5EFCF8134A5 +:1073700081F4B8DEC82FB6DE90E0880F991F3C2F4D +:10738000330F20E0822B932BAA2797FDA095BA2FCD +:1073900096C1803711F483E5D9CF833549F4CAEC1F +:1073A000D1E08991B9DE21E0C13DD207D1F7B3C167 +:1073B000863521F481E3B0DE80E3C8CF833731F432 +:1073C00087E8AADE85E9A8DE8EE1C0CF8536B9F46C +:1073D000E0E0F0E083E095E080935700E89507B6A1 +:1073E00000FCFDCF90935700E89507B600FCFDCF59 +:1073F000E058FF4FE11520E7F20771F7A6CF82377B +:1074000019F4E1E0F0E00EC0863419F4E0E0F0E0B9 +:1074100009C08E3419F4E3E0F0E004C0813539F49A +:10742000E2E0F0E089E08093570084918FCF8236CC +:1074300031F489E571DE80E06FDE80E887CF823449 +:1074400019F0873609F0D1C01092D5011092D401FD +:1074500049DEC82E47DED82E45DE182F85548230EF +:1074600010F08FE373CFDC2D80E0C82FCD29109270 +:107470006F00073609F041C081E180935700E8951D +:10748000B12C01E037C0C090DA01D090DB01E09070 +:10749000DC01F090DD011634B9F4EB2DF0E0EC29BD +:1074A000FD29849139DEBB2069F0E2E0CE0ED11CCB +:1074B000E11CF11CC092DA01D092DB01E092DC0108 +:1074C000F092DD01B02615C0D701C601B695A7958B +:1074D00097958795D5D420DEF2E0CF0ED11CE11C24 +:1074E000F11CC092DA01D092DB01E092DC01F09253 +:1074F000DD012197209739F674C08090DA019090D1 +:10750000DB01A090DC01B090DD01163409F057C01A +:1075100083E0F40180935700E89507B600FCFDCFA7 +:107520004EC0163439F5DD2009F14090DA01509053 +:10753000DB016090DC017090DD01D4DDF82EE12CE0 +:1075400097012C29F201090100935700E8951124B5 +:10755000F2E04F0E511C611C711C4092DA015092F6 +:10756000DB016092DC017092DD0102C0BBDDC82E40 +:10757000D02623C0B7DD682F8091DA019091DB011E +:10758000A091DC01B091DD01B695A79597958795FF +:107590007FD44091DA015091DB016091DC01709160 +:1075A000DD014E5F5F4F6F4F7F4F4093DA01509385 +:1075B000DB016093DC017093DD01219703C0C12CD6 +:1075C000D12C01E0209709F0ACCF163441F485E0CE +:1075D000F40180935700E89507B600FCFDCF8DE0DD +:1075E0009BDD82E080936F0096C0833471F4C0917C +:1075F000DA01D091DB0176DD90E021E0FE010C01A3 +:1076000020935700E8951124A0CE833611F5C09041 +:10761000DA01D090DB01E090DC01F090DD0162DD69 +:10762000B701A601416090E021E0FA010C0120932E +:107630005700E8951124F2E0CF0ED11CE11CF11C9B +:10764000C092DA01D092DB01E092DC01F092DD0120 +:107650007CCE8D3661F4E091DA01F091DB0185E0BA +:1076600080935700E89507B600FCFDCF6ECE8235BB +:1076700051F4E091DA01F091DB01C591D4918D2FA5 +:107680004BDD8C2F63CE843419F52CDD682F80916F +:10769000DA019091DB01A091DC01B091DD01B6959A +:1076A000A79597958795F4D38091DA019091DB01A6 +:1076B000A091DC01B091DD010296A11DB11D809366 +:1076C000DA019093DB01A093DC01B093DD013DCEA4 +:1076D0008436F1F4C090DA01D090DB01E090DC0157 +:1076E000F090DD01D701C601B695A79597958795CE +:1076F000C7D312DD22E0C20ED11CE11CF11CC092E6 +:10770000DA01D092DB01E092DC01F092DD0103C0EE +:107710008B3109F0A6CE83E08093E9009091E800D8 +:107720008091E8008E778093E80095FD11C08091EC +:10773000E80080FD04C08EB38111F9CF15C080919F +:10774000E8008E778093E80003C08EB3882361F051 +:107750008091E80080FFF9CF84E08093E900809178 +:10776000E8008B778093E800DF91CF911F910F9114 +:10777000FF90EF90DF90CF90BF90AF909F908F9051 +:107780007F906F905F904F90089580910008909146 +:107790000108109201081092000844B714BE28E1B5 +:1077A0000FB6F89420936000109260000FBEE0E0E6 +:1077B000F0E0259134912F3F3F4F79F040FF02C018 +:1077C000CADC0BC041FD09C0483039F420910001EA +:1077D000309101018217930799F7E3DC78941092B6 +:1077E000D5011092D4010CC07CDD39D38091D40135 +:1077F0009091D5018131974210F010920201BBDCCB +:10780000809102018111F0CF8091E000816080932E +:10781000E000A1DC80E090E00895292F30E03327DC +:107820002230310539F02330310549F0213031055E +:1078300089F00BC02EE330E08AE791E01EC0882378 +:1078400071F0813089F08230A1F020E030E080E0FA +:1078500090E013C022E130E088EB91E00EC024E01C +:1078600030E086E791E009C022E230E08CE391E06D +:1078700004C028E130E08AE091E0FA01918380833E +:10788000C90108958093E900EBEEF0E0808181600A +:107890008083EDEEF0E010826093EC0040838091F5 +:1078A000EE00881F8827881F08958091E20187FDD8 +:1078B00005C08091E80080FF0DC010C08091E800F5 +:1078C00082FD04C08EB38111F9CF08958091E80044 +:1078D0008B7707C08EB38111ECCF08958091E800BB +:1078E0008E778093E80008950F931F93CF93DF93D3 +:1078F00041D048D0C8EDD0E088818F7788838881D7 +:107900008068888388818F7D888319BC1EBA109215 +:10791000E00100EE10E0F80180818B7F8083888198 +:107920008160888342E060E080E0ACDFE1EEF0E07F +:1079300080818E7F8083E2EEF0E0808181608083B1 +:10794000808188608083F80180818E7F8083888138 +:1079500080618883DF91CF911F910F910895E7EDAA +:10796000F0E08081816080838AE482BF81E080933F +:10797000E101BACFE8EDF0E080818E7F8083109244 +:10798000E20008951092DA001092E10008951F922B +:107990000F920FB60F9211242F933F934F935F9343 +:1079A0006F937F938F939F93AF93BF93EF93FF93C7 +:1079B0008091DA0080FF19C08091D80080FF15C047 +:1079C0008091DA008E7F8093DA008091D90019BC13 +:1079D00080FF09C082E089BD09B400FEFDCF81E0CF +:1079E0008EBB3CD202C01EBA39D28091E10080FF2A +:1079F00017C08091E20080FF13C08091E2008E7F6B +:107A00008093E2008091E20080618093E2008091A7 +:107A1000D80080628093D80019BC85E08EBB1ED24E +:107A20008091E10084FF2BC08091E20084FF27C099 +:107A300019BC82E089BD09B400FEFDCF8091D80059 +:107A40008F7D8093D8008091E1008F7E8093E1004C +:107A50008091E2008F7E8093E2008091E20081605D +:107A60008093E2008091E001811104C08091E300E5 +:107A700087FF02C084E001C081E08EBBEFD180911E +:107A8000E10083FF21C08091E20083FF1DC080914F +:107A9000E100877F8093E10082E08EBB1092E001DD +:107AA0008091E1008E7F8093E1008091E2008E7FE3 +:107AB0008093E2008091E20080618093E20042E0E6 +:107AC00060E080E0DFDECAD1FF91EF91BF91AF911E +:107AD0009F918F917F916F915F914F913F912F91E6 +:107AE0000F900FBE0F901F9018954091E801509194 +:107AF000E9014617570748F06115710539F44091BF +:107B0000E8004E774093E80001C0BA01FC0140E074 +:107B100032C08EB3882309F441C0853009F440C0D7 +:107B20008091E80083FD38C08091E80082FD2EC07E +:107B30008091E80080FF1FC09091F3008091F200D7 +:107B4000392F20E0A901482BCA0106C0419140937A +:107B5000F1006150710901966115710519F08830C5 +:107B60009105A0F341E0089709F040E08091E8001A +:107B70008E778093E8006115710559F64111C9CFE0 +:107B800005C08EB3882351F0853051F08091E80014 +:107B900082FFF7CF80E0089581E0089582E00895A4 +:107BA00083E008956115710529F44091E8004B7751 +:107BB0004093E800AC0127C08EB38823B1F1853033 +:107BC00071F18091E80083FD2CC08091E80082FF74 +:107BD000F3CFFA0107C08091F1008193AF016150AA +:107BE000710961F0AF019091F3008091F200392F9B +:107BF00020E0D901A82BCD01892B69F78091E800FD +:107C00008B778093E80061157105B1F68091E800EB +:107C100080FD09C08EB3882341F08530B9F783E039 +:107C2000089581E0089580E0089582E00895EF923C +:107C3000FF920F931F93CF93DF9300D0CDB7DEB7A2 +:107C4000E2EEF1E08091F100819381E0EA3EF807F5 +:107C5000C9F719DB8091E80083FFE9C08091E20158 +:107C60009091E301953009F46FC038F4913071F1CF +:107C700070F0933009F0DBC029C0983009F4AAC035 +:107C8000993009F4B9C0963009F0D1C083C080386A +:107C900009F4CDC0823809F0CAC08091E601909104 +:107CA000E701877099278093E9009091EB0010928B +:107CB000E9008091E800877F8093E80095FB8827A2 +:107CC00080F98093F1001092F1008FC0882319F0A1 +:107CD000823009F0ACC08F71823009F0A8C0809169 +:107CE000E40181112BC08091E6019091E70187703A +:107CF0009927009709F49BC08093E9002091EB003D +:107D000020FF1CC02091E301233021F48091EB007F +:107D1000806212C09091EB0090619093EB0021E0A3 +:107D200030E001C0220F8A95EAF72093EA00109212 +:107D3000EA008091EB0088608093EB001092E900EC +:107D40008091E800877F54C0811171C00091E401E7 +:107D50001091E5010F771127E02EFFB6F89480917E +:107D6000E800877F8093E800A0DD8091E80080FF35 +:107D7000FCCF8091E3008078802B8093E3008068C3 +:107D80008093E300EE2011F083E001C082E08EBB1F +:107D9000FFBE4DC08058823008F049C0AE014F5F31 +:107DA0005F4F6091E6018091E4019091E50135DD3E +:107DB000009709F43CC02091E800277F2093E80059 +:107DC000BC0189819A8191DE8091E8008B77809354 +:107DD000E8002DC0803859F58091E800877F8093B6 +:107DE000E8008091E0018093F1008091E8008E77B7 +:107DF0008093E8005ADD1BC0811119C09091E40105 +:107E00009230A8F48091E800877F8093E8009093F7 +:107E1000E0014BDD8091E001811104C08091E3001D +:107E200087FF02C084E001C081E08EBB20DA809130 +:107E3000E80083FF0AC08091EB0080628093EB0032 +:107E40008091E800877F8093E8000F900F90DF918A +:107E5000CF911F910F91FF90EF9008950895CF93C8 +:107E60008EB3882359F0C091E900C7701092E900E1 +:107E70008091E80083FDDBDEC093E900CF91089597 +:107E8000F999FECF92BD81BDF89A992780B50895E2 +:107E9000262FF999FECF1FBA92BD81BD20BD0FB626 +:107EA000F894FA9AF99A0FBE01960895F894FFCFC4 +:107EB000777701000000000000081803410064000B +:107EC00061006600720075006900740020004900BE +:107ED0006E00640075007300740072006900650034 +:107EE000730020004C004C004300000022034100BE +:107EF0006400610066007200750069007400200073 +:107F0000430069007200630075006900740020007E +:107F100050006C0061007900670072006F0075000E +:107F20006E00640000000403090409023E0002011F +:107F30000080320904000001020201000524001043 +:107F40000104240204052406000107058203080039 +:107F5000FF09040100020A000000070504021000E6 +:107F60000107058302100001120110010200000840 +:107F70009A23110001000201000143415445524976 +:047F80004E4100006E +:040000030000700089 +:00000001FF diff --git a/variants/circuitplay32u4/pins_arduino.h b/variants/circuitplay32u4/pins_arduino.h new file mode 100644 index 0000000..1da15a9 --- /dev/null +++ b/variants/circuitplay32u4/pins_arduino.h @@ -0,0 +1,387 @@ +/* + 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 + +// Workaround for wrong definitions in "iom32u4.h". +// This should be fixed in the AVR toolchain. +#undef UHCON +#undef UHINT +#undef UHIEN +#undef UHADDR +#undef UHFNUM +#undef UHFNUML +#undef UHFNUMH +#undef UHFLEN +#undef UPINRQX +#undef UPINTX +#undef UPNUM +#undef UPRST +#undef UPCONX +#undef UPCFG0X +#undef UPCFG1X +#undef UPSTAX +#undef UPCFG2X +#undef UPIENX +#undef UPDATX +#undef TCCR2A +#undef WGM20 +#undef WGM21 +#undef COM2B0 +#undef COM2B1 +#undef COM2A0 +#undef COM2A1 +#undef TCCR2B +#undef CS20 +#undef CS21 +#undef CS22 +#undef WGM22 +#undef FOC2B +#undef FOC2A +#undef TCNT2 +#undef TCNT2_0 +#undef TCNT2_1 +#undef TCNT2_2 +#undef TCNT2_3 +#undef TCNT2_4 +#undef TCNT2_5 +#undef TCNT2_6 +#undef TCNT2_7 +#undef OCR2A +#undef OCR2_0 +#undef OCR2_1 +#undef OCR2_2 +#undef OCR2_3 +#undef OCR2_4 +#undef OCR2_5 +#undef OCR2_6 +#undef OCR2_7 +#undef OCR2B +#undef OCR2_0 +#undef OCR2_1 +#undef OCR2_2 +#undef OCR2_3 +#undef OCR2_4 +#undef OCR2_5 +#undef OCR2_6 +#undef OCR2_7 + +#define NUM_DIGITAL_PINS 31 +#define NUM_ANALOG_INPUTS 12 + +#define TXLED0 0 +#define TXLED1 0 +#define RXLED0 0 +#define RXLED1 0 +#define TX_RX_LED_INIT 0 + +static const uint8_t SDA = 2; +static const uint8_t SCL = 3; +#define LED_BUILTIN 13 + +// Map SPI port to 'new' pins D14..D17 +static const uint8_t SS = 17; +static const uint8_t MOSI = 16; +static const uint8_t MISO = 14; +static const uint8_t SCK = 15; + +// Mapping of analog pins as digital I/O +// A6-A11 share with digital pins +static const uint8_t A0 = 18; +static const uint8_t A1 = 19; +static const uint8_t A2 = 20; +static const uint8_t A3 = 21; +static const uint8_t A4 = 22; +static const uint8_t A5 = 23; +static const uint8_t A6 = 24; // D4 +static const uint8_t A7 = 25; // D6 +static const uint8_t A8 = 26; // D8 +static const uint8_t A9 = 27; // D9 +static const uint8_t A10 = 28; // D10 +static const uint8_t A11 = 29; // D12 + +#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) +#define digitalPinToPCICRbit(p) 0 +#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) +#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) + +// __AVR_ATmega32U4__ has an unusual mapping of pins to channels +extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; +#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) + +#define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11 || (p) == 13) + +#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) + +#ifdef ARDUINO_MAIN + +// On the Arduino board, digital pins are also used +// for the analog output (software PWM). Analog input +// pins are a separate set. + +// ATMEL ATMEGA32U4 / ARDUINO LEONARDO / Flora +// +// D0 PD2 RXD1/INT2 +// D1 PD3 TXD1/INT3 +// D2 PD1 SDA SDA/INT1 +// D3# PD0 PWM8/SCL OC0B/SCL/INT0 +// D4 A6 PD4 ADC8 +// D5# PC6 ??? OC3A/#OC4A +// D6# A7 PD7 FastPWM #OC4D/ADC10 +// D7 PE6 INT6/AIN0 +// +// D8 A8 PB4 ADC11/PCINT4 +// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5 +// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6 +// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7 +// D12 A11 PD6 T1/#OC4D/ADC9 +// D13# PC7 PWM10 CLK0/OC4A +// +// A0 D18 PF7 ADC7 +// A1 D19 PF6 ADC6 +// A2 D20 PF5 ADC5 +// A3 D21 PF4 ADC4 +// A4 D22 PF1 ADC1 +// A5 D23 PF0 ADC0 +// +// New pins D14..D17 to map SPI port to digital pins +// +// MISO D14 PB3 MISO,PCINT3 +// SCK D15 PB1 SCK,PCINT1 +// MOSI D16 PB2 MOSI,PCINT2 +// SS D17 PB0 RXLED,SS/PCINT0 +// +// TXLED D30 PD5 +// RXLED PB0 +// HWB PE2 HWB + +// 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, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + PD, // D0 - PD2 + PD, // D1 - PD3 + PD, // D2 - PD1 + PD, // D3 - PD0 + PD, // D4 - PD4 + PC, // D5 - PC6 + PD, // D6 - PD7 + PE, // D7 - PE6 + + PB, // D8 - PB4 + PB, // D9 - PB5 + PB, // D10 - PB6 + PB, // D11 - PB7 + PD, // D12 - PD6 + PC, // D13 - PC7 + + PB, // D14 - MISO - PB3 + PB, // D15 - SCK - PB1 + PB, // D16 - MOSI - PB2 + PB, // D17 - SS - PB0 + + PF, // D18 - A0 - PF7 + PF, // D19 - A1 - PF6 + PF, // D20 - A2 - PF5 + PF, // D21 - A3 - PF4 + PF, // D22 - A4 - PF1 + PF, // D23 - A5 - PF0 + + PD, // D24 / D4 - A6 - PD4 + PD, // D25 / D6 - A7 - PD7 + PB, // D26 / D8 - A8 - PB4 + PB, // D27 / D9 - A9 - PB5 + PB, // D28 / D10 - A10 - PB6 + PD, // D29 / D12 - A11 - PD6 + PD, // D30 - PD5 +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + _BV(2), // D0 - PD2 + _BV(3), // D1 - PD3 + _BV(1), // D2 - PD1 + _BV(0), // D3 - PD0 + _BV(4), // D4 - PD4 + _BV(6), // D5 - PC6 + _BV(7), // D6 - PD7 + _BV(6), // D7 - PE6 + + _BV(4), // D8 - PB4 + _BV(5), // D9 - PB5 + _BV(6), // D10 - PB6 + _BV(7), // D11 - PB7 + _BV(6), // D12 - PD6 + _BV(7), // D13 - PC7 + + _BV(3), // D14 - MISO - PB3 + _BV(1), // D15 - SCK - PB1 + _BV(2), // D16 - MOSI - PB2 + _BV(0), // D17 - SS - PB0 + + _BV(7), // D18 - A0 - PF7 + _BV(6), // D19 - A1 - PF6 + _BV(5), // D20 - A2 - PF5 + _BV(4), // D21 - A3 - PF4 + _BV(1), // D22 - A4 - PF1 + _BV(0), // D23 - A5 - PF0 + + _BV(4), // D24 / D4 - A6 - PD4 + _BV(7), // D25 / D6 - A7 - PD7 + _BV(4), // D26 / D8 - A8 - PB4 + _BV(5), // D27 / D9 - A9 - PB5 + _BV(6), // D28 / D10 - A10 - PB6 + _BV(6), // D29 / D12 - A11 - PD6 + _BV(5), // D30 - PD5 +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + TIMER0B, /* 3 */ + NOT_ON_TIMER, + TIMER3A, /* 5 */ + TIMER4D, /* 6 */ + NOT_ON_TIMER, + + NOT_ON_TIMER, + TIMER1A, /* 9 */ + TIMER1B, /* 10 */ + TIMER0A, /* 11 */ + + NOT_ON_TIMER, + TIMER4A, /* 13 */ + + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, +}; + +const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { + 7, // A0 PF7 ADC7 + 6, // A1 PF6 ADC6 + 5, // A2 PF5 ADC5 + 4, // A3 PF4 ADC4 + 1, // A4 PF1 ADC1 + 0, // A5 PF0 ADC0 + 8, // A6 D4 PD4 ADC8 + 10, // A7 D6 PD7 ADC10 + 11, // A8 D8 PB4 ADC11 + 12, // A9 D9 PB5 ADC12 + 13, // A10 D10 PB6 ADC13 + 9 // A11 D12 PD6 ADC9 +}; + +#endif /* ARDUINO_MAIN */ + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +// Alias SerialUSB to Serial +#define SerialUSB SERIAL_PORT_USBVIRTUAL + +// Bootloader related fields +// Old Caterina bootloader places the MAGIC key into unsafe RAM locations (it can be rewritten +// by the running sketch before to actual reboot). +// Newer bootloaders, recognizable by the LUFA "signature" at the end of the flash, can handle both +// the usafe and the safe location. Check once (in USBCore.cpp) if the bootloader in new, then set the global +// _updatedLUFAbootloader variable to true/false and place the magic key consequently +#ifndef MAGIC_KEY +#define MAGIC_KEY 0x7777 +#endif + +#ifndef MAGIC_KEY_POS +#define MAGIC_KEY_POS 0x0800 +#endif + +#ifndef NEW_LUFA_SIGNATURE +#define NEW_LUFA_SIGNATURE 0xDCFB +#endif + +#endif /* Pins_Arduino_h */