From f48257fff5de8d674158b1c075e970e9fd0aa47b Mon Sep 17 00:00:00 2001 From: "Spence Konde (aka Dr. Azzy)" Date: Thu, 14 Nov 2019 03:44:33 -0500 Subject: [PATCH] boardmanager-1.1.0 --- megaavr/avrdude.conf => avrdude.conf | 0 megaavr/boards.txt => boards.txt | 0 .../optiboot_x/Makefile | 0 .../optiboot_x/README.TXT | 0 .../optiboot_x/baudcheck.c | 0 .../optiboot_x/boot_opt.h | 0 .../optiboot_x/info.sh | 0 .../optiboot_x/make-ccversions | 0 .../optiboot_x/make_all_xtiny.bat | 0 .../optiboot_x/makeoptions | 0 .../optiboot_x/megaTinyCore_Notes.txt | 0 .../optiboot_x/omake | 0 .../optiboot_x/omake.bat | 0 .../optiboot_x/optiboot.c | 0 .../optiboot_x/optiboot_txy2.hex | 60 +- .../optiboot_x/optiboot_txy2_alt.hex | 0 .../optiboot_x/optiboot_txy2_alt_rst.hex | 0 .../optiboot_x/optiboot_txy2_rst.hex | 0 .../optiboot_x/optiboot_txy4.hex | 60 +- .../optiboot_x/optiboot_txy4_alt.hex | 0 .../optiboot_x/optiboot_txy4_alt_rst.hex | 0 .../optiboot_x/optiboot_txy6.hex | 60 +- .../optiboot_x/optiboot_txy6_alt.hex | 0 .../optiboot_x/optiboot_txy6_alt_rst.hex | 0 .../optiboot_x/optiboot_txy6_rst.hex | 0 .../optiboot_x/optiboot_txy7.hex | 60 +- .../optiboot_x/optiboot_txy7_alt.hex | 0 .../optiboot_x/optiboot_txy7_alt_rst.hex | 0 .../optiboot_x/optiboot_txy7_rst.hex | 0 .../optiboot_x/optiboot_x.c | 0 .../optiboot_x/optiboot_xplained416.hex | 64 +- .../optiboot_x/optiboot_xplained817.hex | 64 +- .../optiboot_x/parse_options.mk | 0 .../optiboot_x/pin_defs.h | 0 .../optiboot_x/pin_defs_x.h | 0 .../optiboot_x/stk500.h | 0 {megaavr/cores => cores}/arduino/Arduino.h | 0 {megaavr/cores => cores}/arduino/Tone.cpp | 0 {megaavr/cores => cores}/arduino/UART.cpp | 0 {megaavr/cores => cores}/arduino/UART.h | 0 {megaavr/cores => cores}/arduino/UART0.cpp | 0 {megaavr/cores => cores}/arduino/UART1.cpp | 0 {megaavr/cores => cores}/arduino/UART2.cpp | 0 {megaavr/cores => cores}/arduino/UART3.cpp | 0 .../cores => cores}/arduino/UART_private.h | 0 .../cores => cores}/arduino/WInterrupts.c | 0 {megaavr/cores => cores}/arduino/WMath.cpp | 0 {megaavr/cores => cores}/arduino/abi.cpp | 0 .../cores => cores}/arduino/api/ArduinoAPI.h | 0 {megaavr/cores => cores}/arduino/api/Binary.h | 0 {megaavr/cores => cores}/arduino/api/Client.h | 0 .../cores => cores}/arduino/api/Common.cpp | 0 {megaavr/cores => cores}/arduino/api/Common.h | 0 .../cores => cores}/arduino/api/HardwareI2C.h | 0 .../arduino/api/HardwareSerial.h | 0 .../cores => cores}/arduino/api/IPAddress.cpp | 0 .../cores => cores}/arduino/api/IPAddress.h | 0 .../arduino/api/PluggableUSB.cpp | 0 .../arduino/api/PluggableUSB.h | 0 .../cores => cores}/arduino/api/Print.cpp | 0 {megaavr/cores => cores}/arduino/api/Print.h | 0 .../cores => cores}/arduino/api/Printable.h | 0 .../arduino/api/RingBuffer.cpp | 0 .../cores => cores}/arduino/api/RingBuffer.h | 0 {megaavr/cores => cores}/arduino/api/Server.h | 0 .../cores => cores}/arduino/api/Stream.cpp | 0 {megaavr/cores => cores}/arduino/api/Stream.h | 0 .../cores => cores}/arduino/api/String.cpp | 0 {megaavr/cores => cores}/arduino/api/String.h | 0 {megaavr/cores => cores}/arduino/api/USBAPI.h | 0 {megaavr/cores => cores}/arduino/api/Udp.h | 0 .../cores => cores}/arduino/api/Udp.h.orig | 0 .../cores => cores}/arduino/api/WCharacter.h | 0 .../deprecated-avr-comp/avr/dtostrf.c.impl | 0 .../api/deprecated-avr-comp/avr/dtostrf.h | 0 .../api/deprecated-avr-comp/avr/interrupt.h | 0 .../api/deprecated-avr-comp/avr/pgmspace.h | 0 .../arduino/api/deprecated/Client.h | 0 .../arduino/api/deprecated/IPAddress.h | 0 .../arduino/api/deprecated/Print.h | 0 .../arduino/api/deprecated/Printable.h | 0 .../arduino/api/deprecated/Server.h | 0 .../arduino/api/deprecated/Stream.h | 0 .../arduino/api/deprecated/Udp.h | 0 .../arduino/api/deprecated/WString.h | 0 {megaavr/cores => cores}/arduino/api/itoa.h | 0 {megaavr/cores => cores}/arduino/hooks.c | 0 {megaavr/cores => cores}/arduino/main.cpp | 0 {megaavr/cores => cores}/arduino/new.cpp | 0 {megaavr/cores => cores}/arduino/new.h | 0 {megaavr/cores => cores}/arduino/timers.h | 0 {megaavr/cores => cores}/arduino/wiring.c | 0 .../cores => cores}/arduino/wiring_analog.c | 0 .../cores => cores}/arduino/wiring_digital.c | 0 .../cores => cores}/arduino/wiring_private.h | 0 .../cores => cores}/arduino/wiring_pulse.S | 0 .../cores => cores}/arduino/wiring_pulse.c | 0 .../cores => cores}/arduino/wiring_shift.c | 0 ...sting.sh => create_disassembler_listing.sh | 0 ...ged_output.bat => delete_merged_output.bat | 0 ...erged_output.sh => delete_merged_output.sh | 0 {megaavr/extras => extras}/ATtiny_x02.gif | Bin {megaavr/extras => extras}/ATtiny_x02.md | 0 {megaavr/extras => extras}/ATtiny_x04.gif | Bin {megaavr/extras => extras}/ATtiny_x04.md | 0 {megaavr/extras => extras}/ATtiny_x06.gif | Bin {megaavr/extras => extras}/ATtiny_x06.md | 0 {megaavr/extras => extras}/ATtiny_x07.gif | Bin {megaavr/extras => extras}/ATtiny_x07.md | 0 {megaavr/extras => extras}/ATtiny_x12.gif | Bin {megaavr/extras => extras}/ATtiny_x12.md | 0 {megaavr/extras => extras}/ATtiny_x14.gif | Bin {megaavr/extras => extras}/ATtiny_x14.md | 0 {megaavr/extras => extras}/ATtiny_x16.gif | Bin {megaavr/extras => extras}/ATtiny_x16.md | 0 {megaavr/extras => extras}/ATtiny_x17.gif | Bin {megaavr/extras => extras}/ATtiny_x17.md | 0 {megaavr/extras => extras}/DevConfigUPDI.png | Bin .../DirectPortManipulation.md | 0 .../MinimalConnectionsUPDI.png | Bin {megaavr/extras => extras}/NanoAsUPDI.png | Bin {megaavr/extras => extras}/PinInterrupts.md | 0 {megaavr/extras => extras}/PowerSave.md | 0 {megaavr/extras => extras}/ProMiniAsUPDI.png | Bin {megaavr/extras => extras}/tinyNeoPixel.md | 0 megaavr/libraries/EEPROM/README.md | 139 --- .../examples/eeprom_clear/eeprom_clear.ino | 39 - .../EEPROM/examples/eeprom_crc/eeprom_crc.ino | 52 -- .../EEPROM/examples/eeprom_get/eeprom_get.ino | 68 -- .../eeprom_iteration/eeprom_iteration.ino | 57 -- .../EEPROM/examples/eeprom_put/eeprom_put.ino | 58 -- .../examples/eeprom_read/eeprom_read.ino | 56 -- .../examples/eeprom_update/eeprom_update.ino | 71 -- .../examples/eeprom_write/eeprom_write.ino | 60 -- megaavr/libraries/EEPROM/keywords.txt | 22 - megaavr/libraries/EEPROM/library.properties | 10 - megaavr/libraries/EEPROM/src/EEPROM.h | 146 ---- megaavr/libraries/Logic/README.md | 204 ----- .../Five_input_NOR/Five_input_NOR.ino | 56 -- .../Logic/examples/Interrupt/Interrupt.ino | 66 -- .../Three_input_AND/Three_input_AND.ino | 56 -- .../Three_input_NAND/Three_input_NAND.ino | 56 -- .../Three_input_OR/Three_input_OR.ino | 56 -- .../examples/Two_input_AND/Two_input_AND.ino | 57 -- .../Two_input_NAND/Two_input_NAND.ino | 57 -- .../examples/Two_input_OR/Two_input_OR.ino | 57 -- megaavr/libraries/Logic/keywords.txt | 37 - megaavr/libraries/Logic/library.properties | 9 - megaavr/libraries/Logic/src/Logic.cpp | 321 ------- megaavr/libraries/Logic/src/Logic.h | 112 --- .../BarometricPressureSensor.ino | 143 --- .../DigitalPotControl/DigitalPotControl.ino | 71 -- megaavr/libraries/SPI/keywords.txt | 36 - megaavr/libraries/SPI/library.properties | 10 - megaavr/libraries/SPI/src/SPI.cpp | 269 ------ megaavr/libraries/SPI/src/SPI.h | 215 ----- .../libraries/Servo/examples/Knob/Knob.ino | 27 - .../libraries/Servo/examples/Sweep/Sweep.ino | 32 - megaavr/libraries/Servo/keywords.txt | 24 - megaavr/libraries/Servo/library.properties | 9 - megaavr/libraries/Servo/src/Servo.h | 114 --- megaavr/libraries/Servo/src/megaavr/Servo.cpp | 210 ----- .../libraries/Servo/src/megaavr/ServoTimers.h | 56 -- .../Servo_megaTinyCore/examples/Knob/Knob.ino | 27 - .../examples/Sweep/Sweep.ino | 32 - .../libraries/Servo_megaTinyCore/keywords.txt | 24 - .../Servo_megaTinyCore/library.properties | 9 - .../src/Servo_megaTinyCore.h | 114 --- .../src/megaavr/ServoTimers.h | 56 -- .../src/megaavr/Servo_megaTinyCore.cpp | 210 ----- .../SoftwareSerialExample.ino | 55 -- .../TwoPortReceive/TwoPortReceive.ino | 91 -- megaavr/libraries/SoftwareSerial/keywords.txt | 30 - .../SoftwareSerial/library.properties | 10 - .../SoftwareSerial/src/SoftwareSerial.cpp | 459 ---------- .../SoftwareSerial/src/SoftwareSerial.h | 123 --- .../SFRRanger_reader/SFRRanger_reader.ino | 84 -- .../digital_potentiometer.ino | 34 - .../examples/master_reader/master_reader.ino | 29 - .../examples/master_writer/master_writer.ino | 29 - .../slave_receiver/slave_receiver.ino | 34 - .../examples/slave_sender/slave_sender.ino | 29 - megaavr/libraries/Wire/keywords.txt | 30 - megaavr/libraries/Wire/library.properties | 10 - megaavr/libraries/Wire/src/Wire.cpp | 326 ------- megaavr/libraries/Wire/src/Wire.h | 86 -- megaavr/libraries/Wire/src/utility/twi.c | 771 ---------------- megaavr/libraries/Wire/src/utility/twi.h | 126 --- megaavr/libraries/tinyNeoPixel/COPYING | 165 ---- .../RGBWstrandtest/RGBWstrandtest.ino | 248 ------ .../examples/buttoncycler/buttoncycler.ino | 38 - .../tinyNeoPixel/examples/simple/simple.ino | 39 - .../examples/strandtest/strandtest.ino | 122 --- megaavr/libraries/tinyNeoPixel/keywords.txt | 29 - .../libraries/tinyNeoPixel/library.properties | 9 - .../libraries/tinyNeoPixel/tinyNeoPixel.cpp | 825 ------------------ megaavr/libraries/tinyNeoPixel/tinyNeoPixel.h | 172 ---- megaavr/libraries/tinyNeoPixel_Static/COPYING | 793 ----------------- .../examples/buttoncycler/buttoncycler.ino | 172 ---- .../examples/simple/simple.ino | 57 -- .../examples/strandtest/strandtest.ino | 136 --- .../tinyNeoPixel_Static/keywords.txt | 29 - .../tinyNeoPixel_Static/library.properties | 9 - .../tinyNeoPixel_Static.cpp | 777 ----------------- .../tinyNeoPixel_Static/tinyNeoPixel_Static.h | 156 ---- megaavr/variants/txy2/pins_arduino.h | 208 ----- megaavr/variants/txy2/variant.c | 100 --- megaavr/variants/txy4/pins_arduino.h | 263 ------ megaavr/variants/txy4/variant.c | 100 --- megaavr/variants/txy6/pins_arduino.h | 307 ------- megaavr/variants/txy6/variant.c | 100 --- megaavr/variants/txy7/pins_arduino.h | 332 ------- megaavr/variants/txy7/variant.c | 100 --- megaavr/platform.txt => platform.txt | 0 megaavr/programmers.txt => programmers.txt | 0 215 files changed, 184 insertions(+), 11436 deletions(-) rename megaavr/avrdude.conf => avrdude.conf (100%) rename megaavr/boards.txt => boards.txt (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/Makefile (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/README.TXT (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/baudcheck.c (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/boot_opt.h (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/info.sh (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/make-ccversions (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/make_all_xtiny.bat (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/makeoptions (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/megaTinyCore_Notes.txt (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/omake (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/omake.bat (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot.c (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy2.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy2_alt.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy2_alt_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy2_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy4.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy4_alt.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy4_alt_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy6.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy6_alt.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy6_alt_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy6_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy7.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy7_alt.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy7_alt_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_txy7_rst.hex (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_x.c (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_xplained416.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/optiboot_xplained817.hex (97%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/parse_options.mk (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/pin_defs.h (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/pin_defs_x.h (100%) rename {megaavr/bootloaders => bootloaders}/optiboot_x/stk500.h (100%) rename {megaavr/cores => cores}/arduino/Arduino.h (100%) rename {megaavr/cores => cores}/arduino/Tone.cpp (100%) rename {megaavr/cores => cores}/arduino/UART.cpp (100%) rename {megaavr/cores => cores}/arduino/UART.h (100%) rename {megaavr/cores => cores}/arduino/UART0.cpp (100%) rename {megaavr/cores => cores}/arduino/UART1.cpp (100%) rename {megaavr/cores => cores}/arduino/UART2.cpp (100%) rename {megaavr/cores => cores}/arduino/UART3.cpp (100%) rename {megaavr/cores => cores}/arduino/UART_private.h (100%) rename {megaavr/cores => cores}/arduino/WInterrupts.c (100%) rename {megaavr/cores => cores}/arduino/WMath.cpp (100%) rename {megaavr/cores => cores}/arduino/abi.cpp (100%) rename {megaavr/cores => cores}/arduino/api/ArduinoAPI.h (100%) rename {megaavr/cores => cores}/arduino/api/Binary.h (100%) rename {megaavr/cores => cores}/arduino/api/Client.h (100%) rename {megaavr/cores => cores}/arduino/api/Common.cpp (100%) rename {megaavr/cores => cores}/arduino/api/Common.h (100%) rename {megaavr/cores => cores}/arduino/api/HardwareI2C.h (100%) rename {megaavr/cores => cores}/arduino/api/HardwareSerial.h (100%) rename {megaavr/cores => cores}/arduino/api/IPAddress.cpp (100%) rename {megaavr/cores => cores}/arduino/api/IPAddress.h (100%) rename {megaavr/cores => cores}/arduino/api/PluggableUSB.cpp (100%) rename {megaavr/cores => cores}/arduino/api/PluggableUSB.h (100%) rename {megaavr/cores => cores}/arduino/api/Print.cpp (100%) rename {megaavr/cores => cores}/arduino/api/Print.h (100%) rename {megaavr/cores => cores}/arduino/api/Printable.h (100%) rename {megaavr/cores => cores}/arduino/api/RingBuffer.cpp (100%) rename {megaavr/cores => cores}/arduino/api/RingBuffer.h (100%) rename {megaavr/cores => cores}/arduino/api/Server.h (100%) rename {megaavr/cores => cores}/arduino/api/Stream.cpp (100%) rename {megaavr/cores => cores}/arduino/api/Stream.h (100%) rename {megaavr/cores => cores}/arduino/api/String.cpp (100%) rename {megaavr/cores => cores}/arduino/api/String.h (100%) rename {megaavr/cores => cores}/arduino/api/USBAPI.h (100%) rename {megaavr/cores => cores}/arduino/api/Udp.h (100%) rename {megaavr/cores => cores}/arduino/api/Udp.h.orig (100%) rename {megaavr/cores => cores}/arduino/api/WCharacter.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated-avr-comp/avr/dtostrf.c.impl (100%) rename {megaavr/cores => cores}/arduino/api/deprecated-avr-comp/avr/dtostrf.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated-avr-comp/avr/interrupt.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated-avr-comp/avr/pgmspace.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Client.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/IPAddress.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Print.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Printable.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Server.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Stream.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/Udp.h (100%) rename {megaavr/cores => cores}/arduino/api/deprecated/WString.h (100%) rename {megaavr/cores => cores}/arduino/api/itoa.h (100%) rename {megaavr/cores => cores}/arduino/hooks.c (100%) rename {megaavr/cores => cores}/arduino/main.cpp (100%) rename {megaavr/cores => cores}/arduino/new.cpp (100%) rename {megaavr/cores => cores}/arduino/new.h (100%) rename {megaavr/cores => cores}/arduino/timers.h (100%) rename {megaavr/cores => cores}/arduino/wiring.c (100%) rename {megaavr/cores => cores}/arduino/wiring_analog.c (100%) rename {megaavr/cores => cores}/arduino/wiring_digital.c (100%) rename {megaavr/cores => cores}/arduino/wiring_private.h (100%) rename {megaavr/cores => cores}/arduino/wiring_pulse.S (100%) rename {megaavr/cores => cores}/arduino/wiring_pulse.c (100%) rename {megaavr/cores => cores}/arduino/wiring_shift.c (100%) rename megaavr/create_disassembler_listing.sh => create_disassembler_listing.sh (100%) rename megaavr/delete_merged_output.bat => delete_merged_output.bat (100%) rename megaavr/delete_merged_output.sh => delete_merged_output.sh (100%) rename {megaavr/extras => extras}/ATtiny_x02.gif (100%) rename {megaavr/extras => extras}/ATtiny_x02.md (100%) rename {megaavr/extras => extras}/ATtiny_x04.gif (100%) rename {megaavr/extras => extras}/ATtiny_x04.md (100%) rename {megaavr/extras => extras}/ATtiny_x06.gif (100%) rename {megaavr/extras => extras}/ATtiny_x06.md (100%) rename {megaavr/extras => extras}/ATtiny_x07.gif (100%) rename {megaavr/extras => extras}/ATtiny_x07.md (100%) rename {megaavr/extras => extras}/ATtiny_x12.gif (100%) rename {megaavr/extras => extras}/ATtiny_x12.md (100%) rename {megaavr/extras => extras}/ATtiny_x14.gif (100%) rename {megaavr/extras => extras}/ATtiny_x14.md (100%) rename {megaavr/extras => extras}/ATtiny_x16.gif (100%) rename {megaavr/extras => extras}/ATtiny_x16.md (100%) rename {megaavr/extras => extras}/ATtiny_x17.gif (100%) rename {megaavr/extras => extras}/ATtiny_x17.md (100%) rename {megaavr/extras => extras}/DevConfigUPDI.png (100%) rename {megaavr/extras => extras}/DirectPortManipulation.md (100%) rename {megaavr/extras => extras}/MinimalConnectionsUPDI.png (100%) rename {megaavr/extras => extras}/NanoAsUPDI.png (100%) rename {megaavr/extras => extras}/PinInterrupts.md (100%) rename {megaavr/extras => extras}/PowerSave.md (100%) rename {megaavr/extras => extras}/ProMiniAsUPDI.png (100%) rename {megaavr/extras => extras}/tinyNeoPixel.md (100%) delete mode 100644 megaavr/libraries/EEPROM/README.md delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_crc/eeprom_crc.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_get/eeprom_get.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_put/eeprom_put.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino delete mode 100644 megaavr/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino delete mode 100644 megaavr/libraries/EEPROM/keywords.txt delete mode 100644 megaavr/libraries/EEPROM/library.properties delete mode 100644 megaavr/libraries/EEPROM/src/EEPROM.h delete mode 100644 megaavr/libraries/Logic/README.md delete mode 100644 megaavr/libraries/Logic/examples/Five_input_NOR/Five_input_NOR.ino delete mode 100644 megaavr/libraries/Logic/examples/Interrupt/Interrupt.ino delete mode 100644 megaavr/libraries/Logic/examples/Three_input_AND/Three_input_AND.ino delete mode 100644 megaavr/libraries/Logic/examples/Three_input_NAND/Three_input_NAND.ino delete mode 100644 megaavr/libraries/Logic/examples/Three_input_OR/Three_input_OR.ino delete mode 100644 megaavr/libraries/Logic/examples/Two_input_AND/Two_input_AND.ino delete mode 100644 megaavr/libraries/Logic/examples/Two_input_NAND/Two_input_NAND.ino delete mode 100644 megaavr/libraries/Logic/examples/Two_input_OR/Two_input_OR.ino delete mode 100644 megaavr/libraries/Logic/keywords.txt delete mode 100644 megaavr/libraries/Logic/library.properties delete mode 100644 megaavr/libraries/Logic/src/Logic.cpp delete mode 100644 megaavr/libraries/Logic/src/Logic.h delete mode 100644 megaavr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino delete mode 100644 megaavr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino delete mode 100644 megaavr/libraries/SPI/keywords.txt delete mode 100644 megaavr/libraries/SPI/library.properties delete mode 100644 megaavr/libraries/SPI/src/SPI.cpp delete mode 100644 megaavr/libraries/SPI/src/SPI.h delete mode 100644 megaavr/libraries/Servo/examples/Knob/Knob.ino delete mode 100644 megaavr/libraries/Servo/examples/Sweep/Sweep.ino delete mode 100644 megaavr/libraries/Servo/keywords.txt delete mode 100644 megaavr/libraries/Servo/library.properties delete mode 100644 megaavr/libraries/Servo/src/Servo.h delete mode 100644 megaavr/libraries/Servo/src/megaavr/Servo.cpp delete mode 100644 megaavr/libraries/Servo/src/megaavr/ServoTimers.h delete mode 100644 megaavr/libraries/Servo_megaTinyCore/examples/Knob/Knob.ino delete mode 100644 megaavr/libraries/Servo_megaTinyCore/examples/Sweep/Sweep.ino delete mode 100644 megaavr/libraries/Servo_megaTinyCore/keywords.txt delete mode 100644 megaavr/libraries/Servo_megaTinyCore/library.properties delete mode 100644 megaavr/libraries/Servo_megaTinyCore/src/Servo_megaTinyCore.h delete mode 100644 megaavr/libraries/Servo_megaTinyCore/src/megaavr/ServoTimers.h delete mode 100644 megaavr/libraries/Servo_megaTinyCore/src/megaavr/Servo_megaTinyCore.cpp delete mode 100644 megaavr/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino delete mode 100644 megaavr/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino delete mode 100644 megaavr/libraries/SoftwareSerial/keywords.txt delete mode 100644 megaavr/libraries/SoftwareSerial/library.properties delete mode 100644 megaavr/libraries/SoftwareSerial/src/SoftwareSerial.cpp delete mode 100644 megaavr/libraries/SoftwareSerial/src/SoftwareSerial.h delete mode 100644 megaavr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino delete mode 100644 megaavr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino delete mode 100644 megaavr/libraries/Wire/examples/master_reader/master_reader.ino delete mode 100644 megaavr/libraries/Wire/examples/master_writer/master_writer.ino delete mode 100644 megaavr/libraries/Wire/examples/slave_receiver/slave_receiver.ino delete mode 100644 megaavr/libraries/Wire/examples/slave_sender/slave_sender.ino delete mode 100644 megaavr/libraries/Wire/keywords.txt delete mode 100644 megaavr/libraries/Wire/library.properties delete mode 100644 megaavr/libraries/Wire/src/Wire.cpp delete mode 100644 megaavr/libraries/Wire/src/Wire.h delete mode 100644 megaavr/libraries/Wire/src/utility/twi.c delete mode 100644 megaavr/libraries/Wire/src/utility/twi.h delete mode 100644 megaavr/libraries/tinyNeoPixel/COPYING delete mode 100644 megaavr/libraries/tinyNeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino delete mode 100644 megaavr/libraries/tinyNeoPixel/examples/buttoncycler/buttoncycler.ino delete mode 100644 megaavr/libraries/tinyNeoPixel/examples/simple/simple.ino delete mode 100644 megaavr/libraries/tinyNeoPixel/examples/strandtest/strandtest.ino delete mode 100644 megaavr/libraries/tinyNeoPixel/keywords.txt delete mode 100644 megaavr/libraries/tinyNeoPixel/library.properties delete mode 100644 megaavr/libraries/tinyNeoPixel/tinyNeoPixel.cpp delete mode 100644 megaavr/libraries/tinyNeoPixel/tinyNeoPixel.h delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/COPYING delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/examples/buttoncycler/buttoncycler.ino delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/examples/simple/simple.ino delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/examples/strandtest/strandtest.ino delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/keywords.txt delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/library.properties delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.cpp delete mode 100644 megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.h delete mode 100644 megaavr/variants/txy2/pins_arduino.h delete mode 100644 megaavr/variants/txy2/variant.c delete mode 100644 megaavr/variants/txy4/pins_arduino.h delete mode 100644 megaavr/variants/txy4/variant.c delete mode 100644 megaavr/variants/txy6/pins_arduino.h delete mode 100644 megaavr/variants/txy6/variant.c delete mode 100644 megaavr/variants/txy7/pins_arduino.h delete mode 100644 megaavr/variants/txy7/variant.c rename megaavr/platform.txt => platform.txt (100%) rename megaavr/programmers.txt => programmers.txt (100%) diff --git a/megaavr/avrdude.conf b/avrdude.conf similarity index 100% rename from megaavr/avrdude.conf rename to avrdude.conf diff --git a/megaavr/boards.txt b/boards.txt similarity index 100% rename from megaavr/boards.txt rename to boards.txt diff --git a/megaavr/bootloaders/optiboot_x/Makefile b/bootloaders/optiboot_x/Makefile similarity index 100% rename from megaavr/bootloaders/optiboot_x/Makefile rename to bootloaders/optiboot_x/Makefile diff --git a/megaavr/bootloaders/optiboot_x/README.TXT b/bootloaders/optiboot_x/README.TXT similarity index 100% rename from megaavr/bootloaders/optiboot_x/README.TXT rename to bootloaders/optiboot_x/README.TXT diff --git a/megaavr/bootloaders/optiboot_x/baudcheck.c b/bootloaders/optiboot_x/baudcheck.c similarity index 100% rename from megaavr/bootloaders/optiboot_x/baudcheck.c rename to bootloaders/optiboot_x/baudcheck.c diff --git a/megaavr/bootloaders/optiboot_x/boot_opt.h b/bootloaders/optiboot_x/boot_opt.h similarity index 100% rename from megaavr/bootloaders/optiboot_x/boot_opt.h rename to bootloaders/optiboot_x/boot_opt.h diff --git a/megaavr/bootloaders/optiboot_x/info.sh b/bootloaders/optiboot_x/info.sh similarity index 100% rename from megaavr/bootloaders/optiboot_x/info.sh rename to bootloaders/optiboot_x/info.sh diff --git a/megaavr/bootloaders/optiboot_x/make-ccversions b/bootloaders/optiboot_x/make-ccversions similarity index 100% rename from megaavr/bootloaders/optiboot_x/make-ccversions rename to bootloaders/optiboot_x/make-ccversions diff --git a/megaavr/bootloaders/optiboot_x/make_all_xtiny.bat b/bootloaders/optiboot_x/make_all_xtiny.bat similarity index 100% rename from megaavr/bootloaders/optiboot_x/make_all_xtiny.bat rename to bootloaders/optiboot_x/make_all_xtiny.bat diff --git a/megaavr/bootloaders/optiboot_x/makeoptions b/bootloaders/optiboot_x/makeoptions similarity index 100% rename from megaavr/bootloaders/optiboot_x/makeoptions rename to bootloaders/optiboot_x/makeoptions diff --git a/megaavr/bootloaders/optiboot_x/megaTinyCore_Notes.txt b/bootloaders/optiboot_x/megaTinyCore_Notes.txt similarity index 100% rename from megaavr/bootloaders/optiboot_x/megaTinyCore_Notes.txt rename to bootloaders/optiboot_x/megaTinyCore_Notes.txt diff --git a/megaavr/bootloaders/optiboot_x/omake b/bootloaders/optiboot_x/omake similarity index 100% rename from megaavr/bootloaders/optiboot_x/omake rename to bootloaders/optiboot_x/omake diff --git a/megaavr/bootloaders/optiboot_x/omake.bat b/bootloaders/optiboot_x/omake.bat similarity index 100% rename from megaavr/bootloaders/optiboot_x/omake.bat rename to bootloaders/optiboot_x/omake.bat diff --git a/megaavr/bootloaders/optiboot_x/optiboot.c b/bootloaders/optiboot_x/optiboot.c similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot.c rename to bootloaders/optiboot_x/optiboot.c diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy2.hex b/bootloaders/optiboot_x/optiboot_txy2.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_txy2.hex rename to bootloaders/optiboot_x/optiboot_txy2.hex index 7bfc06db..7b4c57d3 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_txy2.hex +++ b/bootloaders/optiboot_x/optiboot_txy2.hex @@ -1,30 +1,30 @@ -:1000000001C0D1C01124809140008093400083FF43 -:1000100004C0282E80E0AFD0F3C0A895069A0E9AAF -:1000200010920102809182128370813029F58CE553 -:1000300090E0809308089093090881E080930B0872 -:1000400083E0809307081092050880EC80930608EF -:100050008BE091D0079A87E0815089F4A8950DE94B -:1000600083E0D82E7CD08134F1F479D0182F8CD055 -:10007000123889F480E013C083E790E0DACF179A52 -:100080002EEC36E5A8959091040897FDE8CF215015 -:100090003109C1F7E1CF89E0113809F083E058D088 -:1000A00080E156D0DFCF823419F484E175D0F8CFE7 -:1000B000853411F485E0FACF853531F450D0C82F5E -:1000C0004ED0D82F61D0ECCF863519F484E064D0BF -:1000D000D1CF8436B9F443D042D0182F40D08634E3 -:1000E00079F4D0583CD0888321961150D9F74CD060 -:1000F00004BFD0920010809102108370E1F7D0CF3E -:10010000DC5EF0CF843791F42AD029D0182F27D085 -:10011000F82E3AD086E4F81207C0D058888121968C -:1001200017D01150D9F7BCCFDC5EF8CF853751F42A -:100130002BD0809100110CD08091011109D08091B9 -:100140000211ADCF813509F0BDCF81E014D0BACF17 -:100150009091040895FFFCCF809302080895809148 -:10016000040887FFFCCF909101088091000892FD60 -:1001700001C0A89508959091010190FDFCCF98EDE4 -:1001800094BF809300010895EADF803219F081E086 -:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 -:1001A000E9F7CF91F1CF88ED84BF60930001809192 -:0801B00002108370E1F70895CD -:0201FE000009F6 -:00000001FF +:1000000001C0D1C01124809140008093400083FF43 +:1000100004C0282E80E0AFD0F3C0A895069A0E9AAF +:1000200010920102809182128370813029F58CE553 +:1000300090E0809308089093090881E080930B0872 +:1000400083E0809307081092050880EC80930608EF +:100050008BE091D0079A87E0815089F4A8950DE94B +:1000600083E0D82E7CD08134F1F479D0182F8CD055 +:10007000123889F480E013C083E790E0DACF179A52 +:100080002EEC36E5A8959091040897FDE8CF215015 +:100090003109C1F7E1CF89E0113809F083E058D088 +:1000A00080E156D0DFCF823419F484E175D0F8CFE7 +:1000B000853411F485E0FACF853531F450D0C82F5E +:1000C0004ED0D82F61D0ECCF863519F484E064D0BF +:1000D000D1CF8436B9F443D042D0182F40D08634E3 +:1000E00079F4D0583CD0888321961150D9F74CD060 +:1000F00004BFD0920010809102108370E1F7D0CF3E +:10010000DC5EF0CF843791F42AD029D0182F27D085 +:10011000F82E3AD086E4F81207C0D058888121968C +:1001200017D01150D9F7BCCFDC5EF8CF853751F42A +:100130002BD0809100110CD08091011109D08091B9 +:100140000211ADCF813509F0BDCF81E014D0BACF17 +:100150009091040895FFFCCF809302080895809148 +:10016000040887FFFCCF909101088091000892FD60 +:1001700001C0A89508959091010190FDFCCF98EDE4 +:1001800094BF809300010895EADF803219F081E086 +:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 +:1001A000E9F7CF91F1CF88ED84BF60930001809192 +:0801B00002108370E1F70895CD +:0201FE000009F6 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy2_alt.hex b/bootloaders/optiboot_x/optiboot_txy2_alt.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy2_alt.hex rename to bootloaders/optiboot_x/optiboot_txy2_alt.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy2_alt_rst.hex b/bootloaders/optiboot_x/optiboot_txy2_alt_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy2_alt_rst.hex rename to bootloaders/optiboot_x/optiboot_txy2_alt_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy2_rst.hex b/bootloaders/optiboot_x/optiboot_txy2_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy2_rst.hex rename to bootloaders/optiboot_x/optiboot_txy2_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy4.hex b/bootloaders/optiboot_x/optiboot_txy4.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_txy4.hex rename to bootloaders/optiboot_x/optiboot_txy4.hex index f67c6d17..3e7b8842 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_txy4.hex +++ b/bootloaders/optiboot_x/optiboot_txy4.hex @@ -1,30 +1,30 @@ -:1000000001C0D1C01124809140008093400083FF43 -:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 -:1000200010920102809182128370813029F58CE553 -:1000300090E0809308089093090881E080930B0872 -:1000400083E0809307081092050880EC80930608EF -:100050008BE091D0079A87E0815089F4A8950DE94B -:1000600083E0D82E7CD08134F1F479D0182F8CD055 -:10007000123889F480E013C083E790E0DACF179A52 -:100080002EEC36E5A8959091040897FDE8CF215015 -:100090003109C1F7E1CF89E0113809F083E058D088 -:1000A00080E156D0DFCF823419F484E175D0F8CFE7 -:1000B000853411F485E0FACF853531F450D0C82F5E -:1000C0004ED0D82F61D0ECCF863519F484E064D0BF -:1000D000D1CF8436B9F443D042D0182F40D08634E3 -:1000E00079F4D0583CD0888321961150D9F74CD060 -:1000F00004BFD0920010809102108370E1F7D0CF3E -:10010000DC5EF0CF843791F42AD029D0182F27D085 -:10011000F82E3AD086E4F81207C0D058888121968C -:1001200017D01150D9F7BCCFDC5EF8CF853751F42A -:100130002BD0809100110CD08091011109D08091B9 -:100140000211ADCF813509F0BDCF81E014D0BACF17 -:100150009091040895FFFCCF809302080895809148 -:10016000040887FFFCCF909101088091000892FD60 -:1001700001C0A89508959091010190FDFCCF98EDE4 -:1001800094BF809300010895EADF803219F081E086 -:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 -:1001A000E9F7CF91F1CF88ED84BF60930001809192 -:0801B00002108370E1F70895CD -:0201FE000009F6 -:00000001FF +:1000000001C0D1C01124809140008093400083FF43 +:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 +:1000200010920102809182128370813029F58CE553 +:1000300090E0809308089093090881E080930B0872 +:1000400083E0809307081092050880EC80930608EF +:100050008BE091D0079A87E0815089F4A8950DE94B +:1000600083E0D82E7CD08134F1F479D0182F8CD055 +:10007000123889F480E013C083E790E0DACF179A52 +:100080002EEC36E5A8959091040897FDE8CF215015 +:100090003109C1F7E1CF89E0113809F083E058D088 +:1000A00080E156D0DFCF823419F484E175D0F8CFE7 +:1000B000853411F485E0FACF853531F450D0C82F5E +:1000C0004ED0D82F61D0ECCF863519F484E064D0BF +:1000D000D1CF8436B9F443D042D0182F40D08634E3 +:1000E00079F4D0583CD0888321961150D9F74CD060 +:1000F00004BFD0920010809102108370E1F7D0CF3E +:10010000DC5EF0CF843791F42AD029D0182F27D085 +:10011000F82E3AD086E4F81207C0D058888121968C +:1001200017D01150D9F7BCCFDC5EF8CF853751F42A +:100130002BD0809100110CD08091011109D08091B9 +:100140000211ADCF813509F0BDCF81E014D0BACF17 +:100150009091040895FFFCCF809302080895809148 +:10016000040887FFFCCF909101088091000892FD60 +:1001700001C0A89508959091010190FDFCCF98EDE4 +:1001800094BF809300010895EADF803219F081E086 +:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 +:1001A000E9F7CF91F1CF88ED84BF60930001809192 +:0801B00002108370E1F70895CD +:0201FE000009F6 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy4_alt.hex b/bootloaders/optiboot_x/optiboot_txy4_alt.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy4_alt.hex rename to bootloaders/optiboot_x/optiboot_txy4_alt.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy4_alt_rst.hex b/bootloaders/optiboot_x/optiboot_txy4_alt_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy4_alt_rst.hex rename to bootloaders/optiboot_x/optiboot_txy4_alt_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy6.hex b/bootloaders/optiboot_x/optiboot_txy6.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_txy6.hex rename to bootloaders/optiboot_x/optiboot_txy6.hex index f67c6d17..3e7b8842 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_txy6.hex +++ b/bootloaders/optiboot_x/optiboot_txy6.hex @@ -1,30 +1,30 @@ -:1000000001C0D1C01124809140008093400083FF43 -:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 -:1000200010920102809182128370813029F58CE553 -:1000300090E0809308089093090881E080930B0872 -:1000400083E0809307081092050880EC80930608EF -:100050008BE091D0079A87E0815089F4A8950DE94B -:1000600083E0D82E7CD08134F1F479D0182F8CD055 -:10007000123889F480E013C083E790E0DACF179A52 -:100080002EEC36E5A8959091040897FDE8CF215015 -:100090003109C1F7E1CF89E0113809F083E058D088 -:1000A00080E156D0DFCF823419F484E175D0F8CFE7 -:1000B000853411F485E0FACF853531F450D0C82F5E -:1000C0004ED0D82F61D0ECCF863519F484E064D0BF -:1000D000D1CF8436B9F443D042D0182F40D08634E3 -:1000E00079F4D0583CD0888321961150D9F74CD060 -:1000F00004BFD0920010809102108370E1F7D0CF3E -:10010000DC5EF0CF843791F42AD029D0182F27D085 -:10011000F82E3AD086E4F81207C0D058888121968C -:1001200017D01150D9F7BCCFDC5EF8CF853751F42A -:100130002BD0809100110CD08091011109D08091B9 -:100140000211ADCF813509F0BDCF81E014D0BACF17 -:100150009091040895FFFCCF809302080895809148 -:10016000040887FFFCCF909101088091000892FD60 -:1001700001C0A89508959091010190FDFCCF98EDE4 -:1001800094BF809300010895EADF803219F081E086 -:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 -:1001A000E9F7CF91F1CF88ED84BF60930001809192 -:0801B00002108370E1F70895CD -:0201FE000009F6 -:00000001FF +:1000000001C0D1C01124809140008093400083FF43 +:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 +:1000200010920102809182128370813029F58CE553 +:1000300090E0809308089093090881E080930B0872 +:1000400083E0809307081092050880EC80930608EF +:100050008BE091D0079A87E0815089F4A8950DE94B +:1000600083E0D82E7CD08134F1F479D0182F8CD055 +:10007000123889F480E013C083E790E0DACF179A52 +:100080002EEC36E5A8959091040897FDE8CF215015 +:100090003109C1F7E1CF89E0113809F083E058D088 +:1000A00080E156D0DFCF823419F484E175D0F8CFE7 +:1000B000853411F485E0FACF853531F450D0C82F5E +:1000C0004ED0D82F61D0ECCF863519F484E064D0BF +:1000D000D1CF8436B9F443D042D0182F40D08634E3 +:1000E00079F4D0583CD0888321961150D9F74CD060 +:1000F00004BFD0920010809102108370E1F7D0CF3E +:10010000DC5EF0CF843791F42AD029D0182F27D085 +:10011000F82E3AD086E4F81207C0D058888121968C +:1001200017D01150D9F7BCCFDC5EF8CF853751F42A +:100130002BD0809100110CD08091011109D08091B9 +:100140000211ADCF813509F0BDCF81E014D0BACF17 +:100150009091040895FFFCCF809302080895809148 +:10016000040887FFFCCF909101088091000892FD60 +:1001700001C0A89508959091010190FDFCCF98EDE4 +:1001800094BF809300010895EADF803219F081E086 +:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 +:1001A000E9F7CF91F1CF88ED84BF60930001809192 +:0801B00002108370E1F70895CD +:0201FE000009F6 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy6_alt.hex b/bootloaders/optiboot_x/optiboot_txy6_alt.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy6_alt.hex rename to bootloaders/optiboot_x/optiboot_txy6_alt.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy6_alt_rst.hex b/bootloaders/optiboot_x/optiboot_txy6_alt_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy6_alt_rst.hex rename to bootloaders/optiboot_x/optiboot_txy6_alt_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy6_rst.hex b/bootloaders/optiboot_x/optiboot_txy6_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy6_rst.hex rename to bootloaders/optiboot_x/optiboot_txy6_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy7.hex b/bootloaders/optiboot_x/optiboot_txy7.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_txy7.hex rename to bootloaders/optiboot_x/optiboot_txy7.hex index f67c6d17..3e7b8842 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_txy7.hex +++ b/bootloaders/optiboot_x/optiboot_txy7.hex @@ -1,30 +1,30 @@ -:1000000001C0D1C01124809140008093400083FF43 -:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 -:1000200010920102809182128370813029F58CE553 -:1000300090E0809308089093090881E080930B0872 -:1000400083E0809307081092050880EC80930608EF -:100050008BE091D0079A87E0815089F4A8950DE94B -:1000600083E0D82E7CD08134F1F479D0182F8CD055 -:10007000123889F480E013C083E790E0DACF179A52 -:100080002EEC36E5A8959091040897FDE8CF215015 -:100090003109C1F7E1CF89E0113809F083E058D088 -:1000A00080E156D0DFCF823419F484E175D0F8CFE7 -:1000B000853411F485E0FACF853531F450D0C82F5E -:1000C0004ED0D82F61D0ECCF863519F484E064D0BF -:1000D000D1CF8436B9F443D042D0182F40D08634E3 -:1000E00079F4D0583CD0888321961150D9F74CD060 -:1000F00004BFD0920010809102108370E1F7D0CF3E -:10010000DC5EF0CF843791F42AD029D0182F27D085 -:10011000F82E3AD086E4F81207C0D058888121968C -:1001200017D01150D9F7BCCFDC5EF8CF853751F42A -:100130002BD0809100110CD08091011109D08091B9 -:100140000211ADCF813509F0BDCF81E014D0BACF17 -:100150009091040895FFFCCF809302080895809148 -:10016000040887FFFCCF909101088091000892FD60 -:1001700001C0A89508959091010190FDFCCF98EDE4 -:1001800094BF809300010895EADF803219F081E086 -:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 -:1001A000E9F7CF91F1CF88ED84BF60930001809192 -:0801B00002108370E1F70895CD -:0201FE000009F6 -:00000001FF +:1000000001C0D1C01124809140008093400083FF43 +:1000100004C0282E80E0AFD0F3C0A895229A2A9A77 +:1000200010920102809182128370813029F58CE553 +:1000300090E0809308089093090881E080930B0872 +:1000400083E0809307081092050880EC80930608EF +:100050008BE091D0079A87E0815089F4A8950DE94B +:1000600083E0D82E7CD08134F1F479D0182F8CD055 +:10007000123889F480E013C083E790E0DACF179A52 +:100080002EEC36E5A8959091040897FDE8CF215015 +:100090003109C1F7E1CF89E0113809F083E058D088 +:1000A00080E156D0DFCF823419F484E175D0F8CFE7 +:1000B000853411F485E0FACF853531F450D0C82F5E +:1000C0004ED0D82F61D0ECCF863519F484E064D0BF +:1000D000D1CF8436B9F443D042D0182F40D08634E3 +:1000E00079F4D0583CD0888321961150D9F74CD060 +:1000F00004BFD0920010809102108370E1F7D0CF3E +:10010000DC5EF0CF843791F42AD029D0182F27D085 +:10011000F82E3AD086E4F81207C0D058888121968C +:1001200017D01150D9F7BCCFDC5EF8CF853751F42A +:100130002BD0809100110CD08091011109D08091B9 +:100140000211ADCF813509F0BDCF81E014D0BACF17 +:100150009091040895FFFCCF809302080895809148 +:10016000040887FFFCCF909101088091000892FD60 +:1001700001C0A89508959091010190FDFCCF98EDE4 +:1001800094BF809300010895EADF803219F081E086 +:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 +:1001A000E9F7CF91F1CF88ED84BF60930001809192 +:0801B00002108370E1F70895CD +:0201FE000009F6 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy7_alt.hex b/bootloaders/optiboot_x/optiboot_txy7_alt.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy7_alt.hex rename to bootloaders/optiboot_x/optiboot_txy7_alt.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy7_alt_rst.hex b/bootloaders/optiboot_x/optiboot_txy7_alt_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy7_alt_rst.hex rename to bootloaders/optiboot_x/optiboot_txy7_alt_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_txy7_rst.hex b/bootloaders/optiboot_x/optiboot_txy7_rst.hex similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_txy7_rst.hex rename to bootloaders/optiboot_x/optiboot_txy7_rst.hex diff --git a/megaavr/bootloaders/optiboot_x/optiboot_x.c b/bootloaders/optiboot_x/optiboot_x.c similarity index 100% rename from megaavr/bootloaders/optiboot_x/optiboot_x.c rename to bootloaders/optiboot_x/optiboot_x.c diff --git a/megaavr/bootloaders/optiboot_x/optiboot_xplained416.hex b/bootloaders/optiboot_x/optiboot_xplained416.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_xplained416.hex rename to bootloaders/optiboot_x/optiboot_xplained416.hex index 4d2583e5..e55e0142 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_xplained416.hex +++ b/bootloaders/optiboot_x/optiboot_xplained416.hex @@ -1,32 +1,32 @@ -:1000000001C0D1C01124809140008093400083FF43 -:1000100004C0282E80E0AFD0F3C0A895019A099AB9 -:1000200081E080930102809182128370813019F403 -:1000300089EB90E002C087EE90E0809308089093EF -:10004000090881E080930B0883E0809307081092F1 -:10005000050880EC809306088BE08DD0259A88E017 -:10006000815061F0359A2EEC36E5A8959091040800 -:1000700097FD05C021503109C1F7F2CFA8950DE9D0 -:1000800083E0D82E6CD0813461F469D0182F7CD0F5 -:100090001238D9F0113811F489E001C083E058D04A -:1000A00054C0823411F484E103C0853419F485E02E -:1000B00073D04BC0853529F452D0C82F50D0D82FDB -:1000C00043C0863521F484E067D080E0E8CF8436F1 -:1000D000B9F445D044D0182F42D0863411F4D0580A -:1000E00001C0DC5E3CD0888321961150D9F74CD0FA -:1000F00004BFD0920010809102108370E1F725C0F8 -:10010000843791F42CD02BD0182F29D0F82E3CD046 -:1001100086E4F81202C0D05801C0DC5E88812196C6 -:1001200017D01150D9F711C0853751F42DD08091D7 -:1001300000110ED0809101110BD080910211AFCF30 -:10014000813511F481E017D01FD080E101D09ACF22 -:100150009091040895FFFCCF809302080895809148 -:10016000040887FFFCCF909101088091000892FD60 -:1001700001C0A89508959091010190FDFCCF98EDE4 -:1001800094BF809300010895EADF803219F081E086 -:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 -:1001A000E9F7CF91F1CF88ED84BF60930001809192 -:0801B00002108370E1F70895CD -:0201FE000009F6 -:10020000E0E4F0E0808180838091FE019091FF0125 -:1002100040E050E064E080E090E0C5DF0C94000036 -:00000001FF +:1000000001C0D1C01124809140008093400083FF43 +:1000100004C0282E80E0AFD0F3C0A895019A099AB9 +:1000200081E080930102809182128370813019F403 +:1000300089EB90E002C087EE90E0809308089093EF +:10004000090881E080930B0883E0809307081092F1 +:10005000050880EC809306088BE08DD0259A88E017 +:10006000815061F0359A2EEC36E5A8959091040800 +:1000700097FD05C021503109C1F7F2CFA8950DE9D0 +:1000800083E0D82E6CD0813461F469D0182F7CD0F5 +:100090001238D9F0113811F489E001C083E058D04A +:1000A00054C0823411F484E103C0853419F485E02E +:1000B00073D04BC0853529F452D0C82F50D0D82FDB +:1000C00043C0863521F484E067D080E0E8CF8436F1 +:1000D000B9F445D044D0182F42D0863411F4D0580A +:1000E00001C0DC5E3CD0888321961150D9F74CD0FA +:1000F00004BFD0920010809102108370E1F725C0F8 +:10010000843791F42CD02BD0182F29D0F82E3CD046 +:1001100086E4F81202C0D05801C0DC5E88812196C6 +:1001200017D01150D9F711C0853751F42DD08091D7 +:1001300000110ED0809101110BD080910211AFCF30 +:10014000813511F481E017D01FD080E101D09ACF22 +:100150009091040895FFFCCF809302080895809148 +:10016000040887FFFCCF909101088091000892FD60 +:1001700001C0A89508959091010190FDFCCF98EDE4 +:1001800094BF809300010895EADF803219F081E086 +:10019000F2DFFFCF84E1DCCFCF93C82FE0DFC15087 +:1001A000E9F7CF91F1CF88ED84BF60930001809192 +:0801B00002108370E1F70895CD +:0201FE000009F6 +:10020000E0E4F0E0808180838091FE019091FF0125 +:1002100040E050E064E080E090E0C5DF0C94000036 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/optiboot_xplained817.hex b/bootloaders/optiboot_x/optiboot_xplained817.hex similarity index 97% rename from megaavr/bootloaders/optiboot_x/optiboot_xplained817.hex rename to bootloaders/optiboot_x/optiboot_xplained817.hex index 2dbd352d..c0084ed7 100644 --- a/megaavr/bootloaders/optiboot_x/optiboot_xplained817.hex +++ b/bootloaders/optiboot_x/optiboot_xplained817.hex @@ -1,32 +1,32 @@ -:1000000001C0CEC01124809140008093400083FF46 -:1000100004C0282E80E0ACD0F3C0A895229A2A9A7A -:10002000809182128370813019F489EB90E002C0D4 -:1000300087EE90E0809308089093090881E0809310 -:100040000B0883E0809307081092050880EC8093EA -:1000500006088BE08DD0409A87E0815061F0509A7D -:100060002EEC36E5A8959091040897FD05C0215027 -:100070003109C1F7F2CFA8950DE983E0D82E6CD0F5 -:10008000813461F469D0182F7CD01238D9F011383E -:1000900011F489E001C083E058D054C0823411F4D7 -:1000A00084E103C0853419F485E073D04BC08535F5 -:1000B00029F452D0C82F50D0D82F43C0863521F410 -:1000C00084E067D080E0E8CF8436B9F445D044D0EE -:1000D000182F42D0863411F4D05801C0DC5E3CD0D9 -:1000E000888321961150D9F74CD004BFD0920010CC -:1000F000809102108370E1F725C0843791F42CD0F1 -:100100002BD0182F29D0F82E3CD086E4F81202C04C -:10011000D05801C0DC5E8881219617D01150D9F7E4 -:1001200011C0853751F42DD0809100110ED08091EF -:1001300001110BD080910211AFCF813511F481E014 -:1001400017D01FD080E101D09ACF9091040895FF7D -:10015000FCCF8093020808958091040887FFFCCFAC -:10016000909101088091000892FD01C0A895089522 -:100170009091010190FDFCCF98ED94BF8093000118 -:100180000895EADF803219F081E0F2DFFFCF84E1E9 -:10019000DCCFCF93C82FE0DFC150E9F7CF91F1CF8B -:1001A00088ED84BF60930001809102108370E1F7B5 -:0201B0000895B0 -:0201FE000009F6 -:10020000E0E4F0E0808180838091FE019091FF0125 -:1002100040E050E064E080E090E0C2DF0C94000039 -:00000001FF +:1000000001C0CEC01124809140008093400083FF46 +:1000100004C0282E80E0ACD0F3C0A895229A2A9A7A +:10002000809182128370813019F489EB90E002C0D4 +:1000300087EE90E0809308089093090881E0809310 +:100040000B0883E0809307081092050880EC8093EA +:1000500006088BE08DD0409A87E0815061F0509A7D +:100060002EEC36E5A8959091040897FD05C0215027 +:100070003109C1F7F2CFA8950DE983E0D82E6CD0F5 +:10008000813461F469D0182F7CD01238D9F011383E +:1000900011F489E001C083E058D054C0823411F4D7 +:1000A00084E103C0853419F485E073D04BC08535F5 +:1000B00029F452D0C82F50D0D82F43C0863521F410 +:1000C00084E067D080E0E8CF8436B9F445D044D0EE +:1000D000182F42D0863411F4D05801C0DC5E3CD0D9 +:1000E000888321961150D9F74CD004BFD0920010CC +:1000F000809102108370E1F725C0843791F42CD0F1 +:100100002BD0182F29D0F82E3CD086E4F81202C04C +:10011000D05801C0DC5E8881219617D01150D9F7E4 +:1001200011C0853751F42DD0809100110ED08091EF +:1001300001110BD080910211AFCF813511F481E014 +:1001400017D01FD080E101D09ACF9091040895FF7D +:10015000FCCF8093020808958091040887FFFCCFAC +:10016000909101088091000892FD01C0A895089522 +:100170009091010190FDFCCF98ED94BF8093000118 +:100180000895EADF803219F081E0F2DFFFCF84E1E9 +:10019000DCCFCF93C82FE0DFC150E9F7CF91F1CF8B +:1001A00088ED84BF60930001809102108370E1F7B5 +:0201B0000895B0 +:0201FE000009F6 +:10020000E0E4F0E0808180838091FE019091FF0125 +:1002100040E050E064E080E090E0C2DF0C94000039 +:00000001FF diff --git a/megaavr/bootloaders/optiboot_x/parse_options.mk b/bootloaders/optiboot_x/parse_options.mk similarity index 100% rename from megaavr/bootloaders/optiboot_x/parse_options.mk rename to bootloaders/optiboot_x/parse_options.mk diff --git a/megaavr/bootloaders/optiboot_x/pin_defs.h b/bootloaders/optiboot_x/pin_defs.h similarity index 100% rename from megaavr/bootloaders/optiboot_x/pin_defs.h rename to bootloaders/optiboot_x/pin_defs.h diff --git a/megaavr/bootloaders/optiboot_x/pin_defs_x.h b/bootloaders/optiboot_x/pin_defs_x.h similarity index 100% rename from megaavr/bootloaders/optiboot_x/pin_defs_x.h rename to bootloaders/optiboot_x/pin_defs_x.h diff --git a/megaavr/bootloaders/optiboot_x/stk500.h b/bootloaders/optiboot_x/stk500.h similarity index 100% rename from megaavr/bootloaders/optiboot_x/stk500.h rename to bootloaders/optiboot_x/stk500.h diff --git a/megaavr/cores/arduino/Arduino.h b/cores/arduino/Arduino.h similarity index 100% rename from megaavr/cores/arduino/Arduino.h rename to cores/arduino/Arduino.h diff --git a/megaavr/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp similarity index 100% rename from megaavr/cores/arduino/Tone.cpp rename to cores/arduino/Tone.cpp diff --git a/megaavr/cores/arduino/UART.cpp b/cores/arduino/UART.cpp similarity index 100% rename from megaavr/cores/arduino/UART.cpp rename to cores/arduino/UART.cpp diff --git a/megaavr/cores/arduino/UART.h b/cores/arduino/UART.h similarity index 100% rename from megaavr/cores/arduino/UART.h rename to cores/arduino/UART.h diff --git a/megaavr/cores/arduino/UART0.cpp b/cores/arduino/UART0.cpp similarity index 100% rename from megaavr/cores/arduino/UART0.cpp rename to cores/arduino/UART0.cpp diff --git a/megaavr/cores/arduino/UART1.cpp b/cores/arduino/UART1.cpp similarity index 100% rename from megaavr/cores/arduino/UART1.cpp rename to cores/arduino/UART1.cpp diff --git a/megaavr/cores/arduino/UART2.cpp b/cores/arduino/UART2.cpp similarity index 100% rename from megaavr/cores/arduino/UART2.cpp rename to cores/arduino/UART2.cpp diff --git a/megaavr/cores/arduino/UART3.cpp b/cores/arduino/UART3.cpp similarity index 100% rename from megaavr/cores/arduino/UART3.cpp rename to cores/arduino/UART3.cpp diff --git a/megaavr/cores/arduino/UART_private.h b/cores/arduino/UART_private.h similarity index 100% rename from megaavr/cores/arduino/UART_private.h rename to cores/arduino/UART_private.h diff --git a/megaavr/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c similarity index 100% rename from megaavr/cores/arduino/WInterrupts.c rename to cores/arduino/WInterrupts.c diff --git a/megaavr/cores/arduino/WMath.cpp b/cores/arduino/WMath.cpp similarity index 100% rename from megaavr/cores/arduino/WMath.cpp rename to cores/arduino/WMath.cpp diff --git a/megaavr/cores/arduino/abi.cpp b/cores/arduino/abi.cpp similarity index 100% rename from megaavr/cores/arduino/abi.cpp rename to cores/arduino/abi.cpp diff --git a/megaavr/cores/arduino/api/ArduinoAPI.h b/cores/arduino/api/ArduinoAPI.h similarity index 100% rename from megaavr/cores/arduino/api/ArduinoAPI.h rename to cores/arduino/api/ArduinoAPI.h diff --git a/megaavr/cores/arduino/api/Binary.h b/cores/arduino/api/Binary.h similarity index 100% rename from megaavr/cores/arduino/api/Binary.h rename to cores/arduino/api/Binary.h diff --git a/megaavr/cores/arduino/api/Client.h b/cores/arduino/api/Client.h similarity index 100% rename from megaavr/cores/arduino/api/Client.h rename to cores/arduino/api/Client.h diff --git a/megaavr/cores/arduino/api/Common.cpp b/cores/arduino/api/Common.cpp similarity index 100% rename from megaavr/cores/arduino/api/Common.cpp rename to cores/arduino/api/Common.cpp diff --git a/megaavr/cores/arduino/api/Common.h b/cores/arduino/api/Common.h similarity index 100% rename from megaavr/cores/arduino/api/Common.h rename to cores/arduino/api/Common.h diff --git a/megaavr/cores/arduino/api/HardwareI2C.h b/cores/arduino/api/HardwareI2C.h similarity index 100% rename from megaavr/cores/arduino/api/HardwareI2C.h rename to cores/arduino/api/HardwareI2C.h diff --git a/megaavr/cores/arduino/api/HardwareSerial.h b/cores/arduino/api/HardwareSerial.h similarity index 100% rename from megaavr/cores/arduino/api/HardwareSerial.h rename to cores/arduino/api/HardwareSerial.h diff --git a/megaavr/cores/arduino/api/IPAddress.cpp b/cores/arduino/api/IPAddress.cpp similarity index 100% rename from megaavr/cores/arduino/api/IPAddress.cpp rename to cores/arduino/api/IPAddress.cpp diff --git a/megaavr/cores/arduino/api/IPAddress.h b/cores/arduino/api/IPAddress.h similarity index 100% rename from megaavr/cores/arduino/api/IPAddress.h rename to cores/arduino/api/IPAddress.h diff --git a/megaavr/cores/arduino/api/PluggableUSB.cpp b/cores/arduino/api/PluggableUSB.cpp similarity index 100% rename from megaavr/cores/arduino/api/PluggableUSB.cpp rename to cores/arduino/api/PluggableUSB.cpp diff --git a/megaavr/cores/arduino/api/PluggableUSB.h b/cores/arduino/api/PluggableUSB.h similarity index 100% rename from megaavr/cores/arduino/api/PluggableUSB.h rename to cores/arduino/api/PluggableUSB.h diff --git a/megaavr/cores/arduino/api/Print.cpp b/cores/arduino/api/Print.cpp similarity index 100% rename from megaavr/cores/arduino/api/Print.cpp rename to cores/arduino/api/Print.cpp diff --git a/megaavr/cores/arduino/api/Print.h b/cores/arduino/api/Print.h similarity index 100% rename from megaavr/cores/arduino/api/Print.h rename to cores/arduino/api/Print.h diff --git a/megaavr/cores/arduino/api/Printable.h b/cores/arduino/api/Printable.h similarity index 100% rename from megaavr/cores/arduino/api/Printable.h rename to cores/arduino/api/Printable.h diff --git a/megaavr/cores/arduino/api/RingBuffer.cpp b/cores/arduino/api/RingBuffer.cpp similarity index 100% rename from megaavr/cores/arduino/api/RingBuffer.cpp rename to cores/arduino/api/RingBuffer.cpp diff --git a/megaavr/cores/arduino/api/RingBuffer.h b/cores/arduino/api/RingBuffer.h similarity index 100% rename from megaavr/cores/arduino/api/RingBuffer.h rename to cores/arduino/api/RingBuffer.h diff --git a/megaavr/cores/arduino/api/Server.h b/cores/arduino/api/Server.h similarity index 100% rename from megaavr/cores/arduino/api/Server.h rename to cores/arduino/api/Server.h diff --git a/megaavr/cores/arduino/api/Stream.cpp b/cores/arduino/api/Stream.cpp similarity index 100% rename from megaavr/cores/arduino/api/Stream.cpp rename to cores/arduino/api/Stream.cpp diff --git a/megaavr/cores/arduino/api/Stream.h b/cores/arduino/api/Stream.h similarity index 100% rename from megaavr/cores/arduino/api/Stream.h rename to cores/arduino/api/Stream.h diff --git a/megaavr/cores/arduino/api/String.cpp b/cores/arduino/api/String.cpp similarity index 100% rename from megaavr/cores/arduino/api/String.cpp rename to cores/arduino/api/String.cpp diff --git a/megaavr/cores/arduino/api/String.h b/cores/arduino/api/String.h similarity index 100% rename from megaavr/cores/arduino/api/String.h rename to cores/arduino/api/String.h diff --git a/megaavr/cores/arduino/api/USBAPI.h b/cores/arduino/api/USBAPI.h similarity index 100% rename from megaavr/cores/arduino/api/USBAPI.h rename to cores/arduino/api/USBAPI.h diff --git a/megaavr/cores/arduino/api/Udp.h b/cores/arduino/api/Udp.h similarity index 100% rename from megaavr/cores/arduino/api/Udp.h rename to cores/arduino/api/Udp.h diff --git a/megaavr/cores/arduino/api/Udp.h.orig b/cores/arduino/api/Udp.h.orig similarity index 100% rename from megaavr/cores/arduino/api/Udp.h.orig rename to cores/arduino/api/Udp.h.orig diff --git a/megaavr/cores/arduino/api/WCharacter.h b/cores/arduino/api/WCharacter.h similarity index 100% rename from megaavr/cores/arduino/api/WCharacter.h rename to cores/arduino/api/WCharacter.h diff --git a/megaavr/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.c.impl b/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.c.impl similarity index 100% rename from megaavr/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.c.impl rename to cores/arduino/api/deprecated-avr-comp/avr/dtostrf.c.impl diff --git a/megaavr/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.h b/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated-avr-comp/avr/dtostrf.h rename to cores/arduino/api/deprecated-avr-comp/avr/dtostrf.h diff --git a/megaavr/cores/arduino/api/deprecated-avr-comp/avr/interrupt.h b/cores/arduino/api/deprecated-avr-comp/avr/interrupt.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated-avr-comp/avr/interrupt.h rename to cores/arduino/api/deprecated-avr-comp/avr/interrupt.h diff --git a/megaavr/cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h b/cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h rename to cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h diff --git a/megaavr/cores/arduino/api/deprecated/Client.h b/cores/arduino/api/deprecated/Client.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Client.h rename to cores/arduino/api/deprecated/Client.h diff --git a/megaavr/cores/arduino/api/deprecated/IPAddress.h b/cores/arduino/api/deprecated/IPAddress.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/IPAddress.h rename to cores/arduino/api/deprecated/IPAddress.h diff --git a/megaavr/cores/arduino/api/deprecated/Print.h b/cores/arduino/api/deprecated/Print.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Print.h rename to cores/arduino/api/deprecated/Print.h diff --git a/megaavr/cores/arduino/api/deprecated/Printable.h b/cores/arduino/api/deprecated/Printable.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Printable.h rename to cores/arduino/api/deprecated/Printable.h diff --git a/megaavr/cores/arduino/api/deprecated/Server.h b/cores/arduino/api/deprecated/Server.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Server.h rename to cores/arduino/api/deprecated/Server.h diff --git a/megaavr/cores/arduino/api/deprecated/Stream.h b/cores/arduino/api/deprecated/Stream.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Stream.h rename to cores/arduino/api/deprecated/Stream.h diff --git a/megaavr/cores/arduino/api/deprecated/Udp.h b/cores/arduino/api/deprecated/Udp.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/Udp.h rename to cores/arduino/api/deprecated/Udp.h diff --git a/megaavr/cores/arduino/api/deprecated/WString.h b/cores/arduino/api/deprecated/WString.h similarity index 100% rename from megaavr/cores/arduino/api/deprecated/WString.h rename to cores/arduino/api/deprecated/WString.h diff --git a/megaavr/cores/arduino/api/itoa.h b/cores/arduino/api/itoa.h similarity index 100% rename from megaavr/cores/arduino/api/itoa.h rename to cores/arduino/api/itoa.h diff --git a/megaavr/cores/arduino/hooks.c b/cores/arduino/hooks.c similarity index 100% rename from megaavr/cores/arduino/hooks.c rename to cores/arduino/hooks.c diff --git a/megaavr/cores/arduino/main.cpp b/cores/arduino/main.cpp similarity index 100% rename from megaavr/cores/arduino/main.cpp rename to cores/arduino/main.cpp diff --git a/megaavr/cores/arduino/new.cpp b/cores/arduino/new.cpp similarity index 100% rename from megaavr/cores/arduino/new.cpp rename to cores/arduino/new.cpp diff --git a/megaavr/cores/arduino/new.h b/cores/arduino/new.h similarity index 100% rename from megaavr/cores/arduino/new.h rename to cores/arduino/new.h diff --git a/megaavr/cores/arduino/timers.h b/cores/arduino/timers.h similarity index 100% rename from megaavr/cores/arduino/timers.h rename to cores/arduino/timers.h diff --git a/megaavr/cores/arduino/wiring.c b/cores/arduino/wiring.c similarity index 100% rename from megaavr/cores/arduino/wiring.c rename to cores/arduino/wiring.c diff --git a/megaavr/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c similarity index 100% rename from megaavr/cores/arduino/wiring_analog.c rename to cores/arduino/wiring_analog.c diff --git a/megaavr/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c similarity index 100% rename from megaavr/cores/arduino/wiring_digital.c rename to cores/arduino/wiring_digital.c diff --git a/megaavr/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h similarity index 100% rename from megaavr/cores/arduino/wiring_private.h rename to cores/arduino/wiring_private.h diff --git a/megaavr/cores/arduino/wiring_pulse.S b/cores/arduino/wiring_pulse.S similarity index 100% rename from megaavr/cores/arduino/wiring_pulse.S rename to cores/arduino/wiring_pulse.S diff --git a/megaavr/cores/arduino/wiring_pulse.c b/cores/arduino/wiring_pulse.c similarity index 100% rename from megaavr/cores/arduino/wiring_pulse.c rename to cores/arduino/wiring_pulse.c diff --git a/megaavr/cores/arduino/wiring_shift.c b/cores/arduino/wiring_shift.c similarity index 100% rename from megaavr/cores/arduino/wiring_shift.c rename to cores/arduino/wiring_shift.c diff --git a/megaavr/create_disassembler_listing.sh b/create_disassembler_listing.sh similarity index 100% rename from megaavr/create_disassembler_listing.sh rename to create_disassembler_listing.sh diff --git a/megaavr/delete_merged_output.bat b/delete_merged_output.bat similarity index 100% rename from megaavr/delete_merged_output.bat rename to delete_merged_output.bat diff --git a/megaavr/delete_merged_output.sh b/delete_merged_output.sh similarity index 100% rename from megaavr/delete_merged_output.sh rename to delete_merged_output.sh diff --git a/megaavr/extras/ATtiny_x02.gif b/extras/ATtiny_x02.gif similarity index 100% rename from megaavr/extras/ATtiny_x02.gif rename to extras/ATtiny_x02.gif diff --git a/megaavr/extras/ATtiny_x02.md b/extras/ATtiny_x02.md similarity index 100% rename from megaavr/extras/ATtiny_x02.md rename to extras/ATtiny_x02.md diff --git a/megaavr/extras/ATtiny_x04.gif b/extras/ATtiny_x04.gif similarity index 100% rename from megaavr/extras/ATtiny_x04.gif rename to extras/ATtiny_x04.gif diff --git a/megaavr/extras/ATtiny_x04.md b/extras/ATtiny_x04.md similarity index 100% rename from megaavr/extras/ATtiny_x04.md rename to extras/ATtiny_x04.md diff --git a/megaavr/extras/ATtiny_x06.gif b/extras/ATtiny_x06.gif similarity index 100% rename from megaavr/extras/ATtiny_x06.gif rename to extras/ATtiny_x06.gif diff --git a/megaavr/extras/ATtiny_x06.md b/extras/ATtiny_x06.md similarity index 100% rename from megaavr/extras/ATtiny_x06.md rename to extras/ATtiny_x06.md diff --git a/megaavr/extras/ATtiny_x07.gif b/extras/ATtiny_x07.gif similarity index 100% rename from megaavr/extras/ATtiny_x07.gif rename to extras/ATtiny_x07.gif diff --git a/megaavr/extras/ATtiny_x07.md b/extras/ATtiny_x07.md similarity index 100% rename from megaavr/extras/ATtiny_x07.md rename to extras/ATtiny_x07.md diff --git a/megaavr/extras/ATtiny_x12.gif b/extras/ATtiny_x12.gif similarity index 100% rename from megaavr/extras/ATtiny_x12.gif rename to extras/ATtiny_x12.gif diff --git a/megaavr/extras/ATtiny_x12.md b/extras/ATtiny_x12.md similarity index 100% rename from megaavr/extras/ATtiny_x12.md rename to extras/ATtiny_x12.md diff --git a/megaavr/extras/ATtiny_x14.gif b/extras/ATtiny_x14.gif similarity index 100% rename from megaavr/extras/ATtiny_x14.gif rename to extras/ATtiny_x14.gif diff --git a/megaavr/extras/ATtiny_x14.md b/extras/ATtiny_x14.md similarity index 100% rename from megaavr/extras/ATtiny_x14.md rename to extras/ATtiny_x14.md diff --git a/megaavr/extras/ATtiny_x16.gif b/extras/ATtiny_x16.gif similarity index 100% rename from megaavr/extras/ATtiny_x16.gif rename to extras/ATtiny_x16.gif diff --git a/megaavr/extras/ATtiny_x16.md b/extras/ATtiny_x16.md similarity index 100% rename from megaavr/extras/ATtiny_x16.md rename to extras/ATtiny_x16.md diff --git a/megaavr/extras/ATtiny_x17.gif b/extras/ATtiny_x17.gif similarity index 100% rename from megaavr/extras/ATtiny_x17.gif rename to extras/ATtiny_x17.gif diff --git a/megaavr/extras/ATtiny_x17.md b/extras/ATtiny_x17.md similarity index 100% rename from megaavr/extras/ATtiny_x17.md rename to extras/ATtiny_x17.md diff --git a/megaavr/extras/DevConfigUPDI.png b/extras/DevConfigUPDI.png similarity index 100% rename from megaavr/extras/DevConfigUPDI.png rename to extras/DevConfigUPDI.png diff --git a/megaavr/extras/DirectPortManipulation.md b/extras/DirectPortManipulation.md similarity index 100% rename from megaavr/extras/DirectPortManipulation.md rename to extras/DirectPortManipulation.md diff --git a/megaavr/extras/MinimalConnectionsUPDI.png b/extras/MinimalConnectionsUPDI.png similarity index 100% rename from megaavr/extras/MinimalConnectionsUPDI.png rename to extras/MinimalConnectionsUPDI.png diff --git a/megaavr/extras/NanoAsUPDI.png b/extras/NanoAsUPDI.png similarity index 100% rename from megaavr/extras/NanoAsUPDI.png rename to extras/NanoAsUPDI.png diff --git a/megaavr/extras/PinInterrupts.md b/extras/PinInterrupts.md similarity index 100% rename from megaavr/extras/PinInterrupts.md rename to extras/PinInterrupts.md diff --git a/megaavr/extras/PowerSave.md b/extras/PowerSave.md similarity index 100% rename from megaavr/extras/PowerSave.md rename to extras/PowerSave.md diff --git a/megaavr/extras/ProMiniAsUPDI.png b/extras/ProMiniAsUPDI.png similarity index 100% rename from megaavr/extras/ProMiniAsUPDI.png rename to extras/ProMiniAsUPDI.png diff --git a/megaavr/extras/tinyNeoPixel.md b/extras/tinyNeoPixel.md similarity index 100% rename from megaavr/extras/tinyNeoPixel.md rename to extras/tinyNeoPixel.md diff --git a/megaavr/libraries/EEPROM/README.md b/megaavr/libraries/EEPROM/README.md deleted file mode 100644 index a6241361..00000000 --- a/megaavr/libraries/EEPROM/README.md +++ /dev/null @@ -1,139 +0,0 @@ -## **EEPROM Library V2.0** for Arduino - -**Written by:** _Christopher Andrews_. - -### **What is the EEPROM library.** - -Th EEPROM library provides an easy to use interface to interact with the internal non-volatile storage found in AVR based Arduino boards. This library will work on many AVR devices like ATtiny and ATmega chips. - -### **How to use it** -The EEPROM library is included in your IDE download. To add its functionality to your sketch you'll need to reference the library header file. You do this by adding an include directive to the top of your sketch. - -```Arduino -#include - -void setup(){ - -} - -void loop(){ - -} - -``` - -The library provides a global variable named `EEPROM`, you use this variable to access the library functions. The methods provided in the EEPROM class are listed below. - -You can view all the examples [here](examples/). - -### **Library functions** - -#### **`EEPROM.read( address )`** [[_example_]](examples/eeprom_read/eeprom_read.ino) - -This function allows you to read a single byte of data from the eeprom. -Its only parameter is an `int` which should be set to the address you wish to read. - -The function returns an `unsigned char` containing the value read. - -#### **`EEPROM.write( address, value )`** [[_example_]](examples/eeprom_write/eeprom_write.ino) - -The `write()` method allows you to write a single byte of data to the EEPROM. -Two parameters are needed. The first is an `int` containing the address that is to be written, and the second is a the data to be written (`unsigned char`). - -This function does not return any value. - -#### **`EEPROM.update( address, value )`** [[_example_]](examples/eeprom_update/eeprom_update.ino) - -This function is similar to `EEPROM.write()` however this method will only write data if the cell contents pointed to by `address` is different to `value`. This method can help prevent unnecessary wear on the EEPROM cells. - -This function does not return any value. - -#### **`EEPROM.get( address, object )`** [[_example_]](examples/eeprom_get/eeprom_get.ino) - -This function will retrieve any object from the EEPROM. -Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to read. - -This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience. - -#### **`EEPROM.put( address, object )`** [[_example_]](examples/eeprom_put/eeprom_put.ino) - -This function will write any object to the EEPROM. -Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to write. - -This function uses the _update_ method to write its data, and therefore only rewrites changed cells. - -This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience. - -#### **Subscript operator: `EEPROM[address]`** [[_example_]](examples/eeprom_crc/eeprom_crc.ino) - -This operator allows using the identifier `EEPROM` like an array. -EEPROM cells can be read _and_ **_written_** directly using this method. - -This operator returns a reference to the EEPROM cell. - -```c++ -unsigned char val; - -//Read first EEPROM cell. -val = EEPROM[ 0 ]; - -//Write first EEPROM cell. -EEPROM[ 0 ] = val; - -//Compare contents -if( val == EEPROM[ 0 ] ){ - //Do something... -} -``` - -#### **`EEPROM.length()`** - -This function returns an `unsigned int` containing the number of cells in the EEPROM. - ---- - -### **Advanced features** - -This library uses a component based approach to provide its functionality. This means you can also use these components to design a customized approach. Two background classes are available for use: `EERef` & `EEPtr`. - -#### **`EERef` class** - -This object references an EEPROM cell. -Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM. -This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell. - -```C++ -EERef ref = EEPROM[ 10 ]; //Create a reference to 11th cell. - -ref = 4; //write to EEPROM cell. - -unsigned char val = ref; //Read referenced cell. -``` - -#### **`EEPtr` class** - -This object is a bidirectional pointer to EEPROM cells represented by `EERef` objects. -Just like a normal pointer type, this type can be dereferenced and repositioned using -increment/decrement operators. - -```C++ -EEPtr ptr = 10; //Create a pointer to 11th cell. - -*ptr = 4; //dereference and write to EEPROM cell. - -unsigned char val = *ptr; //dereference and read. - -ptr++; //Move to next EEPROM cell. -``` - -#### **`EEPROM.begin()`** - -This function returns an `EEPtr` pointing to the first cell in the EEPROM. -This is useful for STL objects, custom iteration and C++11 style ranged for loops. - -#### **`EEPROM.end()`** - -This function returns an `EEPtr` pointing at the location after the last EEPROM cell. -Used with `begin()` to provide custom iteration. - -**Note:** The `EEPtr` returned is invalid as it is out of range. Infact the hardware causes wrapping of the address (overflow) and `EEPROM.end()` actually references the first EEPROM cell. diff --git a/megaavr/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino b/megaavr/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino deleted file mode 100644 index 8b5121c8..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino +++ /dev/null @@ -1,39 +0,0 @@ -/* - * EEPROM Clear - * - * Sets all of the bytes of the EEPROM to 0. - * Please see eeprom_iteration for a more in depth - * look at how to traverse the EEPROM. - * - * This example code is in the public domain. - */ - -#include - -void setup() { - // initialize the LED pin as an output. - pinMode(13, OUTPUT); - - /*** - Iterate through each byte of the EEPROM storage. - - Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. - - Rather than hard-coding the length, you should use the pre-provided length function. - This will make your code portable to all AVR processors. - ***/ - - for (int i = 0 ; i < EEPROM.length() ; i++) { - EEPROM.write(i, 0); - } - - // turn the LED on when we're done - digitalWrite(13, HIGH); -} - -void loop() { - /** Empty loop. **/ -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_crc/eeprom_crc.ino b/megaavr/libraries/EEPROM/examples/eeprom_crc/eeprom_crc.ino deleted file mode 100644 index c6db85c3..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_crc/eeprom_crc.ino +++ /dev/null @@ -1,52 +0,0 @@ -/*** - Written by Christopher Andrews. - CRC algorithm generated by pycrc, MIT licence ( https://github.com/tpircher/pycrc ). - - A CRC is a simple way of checking whether data has changed or become corrupted. - This example calculates a CRC value directly on the EEPROM values. - The purpose of this example is to highlight how the EEPROM object can be used just like an array. -***/ - -#include -#include - -void setup() { - - //Start serial - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - //Print length of data to run CRC on. - Serial.print("EEPROM length: "); - Serial.println(EEPROM.length()); - - //Print the result of calling eeprom_crc() - Serial.print("CRC32 of EEPROM data: 0x"); - Serial.println(eeprom_crc(), HEX); - Serial.print("\n\nDone!"); -} - -void loop() { - /* Empty loop */ -} - -unsigned long eeprom_crc(void) { - - const unsigned long crc_table[16] = { - 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, - 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, - 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, - 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c - }; - - unsigned long crc = ~0L; - - for (int index = 0 ; index < EEPROM.length() ; ++index) { - crc = crc_table[(crc ^ EEPROM[index]) & 0x0f] ^ (crc >> 4); - crc = crc_table[(crc ^ (EEPROM[index] >> 4)) & 0x0f] ^ (crc >> 4); - crc = ~crc; - } - return crc; -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_get/eeprom_get.ino b/megaavr/libraries/EEPROM/examples/eeprom_get/eeprom_get.ino deleted file mode 100644 index a07cee7c..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_get/eeprom_get.ino +++ /dev/null @@ -1,68 +0,0 @@ -/*** - eeprom_get example. - - This shows how to use the EEPROM.get() method. - - To pre-set the EEPROM data, run the example sketch eeprom_put. - This sketch will run without it, however, the values shown - will be shown from what ever is already on the EEPROM. - - This may cause the serial object to print out a large string - of garbage if there is no null character inside one of the strings - loaded. - - Written by Christopher Andrews 2015 - Released under MIT licence. -***/ - -#include - -void setup() { - - float f = 0.00f; //Variable to store data read from EEPROM. - int eeAddress = 0; //EEPROM address to start reading from - - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - Serial.print("Read float from EEPROM: "); - - //Get the float data from the EEPROM at position 'eeAddress' - EEPROM.get(eeAddress, f); - Serial.println(f, 3); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float. - - /*** - As get also returns a reference to 'f', you can use it inline. - E.g: Serial.print( EEPROM.get( eeAddress, f ) ); - ***/ - - /*** - Get can be used with custom structures too. - I have separated this into an extra function. - ***/ - - secondTest(); //Run the next test. -} - -struct MyObject { - float field1; - byte field2; - char name[10]; -}; - -void secondTest() { - int eeAddress = sizeof(float); //Move address to the next byte after float 'f'. - - MyObject customVar; //Variable to store custom object read from EEPROM. - EEPROM.get(eeAddress, customVar); - - Serial.println("Read custom object from EEPROM: "); - Serial.println(customVar.field1); - Serial.println(customVar.field2); - Serial.println(customVar.name); -} - -void loop() { - /* Empty loop */ -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino b/megaavr/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino deleted file mode 100644 index 3673b472..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino +++ /dev/null @@ -1,57 +0,0 @@ -/*** - eeprom_iteration example. - - A set of example snippets highlighting the - simplest methods for traversing the EEPROM. - - Running this sketch is not necessary, this is - simply highlighting certain programming methods. - - Written by Christopher Andrews 2015 - Released under MIT licence. -***/ - -#include - -void setup() { - - /*** - Iterate the EEPROM using a for loop. - ***/ - - for (int index = 0 ; index < EEPROM.length() ; index++) { - - //Add one to each cell in the EEPROM - EEPROM[ index ] += 1; - } - - /*** - Iterate the EEPROM using a while loop. - ***/ - - int index = 0; - - while (index < EEPROM.length()) { - - //Add one to each cell in the EEPROM - EEPROM[ index ] += 1; - index++; - } - - /*** - Iterate the EEPROM using a do-while loop. - ***/ - - int idx = 0; //Used 'idx' to avoid name conflict with 'index' above. - - do { - - //Add one to each cell in the EEPROM - EEPROM[ idx ] += 1; - idx++; - } while (idx < EEPROM.length()); - - -} //End of setup function. - -void loop() {} \ No newline at end of file diff --git a/megaavr/libraries/EEPROM/examples/eeprom_put/eeprom_put.ino b/megaavr/libraries/EEPROM/examples/eeprom_put/eeprom_put.ino deleted file mode 100644 index c1ba0a57..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_put/eeprom_put.ino +++ /dev/null @@ -1,58 +0,0 @@ -/*** - eeprom_put example. - - This shows how to use the EEPROM.put() method. - Also, this sketch will pre-set the EEPROM data for the - example sketch eeprom_get. - - Note, unlike the single byte version EEPROM.write(), - the put method will use update semantics. As in a byte - will only be written to the EEPROM if the data is actually - different. - - Written by Christopher Andrews 2015 - Released under MIT licence. -***/ - -#include - -struct MyObject { - float field1; - byte field2; - char name[10]; -}; - -void setup() { - - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - float f = 123.456f; //Variable to store in EEPROM. - int eeAddress = 0; //Location we want the data to be put. - - - //One simple call, with the address first and the object second. - EEPROM.put(eeAddress, f); - - Serial.println("Written float data type!"); - - /** Put is designed for use with custom structures also. **/ - - //Data to store. - MyObject customVar = { - 3.14f, - 65, - "Working!" - }; - - eeAddress += sizeof(float); //Move address to the next byte after float 'f'. - - EEPROM.put(eeAddress, customVar); - Serial.print("Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!"); -} - -void loop() { - /* Empty loop */ -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino b/megaavr/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino deleted file mode 100644 index a8a3510d..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino +++ /dev/null @@ -1,56 +0,0 @@ -/* - * EEPROM Read - * - * Reads the value of each byte of the EEPROM and prints it - * to the computer. - * This example code is in the public domain. - */ - -#include - -// start reading from the first byte (address 0) of the EEPROM -int address = 0; -byte value; - -void setup() { - // initialize serial and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } -} - -void loop() { - // read a byte from the current address of the EEPROM - value = EEPROM.read(address); - - Serial.print(address); - Serial.print("\t"); - Serial.print(value, DEC); - Serial.println(); - - /*** - Advance to the next address, when at the end restart at the beginning. - - Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. - - Rather than hard-coding the length, you should use the pre-provided length function. - This will make your code portable to all AVR processors. - ***/ - address = address + 1; - if (address == EEPROM.length()) { - address = 0; - } - - /*** - As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an - EEPROM address is also doable by a bitwise and of the length - 1. - - ++address &= EEPROM.length() - 1; - ***/ - - delay(500); -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino b/megaavr/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino deleted file mode 100644 index 5e3db5b4..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_update/eeprom_update.ino +++ /dev/null @@ -1,71 +0,0 @@ -/*** - EEPROM Update method - - Stores values read from analog input 0 into the EEPROM. - These values will stay in the EEPROM when the board is - turned off and may be retrieved later by another sketch. - - If a value has not changed in the EEPROM, it is not overwritten - which would reduce the life span of the EEPROM unnecessarily. - - Released using MIT licence. - ***/ - -#include - -/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/ -int address = 0; - -void setup() { - /** EMpty setup **/ -} - -void loop() { - /*** - need to divide by 4 because analog inputs range from - 0 to 1023 and each byte of the EEPROM can only hold a - value from 0 to 255. - ***/ - int val = analogRead(0) / 4; - - /*** - Update the particular EEPROM cell. - these values will remain there when the board is - turned off. - ***/ - EEPROM.update(address, val); - - /*** - The function EEPROM.update(address, val) is equivalent to the following: - - if( EEPROM.read(address) != val ){ - EEPROM.write(address, val); - } - ***/ - - - /*** - Advance to the next address, when at the end restart at the beginning. - - Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. - - Rather than hard-coding the length, you should use the pre-provided length function. - This will make your code portable to all AVR processors. - ***/ - address = address + 1; - if (address == EEPROM.length()) { - address = 0; - } - - /*** - As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an - EEPROM address is also doable by a bitwise and of the length - 1. - - ++address &= EEPROM.length() - 1; - ***/ - - delay(100); -} diff --git a/megaavr/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino b/megaavr/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino deleted file mode 100644 index f9bea641..00000000 --- a/megaavr/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino +++ /dev/null @@ -1,60 +0,0 @@ -/* - * EEPROM Write - * - * Stores values read from analog input 0 into the EEPROM. - * These values will stay in the EEPROM when the board is - * turned off and may be retrieved later by another sketch. - */ - -#include - -/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/ -int addr = 0; - -void setup() { - /** Empty setup. **/ -} - -void loop() { - /*** - Need to divide by 4 because analog inputs range from - 0 to 1023 and each byte of the EEPROM can only hold a - value from 0 to 255. - ***/ - - int val = analogRead(0) / 4; - - /*** - Write the value to the appropriate byte of the EEPROM. - these values will remain there when the board is - turned off. - ***/ - - EEPROM.write(addr, val); - - /*** - Advance to the next address, when at the end restart at the beginning. - - Larger AVR processors have larger EEPROM sizes, E.g: - - Arduno Duemilanove: 512b EEPROM storage. - - Arduino Uno: 1kb EEPROM storage. - - Arduino Mega: 4kb EEPROM storage. - - Rather than hard-coding the length, you should use the pre-provided length function. - This will make your code portable to all AVR processors. - ***/ - addr = addr + 1; - if (addr == EEPROM.length()) { - addr = 0; - } - - /*** - As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an - EEPROM address is also doable by a bitwise and of the length - 1. - - ++addr &= EEPROM.length() - 1; - ***/ - - - delay(100); -} diff --git a/megaavr/libraries/EEPROM/keywords.txt b/megaavr/libraries/EEPROM/keywords.txt deleted file mode 100644 index 2cabc0b0..00000000 --- a/megaavr/libraries/EEPROM/keywords.txt +++ /dev/null @@ -1,22 +0,0 @@ -####################################### -# Syntax Coloring Map For EEPROM -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -EEPROM KEYWORD1 -EERef KEYWORD1 -EEPtr KEYWORD2 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -update KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/megaavr/libraries/EEPROM/library.properties b/megaavr/libraries/EEPROM/library.properties deleted file mode 100644 index 2bd55521..00000000 --- a/megaavr/libraries/EEPROM/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=EEPROM -version=2.0 -author=Arduino, Christopher Andrews -maintainer=Arduino -sentence=Enables reading and writing to the permanent board storage. -paragraph=This library allows to read and write data in a memory type, the EEPROM, that keeps its content also when the board is powered off. The amount of EEPROM available depends on the microcontroller type. -category=Data Storage -url=http://www.arduino.cc/en/Reference/EEPROM -architectures=megaavr - diff --git a/megaavr/libraries/EEPROM/src/EEPROM.h b/megaavr/libraries/EEPROM/src/EEPROM.h deleted file mode 100644 index a6008357..00000000 --- a/megaavr/libraries/EEPROM/src/EEPROM.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - EEPROM.h - EEPROM library - Original Copyright (c) 2006 David A. Mellis. All right reserved. - New version by Christopher Andrews 2015. - - 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 EEPROM_h -#define EEPROM_h - -#include -#include -#include - -/*** - EERef class. - - This object references an EEPROM cell. - Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM. - This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell. -***/ - -struct EERef{ - - EERef( const int index ) - : index( index ) {} - - //Access/read members. - uint8_t operator*() const { return eeprom_read_byte( (uint8_t*) index ); } - operator uint8_t() const { return **this; } - - //Assignment/write members. - EERef &operator=( const EERef &ref ) { return *this = *ref; } - EERef &operator=( uint8_t in ) { return eeprom_write_byte( (uint8_t*) index, in ), *this; } - EERef &operator +=( uint8_t in ) { return *this = **this + in; } - EERef &operator -=( uint8_t in ) { return *this = **this - in; } - EERef &operator *=( uint8_t in ) { return *this = **this * in; } - EERef &operator /=( uint8_t in ) { return *this = **this / in; } - EERef &operator ^=( uint8_t in ) { return *this = **this ^ in; } - EERef &operator %=( uint8_t in ) { return *this = **this % in; } - EERef &operator &=( uint8_t in ) { return *this = **this & in; } - EERef &operator |=( uint8_t in ) { return *this = **this | in; } - EERef &operator <<=( uint8_t in ) { return *this = **this << in; } - EERef &operator >>=( uint8_t in ) { return *this = **this >> in; } - - EERef &update( uint8_t in ) { return in != *this ? *this = in : *this; } - - /** Prefix increment/decrement **/ - EERef& operator++() { return *this += 1; } - EERef& operator--() { return *this -= 1; } - - /** Postfix increment/decrement **/ - uint8_t operator++ (int){ - uint8_t ret = **this; - return ++(*this), ret; - } - - uint8_t operator-- (int){ - uint8_t ret = **this; - return --(*this), ret; - } - - int index; //Index of current EEPROM cell. -}; - -/*** - EEPtr class. - - This object is a bidirectional pointer to EEPROM cells represented by EERef objects. - Just like a normal pointer type, this can be dereferenced and repositioned using - increment/decrement operators. -***/ - -struct EEPtr{ - - EEPtr( const int index ) - : index( index ) {} - - operator int() const { return index; } - EEPtr &operator=( int in ) { return index = in, *this; } - - //Iterator functionality. - bool operator!=( const EEPtr &ptr ) { return index != ptr.index; } - EERef operator*() { return index; } - - /** Prefix & Postfix increment/decrement **/ - EEPtr& operator++() { return ++index, *this; } - EEPtr& operator--() { return --index, *this; } - EEPtr operator++ (int) { return index++; } - EEPtr operator-- (int) { return index--; } - - int index; //Index of current EEPROM cell. -}; - -/*** - EEPROMClass class. - - This object represents the entire EEPROM space. - It wraps the functionality of EEPtr and EERef into a basic interface. - This class is also 100% backwards compatible with earlier Arduino core releases. -***/ - -struct EEPROMClass{ - - //Basic user access methods. - EERef operator[]( const int idx ) { return idx; } - uint8_t read( int idx ) { return EERef( idx ); } - void write( int idx, uint8_t val ) { (EERef( idx )) = val; } - void update( int idx, uint8_t val ) { EERef( idx ).update( val ); } - - //STL and C++11 iteration capability. - EEPtr begin() { return 0x00; } - EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid. - uint16_t length() { return EEPROM_SIZE; } - - //Functionality to 'get' and 'put' objects to and from EEPROM. - template< typename T > T &get( int idx, T &t ){ - EEPtr e = idx; - uint8_t *ptr = (uint8_t*) &t; - for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e; - return t; - } - - template< typename T > const T &put( int idx, const T &t ){ - EEPtr e = idx; - const uint8_t *ptr = (const uint8_t*) &t; - for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ ); - return t; - } -}; - -static EEPROMClass EEPROM; -#endif diff --git a/megaavr/libraries/Logic/README.md b/megaavr/libraries/Logic/README.md deleted file mode 100644 index b812c67a..00000000 --- a/megaavr/libraries/Logic/README.md +++ /dev/null @@ -1,204 +0,0 @@ -# Logic -A library for interfacing with the CCL (Configurable Custom Logic) peripherals of the megaAVR-0 MCUs. -Developed by MCUdude for use with [MegaCoreX](https://github.com/MCUdude/MegaCoreX), adapted to megaAVR ATtiny parts by [Tadashi G. Takaoka](https://github.com/tgtakaoka). -The megaTiny parts have either 1 (0-series) or 3 (1-series) blocks of CCL available. -More useful information about CCL can be found in the [Microchip Application Note TB3218](http://ww1.microchip.com/downloads/en/AppNotes/TB3218-Getting-Started-with-CCL-90003218A.pdf) and in the [megaAVR-0 family data sheet](http://ww1.microchip.com/downloads/en/DeviceDoc/megaAVR0-series-Family-Data-Sheet-DS40002015B.pdf). - -### Warning: Examples not updated for ATtiny parts! - - -## Logic -Class for interfacing with the built-in logic block. use the predefined objects `Logic0`, `Logic1`, `Logic2` and `Logic3`. -Each object contains register pointers for interfacing with the right registers. Some of these variables are available to the user. - - -### enable -Variable for enabling or disabling a logic block. -Accepted values: -```c++ -true; // Enable the current logic block -false; // Disable the current logic block -``` - -##### Usage -```c++ -Logic0.enable = true; // Enable logic block 0 -``` - -##### Default state -`Logic0.enable` defaults to `false` if not specified in the user program. - - -### input0..input2 -Variable for setting what mode input 0..2 on a logic block should have. -Accepted values: -``` c++ -in::masked; // Pin not in use -in::unused; // Pin not in use -in::disable; // Pin not in use -in::feedback; // Connect output of the logic block to this input -in::link; // Connect output of logic block n+1 to this input -in::event_a; // Connect input to event A -in::event_b; // Connect input to event B -in::input; // Connect input to GPIO -in::ac; // Connect input to the output of the internal analog comparator -in::input_pullup; // Connect input to GPIO and enable the internal pullup resistor -in::uart; // Connect input to UART TX. Input 0 connects to UART0 TX, input 1 to UART1 TX, and input 2 to UART2 TX -in::spi; // Connect input to SPI. Input 0 and 1 connects to MOSI, and input 2 connects to SCK -in::tca0; // Connect input to TCA0. Input 0 connects to WO0, input 1 to WO1 and input2 to WO2 -in::tcb; // Connect input to TCB. Input 0 connects to TCB0 W0, input 1 to TCB1 WO, and input 2 to TCB2 WO -``` - -##### Usage -``` c++ -Logic0.input0 = in::link; // Connect output from block 1 to input 0 of block 0 -Logic0.input1 = in::input; // Connect the input 1 from block 0 to its GPIO -Logic0.input2 = in::input_pullup; // Connect the input 2 from block 0 to its GPIO and enable pullup -``` - -##### Default state -`LogicN.inputN` defaults to `in::unused` if not specified in the user program. - - -### output -Variable for changing the logic block output pin behavior. Note that the output of the logic block still can be used internally if the output pin is disabled. -Accepted values: -```c++ -out::disable; // Disable the output GPIO pin. Useful when triggering an interrupt instead. -out::enable; // Enable the output GPIO pin -``` - -##### Usage -```c++ -Logic0.output = out::disable; // Disable the output GPIO pin. -``` - -##### Default state -`LogicN.output` defaults to `out::disable` if not specified in the user program. - - -### output_swap -Variable for pin swapping the physical output pin to its alternative position. See the pinout diagrams in the main MegaCoreX README for detailed info. -Accepted values: -```c++ -out::no_swap; // Use default pin position, pin 2 on the port -out::pin_swap; // Use alternative position, pin 6 on the port -``` - -##### Usage -```c++ -Logic0.output_swap = out::no_swap; // No pin swap for output of block0 -``` - -##### Default state -`LogicN.output_swap` defaults to `out::no_swap` if not specified in the user program. - - -### filter -Variable to connecting a filter or synchronizer to the logic block output. Useful when multiple logic blocks are connected internally to prevent logic race. -Accepted values: -```c++ -filter::disable; // No filter used -filter::synchronizer; // Connect synchronizer to output -filter::filter; // Connect filter to output -``` - -##### Usage -```c++ -Logic0.filter = filter::filter; // Enable filter on output of block 0 -``` - -##### Default state -`LogicN.filter` defaults to `filter::disable` if not specified in the user program. - - -### sequencer -Variable for connecting a sequencer to the logic block output. -Accepted values: -```c++ -sequencer::disable; // No sequencer connected -sequencer::d_flip_flop; // D flip flop sequencer connected -sequencer::jk_flip_flop; // JK flip flop sequencer connected -sequencer::d_latch; // D latch sequencer connected -sequencer::rs_latch; // RS latch sequencer connected -``` - -##### Usage -```c++ -Logic0.sequencer = sequencer::disable; // Disable sequencer -``` - -##### Default state -`LogicN.sequencer` defaults to `sequencer::disable` if not specified in the user program. - - -### truth -Variable to hold the 8-bit truth table value. -Accepted values between 0x00 and 0xFF. - -##### Usage -```c++ -Logic0.truth = 0xF0; -``` - -##### Default state -`LogicN.truth` defaults to `0x00` if not specified in the user program. - - - -## init() -Method for initializing a logic block. The logic block object to initialize is passed as an argument. - -##### Usage -```c++ -Logic0.init(); // Initialize block 0 -Logic1.init(); // Initialize block 1 -``` - - - -## start() -Method for starting the CCL hardware after all registers have been initialized using init(block_t). - -##### Usage -```c++ -Logic::start(); // Start CCL hardware -``` - - - -## stop() -Method for stopping the CCL hardware. - -##### Usage -```c++ -Logic::stop(); // Stop CCL -``` - - - -## attachInterrupt() -Method for enabling interrupts for a specific block. -Valid arguments for the third parameters are `RISING`, `FALLING` and `CHANGE`. -This method ins't available on tinyAVR series. - -##### Usage -```c++ -Logic0.attachInterrupt(blinkLED, RISING); // Runthe blinkLED function when the putput goes high - -void blinkLED() -{ - digitalWrite(myLedPin, CHANGE); -} -``` - - - -## detachInterrupt() -Method for disabling interrupts for a specific block. -This method ins't available on tinyAVR series. - -##### Usage -```c++ -Logic0.detachInterrupt(); // Disable interrupts for block 0 -``` diff --git a/megaavr/libraries/Logic/examples/Five_input_NOR/Five_input_NOR.ino b/megaavr/libraries/Logic/examples/Five_input_NOR/Five_input_NOR.ino deleted file mode 100644 index cf9ef8dd..00000000 --- a/megaavr/libraries/Logic/examples/Five_input_NOR/Five_input_NOR.ino +++ /dev/null @@ -1,56 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Five_input_NOR.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use two logic blocks to get five inputs. | -| The output of block 1 is connected to one of the inputs of block 0. | -| With the correct truth tables values we can make the output of | -| block 0 go high when all inputs are low. | -| | -| See Microchip's application note TB3218 for more information. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 1 - // Logic block 1 has three inputs, PC0, PC1 and PC2. - // It's output, PC3 is disabled because we connect the output signal to block 0 internally - Logic1.enable = true; // Enable logic block 1 - Logic1.input0 = in::input_pullup; // Set PC0 as input with pullup - Logic1.input1 = in::input_pullup; // Set PC1 as input with pullup - Logic1.input2 = in::input_pullup; // Set PC2 as input with pullup - Logic1.output = out::disable; // No output on PC3 - Logic1.filter = filter::disable; // No output filter enabled - Logic1.truth = 0xFE; // Set truth table - - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // input2 is internally connected to the output of block1 (which means PA2 is freed up) - // Block 0 output on PA3 - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup - Logic0.input2 = in::link; // Route output from block 1 to this input internally - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0x01; // Set truth table - - // Initialize logic block 0 and 1 - Logic0.init(); - Logic1.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Interrupt/Interrupt.ino b/megaavr/libraries/Logic/examples/Interrupt/Interrupt.ino deleted file mode 100644 index d381bb94..00000000 --- a/megaavr/libraries/Logic/examples/Interrupt/Interrupt.ino +++ /dev/null @@ -1,66 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Interrupt.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 3-input NOR gate using logic block 2 on PORT D. | -| We will use input on PD0, PD1 and PD2. Instead of having an output | -| pin the logic block will instead trigger an interrupt that runs a | -| user defined function. | -| | -| 3-input NOR truth table: | -| If we look at the truth table |PD2|PD1|PD0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 1 | | -| be represented as 00000001. | 0 | 0 | 1 | 0 | | -| If we convert this 8-bit | 0 | 1 | 0 | 0 | | -| binary number into hex, we | 0 | 1 | 1 | 0 | | -| get 0x01. | 1 | 0 | 0 | 0 | | -| | 1 | 0 | 1 | 0 | | -| In this example the output is | 1 | 1 | 0 | 0 | | -| true if all inputs are low. | 1 | 1 | 1 | 0 | | -| | -|***********************************************************************/ - -#include - -void setup() -{ - // Modify the serial port to match your hardware - Serial.begin(9600); - - // Initialize logic block 2 - // Logic block 2 has three inputs, PA0, PA1 and PA2. - // It has one output, but this is disabled because we're using an interrupt instead. - Logic2.enable = true; // Enable logic block 2 - Logic2.input0 = in::input_pullup; // Set PD0 as input with pullup - Logic2.input1 = in::input_pullup; // Set PD1 as input with pullup - Logic2.input2 = in::input_pullup; // Set PD2 as input with pullup - Logic2.output = out::disable; // Disable output on PD3 (we don't have to though) - Logic2.filter = filter::disable; // No output filter enabled - Logic2.truth = 0x01; // Set truth table - - // Initialize logic block 2 - Logic2.init(); - - // Set interrupt (supports RISING, FALLING and CHANGE) - Logic2.attachInterrupt(interruptFunction, RISING); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} - -void interruptFunction() -{ - Serial.println("Output of logic block 2 went high!"); -} diff --git a/megaavr/libraries/Logic/examples/Three_input_AND/Three_input_AND.ino b/megaavr/libraries/Logic/examples/Three_input_AND/Three_input_AND.ino deleted file mode 100644 index fbf2534c..00000000 --- a/megaavr/libraries/Logic/examples/Three_input_AND/Three_input_AND.ino +++ /dev/null @@ -1,56 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Three_input_AND.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 3-input AND gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| Here's how 0x80 turns out to be the correct value to create a 3-input | -| AND gate: | -| 3-input AND truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 0 | | -| be represented as 10000000. | 0 | 0 | 1 | 0 | | -| If we convert this 8-bit | 0 | 1 | 0 | 0 | | -| binary number into hex, we | 0 | 1 | 1 | 0 | | -| get 0x80. | 1 | 0 | 0 | 0 | | -| | 1 | 0 | 1 | 0 | | -| In this example the output pin, | 1 | 1 | 0 | 0 | | -| PA3 will go high if all three | 1 | 1 | 1 | 1 | | -| inputs are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup - Logic0.input2 = in::input_pullup; // Set PA2 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0x80; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Three_input_NAND/Three_input_NAND.ino b/megaavr/libraries/Logic/examples/Three_input_NAND/Three_input_NAND.ino deleted file mode 100644 index 36a39a19..00000000 --- a/megaavr/libraries/Logic/examples/Three_input_NAND/Three_input_NAND.ino +++ /dev/null @@ -1,56 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Three_input_NAND.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 3-input NAND gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| Here's how 0x7F turns out to be the correct value to create a 3-input | -| NAND gate: | -| 3-input NAND truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 1 | | -| be represented as 01111111. | 0 | 0 | 1 | 1 | | -| If we convert this 8-bit | 0 | 1 | 0 | 1 | | -| binary number into hex, we | 0 | 1 | 1 | 1 | | -| get 0x7F. | 1 | 0 | 0 | 1 | | -| | 1 | 0 | 1 | 1 | | -| In this example the output pin | 1 | 1 | 0 | 1 | | -| PA3 will go low if all three | 1 | 1 | 1 | 0 | | -| inputs are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup - Logic0.input2 = in::input_pullup; // Set PA2 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0x7F; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Three_input_OR/Three_input_OR.ino b/megaavr/libraries/Logic/examples/Three_input_OR/Three_input_OR.ino deleted file mode 100644 index 1fd8a2fd..00000000 --- a/megaavr/libraries/Logic/examples/Three_input_OR/Three_input_OR.ino +++ /dev/null @@ -1,56 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Three_input_OR.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 3-input OR gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| Here's how 0xFE turns out to be the correct value to create a 3-input | -| OR gate: | -| 3-input OR truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 0 | | -| be represented as 11111110. | 0 | 0 | 1 | 1 | | -| If we convert this 8-bit | 0 | 1 | 0 | 1 | | -| binary number into hex, we | 0 | 1 | 1 | 1 | | -| get 0xFE. | 1 | 0 | 0 | 1 | | -| | 1 | 0 | 1 | 1 | | -| In this example the output pin, | 1 | 1 | 0 | 1 | | -| PA3 will go high if one or more | 1 | 1 | 1 | 1 | | -| inputs are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup - Logic0.input2 = in::input_pullup; // Set PA2 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0xFE; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Two_input_AND/Two_input_AND.ino b/megaavr/libraries/Logic/examples/Two_input_AND/Two_input_AND.ino deleted file mode 100644 index 961f7033..00000000 --- a/megaavr/libraries/Logic/examples/Two_input_AND/Two_input_AND.ino +++ /dev/null @@ -1,57 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Two_input_AND.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 2-input AND gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| We will only use PA0 and PA1 as inputs. When the last input is | -| disabled it will always be read as 0. | -| Here's how 0x08 turns out to be the correct value to create a 2-input | -| NAND gate: | -| 2-input AND truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 0 | | -| be represented as 00001000. | 0 | 0 | 1 | 0 | | -| If we convert this 8-bit | 0 | 1 | 0 | 0 | | -| binary number into hex, we | 0 | 1 | 1 | 1 | | -| get 0x08. | 1 | 0 | 0 | 0 | PA2 is always 0 | -| | 1 | 0 | 1 | 0 | PA2 is always 0 | -| In this example the output pin, | 1 | 1 | 0 | 0 | PA2 is always 0 | -| PA3 will only go high if the | 1 | 1 | 1 | 0 | PA2 is always 0 | -| two input pins are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0x08; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Two_input_NAND/Two_input_NAND.ino b/megaavr/libraries/Logic/examples/Two_input_NAND/Two_input_NAND.ino deleted file mode 100644 index 3266d2a4..00000000 --- a/megaavr/libraries/Logic/examples/Two_input_NAND/Two_input_NAND.ino +++ /dev/null @@ -1,57 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Two_input_NAND.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 2-input NAND gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| We will only use PA0 and PA1 as inputs. when the last input is | -| disabled it will always be read as 0. | -| Here's how 0xF7 turns out to be the correct value to create a 2-input | -| NAND gate: | -| 2-input NAND truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 1 | | -| be represented as 11110111. | 0 | 0 | 1 | 1 | | -| If we convert this 8-bit | 0 | 1 | 0 | 1 | | -| binary number into hex, we | 0 | 1 | 1 | 0 | | -| get 0xF7. | 1 | 0 | 0 | 1 | PA2 is always 0 | -| | 1 | 0 | 1 | 1 | PA2 is always 0 | -| In this example the output pin, | 1 | 1 | 0 | 1 | PA2 is always 0 | -| PA3 will only go low if the | 1 | 1 | 1 | 1 | PA2 is always 0 | -| two input pins are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0xF7; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/examples/Two_input_OR/Two_input_OR.ino b/megaavr/libraries/Logic/examples/Two_input_OR/Two_input_OR.ino deleted file mode 100644 index fb5f5392..00000000 --- a/megaavr/libraries/Logic/examples/Two_input_OR/Two_input_OR.ino +++ /dev/null @@ -1,57 +0,0 @@ -/***********************************************************************| -| megaAVR Configurable Custom Logic library | -| | -| Two_input_OR.ino | -| | -| A library for interfacing with the megaAVR Configurable Custom Logic. | -| Developed in 2019 by MCUdude. | -| https://github.com/MCUdude/ | -| | -| In this example we use the configurable logic peripherals the the | -| megaAVR to create a 2-input OR gate using logic block 0 on PORT A. | -| The example is pretty straight forward, but the truth table value may | -| be a little difficult to understand at first glance. | -| We will only use PA0 and PA1 as inputs. When the last input is | -| disabled it will always be read as 0. | -| Here's how 0xFE turns out to be the correct value to create a 2-input | -| OR gate: | -| 2-input OR truth table: | -| If we look at the truth table |PA2|PA1|PA0| Y | | -| to the right, we can see that |---|---|---|---| | -| all binary values for Y can | 0 | 0 | 0 | 0 | | -| be represented as 11111110. | 0 | 0 | 1 | 1 | | -| If we convert this 8-bit | 0 | 1 | 0 | 1 | | -| binary number into hex, we | 0 | 1 | 1 | 1 | | -| get 0xFE. | 1 | 0 | 0 | 1 | PA2 is always 0 | -| | 1 | 0 | 1 | 1 | PA2 is always 0 | -| In this example the output pin, | 1 | 1 | 0 | 1 | PA2 is always 0 | -| PA3 will go high if one of | 1 | 1 | 1 | 1 | PA2 is always 0 | -| the input pins are high. | -|***********************************************************************/ - -#include - -void setup() -{ - // Initialize logic block 0 - // Logic block 0 has three inputs, PA0, PA1 and PA2. - // It has one output, PA3, but can be swapped to PA6 if needed - Logic0.enable = true; // Enable logic block 0 - Logic0.input0 = in::input_pullup; // Set PA0 as input with pullup - Logic0.input1 = in::input_pullup; // Set PA1 as input with pullup -//Logic0.output_swap = out::pin_swap; // Uncomment this line to route the output to PA6 instead of PA3 - Logic0.output = out::enable; // Enable logic block 0 output pin (PA3) - Logic0.filter = filter::disable; // No output filter enabled - Logic0.truth = 0xFE; // Set truth table - - // Initialize logic block 0 - Logic0.init(); - - // Start the AVR logic hardware - Logic::start(); -} - -void loop() -{ - // When using configurable custom logic the CPU isn't doing anything! -} diff --git a/megaavr/libraries/Logic/keywords.txt b/megaavr/libraries/Logic/keywords.txt deleted file mode 100644 index 720da20e..00000000 --- a/megaavr/libraries/Logic/keywords.txt +++ /dev/null @@ -1,37 +0,0 @@ -####################################### -# Syntax Coloring Map For Wire -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -start KEYWORD2 -stop KEYWORD2 -init KEYWORD2 -attachInterrupt KEYWORD2 -detachInterrupt KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - -Logic KEYWORD2 -Logic0 KEYWORD2 -Logic1 KEYWORD2 -Logic2 KEYWORD2 -Logic3 KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - -in LITERAL1 -out LITERAL1 -filter LITERAL1 -sequencer LITERAL1 diff --git a/megaavr/libraries/Logic/library.properties b/megaavr/libraries/Logic/library.properties deleted file mode 100644 index 984a10c3..00000000 --- a/megaavr/libraries/Logic/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Logic -version=1.0.0 -author=MCUdude -maintainer=MCUdude -sentence=A library for interfacing with the customizable logic in megaAVR chips -paragraph= -category=Signal Input/Output -url=https://github.com/MCUdude/MegaCoreX -architectures=megaavr diff --git a/megaavr/libraries/Logic/src/Logic.cpp b/megaavr/libraries/Logic/src/Logic.cpp deleted file mode 100644 index 72016624..00000000 --- a/megaavr/libraries/Logic/src/Logic.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#include "Logic.h" - -#if defined(CCL_CCL_vect) -// Array for storing ISR function pointers -static volatile voidFuncPtr intFuncCCL[4]; -#endif - -struct Logic::CCLBlock -{ - const uint8_t number; - const uint8_t input0_bm; - const uint8_t input1_bm; - const uint8_t input2_bm; - const uint8_t output_bm; - const uint8_t output_alt_bm; - PORT_t& PORT_IN; - PORT_t& PORT_OUT; - PORT_t& PORT_ALT_OUT; - volatile register8_t& SEQCTRL; - volatile register8_t& LUTCTRLA; - volatile register8_t& LUTCTRLB; - volatile register8_t& LUTCTRLC; - volatile register8_t& TRUTH; -}; - -static const struct Logic::CCLBlock blocks[] = { -#if defined(__AVR_ATtiny202__) || defined(__AVR_ATtiny402__) || \ - defined(__AVR_ATtiny204__) || defined(__AVR_ATtiny404__) || \ - defined(__AVR_ATtiny804__) || defined(__AVR_ATtiny1604__) || \ - defined(__AVR_ATtiny212__) || defined(__AVR_ATtiny412__) || \ - defined(__AVR_ATtiny214__) || defined(__AVR_ATtiny414__) || \ - defined(__AVR_ATtiny814__) || defined(__AVR_ATtiny1614__) - { - 0, - PIN0_bm, PIN1_bm, PIN2_bm, PIN6_bm, 0, - PORTA, PORTA, PORTA, - CCL.SEQCTRL0, CCL.LUT0CTRLA, CCL.LUT0CTRLB, CCL.LUT0CTRLC, CCL.TRUTH0, - }, - { - 1, - 0, 0, 0, PIN7_bm, 0, - PORTA, PORTA, PORTA, - CCL.SEQCTRL0, CCL.LUT1CTRLA, CCL.LUT1CTRLB, CCL.LUT1CTRLC, CCL.TRUTH1, - }, -#endif -#if defined(__AVR_ATtiny406__) || defined(__AVR_ATtiny806__) || \ - defined(__AVR_ATtiny1606__) || \ - defined(__AVR_ATtiny416__) || defined(__AVR_ATtiny816__) || \ - defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) -#define PORTMUX_CCL PORTMUX.CTRLA -#define PORTMUX_ALTOUT_bm (1 << (block.number + 4)) - { - 0, - PIN0_bm, PIN1_bm, PIN2_bm, PIN6_bm, PIN4_bm, - PORTA, PORTA, PORTB, - CCL.SEQCTRL0, CCL.LUT0CTRLA, CCL.LUT0CTRLB, CCL.LUT0CTRLC, CCL.TRUTH0, - }, - { - 1, - PIN3_bm, 0, 0, PIN7_bm, PIN1_bm, - PORTC, PORTA, PORTC, - CCL.SEQCTRL0, CCL.LUT1CTRLA, CCL.LUT1CTRLB, CCL.LUT1CTRLC, CCL.TRUTH1, - }, -#endif -#if defined(__AVR_ATtiny807__) || defined(__AVR_ATtiny1607__) || \ - defined(__AVR_ATtiny417__) || defined(__AVR_ATtiny817__) || \ - defined(__AVR_ATtiny1617__) || defined(__AVR_ATtiny3217__) -#define PORTMUX_CCL PORTMUX.CTRLA -#define PORTMUX_ALTOUT_bm (1 << (block.number + 4)) - { - 0, - PIN0_bm, PIN1_bm, PIN2_bm, PIN6_bm, PIN4_bm, - PORTA, PORTA, PORTB, - CCL.SEQCTRL0, CCL.LUT0CTRLA, CCL.LUT0CTRLB, CCL.LUT0CTRLC, CCL.TRUTH0, - }, - { - 1, - PIN3_bm, PIN4_bm, PIN5_bm, PIN7_bm, PIN1_bm, - PORTC, PORTA, PORTC, - CCL.SEQCTRL0, CCL.LUT1CTRLA, CCL.LUT1CTRLB, CCL.LUT1CTRLC, CCL.TRUTH1, - }, -#endif -#if defined(__AVR_ATmega808__) || defined(__AVR_ATmega1608__) || \ - defined(__AVR_ATmega3208__) || defined(__AVR_ATmega4808__) -#define PORTMUX_CCL PORTMUX.CCLROUTEA -#define PORTMUX_ALTOUT_bm (1 << block.number) - { - 0, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTA, PORTA, PORTA, - CCL.SEQCTRL0, CCL.LUT0CTRLA, CCL.LUT0CTRLB, CCL.LUT0CTRLC, CCL.TRUTH0, - }, - { - 1, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, 0, - PORTC, PORTC, PORTC, - CCL.SEQCTRL0, CCL.LUT1CTRLA, CCL.LUT1CTRLB, CCL.LUT1CTRLC, CCL.TRUTH1, - }, - { - 2, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTD, PORTD, PORTD, - CCL.SEQCTRL1, CCL.LUT2CTRLA, CCL.LUT2CTRLB, CCL.LUT2CTRLC, CCL.TRUTH2, - }, - { // Note: 28-Pin version doesn't have input2 and output_alt. - 3, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTF, PORTF, PORTF, - CCL.SEQCTRL1, CCL.LUT3CTRLA, CCL.LUT3CTRLB, CCL.LUT3CTRLC, CCL.TRUTH3, - }, -#endif -#if defined(__AVR_ATmega809__) || defined(__AVR_ATmega1609__) || \ - defined(__AVR_ATmega3209__) || defined(__AVR_ATmega4809__) -#define PORTMUX_CCL PORTMUX.CCLROUTEA -#define PORTMUX_ALTOUT_bm (1 << block.number) - { - 0, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTA, PORTA, PORTA, - CCL.SEQCTRL0, CCL.LUT0CTRLA, CCL.LUT0CTRLB, CCL.LUT0CTRLC, CCL.TRUTH0, - }, - { // Note: 40-Pin version doesn't have output_alt. - 1, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTC, PORTC, PORTC, - CCL.SEQCTRL0, CCL.LUT1CTRLA, CCL.LUT1CTRLB, CCL.LUT1CTRLC, CCL.TRUTH1, - }, - { - 2, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTD, PORTD, PORTD, - CCL.SEQCTRL1, CCL.LUT2CTRLA, CCL.LUT2CTRLB, CCL.LUT2CTRLC, CCL.TRUTH2, - }, - { - 3, - PIN0_bm, PIN1_bm, PIN2_bm, PIN3_bm, PIN6_bm, - PORTF, PORTF, PORTF, - CCL.SEQCTRL1, CCL.LUT3CTRLA, CCL.LUT3CTRLB, CCL.LUT3CTRLC, CCL.TRUTH3, - }, -#endif -}; - -#if defined(CCL_TRUTH0) -Logic Logic0(0); -#endif -#if defined(CCL_TRUTH1) -Logic Logic1(1); -#endif -#if defined(CCL_TRUTH2) -Logic Logic2(2); -#endif -#if defined(CCL_TRUTH3) -Logic Logic3(3); -#endif - -Logic::Logic(const uint8_t block_number) - : enable(false), - input0(in::masked), - input1(in::masked), - input2(in::masked), - output(out::disable), - output_swap(out::no_swap), - filter(filter::disable), - truth(0x00), - sequencer(sequencer::disable), - block(blocks[block_number]) -{ -} - -// static -void Logic::start(bool state) -{ - CCL.CTRLA = (state ? CCL_ENABLE_bm : 0); -} - - -// static -void Logic::stop() -{ - start(false); -} - -static volatile register8_t& PINCTRL(PORT_t& port, const uint8_t pin_bm) -{ - if(pin_bm == PIN0_bm) return port.PIN0CTRL; - if(pin_bm == PIN1_bm) return port.PIN1CTRL; - if(pin_bm == PIN2_bm) return port.PIN2CTRL; - if(pin_bm == PIN3_bm) return port.PIN3CTRL; - if(pin_bm == PIN4_bm) return port.PIN4CTRL; - if(pin_bm == PIN5_bm) return port.PIN5CTRL; - if(pin_bm == PIN6_bm) return port.PIN6CTRL; - return port.PIN7CTRL; -} - - -void Logic::initInput(in::input_t& input, PORT_t& port, const uint8_t pin_bm) -{ - if(input == in::input && pin_bm) - { - port.DIRCLR = pin_bm; - PINCTRL(port, pin_bm) &= ~PORT_PULLUPEN_bm; - } - else if (input == in::input_pullup && pin_bm) - { - port.DIRCLR = pin_bm; - PINCTRL(port, pin_bm) |= PORT_PULLUPEN_bm; - input = in::input; - } -} - - -void Logic::init() -{ - initInput(input0, block.PORT_IN, block.input0_bm); - initInput(input1, block.PORT_IN, block.input1_bm); - initInput(input2, block.PORT_IN, block.input2_bm); - - // Set inputs modes - block.LUTCTRLB = (input1 << CCL_INSEL1_gp) | (input0 << CCL_INSEL0_gp); - block.LUTCTRLC = (input2 << CCL_INSEL2_gp); - - // Set truth table - block.TRUTH = truth; - - // Set sequencer - block.SEQCTRL = sequencer; - - // Set output pin state and output pin swap - if(output == out::enable) - { - if(output_swap == out::pin_swap && block.output_alt_bm) - { -#if defined(PORTMUX_CCL) - PORTMUX_CCL |= PORTMUX_ALTOUT_bm; -#endif - block.PORT_OUT.DIRSET = block.output_alt_bm; - } - else if(output_swap == out::no_swap && block.output_bm) - { -#if defined(PORTMUX_CCL) - PORTMUX_CCL &= ~PORTMUX_ALTOUT_bm; -#endif - block.PORT_ALT_OUT.DIRSET = block.output_bm; - } - } - - // Set logic output state and output filter - block.LUTCTRLA = (output ? CCL_OUTEN_bm : 0) - | (filter << CCL_FILTSEL_gp) - | (enable ? CCL_ENABLE_bm : 0); -} - - -#if defined(CCL_CCL_vect) -void Logic::attachInterrupt(void (*userFunc)(void), PinStatus mode) -{ - CCL_INTMODE0_t intmode; - switch (mode) - { - // Set RISING, FALLING or CHANGE interrupt trigger for a block output - case RISING: - intmode = CCL_INTMODE0_RISING_gc; - break; - case FALLING: - intmode = CCL_INTMODE0_FALLING_gc; - break; - case CHANGE: - intmode = CCL_INTMODE0_BOTH_gc; - break; - default: - // Only RISING, FALLING and CHANGE is supported - return; - } - const int intmode_bp = block.number * 2; - CCL.INTCTRL0 = (CCL.INTCTRL0 & ~(CCL_INTMODE0_gm << intmode_bp)) - | (intmode << intmode_bp); - - // Store function pointer - intFuncCCL[block.number] = userFunc; -} - - -void Logic::detachInterrupt() -{ - // Disable interrupt for a given block output - CCL.INTCTRL0 &= ~(CCL_INTMODE0_gm << (block.number * 2)); -} - - -// CCL interrupt service routine -// Use attachIntterupt to activate this. -ISR(CCL_CCL_vect) -{ - // Cleck for block 0 interrupt - if(CCL.INTFLAGS & CCL_INT0_bm) - { - // Run user function - intFuncCCL[CCL_INT0_bp](); - // Clear flag - CCL.INTFLAGS |= CCL_INT0_bm; - } - if(CCL.INTFLAGS & CCL_INT1_bm) - { - intFuncCCL[CCL_INT1_bp](); - CCL.INTFLAGS |= CCL_INT1_bm; - } - if(CCL.INTFLAGS & CCL_INT2_bm) - { - intFuncCCL[CCL_INT2_bp](); - CCL.INTFLAGS |= CCL_INT2_bm; - } - // Cleck for block 3 interrupt - if(CCL.INTFLAGS & CCL_INT3_bm) - { - // Run user function - intFuncCCL[CCL_INT3_bp](); - // Clear flag - CCL.INTFLAGS |= CCL_INT3_bm; - } -} -#endif // CCL_CCL_vect diff --git a/megaavr/libraries/Logic/src/Logic.h b/megaavr/libraries/Logic/src/Logic.h deleted file mode 100644 index 212b80eb..00000000 --- a/megaavr/libraries/Logic/src/Logic.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef LOGIC_h -#define LOGIC_h - -#include - -//Use in:: when working with logic inputs -namespace in -{ - enum input_t : uint8_t - { - masked = 0x00, - unused = 0x00, - disable = 0x00, - feedback = 0x01, - link = 0x02, - event_a = 0x03, - event_b = 0x04, - input = 0x05, - ac = 0x06, - input_pullup = 0x07, - usart = 0x08, - spi = 0x09, - tca0 = 0x0A, - tcb = 0x0C, - }; -}; - -// Use out:: when working with logic outputs -namespace out -{ - enum output_t : uint8_t - { - disable = 0x00, - enable = 0x01, - }; - enum pinswap_t : uint8_t - { - no_swap = 0x00, - pin_swap = 0x01, - }; -}; - -// Use filter:: when working with logic output filter -namespace filter -{ - enum filter_t : uint8_t - { - disable = 0x00, - synchronizer = 0x01, - filter = 0x02, - }; -}; - -// Use sequencer:: when working with LUT sequencer -namespace sequencer -{ - enum sequencer_t : uint8_t - { - disable = 0x00, - d_flip_flop = 0x01, - jk_flip_flop = 0x02, - d_latch = 0x03, - sr_latch = 0x04, - rs_latch = 0x04, - }; -}; - -class Logic -{ - public: - static void start(bool state = true); - static void stop(); - - Logic(const uint8_t block_number); - void init(); -#if defined(CCL_CCL_vect) - void attachInterrupt(voidFuncPtr callback, PinStatus mode); - void detachInterrupt(); -#endif - - bool enable; - in::input_t input0; - in::input_t input1; - in::input_t input2; - out::output_t output; - out::pinswap_t output_swap; - filter::filter_t filter; - uint8_t truth; - sequencer::sequencer_t sequencer; - - struct CCLBlock; - - private: - const struct CCLBlock& block; - - void initInput(in::input_t& input, PORT_t& port, const uint8_t pin_bm); -}; - -#if defined(CCL_TRUTH0) -extern Logic Logic0; -#endif -#if defined(CCL_TRUTH1) -extern Logic Logic1; -#endif -#if defined(CCL_TRUTH2) -extern Logic Logic2; -#endif -#if defined(CCL_TRUTH3) -extern Logic Logic3; -#endif - -#endif diff --git a/megaavr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/megaavr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino deleted file mode 100644 index df73adeb..00000000 --- a/megaavr/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino +++ /dev/null @@ -1,143 +0,0 @@ -/* - SCP1000 Barometric Pressure Sensor Display - - Shows the output of a Barometric Pressure Sensor on a - Uses the SPI library. For details on the sensor, see: - http://www.sparkfun.com/commerce/product_info.php?products_id=8161 - http://www.vti.fi/en/support/obsolete_products/pressure_sensors/ - - This sketch adapted from Nathan Seidle's SCP1000 example for PIC: - http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip - - Circuit: - SCP1000 sensor attached to pins 6, 7, 10 - 13: - DRDY: pin 6 - CSB: pin 7 - MOSI: pin 11 - MISO: pin 12 - SCK: pin 13 - - created 31 July 2010 - modified 14 August 2010 - by Tom Igoe - */ - -// the sensor communicates using SPI, so include the library: -#include - -//Sensor's memory register addresses: -const int PRESSURE = 0x1F; //3 most significant bits of pressure -const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure -const int TEMPERATURE = 0x21; //16 bit temperature reading -const byte READ = 0b11111100; // SCP1000's read command -const byte WRITE = 0b00000010; // SCP1000's write command - -// pins used for the connection with the sensor -// the other you need are controlled by the SPI library): -const int dataReadyPin = 6; -const int chipSelectPin = 7; - -void setup() { - Serial.begin(9600); - - // start the SPI library: - SPI.begin(); - - // initalize the data ready and chip select pins: - pinMode(dataReadyPin, INPUT); - pinMode(chipSelectPin, OUTPUT); - - //Configure SCP1000 for low noise configuration: - writeRegister(0x02, 0x2D); - writeRegister(0x01, 0x03); - writeRegister(0x03, 0x02); - // give the sensor time to set up: - delay(100); -} - -void loop() { - //Select High Resolution Mode - writeRegister(0x03, 0x0A); - - // don't do anything until the data ready pin is high: - if (digitalRead(dataReadyPin) == HIGH) { - //Read the temperature data - int tempData = readRegister(0x21, 2); - - // convert the temperature to celsius and display it: - float realTemp = (float)tempData / 20.0; - Serial.print("Temp[C]="); - Serial.print(realTemp); - - - //Read the pressure data highest 3 bits: - byte pressure_data_high = readRegister(0x1F, 1); - pressure_data_high &= 0b00000111; //you only needs bits 2 to 0 - - //Read the pressure data lower 16 bits: - unsigned int pressure_data_low = readRegister(0x20, 2); - //combine the two parts into one 19-bit number: - long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4; - - // display the temperature: - Serial.println("\tPressure [Pa]=" + String(pressure)); - } -} - -//Read from or write to register from the SCP1000: -unsigned int readRegister(byte thisRegister, int bytesToRead) { - byte inByte = 0; // incoming byte from the SPI - unsigned int result = 0; // result to return - Serial.print(thisRegister, BIN); - Serial.print("\t"); - // SCP1000 expects the register name in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the address and the command into one byte - byte dataToSend = thisRegister & READ; - Serial.println(thisRegister, BIN); - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - // send the device the register you want to read: - SPI.transfer(dataToSend); - // send a value of 0 to read the first byte returned: - result = SPI.transfer(0x00); - // decrement the number of bytes left to read: - bytesToRead--; - // if you still have another byte to read: - if (bytesToRead > 0) { - // shift the first byte left, then get the second byte: - result = result << 8; - inByte = SPI.transfer(0x00); - // combine the byte you just got with the previous one: - result = result | inByte; - // decrement the number of bytes left to read: - bytesToRead--; - } - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); - // return the result: - return (result); -} - - -//Sends a write command to SCP1000 - -void writeRegister(byte thisRegister, byte thisValue) { - - // SCP1000 expects the register address in the upper 6 bits - // of the byte. So shift the bits left by two bits: - thisRegister = thisRegister << 2; - // now combine the register address and the command into one byte: - byte dataToSend = thisRegister | WRITE; - - // take the chip select low to select the device: - digitalWrite(chipSelectPin, LOW); - - SPI.transfer(dataToSend); //Send register location - SPI.transfer(thisValue); //Send value to record into register - - // take the chip select high to de-select: - digitalWrite(chipSelectPin, HIGH); -} - diff --git a/megaavr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/megaavr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino deleted file mode 100644 index c7afcc0a..00000000 --- a/megaavr/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino +++ /dev/null @@ -1,71 +0,0 @@ -/* - Digital Pot Control - - This example controls an Analog Devices AD5206 digital potentiometer. - The AD5206 has 6 potentiometer channels. Each channel's pins are labeled - A - connect this to voltage - W - this is the pot's wiper, which changes when you set it - B - connect this to ground. - - The AD5206 is SPI-compatible,and to command it, you send two bytes, - one with the channel number (0 - 5) and one with the resistance value for the - channel (0 - 255). - - The circuit: - * All A pins of AD5206 connected to +5V - * All B pins of AD5206 connected to ground - * An LED and a 220-ohm resisor in series connected from each W pin to ground - * CS - to digital pin 10 (SS pin) - * SDI - to digital pin 11 (MOSI pin) - * CLK - to digital pin 13 (SCK pin) - - created 10 Aug 2010 - by Tom Igoe - - Thanks to Heather Dewey-Hagborg for the original tutorial, 2005 - -*/ - - -// inslude the SPI library: -#include - - -// set pin 10 as the slave select for the digital pot: -const int slaveSelectPin = 10; - -void setup() { - // set the slaveSelectPin as an output: - pinMode(slaveSelectPin, OUTPUT); - // initialize SPI: - SPI.begin(); -} - -void loop() { - // go through the six channels of the digital pot: - for (int channel = 0; channel < 6; channel++) { - // change the resistance on this channel from min to max: - for (int level = 0; level < 255; level++) { - digitalPotWrite(channel, level); - delay(10); - } - // wait a second at the top: - delay(100); - // change the resistance on this channel from max to min: - for (int level = 0; level < 255; level++) { - digitalPotWrite(channel, 255 - level); - delay(10); - } - } - -} - -void digitalPotWrite(int address, int value) { - // take the SS pin low to select the chip: - digitalWrite(slaveSelectPin, LOW); - // send in the address and value via SPI: - SPI.transfer(address); - SPI.transfer(value); - // take the SS pin high to de-select the chip: - digitalWrite(slaveSelectPin, HIGH); -} diff --git a/megaavr/libraries/SPI/keywords.txt b/megaavr/libraries/SPI/keywords.txt deleted file mode 100644 index fa761658..00000000 --- a/megaavr/libraries/SPI/keywords.txt +++ /dev/null @@ -1,36 +0,0 @@ -####################################### -# Syntax Coloring Map SPI -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SPI KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -begin KEYWORD2 -end KEYWORD2 -transfer KEYWORD2 -setBitOrder KEYWORD2 -setDataMode KEYWORD2 -setClockDivider KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### -SPI_CLOCK_DIV4 LITERAL1 -SPI_CLOCK_DIV16 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_CLOCK_DIV128 LITERAL1 -SPI_CLOCK_DIV2 LITERAL1 -SPI_CLOCK_DIV8 LITERAL1 -SPI_CLOCK_DIV32 LITERAL1 -SPI_CLOCK_DIV64 LITERAL1 -SPI_MODE0 LITERAL1 -SPI_MODE1 LITERAL1 -SPI_MODE2 LITERAL1 -SPI_MODE3 LITERAL1 \ No newline at end of file diff --git a/megaavr/libraries/SPI/library.properties b/megaavr/libraries/SPI/library.properties deleted file mode 100644 index 34a1b624..00000000 --- a/megaavr/libraries/SPI/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=SPI -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. -paragraph=SPI is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances. It uses three lines common to all devices (MISO, MOSI and SCK) and one specific for each device. -category=Communication -url=http://www.arduino.cc/en/Reference/SPI -architectures=megaavr - diff --git a/megaavr/libraries/SPI/src/SPI.cpp b/megaavr/libraries/SPI/src/SPI.cpp deleted file mode 100644 index 5888c8f8..00000000 --- a/megaavr/libraries/SPI/src/SPI.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - * SPI Master library for Arduino Zero. - * Copyright (c) 2015 Arduino LLC - * - * 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 "SPI.h" -#include - -#define SPI_IMODE_NONE 0 -#define SPI_IMODE_EXTINT 1 -#define SPI_IMODE_GLOBAL 2 - -const SPISettings DEFAULT_SPI_SETTINGS = SPISettings(); - -SPIClass::SPIClass(uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI, uint8_t uc_pinSS, uint8_t uc_mux) -{ - initialized = false; - - // pins - _uc_mux = uc_mux; - _uc_pinMiso = uc_pinMISO; - _uc_pinSCK = uc_pinSCK; - _uc_pinMosi = uc_pinMOSI; - _uc_pinSS = uc_pinSS; -} - -void SPIClass::begin() -{ - init(); - - #if defined(TWISPIROUTEA) - PORTMUX.TWISPIROUTEA |= _uc_mux; - #endif - - pinMode(_uc_pinMosi, OUTPUT); - pinMode(_uc_pinSCK, OUTPUT); - // MISO is set to input by the controller - - // We don't need HW SS since salve/master mode is selected via registers - SPI0.CTRLB |= (SPI_SSD_bm); - SPI0.CTRLA |= (SPI_ENABLE_bm | SPI_MASTER_bm); - - config(DEFAULT_SPI_SETTINGS); -} - -void SPIClass::init() -{ - if (initialized) - return; - interruptMode = SPI_IMODE_NONE; - interruptSave = 0; - interruptMask_lo = 0; - interruptMask_hi = 0; - initialized = true; -} - -void SPIClass::config(SPISettings settings) -{ - SPI0.CTRLA = settings.ctrla; - SPI0.CTRLB = settings.ctrlb; -} - -void SPIClass::end() -{ - SPI0.CTRLA &= ~(SPI_ENABLE_bm); - initialized = false; -} - -void SPIClass::usingInterrupt(int interruptNumber) -{ - if ((interruptNumber == NOT_AN_INTERRUPT)) - return; - - if (interruptNumber >= EXTERNAL_NUM_INTERRUPTS) - interruptMode = SPI_IMODE_GLOBAL; - else - { - #if USE_MALLOC_FOR_IRQ_MAP - if (irqMap == NULL) { - irqMap = (uint8_t*)malloc(EXTERNAL_NUM_INTERRUPTS); - } - #endif - - interruptMode |= SPI_IMODE_EXTINT; - if (interruptNumber < 32) { - interruptMask_lo |= 1 << interruptNumber; - } else { - interruptMask_hi |= 1 << (interruptNumber - 32); - } - } -} - -void SPIClass::notUsingInterrupt(int interruptNumber) -{ - if ((interruptNumber == NOT_AN_INTERRUPT)) - return; - - if (interruptMode & SPI_IMODE_GLOBAL) - return; // can't go back, as there is no reference count - - if (interruptNumber < 32) { - interruptMask_lo &= ~(1 << interruptNumber); - } else { - interruptMask_hi &= ~(1 << (interruptNumber - 32)); - } - - if (interruptMask_lo == 0 && interruptMask_hi == 0) { - interruptMode = SPI_IMODE_NONE; - #if USE_MALLOC_FOR_IRQ_MAP - free(irqMap); - irqMap = NULL; - #endif - } -} - -void SPIClass::detachMaskedInterrupts() { - uint64_t temp = interruptMask_lo; - uint8_t shift = 0; - while (temp != 0) { - if (temp & 1) { - volatile uint8_t* pin_ctrl_reg = getPINnCTRLregister(portToPortStruct(shift/8), shift%8); - irqMap[shift] = *pin_ctrl_reg; - *pin_ctrl_reg &= ~(PORT_ISC_gm); - } - temp = temp >> 1; - shift++; - } - temp = interruptMask_hi; - shift = 32; - while (temp != 0) { - if (temp & 1) { - volatile uint8_t* pin_ctrl_reg = getPINnCTRLregister(portToPortStruct(shift/8), shift%8); - irqMap[shift] = *pin_ctrl_reg; - *pin_ctrl_reg &= ~(PORT_ISC_gm); - } - temp = temp >> 1; - shift++; - } -} - -void SPIClass::reattachMaskedInterrupts() { - uint64_t temp = interruptMask_lo; - uint8_t shift = 0; - while (temp != 0) { - if (temp & 1) { - volatile uint8_t* pin_ctrl_reg = getPINnCTRLregister(portToPortStruct(shift/8), shift%8); - *pin_ctrl_reg |= irqMap[shift]; - } - temp = temp >> 1; - shift++; - } - temp = interruptMask_hi; - shift = 32; - while (temp != 0) { - if (temp & 1) { - volatile uint8_t* pin_ctrl_reg = getPINnCTRLregister(portToPortStruct(shift/8), shift%8); - *pin_ctrl_reg |= irqMap[shift]; - } - temp = temp >> 1; - shift++; - } -} - -void SPIClass::beginTransaction(SPISettings settings) -{ - if (interruptMode != SPI_IMODE_NONE) - { - if (interruptMode & SPI_IMODE_GLOBAL) - { - noInterrupts(); - } - else if (interruptMode & SPI_IMODE_EXTINT) - { - detachMaskedInterrupts(); - } - } - config(settings); -} - -void SPIClass::endTransaction(void) -{ - if (interruptMode != SPI_IMODE_NONE) - { - if (interruptMode & SPI_IMODE_GLOBAL) - { - interrupts(); - } - else if (interruptMode & SPI_IMODE_EXTINT) - reattachMaskedInterrupts(); - } -} - -void SPIClass::setBitOrder(BitOrder order) -{ - if (order == LSBFIRST) - SPI0.CTRLA |= (SPI_DORD_bm); - else - SPI0.CTRLA &= ~(SPI_DORD_bm); -} - -void SPIClass::setDataMode(uint8_t mode) -{ - SPI0.CTRLB = ((SPI0.CTRLB & (~SPI_MODE_gm)) | mode ); -} - -void SPIClass::setClockDivider(uint8_t div) -{ - SPI0.CTRLA = ((SPI0.CTRLA & - ((~SPI_PRESC_gm) | (~SPI_CLK2X_bm) )) // mask out values - | div); // write value -} - -byte SPIClass::transfer(uint8_t data) -{ - /* - * The following NOP introduces a small delay that can prevent the wait - * loop from iterating when running at the maximum speed. This gives - * about 10% more speed, even if it seems counter-intuitive. At lower - * speeds it is unnoticed. - */ - asm volatile("nop"); - - SPI0.DATA = data; - while ((SPI0.INTFLAGS & SPI_RXCIF_bm) == 0); // wait for complete send - return SPI0.DATA; // read data back -} - -uint16_t SPIClass::transfer16(uint16_t data) { - union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } t; - - t.val = data; - - if ((SPI0.CTRLA & SPI_DORD_bm) == 0) { - t.msb = transfer(t.msb); - t.lsb = transfer(t.lsb); - } else { - t.lsb = transfer(t.lsb); - t.msb = transfer(t.msb); - } - - return t.val; -} - -void SPIClass::transfer(void *buf, size_t count) -{ - uint8_t *buffer = reinterpret_cast(buf); - for (size_t i=0; i 0 - SPIClass SPI (PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI, PIN_SPI_SS, MUX_SPI); -#endif \ No newline at end of file diff --git a/megaavr/libraries/SPI/src/SPI.h b/megaavr/libraries/SPI/src/SPI.h deleted file mode 100644 index 18262c9d..00000000 --- a/megaavr/libraries/SPI/src/SPI.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * SPI Master library for Arduino Zero. - * Copyright (c) 2015 Arduino LLC - * - * 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 _SPI_H_INCLUDED -#define _SPI_H_INCLUDED - -#include - -#ifndef USE_MALLOC_FOR_IRQ_MAP -#define USE_MALLOC_FOR_IRQ_MAP 0 -#endif - -// SPI_HAS_TRANSACTION means SPI has -// - beginTransaction() -// - endTransaction() -// - usingInterrupt() -// - SPISetting(clock, bitOrder, dataMode) -#define SPI_HAS_TRANSACTION 1 - -// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method -#define SPI_HAS_NOTUSINGINTERRUPT 1 - -#define SPI_MODE0 ( SPI_MODE_0_gc ) -#define SPI_MODE1 ( SPI_MODE_1_gc ) -#define SPI_MODE2 ( SPI_MODE_2_gc ) -#define SPI_MODE3 ( SPI_MODE_3_gc ) - -#define SPI_MODE_MASK ( SPI_MODE_gm ) -#define SPI_CLOCK_MASK ( SPI_PRESC_gm ) -#define SPI_2XCLOCK_MASK ( SPI_CLK2X_bm ) - -#define SPI_INTERRUPT_DISABLE 0 -#define SPI_INTERRUPT_ENABLE 1 - -#ifndef EXTERNAL_NUM_INTERRUPTS -#define EXTERNAL_NUM_INTERRUPTS NUM_TOTAL_PINS -#endif - -class SPISettings { - public: - SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - if (__builtin_constant_p(clock)) { - init_AlwaysInline(clock, bitOrder, dataMode); - } else { - init_MightInline(clock, bitOrder, dataMode); - } - } - - // Default speed set to 4MHz, SPI mode set to MODE 0 and Bit order set to MSB first. - SPISettings() { init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0); } - - private: - void init_MightInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) { - init_AlwaysInline(clock, bitOrder, dataMode); - } - - void init_AlwaysInline(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) __attribute__((__always_inline__)) { - // Clock settings are defined as follows. Note that this shows SPI2X - // inverted, so the bits form increasing numbers. Also note that - // fosc/64 appears twice. If FOSC is 16 Mhz - // PRESC[1:0] ~SPI2X Freq - // 0 0 0 fosc/2 8.00 MHz - // 0 0 1 fosc/4 4.00 MHz - // 0 1 0 fosc/8 2.00 MHz - // 0 1 1 fosc/16 1.00 MHz - // 1 0 0 fosc/32 500 kHz - // 1 0 1 fosc/64 250 kHz - // 1 1 0 fosc/64 250 kHz - // 1 1 1 fosc/128 125 kHz - - // We find the fastest clock that is less than or equal to the - // given clock rate. The clock divider that results in clock_setting - // is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the - // slowest (128 == 2 ^^ 7, so clock_div = 6). - uint8_t clockDiv; - - // When the clock is known at compiletime, use this if-then-else - // cascade, which the compiler knows how to completely optimize - // away. When clock is not known, use a loop instead, which generates - // shorter code. - - /* This is no longer the case since, F_CPU_CORRECTED is variable */ - /* set at run time. */ - - uint32_t clockSetting = 0; - - clockSetting = F_CPU_CORRECTED / 2; - clockDiv = 0; - while ((clockDiv < 6) && (clock < clockSetting)) { - clockSetting /= 2; - clockDiv++; - } - - // Compensate for the duplicate fosc/64, - // should be fosc/128 if clockdiv 6. - if (clockDiv == 6) - { - clockDiv++; - } - - // Invert the SPI2X bit - clockDiv ^= 0x1; - - /* Pack into the SPISettings::ctrlb class */ - /* Set mode, disable master slave select, and disable buffering. */ - /* dataMode is register correct, when using SPI_MODE defines */ - ctrlb = (dataMode) | - (SPI_SSD_bm) | - (0 << SPI_BUFWR_bp) | - (0 << SPI_BUFEN_bp); - - /* Get Clock related values.*/ - uint8_t clockDiv_mult = (clockDiv & 0x1); - uint8_t clockDiv_pres = (clockDiv >> 1); - - /* Pack into the SPISettings::ctrlb class */ - /* Set Prescaler, x2, SPI to Master, and Bit Order. */ - - ctrla = (clockDiv_pres << SPI_PRESC_gp) | - (clockDiv_mult << SPI_CLK2X_bp) | - (SPI_ENABLE_bm) | - (SPI_MASTER_bm) | - ((bitOrder == LSBFIRST) << SPI_DORD_bp); - - } - /* member variables containing the desired SPI settings */ - uint8_t ctrla; - uint8_t ctrlb; - friend class SPIClass; -}; - -class SPIClass { - public: - SPIClass(uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI, uint8_t uc_pinSS, uint8_t uc_mux); - - byte transfer(uint8_t data); - uint16_t transfer16(uint16_t data); - void transfer(void *buf, size_t count); - - // Transaction Functions - void usingInterrupt(int interruptNumber); - void notUsingInterrupt(int interruptNumber); - void beginTransaction(SPISettings settings); - void endTransaction(void); - - void begin(); - void end(); - - void setBitOrder(BitOrder order); - void setDataMode(uint8_t uc_mode); - void setClockDivider(uint8_t uc_div); - - private: - - void init(); - void config(SPISettings settings); - - // These undocumented functions should not be used. SPI.transfer() - // polls the hardware flag which is automatically cleared as the - // AVR responds to SPI's interrupt - inline static void attachInterrupt() { SPI0.INTCTRL |= (SPI_IE_bm); } - inline static void detachInterrupt() { SPI0.INTCTRL &= ~(SPI_IE_bm); } - - void detachMaskedInterrupts(); - void reattachMaskedInterrupts(); - - uint8_t _uc_pinMiso; - uint8_t _uc_pinMosi; - uint8_t _uc_pinSCK; - uint8_t _uc_pinSS; - uint8_t _uc_mux; - - bool initialized; - uint8_t interruptMode; - char interruptSave; - uint32_t interruptMask_lo; - uint32_t interruptMask_hi; - - #if USE_MALLOC_FOR_IRQ_MAP - uint8_t* irqMap = NULL; - #else - volatile uint8_t irqMap[EXTERNAL_NUM_INTERRUPTS]; - #endif -}; - - -#if SPI_INTERFACES_COUNT > 0 - extern SPIClass SPI; -#endif - -#define SPI_CLOCK_DIV2 ( SPI_PRESC_DIV4_gc | SPI_CLK2X_bm ) -#define SPI_CLOCK_DIV4 ( SPI_PRESC_DIV4_gc ) -#define SPI_CLOCK_DIV8 ( SPI_PRESC_DIV16_gc | SPI_CLK2X_bm ) -#define SPI_CLOCK_DIV16 ( SPI_PRESC_DIV16_gc ) -#define SPI_CLOCK_DIV32 ( SPI_PRESC_DIV64_gc | SPI_CLK2X_bm ) -#define SPI_CLOCK_DIV64 ( SPI_PRESC_DIV64_gc ) -#define SPI_CLOCK_DIV128 ( SPI_PRESC_DIV128_gc ) - -#endif \ No newline at end of file diff --git a/megaavr/libraries/Servo/examples/Knob/Knob.ino b/megaavr/libraries/Servo/examples/Knob/Knob.ino deleted file mode 100644 index 0db8770b..00000000 --- a/megaavr/libraries/Servo/examples/Knob/Knob.ino +++ /dev/null @@ -1,27 +0,0 @@ -/* - Controlling a servo position using a potentiometer (variable resistor) - by Michal Rinott - - modified on 8 Nov 2013 - by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/Knob -*/ - -#include - -Servo myservo; // create servo object to control a servo - -int potpin = 0; // analog pin used to connect the potentiometer -int val; // variable to read the value from the analog pin - -void setup() { - myservo.attach(9); // attaches the servo on pin 9 to the servo object -} - -void loop() { - val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) - val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) - myservo.write(val); // sets the servo position according to the scaled value - delay(15); // waits for the servo to get there -} - diff --git a/megaavr/libraries/Servo/examples/Sweep/Sweep.ino b/megaavr/libraries/Servo/examples/Sweep/Sweep.ino deleted file mode 100644 index df904afb..00000000 --- a/megaavr/libraries/Servo/examples/Sweep/Sweep.ino +++ /dev/null @@ -1,32 +0,0 @@ -/* Sweep - by BARRAGAN - This example code is in the public domain. - - modified 8 Nov 2013 - by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/Sweep -*/ - -#include - -Servo myservo; // create servo object to control a servo -// twelve servo objects can be created on most boards - -int pos = 0; // variable to store the servo position - -void setup() { - myservo.attach(9); // attaches the servo on pin 9 to the servo object -} - -void loop() { - for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees - // in steps of 1 degree - myservo.write(pos); // tell servo to go to position in variable 'pos' - delay(15); // waits 15ms for the servo to reach the position - } - for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees - myservo.write(pos); // tell servo to go to position in variable 'pos' - delay(15); // waits 15ms for the servo to reach the position - } -} - diff --git a/megaavr/libraries/Servo/keywords.txt b/megaavr/libraries/Servo/keywords.txt deleted file mode 100644 index 0a7ca1e3..00000000 --- a/megaavr/libraries/Servo/keywords.txt +++ /dev/null @@ -1,24 +0,0 @@ -####################################### -# Syntax Coloring Map Servo -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Servo KEYWORD1 Servo - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -attach KEYWORD2 -detach KEYWORD2 -write KEYWORD2 -read KEYWORD2 -attached KEYWORD2 -writeMicroseconds KEYWORD2 -readMicroseconds KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/megaavr/libraries/Servo/library.properties b/megaavr/libraries/Servo/library.properties deleted file mode 100644 index 2b329391..00000000 --- a/megaavr/libraries/Servo/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Servo -version=1.1.4 -author=Spence Konde based on work by Michael Margolis, Arduino -maintainer=Spence Konde -sentence=Allows megaTinyCore-supported parts to control a variety of servo motors. -paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
-category=Device Control -url=http://www.arduino.cc/en/Reference/Servo -architectures=megaavr diff --git a/megaavr/libraries/Servo/src/Servo.h b/megaavr/libraries/Servo/src/Servo.h deleted file mode 100644 index d43d2d98..00000000 --- a/megaavr/libraries/Servo/src/Servo.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. 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 -*/ - -/* - A servo is activated by creating an instance of the Servo class passing - the desired pin to the attach() method. - The servos are pulsed in the background using the value most recently - written using the write() method. - - Note that analogWrite of PWM on pins associated with the timer are - disabled when the first servo is attached. - Timers are seized as needed in groups of 12 servos - 24 servos use two - timers, 48 servos will use four. - The sequence used to sieze timers is defined in timers.h - - The methods are: - - Servo - Class for manipulating servo motors connected to Arduino pins. - - attach(pin ) - Attaches a servo motor to an i/o pin. - attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds - default min is 544, max is 2400 - - write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) - writeMicroseconds() - Sets the servo pulse width in microseconds - read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) - attached() - Returns true if there is a servo attached. - detach() - Stops an attached servos from pulsing its i/o pin. - */ - -#ifndef Servo_h -#define Servo_h - -#include - -/* - * Defines for 16 bit timers used with Servo library - * - * If _useTimerX is defined then TimerX is a 16 bit timer on the current board - * timer16_Sequence_t enumerates the sequence that the timers should be allocated - * _Nbr_16timers indicates how many 16 bit timers are available. - */ - -// Architecture specific include -#if defined(ARDUINO_ARCH_MEGAAVR) && defined(MEGATINYCORE) -#include "megaavr/ServoTimers.h" -#if (F_CPU==1000000) -#warning "Running at 1MHz results in unstable servo signal." -#endif -#else -#error "This version of the library only supports megaTinyCore-supported processors." -#endif - -#define Servo_VERSION 2 // software version of this library - -#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo -#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo -#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached -#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds - -#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer -#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) - -#define INVALID_SERVO 255 // flag indicating an invalid servo index - -#if !defined(ARDUINO_ARCH_STM32F4) - -typedef struct { - uint8_t nbr :6 ; // a pin number from 0 to 63 - uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false -} ServoPin_t ; - -typedef struct { - ServoPin_t Pin; - volatile unsigned int ticks; -} servo_t; - -class Servo -{ -public: - Servo(); - uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure - uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. - void detach(); - void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds - void writeMicroseconds(int value); // Write pulse width in microseconds - int read(); // returns current pulse width as an angle between 0 and 180 degrees - int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) - bool attached(); // return true if this servo is attached, otherwise false -private: - uint8_t servoIndex; // index into the channel data for this servo - int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH - int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH -}; - -#endif -#endif diff --git a/megaavr/libraries/Servo/src/megaavr/Servo.cpp b/megaavr/libraries/Servo/src/megaavr/Servo.cpp deleted file mode 100644 index 236ccd4b..00000000 --- a/megaavr/libraries/Servo/src/megaavr/Servo.cpp +++ /dev/null @@ -1,210 +0,0 @@ -#if defined(ARDUINO_ARCH_MEGAAVR) - -#include -#include - -#define usToTicks(_us) ((( _us / 16) * clockCyclesPerMicrosecond()) / 4) // converts microseconds to tick -#define ticksToUs(_ticks) (((unsigned) _ticks * 16 * 4) / clockCyclesPerMicrosecond()) // converts from ticks back to microseconds - -#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays - -static servo_t servos[MAX_SERVOS]; // static array of servo structures - -uint8_t ServoCount = 0; // the total number of attached servos - -static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval) - -// convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel - -#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo -#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo - -void ServoHandler(int timer) -{ - if (currentServoIndex[timer] < 0) { - // Write compare register - _timer->CCMP = 0; - } else { - if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && SERVO(timer, currentServoIndex[timer]).Pin.isActive == true) { - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, LOW); // pulse this channel low if activated - } - } - - // Select the next servo controlled by this timer - currentServoIndex[timer]++; - - if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && currentServoIndex[timer] < SERVOS_PER_TIMER) { - if (SERVO(timer, currentServoIndex[timer]).Pin.isActive == true) { // check if activated - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high - } - - // Get the counter value - uint16_t tcCounterValue = 0; //_timer->CCMP; - _timer->CCMP = (uint16_t) (tcCounterValue + SERVO(timer, currentServoIndex[timer]).ticks); - } - else { - // finished all channels so wait for the refresh period to expire before starting over - - // Get the counter value - uint16_t tcCounterValue = _timer->CCMP; - - if (tcCounterValue + 4UL < usToTicks(REFRESH_INTERVAL)) { // allow a few ticks to ensure the next OCR1A not missed - _timer->CCMP = (uint16_t) usToTicks(REFRESH_INTERVAL); - } - else { - _timer->CCMP = (uint16_t) (tcCounterValue + 4UL); // at least REFRESH_INTERVAL has elapsed - } - - currentServoIndex[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - } - - /* Clear flag */ - _timer->INTFLAGS = TCB_CAPT_bm; -} - -#if defined USE_TIMERB0 -ISR(TCB0_INT_vect) -#elif defined USE_TIMERB1 -ISR(TCB1_INT_vect) -#elif defined USE_TIMERB2 -ISR(TCB2_INT_vect) -#endif -{ - ServoHandler(0); -} - -static void initISR(timer16_Sequence_t timer) -{ - //TCA0.SINGLE.CTRLA = (TCA_SINGLE_CLKSEL_DIV16_gc) | (TCA_SINGLE_ENABLE_bm); - _timer->CTRLA = TCB_CLKSEL_CLKTCA_gc; - // Timer to Periodic interrupt mode - // This write will also disable any active PWM outputs - _timer->CTRLB = TCB_CNTMODE_INT_gc; - // Enable interrupt - _timer->INTCTRL = TCB_CAPTEI_bm; - // Enable timer - _timer->CTRLA |= TCB_ENABLE_bm; -} - -static void finISR(timer16_Sequence_t timer) -{ - // Disable interrupt - _timer->INTCTRL = 0; -} - -static boolean isTimerActive(timer16_Sequence_t timer) -{ - // returns true if any servo is active on this timer - for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { - if(SERVO(timer,channel).Pin.isActive == true) - return true; - } - return false; -} - -/****************** end of static functions ******************************/ - -Servo::Servo() -{ - if (ServoCount < MAX_SERVOS) { - this->servoIndex = ServoCount++; // assign a servo index to this instance - servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - } else { - this->servoIndex = INVALID_SERVO; // too many servos - } -} - -uint8_t Servo::attach(int pin) -{ - return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); -} - -uint8_t Servo::attach(int pin, int min, int max) -{ - timer16_Sequence_t timer; - - if (this->servoIndex < MAX_SERVOS) { - pinMode(pin, OUTPUT); // set servo pin to output - servos[this->servoIndex].Pin.nbr = pin; - // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 - this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS - this->max = (MAX_PULSE_WIDTH - max)/4; - // initialize the timer if it has not already been initialized - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if (isTimerActive(timer) == false) { - initISR(timer); - } - servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive - } - return this->servoIndex; -} - -void Servo::detach() -{ - timer16_Sequence_t timer; - - servos[this->servoIndex].Pin.isActive = false; - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) { - finISR(timer); - } -} - -void Servo::write(int value) -{ - // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - if (value < MIN_PULSE_WIDTH) - { - if (value < 0) - value = 0; - else if (value > 180) - value = 180; - - value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); - } - writeMicroseconds(value); -} - -void Servo::writeMicroseconds(int value) -{ - // calculate and store the values for the given channel - byte channel = this->servoIndex; - if( (channel < MAX_SERVOS) ) // ensure channel is valid - { - if (value < SERVO_MIN()) // ensure pulse width is valid - value = SERVO_MIN(); - else if (value > SERVO_MAX()) - value = SERVO_MAX(); - - value = value - TRIM_DURATION; - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - servos[channel].ticks = value; - } -} - -int Servo::read() // return the value as degrees -{ - return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); -} - -int Servo::readMicroseconds() -{ - unsigned int pulsewidth; - if (this->servoIndex != INVALID_SERVO) - pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; - else - pulsewidth = 0; - - return pulsewidth; -} - -bool Servo::attached() -{ - return servos[this->servoIndex].Pin.isActive; -} - -#endif \ No newline at end of file diff --git a/megaavr/libraries/Servo/src/megaavr/ServoTimers.h b/megaavr/libraries/Servo/src/megaavr/ServoTimers.h deleted file mode 100644 index 145f3c4d..00000000 --- a/megaavr/libraries/Servo/src/megaavr/ServoTimers.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (c) 2018 Arduino LLC. 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 -*/ - -/* - * Defines for 16 bit timers used with Servo library - * - */ - -// Adapted by Spence Konde for megaTinyCore 2019 - - -#ifndef __SERVO_TIMERS_H__ -#define __SERVO_TIMERS_H__ - -#ifdef TCB1 -#define USE_TIMERB1 -#else -#define USE_TIMERB0 -#endif - -#if !defined(USE_TIMERB1) && !defined(USE_TIMERB2) && !defined(USE_TIMERB0) - # error "Can't Happen: No timer available for servo. Please report this to github.com/SpenceKonde/megaTinyCore" -#endif - -static volatile TCB_t* _timer = -#if defined(USE_TIMERB0) -&TCB0; -#endif -#if defined(USE_TIMERB1) -&TCB1; -#endif -#if defined(USE_TIMERB2) -&TCB2; -#endif - -typedef enum { - timer0, - _Nbr_16timers } timer16_Sequence_t; - - -#endif /* __SERVO_TIMERS_H__ */ diff --git a/megaavr/libraries/Servo_megaTinyCore/examples/Knob/Knob.ino b/megaavr/libraries/Servo_megaTinyCore/examples/Knob/Knob.ino deleted file mode 100644 index 0db8770b..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/examples/Knob/Knob.ino +++ /dev/null @@ -1,27 +0,0 @@ -/* - Controlling a servo position using a potentiometer (variable resistor) - by Michal Rinott - - modified on 8 Nov 2013 - by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/Knob -*/ - -#include - -Servo myservo; // create servo object to control a servo - -int potpin = 0; // analog pin used to connect the potentiometer -int val; // variable to read the value from the analog pin - -void setup() { - myservo.attach(9); // attaches the servo on pin 9 to the servo object -} - -void loop() { - val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) - val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) - myservo.write(val); // sets the servo position according to the scaled value - delay(15); // waits for the servo to get there -} - diff --git a/megaavr/libraries/Servo_megaTinyCore/examples/Sweep/Sweep.ino b/megaavr/libraries/Servo_megaTinyCore/examples/Sweep/Sweep.ino deleted file mode 100644 index df904afb..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/examples/Sweep/Sweep.ino +++ /dev/null @@ -1,32 +0,0 @@ -/* Sweep - by BARRAGAN - This example code is in the public domain. - - modified 8 Nov 2013 - by Scott Fitzgerald - http://www.arduino.cc/en/Tutorial/Sweep -*/ - -#include - -Servo myservo; // create servo object to control a servo -// twelve servo objects can be created on most boards - -int pos = 0; // variable to store the servo position - -void setup() { - myservo.attach(9); // attaches the servo on pin 9 to the servo object -} - -void loop() { - for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees - // in steps of 1 degree - myservo.write(pos); // tell servo to go to position in variable 'pos' - delay(15); // waits 15ms for the servo to reach the position - } - for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees - myservo.write(pos); // tell servo to go to position in variable 'pos' - delay(15); // waits 15ms for the servo to reach the position - } -} - diff --git a/megaavr/libraries/Servo_megaTinyCore/keywords.txt b/megaavr/libraries/Servo_megaTinyCore/keywords.txt deleted file mode 100644 index 0a7ca1e3..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/keywords.txt +++ /dev/null @@ -1,24 +0,0 @@ -####################################### -# Syntax Coloring Map Servo -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -Servo KEYWORD1 Servo - -####################################### -# Methods and Functions (KEYWORD2) -####################################### -attach KEYWORD2 -detach KEYWORD2 -write KEYWORD2 -read KEYWORD2 -attached KEYWORD2 -writeMicroseconds KEYWORD2 -readMicroseconds KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/megaavr/libraries/Servo_megaTinyCore/library.properties b/megaavr/libraries/Servo_megaTinyCore/library.properties deleted file mode 100644 index e90e1647..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Servo_megaTinyCore -version=1.1.4 -author=Spence Konde based on work by Michael Margolis, Arduino -maintainer=Spence Konde -sentence=Allows megaTinyCore-supported parts to control a variety of servo motors. -paragraph=This library can control a great number of servos.
It makes careful use of timers: the library can control 12 servos using only 1 timer.
-category=Device Control -url=http://www.arduino.cc/en/Reference/Servo -architectures=megaavr diff --git a/megaavr/libraries/Servo_megaTinyCore/src/Servo_megaTinyCore.h b/megaavr/libraries/Servo_megaTinyCore/src/Servo_megaTinyCore.h deleted file mode 100644 index d43d2d98..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/src/Servo_megaTinyCore.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. 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 -*/ - -/* - A servo is activated by creating an instance of the Servo class passing - the desired pin to the attach() method. - The servos are pulsed in the background using the value most recently - written using the write() method. - - Note that analogWrite of PWM on pins associated with the timer are - disabled when the first servo is attached. - Timers are seized as needed in groups of 12 servos - 24 servos use two - timers, 48 servos will use four. - The sequence used to sieze timers is defined in timers.h - - The methods are: - - Servo - Class for manipulating servo motors connected to Arduino pins. - - attach(pin ) - Attaches a servo motor to an i/o pin. - attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds - default min is 544, max is 2400 - - write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) - writeMicroseconds() - Sets the servo pulse width in microseconds - read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) - attached() - Returns true if there is a servo attached. - detach() - Stops an attached servos from pulsing its i/o pin. - */ - -#ifndef Servo_h -#define Servo_h - -#include - -/* - * Defines for 16 bit timers used with Servo library - * - * If _useTimerX is defined then TimerX is a 16 bit timer on the current board - * timer16_Sequence_t enumerates the sequence that the timers should be allocated - * _Nbr_16timers indicates how many 16 bit timers are available. - */ - -// Architecture specific include -#if defined(ARDUINO_ARCH_MEGAAVR) && defined(MEGATINYCORE) -#include "megaavr/ServoTimers.h" -#if (F_CPU==1000000) -#warning "Running at 1MHz results in unstable servo signal." -#endif -#else -#error "This version of the library only supports megaTinyCore-supported processors." -#endif - -#define Servo_VERSION 2 // software version of this library - -#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo -#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo -#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached -#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds - -#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer -#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) - -#define INVALID_SERVO 255 // flag indicating an invalid servo index - -#if !defined(ARDUINO_ARCH_STM32F4) - -typedef struct { - uint8_t nbr :6 ; // a pin number from 0 to 63 - uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false -} ServoPin_t ; - -typedef struct { - ServoPin_t Pin; - volatile unsigned int ticks; -} servo_t; - -class Servo -{ -public: - Servo(); - uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure - uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. - void detach(); - void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds - void writeMicroseconds(int value); // Write pulse width in microseconds - int read(); // returns current pulse width as an angle between 0 and 180 degrees - int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) - bool attached(); // return true if this servo is attached, otherwise false -private: - uint8_t servoIndex; // index into the channel data for this servo - int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH - int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH -}; - -#endif -#endif diff --git a/megaavr/libraries/Servo_megaTinyCore/src/megaavr/ServoTimers.h b/megaavr/libraries/Servo_megaTinyCore/src/megaavr/ServoTimers.h deleted file mode 100644 index 145f3c4d..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/src/megaavr/ServoTimers.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (c) 2018 Arduino LLC. 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 -*/ - -/* - * Defines for 16 bit timers used with Servo library - * - */ - -// Adapted by Spence Konde for megaTinyCore 2019 - - -#ifndef __SERVO_TIMERS_H__ -#define __SERVO_TIMERS_H__ - -#ifdef TCB1 -#define USE_TIMERB1 -#else -#define USE_TIMERB0 -#endif - -#if !defined(USE_TIMERB1) && !defined(USE_TIMERB2) && !defined(USE_TIMERB0) - # error "Can't Happen: No timer available for servo. Please report this to github.com/SpenceKonde/megaTinyCore" -#endif - -static volatile TCB_t* _timer = -#if defined(USE_TIMERB0) -&TCB0; -#endif -#if defined(USE_TIMERB1) -&TCB1; -#endif -#if defined(USE_TIMERB2) -&TCB2; -#endif - -typedef enum { - timer0, - _Nbr_16timers } timer16_Sequence_t; - - -#endif /* __SERVO_TIMERS_H__ */ diff --git a/megaavr/libraries/Servo_megaTinyCore/src/megaavr/Servo_megaTinyCore.cpp b/megaavr/libraries/Servo_megaTinyCore/src/megaavr/Servo_megaTinyCore.cpp deleted file mode 100644 index eb5bbbf0..00000000 --- a/megaavr/libraries/Servo_megaTinyCore/src/megaavr/Servo_megaTinyCore.cpp +++ /dev/null @@ -1,210 +0,0 @@ -#if defined(ARDUINO_ARCH_MEGAAVR) - -#include -#include - -#define usToTicks(_us) ((( _us / 16) * clockCyclesPerMicrosecond()) / 4) // converts microseconds to tick -#define ticksToUs(_ticks) (((unsigned) _ticks * 16 * 4) / clockCyclesPerMicrosecond()) // converts from ticks back to microseconds - -#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays - -static servo_t servos[MAX_SERVOS]; // static array of servo structures - -uint8_t ServoCount = 0; // the total number of attached servos - -static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval) - -// convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel - -#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo -#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo - -void ServoHandler(int timer) -{ - if (currentServoIndex[timer] < 0) { - // Write compare register - _timer->CCMP = 0; - } else { - if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && SERVO(timer, currentServoIndex[timer]).Pin.isActive == true) { - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, LOW); // pulse this channel low if activated - } - } - - // Select the next servo controlled by this timer - currentServoIndex[timer]++; - - if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && currentServoIndex[timer] < SERVOS_PER_TIMER) { - if (SERVO(timer, currentServoIndex[timer]).Pin.isActive == true) { // check if activated - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high - } - - // Get the counter value - uint16_t tcCounterValue = 0; //_timer->CCMP; - _timer->CCMP = (uint16_t) (tcCounterValue + SERVO(timer, currentServoIndex[timer]).ticks); - } - else { - // finished all channels so wait for the refresh period to expire before starting over - - // Get the counter value - uint16_t tcCounterValue = _timer->CCMP; - - if (tcCounterValue + 4UL < usToTicks(REFRESH_INTERVAL)) { // allow a few ticks to ensure the next OCR1A not missed - _timer->CCMP = (uint16_t) usToTicks(REFRESH_INTERVAL); - } - else { - _timer->CCMP = (uint16_t) (tcCounterValue + 4UL); // at least REFRESH_INTERVAL has elapsed - } - - currentServoIndex[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - } - - /* Clear flag */ - _timer->INTFLAGS = TCB_CAPT_bm; -} - -#if defined USE_TIMERB0 -ISR(TCB0_INT_vect) -#elif defined USE_TIMERB1 -ISR(TCB1_INT_vect) -#elif defined USE_TIMERB2 -ISR(TCB2_INT_vect) -#endif -{ - ServoHandler(0); -} - -static void initISR(timer16_Sequence_t timer) -{ - //TCA0.SINGLE.CTRLA = (TCA_SINGLE_CLKSEL_DIV16_gc) | (TCA_SINGLE_ENABLE_bm); - _timer->CTRLA = TCB_CLKSEL_CLKTCA_gc; - // Timer to Periodic interrupt mode - // This write will also disable any active PWM outputs - _timer->CTRLB = TCB_CNTMODE_INT_gc; - // Enable interrupt - _timer->INTCTRL = TCB_CAPTEI_bm; - // Enable timer - _timer->CTRLA |= TCB_ENABLE_bm; -} - -static void finISR(timer16_Sequence_t timer) -{ - // Disable interrupt - _timer->INTCTRL = 0; -} - -static boolean isTimerActive(timer16_Sequence_t timer) -{ - // returns true if any servo is active on this timer - for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { - if(SERVO(timer,channel).Pin.isActive == true) - return true; - } - return false; -} - -/****************** end of static functions ******************************/ - -Servo::Servo() -{ - if (ServoCount < MAX_SERVOS) { - this->servoIndex = ServoCount++; // assign a servo index to this instance - servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - } else { - this->servoIndex = INVALID_SERVO; // too many servos - } -} - -uint8_t Servo::attach(int pin) -{ - return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); -} - -uint8_t Servo::attach(int pin, int min, int max) -{ - timer16_Sequence_t timer; - - if (this->servoIndex < MAX_SERVOS) { - pinMode(pin, OUTPUT); // set servo pin to output - servos[this->servoIndex].Pin.nbr = pin; - // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 - this->min = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS - this->max = (MAX_PULSE_WIDTH - max)/4; - // initialize the timer if it has not already been initialized - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if (isTimerActive(timer) == false) { - initISR(timer); - } - servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive - } - return this->servoIndex; -} - -void Servo::detach() -{ - timer16_Sequence_t timer; - - servos[this->servoIndex].Pin.isActive = false; - timer = SERVO_INDEX_TO_TIMER(servoIndex); - if(isTimerActive(timer) == false) { - finISR(timer); - } -} - -void Servo::write(int value) -{ - // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) - if (value < MIN_PULSE_WIDTH) - { - if (value < 0) - value = 0; - else if (value > 180) - value = 180; - - value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); - } - writeMicroseconds(value); -} - -void Servo::writeMicroseconds(int value) -{ - // calculate and store the values for the given channel - byte channel = this->servoIndex; - if( (channel < MAX_SERVOS) ) // ensure channel is valid - { - if (value < SERVO_MIN()) // ensure pulse width is valid - value = SERVO_MIN(); - else if (value > SERVO_MAX()) - value = SERVO_MAX(); - - value = value - TRIM_DURATION; - value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - servos[channel].ticks = value; - } -} - -int Servo::read() // return the value as degrees -{ - return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); -} - -int Servo::readMicroseconds() -{ - unsigned int pulsewidth; - if (this->servoIndex != INVALID_SERVO) - pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; - else - pulsewidth = 0; - - return pulsewidth; -} - -bool Servo::attached() -{ - return servos[this->servoIndex].Pin.isActive; -} - -#endif \ No newline at end of file diff --git a/megaavr/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/megaavr/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino deleted file mode 100644 index 61ce88c6..00000000 --- a/megaavr/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino +++ /dev/null @@ -1,55 +0,0 @@ -/* - Software serial multple serial test - - Receives from the hardware serial, sends to software serial. - Receives from software serial, sends to hardware serial. - - The circuit: - * RX is digital pin 10 (connect to TX of other device) - * TX is digital pin 11 (connect to RX of other device) - - Note: - Not all pins on the Mega and Mega 2560 support change interrupts, - so only the following can be used for RX: - 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 - - Not all pins on the Leonardo and Micro support change interrupts, - so only the following can be used for RX: - 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). - - created back in the mists of time - modified 25 May 2012 - by Tom Igoe - based on Mikal Hart's example - - This example code is in the public domain. - - */ -#include - -SoftwareSerial mySerial(10, 11); // RX, TX - -void setup() { - // Open serial communications and wait for port to open: - Serial.begin(57600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - - Serial.println("Goodnight moon!"); - - // set the data rate for the SoftwareSerial port - mySerial.begin(4800); - mySerial.println("Hello, world?"); -} - -void loop() { // run over and over - if (mySerial.available()) { - Serial.write(mySerial.read()); - } - if (Serial.available()) { - mySerial.write(Serial.read()); - } -} - diff --git a/megaavr/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/megaavr/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino deleted file mode 100644 index 8d7f93e8..00000000 --- a/megaavr/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino +++ /dev/null @@ -1,91 +0,0 @@ -/* - Software serial multple serial test - - Receives from the two software serial ports, - sends to the hardware serial port. - - In order to listen on a software port, you call port.listen(). - When using two software serial ports, you have to switch ports - by listen()ing on each one in turn. Pick a logical time to switch - ports, like the end of an expected transmission, or when the - buffer is empty. This example switches ports when there is nothing - more to read from a port - - The circuit: - Two devices which communicate serially are needed. - * First serial device's TX attached to digital pin 10(RX), RX to pin 11(TX) - * Second serial device's TX attached to digital pin 8(RX), RX to pin 9(TX) - - Note: - Not all pins on the Mega and Mega 2560 support change interrupts, - so only the following can be used for RX: - 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 - - Not all pins on the Leonardo support change interrupts, - so only the following can be used for RX: - 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). - - created 18 Apr. 2011 - modified 19 March 2016 - by Tom Igoe - based on Mikal Hart's twoPortRXExample - - This example code is in the public domain. - - */ - -#include -// software serial #1: RX = digital pin 10, TX = digital pin 11 -SoftwareSerial portOne(10, 11); - -// software serial #2: RX = digital pin 8, TX = digital pin 9 -// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega -SoftwareSerial portTwo(8, 9); - -void setup() { - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - - // Start each software serial port - portOne.begin(9600); - portTwo.begin(9600); -} - -void loop() { - // By default, the last intialized port is listening. - // when you want to listen on a port, explicitly select it: - portOne.listen(); - Serial.println("Data from port one:"); - // while there is data coming in, read it - // and send to the hardware serial port: - while (portOne.available() > 0) { - char inByte = portOne.read(); - Serial.write(inByte); - } - - // blank line to separate data from the two ports: - Serial.println(); - - // Now listen on the second port - portTwo.listen(); - // while there is data coming in, read it - // and send to the hardware serial port: - Serial.println("Data from port two:"); - while (portTwo.available() > 0) { - char inByte = portTwo.read(); - Serial.write(inByte); - } - - // blank line to separate data from the two ports: - Serial.println(); -} - - - - - - diff --git a/megaavr/libraries/SoftwareSerial/keywords.txt b/megaavr/libraries/SoftwareSerial/keywords.txt deleted file mode 100644 index aaea17c2..00000000 --- a/megaavr/libraries/SoftwareSerial/keywords.txt +++ /dev/null @@ -1,30 +0,0 @@ -####################################### -# Syntax Coloring Map for SoftwareSerial -# (formerly NewSoftSerial) -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -SoftwareSerial KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -end KEYWORD2 -read KEYWORD2 -write KEYWORD2 -available KEYWORD2 -isListening KEYWORD2 -overflow KEYWORD2 -flush KEYWORD2 -listen KEYWORD2 -peek KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/megaavr/libraries/SoftwareSerial/library.properties b/megaavr/libraries/SoftwareSerial/library.properties deleted file mode 100644 index 245c2f33..00000000 --- a/megaavr/libraries/SoftwareSerial/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=SoftwareSerial -version=1.0 -author=Arduino -maintainer=Arduino -sentence=Enables serial communication on any digital pin. -paragraph=The SoftwareSerial library has been developed to allow serial communication on any digital pin of the board, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. -category=Communication -url=http://www.arduino.cc/en/Reference/SoftwareSerial -architectures=megaavr - diff --git a/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.cpp b/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.cpp deleted file mode 100644 index 6c101a1f..00000000 --- a/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.cpp +++ /dev/null @@ -1,459 +0,0 @@ -/* -SoftwareSerial.cpp (formerly NewSoftSerial.cpp) - -Multi-instance software serial library for Arduino/Wiring --- Interrupt-driven receive and other improvements by ladyada - (http://ladyada.net) --- Tuning, circular buffer, derivation from class Print/Stream, - multi-instance support, porting to 8MHz processors, - various optimizations, PROGMEM delay tables, inverse logic and - direct port writing by Mikal Hart (http://www.arduiniana.org) --- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) --- 20MHz processor support by Garrett Mace (http://www.macetech.com) --- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) - -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 - -The latest version of this library can always be found at -http://arduiniana.org. -*/ - -// When set, _DEBUG co-opts pins 11 and 13 for debugging with an -// oscilloscope or logic analyzer. Beware: it also slightly modifies -// the bit times, so don't rely on it too much at high baud rates -#define _DEBUG 0 -#define _DEBUG_PIN1 11 -#define _DEBUG_PIN2 13 -// -// Includes -// -#include -#include -#include -#include -#include - -// -// Statics -// -SoftwareSerial *SoftwareSerial::active_object = 0; -uint8_t SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF]; -volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; -volatile uint8_t SoftwareSerial::_receive_buffer_head = 0; - -// -// Debugging -// -// This function generates a brief pulse -// for debugging or measuring on an oscilloscope. -#if _DEBUG -inline void DebugPulse(uint8_t pin, uint8_t count) -{ - volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin)); - - uint8_t val = *pport; - while (count--) - { - *pport = val | digitalPinToBitMask(pin); - *pport = val; - } -} -#else -inline void DebugPulse(uint8_t, uint8_t) {} -#endif - -// -// Private methods -// - -/* static */ -inline void SoftwareSerial::tunedDelay(uint16_t delay) { - _delay_loop_2(delay); -} - -// This function sets the current object as the "listening" -// one and returns true if it replaces another -bool SoftwareSerial::listen() -{ - if (!_rx_delay_stopbit) - return false; - - if (active_object != this) - { - if (active_object) - active_object->stopListening(); - - _buffer_overflow = false; - _receive_buffer_head = _receive_buffer_tail = 0; - active_object = this; - - setRxIntMsk(true); - return true; - } - - return false; -} - -// Stop listening. Returns true if we were actually listening. -bool SoftwareSerial::stopListening() -{ - if (active_object == this) - { - setRxIntMsk(false); - active_object = NULL; - return true; - } - return false; -} - -// -// The receive routine called by the interrupt handler -// -void SoftwareSerial::recv() -{ - -#if GCC_VERSION < 40302 -// Work-around for avr-gcc 4.3.0 OSX version bug -// Preserve the registers that the compiler misses -// (courtesy of Arduino forum user *etracer*) - asm volatile( - "push r18 \n\t" - "push r19 \n\t" - "push r20 \n\t" - "push r21 \n\t" - "push r22 \n\t" - "push r23 \n\t" - "push r26 \n\t" - "push r27 \n\t" - ::); -#endif - - uint8_t d = 0; - - // If RX line is high, then we don't see any start bit - // so interrupt is probably not for us - if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) - { - // Disable further interrupts during reception, this prevents - // triggering another interrupt directly after we return, which can - // cause problems at higher baudrates. - setRxIntMsk(false); - - // Wait approximately 1/2 of a bit width to "center" the sample - tunedDelay(_rx_delay_centering); - DebugPulse(_DEBUG_PIN2, 1); - - // Read each of the 8 bits - for (uint8_t i=8; i > 0; --i) - { - tunedDelay(_rx_delay_intrabit); - d >>= 1; - DebugPulse(_DEBUG_PIN2, 1); - if (rx_pin_read()) - d |= 0x80; - } - - if (_inverse_logic) - d = ~d; - - // if buffer full, set the overflow flag and return - uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF; - if (next != _receive_buffer_head) - { - // save new data in buffer: tail points to where byte goes - _receive_buffer[_receive_buffer_tail] = d; // save new byte - _receive_buffer_tail = next; - } - else - { - DebugPulse(_DEBUG_PIN1, 1); - _buffer_overflow = true; - } - - // skip the stop bit - tunedDelay(_rx_delay_stopbit); - DebugPulse(_DEBUG_PIN1, 1); - - // Re-enable interrupts when we're sure to be inside the stop bit - setRxIntMsk(true); - - } - -#if GCC_VERSION < 40302 -// Work-around for avr-gcc 4.3.0 OSX version bug -// Restore the registers that the compiler misses - asm volatile( - "pop r27 \n\t" - "pop r26 \n\t" - "pop r23 \n\t" - "pop r22 \n\t" - "pop r21 \n\t" - "pop r20 \n\t" - "pop r19 \n\t" - "pop r18 \n\t" - ::); -#endif -} - -uint8_t SoftwareSerial::rx_pin_read() -{ - return *_receivePortRegister & _receiveBitMask; -} - -// -// Interrupt handling -// - -/* static */ -inline void SoftwareSerial::handle_interrupt() -{ - if (active_object) - { - active_object->recv(); - } -} - -// -// Constructor -// -SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) : - _rx_delay_centering(0), - _rx_delay_intrabit(0), - _rx_delay_stopbit(0), - _tx_delay(0), - _buffer_overflow(false), - _inverse_logic(inverse_logic) -{ - setTX(transmitPin); - setRX(receivePin); -} - -// -// Destructor -// -SoftwareSerial::~SoftwareSerial() -{ - end(); -} - -void SoftwareSerial::setTX(uint8_t tx) -{ - // First write, then set output. If we do this the other way around, - // the pin would be output low for a short while before switching to - // output high. Now, it is input with pullup for a short while, which - // is fine. With inverse logic, either order is fine. - digitalWrite(tx, _inverse_logic ? LOW : HIGH); - pinMode(tx, OUTPUT); - _transmitBitMask = digitalPinToBitMask(tx); - uint8_t port = digitalPinToPort(tx); - _transmitPortRegister = portOutputRegister(port); -} - -void SoftwareSerial::setRX(uint8_t rx) -{ - pinMode(rx, INPUT); - if (!_inverse_logic) - digitalWrite(rx, HIGH); // pullup for normal logic! - _receivePin = rx; - _receiveBitMask = digitalPinToBitMask(rx); - uint8_t port = digitalPinToPort(rx); - _receivePortRegister = portInputRegister(port); -} - -uint16_t SoftwareSerial::subtract_cap(uint16_t num, uint16_t sub) { - if (num > sub) - return num - sub; - else - return 1; -} - -// -// Public methods -// - -void SoftwareSerial::begin(long speed) -{ - _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; - - // Precalculate the various delays, in number of 4-cycle delays - uint16_t bit_delay = (F_CPU / speed) / 4; - - // 12 (gcc 4.8.2) or 13 (gcc 4.3.2) cycles from start bit to first bit, - // 15 (gcc 4.8.2) or 16 (gcc 4.3.2) cycles between bits, - // 12 (gcc 4.8.2) or 14 (gcc 4.3.2) cycles from last bit to stop bit - // These are all close enough to just use 15 cycles, since the inter-bit - // timings are the most critical (deviations stack 8 times) - _tx_delay = subtract_cap(bit_delay, 15 / 4); - - // Only setup rx when we have a valid PCINT for this pin - if (1) { - #if GCC_VERSION > 40800 - // Timings counted from gcc 4.8.2 output. This works up to 115200 on - // 16Mhz and 57600 on 8Mhz. - // - // When the start bit occurs, there are 3 or 4 cycles before the - // interrupt flag is set, 4 cycles before the PC is set to the right - // interrupt vector address and the old PC is pushed on the stack, - // and then 75 cycles of instructions (including the RJMP in the - // ISR vector table) until the first delay. After the delay, there - // are 17 more cycles until the pin value is read (excluding the - // delay in the loop). - // We want to have a total delay of 1.5 bit time. Inside the loop, - // we already wait for 1 bit time - 23 cycles, so here we wait for - // 0.5 bit time - (71 + 18 - 22) cycles. - _rx_delay_centering = subtract_cap(bit_delay / 2, (4 + 4 + 75 + 17 - 23) / 4); - - // There are 23 cycles in each loop iteration (excluding the delay) - _rx_delay_intrabit = subtract_cap(bit_delay, 23 / 4); - - // There are 37 cycles from the last bit read to the start of - // stopbit delay and 11 cycles from the delay until the interrupt - // mask is enabled again (which _must_ happen during the stopbit). - // This delay aims at 3/4 of a bit time, meaning the end of the - // delay will be at 1/4th of the stopbit. This allows some extra - // time for ISR cleanup, which makes 115200 baud at 16Mhz work more - // reliably - _rx_delay_stopbit = subtract_cap(bit_delay * 3 / 4, (37 + 11) / 4); - #else // Timings counted from gcc 4.3.2 output - // Note that this code is a _lot_ slower, mostly due to bad register - // allocation choices of gcc. This works up to 57600 on 16Mhz and - // 38400 on 8Mhz. - _rx_delay_centering = subtract_cap(bit_delay / 2, (4 + 4 + 97 + 29 - 11) / 4); - _rx_delay_intrabit = subtract_cap(bit_delay, 11 / 4); - _rx_delay_stopbit = subtract_cap(bit_delay * 3 / 4, (44 + 17) / 4); - #endif - - attachInterrupt(_receivePin, SoftwareSerial::handle_interrupt, CHANGE); - - tunedDelay(_tx_delay); // if we were low this establishes the end - } - -#if _DEBUG - pinMode(_DEBUG_PIN1, OUTPUT); - pinMode(_DEBUG_PIN2, OUTPUT); -#endif - - listen(); -} - -void SoftwareSerial::setRxIntMsk(bool enable) -{ - if (enable) - *_pcint_maskreg |= _pcint_maskvalue; - else - *_pcint_maskreg &= ~_pcint_maskvalue; -} - -void SoftwareSerial::end() -{ - stopListening(); -} - - -// Read data from buffer -int SoftwareSerial::read() -{ - if (!isListening()) - return -1; - - // Empty buffer? - if (_receive_buffer_head == _receive_buffer_tail) - return -1; - - // Read from "head" - uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte - _receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF; - return d; -} - -int SoftwareSerial::available() -{ - if (!isListening()) - return 0; - - return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF; -} - -size_t SoftwareSerial::write(uint8_t b) -{ - if (_tx_delay == 0) { - setWriteError(); - return 0; - } - - // By declaring these as local variables, the compiler will put them - // in registers _before_ disabling interrupts and entering the - // critical timing sections below, which makes it a lot easier to - // verify the cycle timings - volatile uint8_t *reg = _transmitPortRegister; - uint8_t reg_mask = _transmitBitMask; - uint8_t inv_mask = ~_transmitBitMask; - uint8_t oldSREG = SREG; - bool inv = _inverse_logic; - uint16_t delay = _tx_delay; - - if (inv) - b = ~b; - - cli(); // turn off interrupts for a clean txmit - - // Write the start bit - if (inv) - *reg |= reg_mask; - else - *reg &= inv_mask; - - tunedDelay(delay); - - // Write each of the 8 bits - for (uint8_t i = 8; i > 0; --i) - { - if (b & 1) // choose bit - *reg |= reg_mask; // send 1 - else - *reg &= inv_mask; // send 0 - - tunedDelay(delay); - b >>= 1; - } - - // restore pin to natural state - if (inv) - *reg &= inv_mask; - else - *reg |= reg_mask; - - SREG = oldSREG; // turn interrupts back on - tunedDelay(_tx_delay); - - return 1; -} - -void SoftwareSerial::flush() -{ - // There is no tx buffering, simply return -} - -int SoftwareSerial::peek() -{ - if (!isListening()) - return -1; - - // Empty buffer? - if (_receive_buffer_head == _receive_buffer_tail) - return -1; - - // Read from "head" - return _receive_buffer[_receive_buffer_head]; -} diff --git a/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.h b/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.h deleted file mode 100644 index 5a139d4a..00000000 --- a/megaavr/libraries/SoftwareSerial/src/SoftwareSerial.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -SoftwareSerial.h (formerly NewSoftSerial.h) - -Multi-instance software serial library for Arduino/Wiring --- Interrupt-driven receive and other improvements by ladyada - (http://ladyada.net) --- Tuning, circular buffer, derivation from class Print/Stream, - multi-instance support, porting to 8MHz processors, - various optimizations, PROGMEM delay tables, inverse logic and - direct port writing by Mikal Hart (http://www.arduiniana.org) --- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) --- 20MHz processor support by Garrett Mace (http://www.macetech.com) --- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) - -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 - -The latest version of this library can always be found at -http://arduiniana.org. -*/ - -#ifndef SoftwareSerial_h -#define SoftwareSerial_h - -#include -#include - -/****************************************************************************** -* Definitions -******************************************************************************/ - -#ifndef _SS_MAX_RX_BUFF -#define _SS_MAX_RX_BUFF 64 // RX buffer size -#endif - -#ifndef GCC_VERSION -#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif - -class SoftwareSerial : public Stream -{ -private: - // per object data - uint8_t _receivePin; - uint8_t _receiveBitMask; - volatile uint8_t *_receivePortRegister; - uint8_t _transmitBitMask; - volatile uint8_t *_transmitPortRegister; - volatile uint8_t *_pcint_maskreg; - uint8_t _pcint_maskvalue; - - // Expressed as 4-cycle delays (must never be 0!) - uint16_t _rx_delay_centering; - uint16_t _rx_delay_intrabit; - uint16_t _rx_delay_stopbit; - uint16_t _tx_delay; - - uint16_t _buffer_overflow:1; - uint16_t _inverse_logic:1; - - // static data - static uint8_t _receive_buffer[_SS_MAX_RX_BUFF]; - static volatile uint8_t _receive_buffer_tail; - static volatile uint8_t _receive_buffer_head; - static SoftwareSerial *active_object; - - // private methods - inline void recv() __attribute__((__always_inline__)); - uint8_t rx_pin_read(); - void setTX(uint8_t transmitPin); - void setRX(uint8_t receivePin); - inline void setRxIntMsk(bool enable) __attribute__((__always_inline__)); - - // Return num - sub, or 1 if the result would be < 1 - static uint16_t subtract_cap(uint16_t num, uint16_t sub); - - // private static method for timing - static inline void tunedDelay(uint16_t delay); - -public: - // public methods - SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false); - ~SoftwareSerial(); - void begin(long speed); - bool listen(); - void end(); - bool isListening() { return this == active_object; } - bool stopListening(); - bool overflow() { bool ret = _buffer_overflow; if (ret) _buffer_overflow = false; return ret; } - int peek(); - - virtual size_t write(uint8_t byte); - virtual int read(); - virtual int available(); - virtual void flush(); - operator bool() { return true; } - - using Print::write; - - // public only for easy access by interrupt handlers - static inline void handle_interrupt() __attribute__((__always_inline__)); -}; - -// Arduino 0012 workaround -#undef int -#undef char -#undef long -#undef byte -#undef float -#undef abs -#undef round - -#endif diff --git a/megaavr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/megaavr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino deleted file mode 100644 index 4d0a68f8..00000000 --- a/megaavr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino +++ /dev/null @@ -1,84 +0,0 @@ -// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder -// by Nicholas Zambetti -// and James Tichenor - -// Demonstrates use of the Wire library reading data from the -// Devantech Utrasonic Rangers SFR08 and SFR10 - -// Created 29 April 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(); // join i2c bus (address optional for master) - Serial.begin(9600); // start serial communication at 9600bps -} - -int reading = 0; - -void loop() { - // step 1: instruct sensor to read echoes - Wire.beginTransmission(112); // transmit to device #112 (0x70) - // the address specified in the datasheet is 224 (0xE0) - // but i2c adressing uses the high 7 bits so it's 112 - Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) - Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) - // use 0x51 for centimeters - // use 0x52 for ping microseconds - Wire.endTransmission(); // stop transmitting - - // step 2: wait for readings to happen - delay(70); // datasheet suggests at least 65 milliseconds - - // step 3: instruct sensor to return a particular echo reading - Wire.beginTransmission(112); // transmit to device #112 - Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) - Wire.endTransmission(); // stop transmitting - - // step 4: request reading from sensor - Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 - - // step 5: receive reading from sensor - if (2 <= Wire.available()) { // if two bytes were received - reading = Wire.read(); // receive high byte (overwrites previous reading) - reading = reading << 8; // shift high byte to be high 8 bits - reading |= Wire.read(); // receive low byte as lower 8 bits - Serial.println(reading); // print the reading - } - - delay(250); // wait a bit since people have to read the output :) -} - - -/* - -// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08) -// usage: changeAddress(0x70, 0xE6); - -void changeAddress(byte oldAddress, byte newAddress) -{ - Wire.beginTransmission(oldAddress); - Wire.write(byte(0x00)); - Wire.write(byte(0xA0)); - Wire.endTransmission(); - - Wire.beginTransmission(oldAddress); - Wire.write(byte(0x00)); - Wire.write(byte(0xAA)); - Wire.endTransmission(); - - Wire.beginTransmission(oldAddress); - Wire.write(byte(0x00)); - Wire.write(byte(0xA5)); - Wire.endTransmission(); - - Wire.beginTransmission(oldAddress); - Wire.write(byte(0x00)); - Wire.write(newAddress); - Wire.endTransmission(); -} - -*/ diff --git a/megaavr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino b/megaavr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino deleted file mode 100644 index dd40a252..00000000 --- a/megaavr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino +++ /dev/null @@ -1,34 +0,0 @@ -// I2C Digital Potentiometer -// by Nicholas Zambetti -// and Shawn Bonkowski - -// Demonstrates use of the Wire library -// Controls AD5171 digital potentiometer via I2C/TWI - -// Created 31 March 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(); // join i2c bus (address optional for master) -} - -byte val = 0; - -void loop() { - Wire.beginTransmission(44); // transmit to device #44 (0x2c) - // device address is specified in datasheet - Wire.write(byte(0x00)); // sends instruction byte - Wire.write(val); // sends potentiometer value byte - Wire.endTransmission(); // stop transmitting - - val++; // increment value - if (val == 64) { // if reached 64th position (max) - val = 0; // start over from lowest value - } - delay(500); -} - diff --git a/megaavr/libraries/Wire/examples/master_reader/master_reader.ino b/megaavr/libraries/Wire/examples/master_reader/master_reader.ino deleted file mode 100644 index ecab72ab..00000000 --- a/megaavr/libraries/Wire/examples/master_reader/master_reader.ino +++ /dev/null @@ -1,29 +0,0 @@ -// Wire Master Reader -// by Nicholas Zambetti - -// Demonstrates use of the Wire library -// Reads data from an I2C/TWI slave device -// Refer to the "Wire Slave Sender" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(); // join i2c bus (address optional for master) - Serial.begin(9600); // start serial for output -} - -void loop() { - Wire.requestFrom(8, 6); // request 6 bytes from slave device #8 - - while (Wire.available()) { // slave may send less than requested - char c = Wire.read(); // receive a byte as character - Serial.print(c); // print the character - } - - delay(500); -} diff --git a/megaavr/libraries/Wire/examples/master_writer/master_writer.ino b/megaavr/libraries/Wire/examples/master_writer/master_writer.ino deleted file mode 100644 index 5cbea117..00000000 --- a/megaavr/libraries/Wire/examples/master_writer/master_writer.ino +++ /dev/null @@ -1,29 +0,0 @@ -// Wire Master Writer -// by Nicholas Zambetti - -// Demonstrates use of the Wire library -// Writes data to an I2C/TWI slave device -// Refer to the "Wire Slave Receiver" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(); // join i2c bus (address optional for master) -} - -byte x = 0; - -void loop() { - Wire.beginTransmission(8); // transmit to device #8 - Wire.write("x is "); // sends five bytes - Wire.write(x); // sends one byte - Wire.endTransmission(); // stop transmitting - - x++; - delay(500); -} diff --git a/megaavr/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/megaavr/libraries/Wire/examples/slave_receiver/slave_receiver.ino deleted file mode 100644 index 8051d53a..00000000 --- a/megaavr/libraries/Wire/examples/slave_receiver/slave_receiver.ino +++ /dev/null @@ -1,34 +0,0 @@ -// Wire Slave Receiver -// by Nicholas Zambetti - -// Demonstrates use of the Wire library -// Receives data as an I2C/TWI slave device -// Refer to the "Wire Master Writer" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(8); // join i2c bus with address #8 - Wire.onReceive(receiveEvent); // register event - Serial.begin(9600); // start serial for output -} - -void loop() { - delay(100); -} - -// function that executes whenever data is received from master -// this function is registered as an event, see setup() -void receiveEvent(int howMany) { - while (1 < Wire.available()) { // loop through all but the last - char c = Wire.read(); // receive byte as a character - Serial.print(c); // print the character - } - int x = Wire.read(); // receive byte as an integer - Serial.println(x); // print the integer -} diff --git a/megaavr/libraries/Wire/examples/slave_sender/slave_sender.ino b/megaavr/libraries/Wire/examples/slave_sender/slave_sender.ino deleted file mode 100644 index d2e72bbc..00000000 --- a/megaavr/libraries/Wire/examples/slave_sender/slave_sender.ino +++ /dev/null @@ -1,29 +0,0 @@ -// Wire Slave Sender -// by Nicholas Zambetti - -// Demonstrates use of the Wire library -// Sends data as an I2C/TWI slave device -// Refer to the "Wire Master Reader" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include - -void setup() { - Wire.begin(8); // join i2c bus with address #8 - Wire.onRequest(requestEvent); // register event -} - -void loop() { - delay(100); -} - -// function that executes whenever data is requested by master -// this function is registered as an event, see setup() -void requestEvent() { - Wire.write("hello "); // respond with message of 6 bytes - // as expected by master -} diff --git a/megaavr/libraries/Wire/keywords.txt b/megaavr/libraries/Wire/keywords.txt deleted file mode 100644 index 5e3d2b1c..00000000 --- a/megaavr/libraries/Wire/keywords.txt +++ /dev/null @@ -1,30 +0,0 @@ -####################################### -# Syntax Coloring Map For Wire -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -setClock KEYWORD2 -beginTransmission KEYWORD2 -endTransmission KEYWORD2 -requestFrom KEYWORD2 -onReceive KEYWORD2 -onRequest KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - -Wire KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/megaavr/libraries/Wire/library.properties b/megaavr/libraries/Wire/library.properties deleted file mode 100644 index d8ba8691..00000000 --- a/megaavr/libraries/Wire/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=Wire -version=1.0 -author=Arduino -maintainer=Arduino -sentence=This library allows you to communicate with I2C and Two Wire Interface devices. -paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line). -category=Communication -url=http://www.arduino.cc/en/Reference/Wire -architectures=megaavr - diff --git a/megaavr/libraries/Wire/src/Wire.cpp b/megaavr/libraries/Wire/src/Wire.cpp deleted file mode 100644 index 1fd823a8..00000000 --- a/megaavr/libraries/Wire/src/Wire.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - TwoWire.cpp - TWI/I2C library for Wiring & Arduino - 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 2012 by Todd Krein (todd@krein.org) to implement repeated starts - Modified 2017 by Chuck Todd (ctodd@cableone.net) to correct Unconfigured Slave Mode reboot -*/ - -extern "C" { - #include - #include - #include - #include "utility/twi.h" -} - -#include "Wire.h" - -#define DEFAULT_FREQUENCY 100000 - -// Initialize Class Variables ////////////////////////////////////////////////// - -uint8_t TwoWire::rxBuffer[BUFFER_LENGTH]; -uint8_t TwoWire::rxBufferIndex = 0; //head -uint8_t TwoWire::rxBufferLength = 0; //tail - -uint8_t TwoWire::txAddress = 0; -uint8_t TwoWire::txBuffer[BUFFER_LENGTH]; -uint8_t TwoWire::txBufferIndex = 0; //head -uint8_t TwoWire::txBufferLength = 0; //tail - -uint8_t TwoWire::transmitting = 0; -void (*TwoWire::user_onRequest)(void); -void (*TwoWire::user_onReceive)(int); - -// Constructors //////////////////////////////////////////////////////////////// - -TwoWire::TwoWire() -{ -} - -// Public Methods ////////////////////////////////////////////////////////////// - -void TwoWire::begin(void) -{ - rxBufferIndex = 0; - rxBufferLength = 0; - - txBufferIndex = 0; - txBufferLength = 0; - - TWI_MasterInit(DEFAULT_FREQUENCY); -} - -void TwoWire::begin(uint8_t address) -{ - rxBufferIndex = 0; - rxBufferLength = 0; - - txBufferIndex = 0; - txBufferLength = 0; - - TWI_SlaveInit(address); - - TWI_attachSlaveTxEvent(onRequestService, txBuffer); // default callback must exist - TWI_attachSlaveRxEvent(onReceiveService, rxBuffer, BUFFER_LENGTH); // default callback must exist - -} - -void TwoWire::begin(int address) -{ - begin((uint8_t)address); -} - -void TwoWire::end(void) -{ - TWI_Disable(); -} - -void TwoWire::setClock(uint32_t clock) -{ - TWI_MasterSetBaud(clock); -} - -uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool sendStop) { - if(quantity > BUFFER_LENGTH){ - quantity = BUFFER_LENGTH; - } - - uint8_t bytes_read = TWI_MasterRead(address, rxBuffer, quantity, sendStop); - - /* Initialize read variables */ - rxBufferIndex = 0; - rxBufferLength = bytes_read; - - return bytes_read; -} - -uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity) -{ - return requestFrom(address, quantity, true); -} - -uint8_t TwoWire::requestFrom(int address, size_t quantity) -{ - return requestFrom((uint8_t)address, quantity, true); -} - -uint8_t TwoWire::requestFrom(int address, size_t quantity, int sendStop) -{ - return requestFrom((uint8_t)address, quantity, (bool)sendStop); -} - -void TwoWire::beginTransmission(uint8_t address) -{ - // indicate that we are transmitting - transmitting = 1; - // set address of targeted slave - txAddress = address; - // reset tx buffer iterator vars - txBufferIndex = 0; - txBufferLength = 0; -} - -void TwoWire::beginTransmission(int address) -{ - beginTransmission((uint8_t)address); -} - -// -// Originally, 'endTransmission' was an f(void) function. -// It has been modified to take one parameter indicating -// whether or not a STOP should be performed on the bus. -// Calling endTransmission(false) allows a sketch to -// perform a repeated start. -// -// WARNING: Nothing in the library keeps track of whether -// the bus tenure has been properly ended with a STOP. It -// is very possible to leave the bus in a hung state if -// no call to endTransmission(true) is made. Some I2C -// devices will behave oddly if they do not see a STOP. -// -uint8_t TwoWire::endTransmission(bool sendStop) -{ - // transmit buffer (blocking) - uint8_t status = TWI_MasterWrite(txAddress, txBuffer, txBufferLength, sendStop); - - // reset tx buffer iterator vars - txBufferIndex = 0; - txBufferLength = 0; - - // indicate that we are done transmitting - transmitting = 0; - - return status; -} - -// This provides backwards compatibility with the original -// definition, and expected behaviour, of endTransmission -// -uint8_t TwoWire::endTransmission(void) -{ - return endTransmission(true); -} - -// must be called in: -// slave tx event callback -// or after beginTransmission(address) -size_t TwoWire::write(uint8_t data) -{ - /* Check if buffer is full */ - if(txBufferLength >= BUFFER_LENGTH){ - setWriteError(); - return 0; - } - - /* Put byte in txBuffer */ - txBuffer[txBufferIndex] = data; - txBufferIndex++; - - /* Update buffer length */ - txBufferLength = txBufferIndex; - - return 1; -} - -// must be called in: -// slave tx event callback -// or after beginTransmission(address) -size_t TwoWire::write(const uint8_t *data, size_t quantity) -{ - - for(size_t i = 0; i < quantity; i++){ - write(*(data + i)); - } - - return quantity; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::available(void) -{ - return rxBufferLength - rxBufferIndex; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::read(void) -{ - int value = -1; - - // get each successive byte on each call - if(rxBufferIndex < rxBufferLength){ - value = rxBuffer[rxBufferIndex]; - rxBufferIndex++; - } - - return value; -} - -// must be called in: -// slave rx event callback -// or after requestFrom(address, numBytes) -int TwoWire::peek(void) -{ - int value = -1; - - if(rxBufferIndex < rxBufferLength){ - value = rxBuffer[rxBufferIndex]; - } - - return value; -} - -// can be used to get out of an error state in TWI module -// e.g. when MDATA regsiter is written before MADDR -void TwoWire::flush(void) -{ -// /* Clear buffers */ -// for(uint8_t i = 0; i < BUFFER_LENGTH; i++){ -// txBuffer[i] = 0; -// rxBuffer[i] = 0; -// } -// -// /* Clear buffer variables */ -// txBufferIndex = 0; -// txBufferLength = 0; -// rxBufferIndex = 0; -// rxBufferLength = 0; -// -// /* Turn off and on TWI module */ -// TWI_Flush(); -} - -// behind the scenes function that is called when data is received -void TwoWire::onReceiveService(int numBytes) -{ - // don't bother if user hasn't registered a callback - if(!user_onReceive){ - return; - } - // don't bother if rx buffer is in use by a master requestFrom() op - // i know this drops data, but it allows for slight stupidity - // meaning, they may not have read all the master requestFrom() data yet - if(rxBufferIndex < rxBufferLength){ - return; - } - - // set rx iterator vars - rxBufferIndex = 0; - rxBufferLength = numBytes; - - // alert user program - user_onReceive(numBytes); -} - -// behind the scenes function that is called when data is requested -uint8_t TwoWire::onRequestService(void) -{ - // don't bother if user hasn't registered a callback - if(!user_onRequest){ - return 0; - } - - // reset slave write buffer iterator var - txBufferIndex = 0; - txBufferLength = 0; - - // alert user program - user_onRequest(); - - return txBufferLength; -} - -// sets function called on slave write -void TwoWire::onReceive( void (*function)(int) ) -{ - user_onReceive = function; -} - -// sets function called on slave read -void TwoWire::onRequest( void (*function)(void) ) -{ - user_onRequest = function; -} - -// Preinstantiate Objects ////////////////////////////////////////////////////// - -TwoWire Wire = TwoWire(); - diff --git a/megaavr/libraries/Wire/src/Wire.h b/megaavr/libraries/Wire/src/Wire.h deleted file mode 100644 index c0c2f8fb..00000000 --- a/megaavr/libraries/Wire/src/Wire.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - TwoWire.h - TWI/I2C library for Arduino & 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 2012 by Todd Krein (todd@krein.org) to implement repeated starts -*/ - -#ifndef TwoWire_h -#define TwoWire_h - -#include - -#if ((RAMEND - RAMSTART) < 1023) -#define BUFFER_LENGTH 16 -#else -#define BUFFER_LENGTH 32 -#endif -// WIRE_HAS_END means Wire has end() -#define WIRE_HAS_END 1 - -class TwoWire : public HardwareI2C -{ - private: - static uint8_t rxBuffer[]; - static uint8_t rxBufferIndex; - static uint8_t rxBufferLength; - - static uint8_t txAddress; - static uint8_t txBuffer[]; - static uint8_t txBufferIndex; - static uint8_t txBufferLength; - - static uint8_t transmitting; - static void (*user_onRequest)(void); - static void (*user_onReceive)(int); - static uint8_t onRequestService(void); - static void onReceiveService(int); - public: - TwoWire(); - void begin(); - void begin(uint8_t); - void begin(int); - void end(); - void setClock(uint32_t); - void beginTransmission(uint8_t); - void beginTransmission(int); - uint8_t endTransmission(void); - uint8_t endTransmission(bool); - uint8_t requestFrom(uint8_t, size_t); - uint8_t requestFrom(uint8_t, size_t, bool); - uint8_t requestFrom(int, size_t); - uint8_t requestFrom(int, size_t, int); - virtual size_t write(uint8_t); - virtual size_t write(const uint8_t *, size_t); - virtual int available(void); - virtual int read(void); - virtual int peek(void); - virtual void flush(void); - void onReceive( void (*)(int) ); - void onRequest( void (*)(void) ); - - inline size_t write(unsigned long n) { return write((uint8_t)n); } - inline size_t write(long n) { return write((uint8_t)n); } - inline size_t write(unsigned int n) { return write((uint8_t)n); } - inline size_t write(int n) { return write((uint8_t)n); } - using Print::write; -}; - -extern TwoWire Wire; - -#endif - diff --git a/megaavr/libraries/Wire/src/utility/twi.c b/megaavr/libraries/Wire/src/utility/twi.c deleted file mode 100644 index 0f79a379..00000000 --- a/megaavr/libraries/Wire/src/utility/twi.c +++ /dev/null @@ -1,771 +0,0 @@ -/****************************************************************************** -* © 2018 Microchip Technology Inc. and its subsidiaries. -* -* Subject to your compliance with these terms, you may use Microchip software -* and any derivatives exclusively with Microchip products. It is your -* responsibility to comply with third party license terms applicable to your -* use of third party software (including open source software) that may -* accompany Microchip software. -* -* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR -* PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, -* PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY -* KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP -* HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN -* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -* - *****************************************************************************/ - -#include "twi.h" -#include "Arduino.h" - -/* Master variables */ -static register8_t master_slaveAddress; /*!< Slave address */ -static register8_t* master_writeData; /*!< Data to write */ -static register8_t* master_readData; /*!< Read data */ -static register8_t master_bytesToWrite; /*!< Number of bytes to write */ -static register8_t master_bytesToRead; /*!< Number of bytes to read */ -static register8_t master_bytesWritten; /*!< Number of bytes written */ -static register8_t master_bytesRead; /*!< Number of bytes read */ -static register8_t master_sendStop; /*!< To send a stop at the end of the transaction or not */ -static register8_t master_trans_status; /*!< Status of transaction */ -static register8_t master_result; /*!< Result of transaction */ - -/* Slave variables */ -static uint8_t (*TWI_onSlaveTransmit)(void) __attribute__((unused)); -static void (*TWI_onSlaveReceive)(int) __attribute__((unused)); -static register8_t* slave_writeData; -static register8_t* slave_readData; -static register8_t slave_bytesToWrite; -static register8_t slave_bytesWritten; -static register8_t slave_bytesToRead; -static register8_t slave_bytesRead; -static register8_t slave_trans_status; -static register8_t slave_result; -static register8_t slave_callUserReceive; -static register8_t slave_callUserRequest; - -/* TWI module mode */ -static volatile TWI_MODE_t twi_mode; - -/*! \brief Initialize the TWI module as a master. - * - * TWI master initialization function. - * Enables master read and write interrupts. - * Remember to enable interrupts globally from the main application. - * - * \param frequency The required baud. - */ -void TWI_MasterInit(uint32_t frequency) -{ - if(twi_mode != TWI_MODE_UNKNOWN) return; - - // Enable pullups just in case, should have external ones though -#ifdef NO_EXTERNAL_I2C_PULLUP - pinMode(PIN_WIRE_SDA, INPUT_PULLUP); - pinMode(PIN_WIRE_SCL, INPUT_PULLUP); -#endif -/* This is done in wiring.c if this is needed for the part. -#if defined(TWISPIROUTEA) - PORTMUX.TWISPIROUTEA |= TWI_MUX; -#endif -*/ - twi_mode = TWI_MODE_MASTER; - - master_bytesRead = 0; - master_bytesWritten = 0; - master_trans_status = TWIM_STATUS_READY; - master_result = TWIM_RESULT_UNKNOWN; - - TWI0.MCTRLA = TWI_RIEN_bm | TWI_WIEN_bm | TWI_ENABLE_bm; - TWI_MasterSetBaud(frequency); - TWI0.MSTATUS = TWI_BUSSTATE_IDLE_gc; -} - -/*! \brief Initialize the TWI module as a slave. - * - * TWI slave initialization function. - * Enables slave address/stop and data interrupts. - * Assigns slave's own address. - * Remember to enable interrupts globally from the main application. - * - * \param address The TWI Slave's own address. - */ -void TWI_SlaveInit(uint8_t address) -{ - if(twi_mode != TWI_MODE_UNKNOWN) return; - - twi_mode = TWI_MODE_SLAVE; - - slave_bytesRead = 0; - slave_bytesWritten = 0; - slave_trans_status = TWIS_STATUS_READY; - slave_result = TWIS_RESULT_UNKNOWN; - slave_callUserRequest = 0; - slave_callUserReceive = 0; - - TWI0.SADDR = address << 1; - TWI0.SCTRLA = TWI_DIEN_bm | TWI_APIEN_bm | TWI_PIEN_bm | TWI_ENABLE_bm; - - /* Bus Error Detection circuitry needs Master enabled to work */ - TWI0.MCTRLA = TWI_ENABLE_bm; -} - -void TWI_Flush(void){ - TWI0.MCTRLB |= TWI_FLUSH_bm; -} - -/*! \brief Disable the TWI module. - * - * TWI module disable function. - * Disables both master and slave modes - * - * \param frequency The required baud. - */ -void TWI_Disable(void) -{ - TWI0.MCTRLA = 0x00; - TWI0.MBAUD = 0x00; - TWI0.MSTATUS = TWI_BUSSTATE_IDLE_gc; - TWI0.SADDR = 0x00; - TWI0.SCTRLA = 0x00; - - twi_mode = TWI_MODE_UNKNOWN; -} - -/*! \brief Returns the TWI bus state. - * - * Returns the TWI bus state (type defined in device headerfile), - * unknown, idle, owner or busy. - * - * \param twi The TWI_Master_t struct instance. - * - * \retval TWI_MASTER_BUSSTATE_UNKNOWN_gc Bus state is unknown. - * \retval TWI_MASTER_BUSSTATE_IDLE_gc Bus state is idle. - * \retval TWI_MASTER_BUSSTATE_OWNER_gc Bus state is owned by the master. - * \retval TWI_MASTER_BUSSTATE_BUSY_gc Bus state is busy. - */ -TWI_BUSSTATE_t TWI_MasterState(void) -{ - TWI_BUSSTATE_t twi_status; - twi_status = (TWI_BUSSTATE_t) (TWI0.MSTATUS & TWI_BUSSTATE_gm); - return twi_status; -} - - -/*! \brief Returns true if transaction is ready. - * - * This function returns a boolean whether the TWI Master is ready - * for a new transaction. - * - * \param twi The TWI_Master_t struct instance. - * - * \retval true If transaction could be started. - * \retval false If transaction could not be started. - */ -uint8_t TWI_MasterReady(void) -{ - uint8_t twi_status = (master_trans_status & TWIM_STATUS_READY); - return twi_status; -} - -/*! \brief Set the TWI baud rate. - * - * Sets the baud rate used by TWI Master. - * - * \param frequency The required baud. - */ -void TWI_MasterSetBaud(uint32_t frequency){ - -// Formula is: BAUD = ((F_CLKPER/frequency) - F_CLKPER*T_RISE - 10)/2; -// Where T_RISE varies depending on operating frequency... -// From 1617 DS: 1000ns @ 100kHz / 300ns @ 400kHz / 120ns @ 1MHz - - uint16_t t_rise; - - if(frequency < 200000){ - frequency = 100000; - t_rise = 1000; - - } else if (frequency < 800000){ - frequency = 400000; - t_rise = 300; - - } else if (frequency < 1200000){ - frequency = 1000000; - t_rise = 120; - - } else { - frequency = 100000; - t_rise = 1000; - } - - uint32_t baud = ((F_CPU_CORRECTED/frequency) - (((F_CPU_CORRECTED*t_rise)/1000)/1000)/1000 - 10)/2; - TWI0.MBAUD = (uint8_t)baud; - -} - -/*! \brief TWI write transaction. - * - * This function is TWI Master wrapper for a write-only transaction. - * - * \param twi The TWI_Master_t struct instance. - * \param address Slave address. - * \param writeData Pointer to data to write. - * \param bytesToWrite Number of data bytes to write. - * - * \retval true If transaction could be started. - * \retval false If transaction could not be started. - */ -uint8_t TWI_MasterWrite(uint8_t slave_address, - uint8_t *write_data, - uint8_t bytes_to_write, - uint8_t send_stop) -{ - return TWI_MasterWriteRead(slave_address, - write_data, - bytes_to_write, - 0, - send_stop); -} - - -/*! \brief TWI read transaction. - * - * This function is a TWI Master wrapper for read-only transaction. - * - * \param twi The TWI_Master_t struct instance. - * \param address The slave address. - * \param bytesToRead The number of bytes to read. - * - * \retval true If transaction could be started. - * \retval false If transaction could not be started. - */ -uint8_t TWI_MasterRead(uint8_t slave_address, - uint8_t* read_data, - uint8_t bytes_to_read, - uint8_t send_stop) -{ - master_readData = read_data; - - uint8_t bytes_read = TWI_MasterWriteRead(slave_address, - 0, - 0, - bytes_to_read, - send_stop); - return bytes_read; -} - - -/*! \brief TWI write and/or read transaction. - * - * This function is a TWI Master write and/or read transaction. The function - * can be used to both write and/or read bytes to/from the TWI Slave in one - * transaction. - * - * \param twi The TWI_Master_t struct instance. - * \param address The slave address. - * \param writeData Pointer to data to write. - * \param bytesToWrite Number of bytes to write. - * \param bytesToRead Number of bytes to read. - * - * \retval true If transaction could be started. - * \retval false If transaction could not be started. - */ -uint8_t TWI_MasterWriteRead(uint8_t slave_address, - uint8_t *write_data, - uint8_t bytes_to_write, - uint8_t bytes_to_read, - uint8_t send_stop) -{ - if(twi_mode != TWI_MODE_MASTER) return false; - - /*Initiate transaction if bus is ready. */ - if (master_trans_status == TWIM_STATUS_READY) { - - master_trans_status = TWIM_STATUS_BUSY; - master_result = TWIM_RESULT_UNKNOWN; - - master_writeData = write_data; - - master_bytesToWrite = bytes_to_write; - master_bytesToRead = bytes_to_read; - master_bytesWritten = 0; - master_bytesRead = 0; - master_sendStop = send_stop; - master_slaveAddress = slave_address<<1; - -trigger_action: - - /* If write command, send the START condition + Address + - * 'R/_W = 0' - */ - if (master_bytesToWrite > 0) { - twi_mode = TWI_MODE_MASTER_TRANSMIT; - uint8_t writeAddress = ADD_WRITE_BIT(master_slaveAddress); - TWI0.MADDR = writeAddress; - } - - /* If read command, send the START condition + Address + - * 'R/_W = 1' - */ - else if (master_bytesToRead > 0) { - twi_mode = TWI_MODE_MASTER_RECEIVE; - uint8_t readAddress = ADD_READ_BIT(master_slaveAddress); - TWI0.MADDR = readAddress; - } - - else if (master_bytesToWrite == 0 && master_bytesToRead == 0) { - twi_mode = TWI_MODE_MASTER_TRANSMIT; - uint8_t writeAddress = ADD_WRITE_BIT(master_slaveAddress); - TWI0.MADDR = writeAddress; - } - - /* Arduino requires blocking function */ - while(master_result == TWIM_RESULT_UNKNOWN) {} - - // in case of arbitration lost, retry sending - if (master_result == TWIM_RESULT_ARBITRATION_LOST) { - goto trigger_action; - } - - uint8_t ret = 0; - if (master_bytesToRead > 0) { - // return bytes really read - ret = master_bytesRead; - } else { - // return 0 if success, >0 otherwise - ret = (master_result == TWIM_RESULT_OK ? 0 : 1); - } - - return ret; - } else { - return 1; - } -} - - -/*! \brief Common TWI master interrupt service routine. - * - * Check current status and calls the appropriate handler. - * - */ -void TWI_MasterInterruptHandler() -{ - uint8_t currentStatus = TWI0.MSTATUS; - - /* If arbitration lost or bus error. */ - if ((currentStatus & TWI_ARBLOST_bm) || - (currentStatus & TWI_BUSERR_bm)) { - - TWI_MasterArbitrationLostBusErrorHandler(); - } - - /* If master write interrupt. */ - else if (currentStatus & TWI_WIF_bm) { - TWI_MasterWriteHandler(); - } - - /* If master read interrupt. */ - else if (currentStatus & TWI_RIF_bm) { - TWI_MasterReadHandler(); - } - - /* If unexpected state. */ - else { - TWI_MasterTransactionFinished(TWIM_RESULT_FAIL); - } -} - -/*! \brief TWI master arbitration lost and bus error interrupt handler. - * - * Handles TWI responses to lost arbitration and bus error. - * - */ -void TWI_MasterArbitrationLostBusErrorHandler() -{ - uint8_t currentStatus = TWI0.MSTATUS; - - /* If bus error. */ - if (currentStatus & TWI_BUSERR_bm) { - master_result = TWIM_RESULT_BUS_ERROR; - } - /* If arbitration lost. */ - else { - master_result = TWIM_RESULT_ARBITRATION_LOST; - } - - /* Clear all flags, abort operation */ - TWI0.MSTATUS = currentStatus; - - /* Wait for a new operation */ - twi_mode = TWI_MODE_MASTER; - master_trans_status = TWIM_STATUS_READY; -} - - -/*! \brief TWI master write interrupt handler. - * - * Handles TWI transactions (master write) and responses to (N)ACK. - * - */ -void TWI_MasterWriteHandler() -{ - /* Local variables used in if tests to avoid compiler warning. */ - uint8_t bytesToWrite = master_bytesToWrite; - uint8_t bytesToRead = master_bytesToRead; - - /* If NOT acknowledged (NACK) by slave cancel the transaction. */ - if (TWI0.MSTATUS & TWI_RXACK_bm) { - if(master_sendStop){ - TWI0.MCTRLB = TWI_MCMD_STOP_gc; - } else { - TWI0.MCTRLB = TWI_MCMD_REPSTART_gc; - - } - TWI_MasterTransactionFinished(TWIM_RESULT_NACK_RECEIVED); - } - - /* If more bytes to write, send data. */ - else if (master_bytesWritten < bytesToWrite) { - uint8_t data = master_writeData[master_bytesWritten]; - TWI0.MDATA = data; - master_bytesWritten++; - } - - /* If bytes to read, send START condition + Address + - * 'R/_W = 1' - */ - else if (master_bytesRead < bytesToRead) { - twi_mode = TWI_MODE_MASTER_RECEIVE; - uint8_t readAddress = ADD_READ_BIT(master_slaveAddress); - TWI0.MADDR = readAddress; - } - - /* If transaction finished, send ACK/STOP condition if instructed and set RESULT OK. */ - else { - if(master_sendStop){ - TWI0.MCTRLB = TWI_MCMD_STOP_gc; - } else { - TWI0.MCTRLB = TWI_MCMD_REPSTART_gc; - } - TWI_MasterTransactionFinished(TWIM_RESULT_OK); - } -} - - -/*! \brief TWI master read interrupt handler. - * - * This is the master read interrupt handler that takes care of - * reading bytes from the TWI slave. - * - * \param twi The TWI_Master_t struct instance. - */ -void TWI_MasterReadHandler() -{ - /* Fetch data if bytes to be read. */ - if (master_bytesRead < master_bytesToRead) { - uint8_t data = TWI0.MDATA; - master_readData[master_bytesRead] = data; - master_bytesRead++; - } - - /* If buffer overflow, issue NACK/STOP and BUFFER_OVERFLOW condition. */ - else { - if(master_sendStop){ - TWI0.MCTRLB = TWI_ACKACT_bm | TWI_MCMD_STOP_gc; - } else { - TWI0.MCTRLB = TWI_ACKACT_bm | TWI_MCMD_REPSTART_gc; - } - - TWI_MasterTransactionFinished(TWIM_RESULT_BUFFER_OVERFLOW); - master_bytesToRead = 0; - return; - } - - /* Local variable used in if test to avoid compiler warning. */ - uint8_t bytesToRead = master_bytesToRead; - - /* If more bytes to read, issue ACK and start a byte read. */ - if (master_bytesRead < bytesToRead) { - TWI0.MCTRLB = TWI_MCMD_RECVTRANS_gc; - } - - /* If transaction finished, issue NACK and STOP condition if instructed. */ - else { - if(master_sendStop){ - TWI0.MCTRLB = TWI_ACKACT_bm | TWI_MCMD_STOP_gc; - } else { - TWI0.MCTRLB = TWI_ACKACT_bm | TWI_MCMD_REPSTART_gc; - } - - TWI_MasterTransactionFinished(TWIM_RESULT_OK); - } -} - - -/*! \brief TWI transaction finished handler. - * - * Prepares module for new transaction. - * - * \param result The result of the operation. - */ -void TWI_MasterTransactionFinished(uint8_t result) -{ - master_result = result; - master_trans_status = TWIM_STATUS_READY; - twi_mode = TWI_MODE_MASTER; -} - - -/*! \brief Common TWI slave interrupt service routine. - * - * Check current status and calls the appropriate handler. - * - */ -void TWI_SlaveInterruptHandler(){ - uint8_t currentStatus = TWI0.SSTATUS; - - /* If bus error */ - if(currentStatus & TWI_BUSERR_bm){ - slave_bytesRead = 0; - slave_bytesWritten = 0; - slave_bytesToWrite = 0; - TWI_SlaveTransactionFinished(TWIS_RESULT_BUS_ERROR); - } - - /* If Address or Stop */ - else if(currentStatus & TWI_APIF_bm){ - - /* Call user onReceive function if end of Master Write/Slave Read. - * This should be hit when there is a STOP or REPSTART - */ - if(slave_callUserReceive == 1){ - TWI_onSlaveReceive(slave_bytesRead); - slave_callUserReceive = 0; - } - - /* If address match */ - if(currentStatus & TWI_AP_bm){ - TWI_SlaveAddressMatchHandler(); - } - - /* If stop */ - else { - TWI_SlaveStopHandler(); - - /* If CLKHOLD is high, we have missed an address match - from a fast start after stop. - Because the flag is shared we need to handle this here. - */ - if(TWI0.SSTATUS & TWI_CLKHOLD_bm){ - - /* CLKHOLD will be cleared by servicing the address match */ - TWI_SlaveAddressMatchHandler(); - } - } - } - - /* If Data Interrupt */ - else if (currentStatus & TWI_DIF_bm){ - - /* If collision flag is raised, slave transmit unsuccessful */ - if (currentStatus & TWI_COLL_bm){ - slave_bytesRead = 0; - slave_bytesWritten = 0; - slave_bytesToWrite = 0; - TWI_SlaveTransactionFinished(TWIS_RESULT_TRANSMIT_COLLISION); - } - - /* Otherwise, normal data interrupt */ - else { - TWI_SlaveDataHandler(); - } - } - - /* If unexpected state */ - else { - TWI_SlaveTransactionFinished(TWIS_RESULT_FAIL); - } -} - -/*! \brief TWI slave address interrupt handler. - * - * This is the slave address match handler that takes care of responding to - * being addressed by a master - * - */ -void TWI_SlaveAddressMatchHandler(){ - slave_trans_status = TWIS_STATUS_BUSY; - slave_result = TWIS_RESULT_UNKNOWN; - - /* Send ACK, wait for data interrupt */ - TWI0.SCTRLB = TWI_SCMD_RESPONSE_gc; - - /* If Master Read/Slave Write */ - if(TWI0.SSTATUS & TWI_DIR_bm){ - slave_bytesWritten = 0; - /* Call user function */ - slave_bytesToWrite = TWI_onSlaveTransmit(); - twi_mode = TWI_MODE_SLAVE_TRANSMIT; - } - /* If Master Write/Slave Read */ - else { - slave_bytesRead = 0; - slave_callUserReceive = 1; - twi_mode = TWI_MODE_SLAVE_RECEIVE; - } - - /* Data interrupt to follow... */ -} - -/*! \brief TWI slave stop interrupt handler. - * - */ -void TWI_SlaveStopHandler(){ - - /* Clear APIF, don't ACK or NACK */ - TWI0.SSTATUS = TWI_APIF_bm; - - TWI_SlaveTransactionFinished(TWIS_RESULT_OK); - -} - -/*! \brief TWI slave data interrupt handler. - * - * This is the slave data handler that takes care of sending data to or - * receiving data from a master - * - */ -void TWI_SlaveDataHandler(){ - - /* Enable stop interrupt */ - TWI0.SCTRLA |= (TWI_APIEN_bm | TWI_PIEN_bm); - - /* If Master Read/Slave Write */ - if(TWI0.SSTATUS & TWI_DIR_bm){ - - TWI_SlaveWriteHandler(); - } - - /* If Master Write/Slave Read */ - else { - TWI_SlaveReadHandler(); - } - - -} - -/*! \brief TWI slave data write interrupt handler. - * - * This is the slave data handler that takes care of sending data to a master - * - */ -void TWI_SlaveWriteHandler(){ - - /* If NACK, slave write transaction finished */ - if((slave_bytesWritten > 0) && (TWI0.SSTATUS & TWI_RXACK_bm)){ - - TWI0.SCTRLB = TWI_SCMD_COMPTRANS_gc; - TWI_SlaveTransactionFinished(TWIS_RESULT_OK); - } - - /* If ACK, master expects more data */ - else { - - if(slave_bytesWritten < slave_bytesToWrite){ - uint8_t data = slave_writeData[slave_bytesWritten]; - TWI0.SDATA = data; - slave_bytesWritten++; - - /* Send data, wait for data interrupt */ - TWI0.SCTRLB = TWI_SCMD_RESPONSE_gc; - - } - - /* If buffer overflow */ - else { - TWI0.SCTRLB = TWI_SCMD_COMPTRANS_gc; - TWI_SlaveTransactionFinished(TWIS_RESULT_BUFFER_OVERFLOW); - - } - - - } -} - -/*! \brief TWI slave data read interrupt handler. - * - * This is the slave data handler that takes care of receiving data from a master - * - */ -void TWI_SlaveReadHandler(){ - - /* If free space in buffer */ - if(slave_bytesRead < slave_bytesToRead){ - - /* Fetch data */ - uint8_t data = TWI0.SDATA; - slave_readData[slave_bytesRead] = data; - slave_bytesRead++; - - /* Send ACK and wait for data interrupt */ - TWI0.SCTRLB = TWI_SCMD_RESPONSE_gc; - } - /* If buffer overflow, send NACK and wait for next START. - Set result buffer overflow */ - else { - TWI0.SCTRLB = TWI_ACKACT_bm | TWI_SCMD_COMPTRANS_gc; - TWI_SlaveTransactionFinished(TWIS_RESULT_BUFFER_OVERFLOW); - } -} - -/* - * Function twi_attachSlaveRxEvent - * Desc sets function called before a slave read operation - * Input function: callback function to use - * Output none - */ -void TWI_attachSlaveRxEvent( void (*function)(int), uint8_t *read_data, uint8_t bytes_to_read ){ - TWI_onSlaveReceive = function; - slave_readData = read_data; - slave_bytesToRead = bytes_to_read; -} - -/* - * Function twi_attachSlaveTxEvent - * Desc sets function called before a slave write operation - * Input function: callback function to use - * Output none - */ -void TWI_attachSlaveTxEvent( uint8_t (*function)(void), uint8_t* write_data ){ - TWI_onSlaveTransmit = function; - slave_writeData = write_data; -} - - -/*! \brief TWI slave transaction finished handler. - * - * Prepares module for new transaction. - * - * \param result The result of the operation. - */ -void TWI_SlaveTransactionFinished(uint8_t result) -{ - TWI0.SCTRLA |= (TWI_APIEN_bm | TWI_PIEN_bm); - twi_mode = TWI_MODE_SLAVE; - slave_result = result; - slave_trans_status = TWIM_STATUS_READY; -} - -ISR(TWI0_TWIM_vect){ - TWI_MasterInterruptHandler(); -} - -ISR(TWI0_TWIS_vect){ - TWI_SlaveInterruptHandler(); -} \ No newline at end of file diff --git a/megaavr/libraries/Wire/src/utility/twi.h b/megaavr/libraries/Wire/src/utility/twi.h deleted file mode 100644 index 8e76e546..00000000 --- a/megaavr/libraries/Wire/src/utility/twi.h +++ /dev/null @@ -1,126 +0,0 @@ -/****************************************************************************** -* © 2018 Microchip Technology Inc. and its subsidiaries. -* -* Subject to your compliance with these terms, you may use Microchip software -* and any derivatives exclusively with Microchip products. It is your -* responsibility to comply with third party license terms applicable to your -* use of third party software (including open source software) that may -* accompany Microchip software. -* -* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER -* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED -* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR -* PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, -* PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY -* KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP -* HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE -* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN -* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, -* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. -* - *****************************************************************************/ -#ifndef TWI_DRIVER_H -#define TWI_DRIVER_H - -#include "avr/io.h" - -/*! Transaction status defines. */ -#define TWIM_STATUS_READY 0 -#define TWIM_STATUS_BUSY 1 - -/* Transaction status defines.*/ -#define TWIS_STATUS_READY 0 -#define TWIS_STATUS_BUSY 1 - -/*! Transaction result enumeration. */ -typedef enum TWIM_RESULT_enum { - TWIM_RESULT_UNKNOWN = (0x00<<0), - TWIM_RESULT_OK = (0x01<<0), - TWIM_RESULT_BUFFER_OVERFLOW = (0x02<<0), - TWIM_RESULT_ARBITRATION_LOST = (0x03<<0), - TWIM_RESULT_BUS_ERROR = (0x04<<0), - TWIM_RESULT_NACK_RECEIVED = (0x05<<0), - TWIM_RESULT_FAIL = (0x06<<0), -} TWIM_RESULT_t; - -/* Transaction result enumeration */ -typedef enum TWIS_RESULT_enum { - TWIS_RESULT_UNKNOWN = (0x00<<0), - TWIS_RESULT_OK = (0x01<<0), - TWIS_RESULT_BUFFER_OVERFLOW = (0x02<<0), - TWIS_RESULT_TRANSMIT_COLLISION = (0x03<<0), - TWIS_RESULT_BUS_ERROR = (0x04<<0), - TWIS_RESULT_FAIL = (0x05<<0), - TWIS_RESULT_ABORTED = (0x06<<0), -} TWIS_RESULT_t; - -/*! TWI Modes */ -typedef enum TWI_MODE_enum { - TWI_MODE_UNKNOWN = 0, - TWI_MODE_MASTER = 1, - TWI_MODE_SLAVE = 2, - TWI_MODE_MASTER_TRANSMIT = 3, - TWI_MODE_MASTER_RECEIVE = 4, - TWI_MODE_SLAVE_TRANSMIT = 5, - TWI_MODE_SLAVE_RECEIVE = 6 -} TWI_MODE_t; - -/*! For adding R/_W bit to address */ -#define ADD_READ_BIT(address) (address | 0x01) -#define ADD_WRITE_BIT(address) (address & ~0x01) - -void TWI_MasterInit(uint32_t frequency); -void TWI_SlaveInit(uint8_t address); -void TWI_Flush(void); -void TWI_Disable(void); -TWI_BUSSTATE_t TWI_MasterState(void); -uint8_t TWI_MasterReady(void); -void TWI_MasterSetBaud(uint32_t frequency); -uint8_t TWI_MasterWrite(uint8_t slave_address, - uint8_t *write_data, - uint8_t bytes_to_write, - uint8_t send_stop); -uint8_t TWI_MasterRead(uint8_t slave_address, - uint8_t* read_data, - uint8_t bytes_to_read, - uint8_t send_stop); -uint8_t TWI_MasterWriteRead(uint8_t slave_address, - uint8_t *write_data, - uint8_t bytes_to_write, - uint8_t bytes_to_read, - uint8_t send_stop); -void TWI_MasterInterruptHandler(void); -void TWI_MasterArbitrationLostBusErrorHandler(void); -void TWI_MasterWriteHandler(void); -void TWI_MasterReadHandler(void); -void TWI_MasterTransactionFinished(uint8_t result); - -void TWI_SlaveInterruptHandler(void); -void TWI_SlaveAddressMatchHandler(void); -void TWI_SlaveStopHandler(void); -void TWI_SlaveDataHandler(void); -void TWI_SlaveWriteHandler(void); -void TWI_SlaveReadHandler(void); -void TWI_attachSlaveRxEvent( void (*function)(int), uint8_t *read_data, uint8_t bytes_to_read ); -void TWI_attachSlaveTxEvent( uint8_t (*function)(void), uint8_t *write_data ); -void TWI_SlaveTransactionFinished(uint8_t result); -/*! TWI master interrupt service routine. - * - * Interrupt service routine for the TWI master. Copy the needed vectors - * into your code. - * - - - ISR(TWI0_TWIM_vect){ - TWI_MasterInterruptHandler(); - } - - ISR(TWI0_TWIS_vect){ - TWI_SlaveInterruptHandler(); - } - - * - */ - - -#endif /* TWI_DRIVER_H */ diff --git a/megaavr/libraries/tinyNeoPixel/COPYING b/megaavr/libraries/tinyNeoPixel/COPYING deleted file mode 100644 index 65c5ca88..00000000 --- a/megaavr/libraries/tinyNeoPixel/COPYING +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/megaavr/libraries/tinyNeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino b/megaavr/libraries/tinyNeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino deleted file mode 100644 index 9497b8b0..00000000 --- a/megaavr/libraries/tinyNeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino +++ /dev/null @@ -1,248 +0,0 @@ -#include - - -#define PIN 6 - -#define NUM_LEDS 60 - -#define BRIGHTNESS 50 - -tinyNeoPixel strip = tinyNeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800); - -int gamma[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, - 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, - 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, - 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, - 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, - 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, - 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, - 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, - 90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114, - 115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142, - 144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175, - 177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213, - 215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 }; - - -void setup() { - Serial.begin(115200); - strip.setBrightness(BRIGHTNESS); - strip.begin(); - strip.show(); // Initialize all pixels to 'off' -} - -void loop() { - // Some example procedures showing how to display to the pixels: - colorWipe(strip.Color(255, 0, 0), 50); // Red - colorWipe(strip.Color(0, 255, 0), 50); // Green - colorWipe(strip.Color(0, 0, 255), 50); // Blue - colorWipe(strip.Color(0, 0, 0, 255), 50); // White - - whiteOverRainbow(20,75,5); - - pulseWhite(5); - - // fullWhite(); - // delay(2000); - - rainbowFade2White(3,3,1); - - -} - -// Fill the dots one after the other with a color -void colorWipe(uint32_t c, uint8_t wait) { - for(uint16_t i=0; i= 0 ; j--){ - for(uint16_t i=0; i 255 - fadeMax ){ - fadeVal--; - } - - strip.show(); - delay(wait); - } - } - - - - delay(500); - - - for(int k = 0 ; k < whiteLoops ; k ++){ - - for(int j = 0; j < 256 ; j++){ - - for(uint16_t i=0; i < strip.numPixels(); i++) { - strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) ); - } - strip.show(); - } - - delay(2000); - for(int j = 255; j >= 0 ; j--){ - - for(uint16_t i=0; i < strip.numPixels(); i++) { - strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) ); - } - strip.show(); - } - } - - delay(500); - - -} - -void whiteOverRainbow(uint8_t wait, uint8_t whiteSpeed, uint8_t whiteLength ) { - if(whiteLength >= strip.numPixels()) whiteLength = strip.numPixels() - 1; - - int head = whiteLength - 1; - int tail = 0; - - int loops = 3; - int loopNum = 0; - - static unsigned long lastTime = 0; - - - while(true){ - for(int j=0; j<256; j++) { - for(uint16_t i=0; i= tail && i <= head) || (tail > head && i >= tail) || (tail > head && i <= head) ){ - strip.setPixelColor(i, strip.Color(0,0,0, 255 ) ); - } - else{ - strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); - } - } - - if(millis() - lastTime > whiteSpeed) { - head++; - tail++; - if(head == strip.numPixels()){ - loopNum++; - } - lastTime = millis(); - } - - if(loopNum == loops) return; - head%=strip.numPixels(); - tail%=strip.numPixels(); - strip.show(); - delay(wait); - } - } -} - -void fullWhite() { - for(uint16_t i=0; i> 8); -} -uint8_t green(uint32_t c) { - return (c >> 16); -} -uint8_t blue(uint32_t c) { - return (c); -} diff --git a/megaavr/libraries/tinyNeoPixel/examples/buttoncycler/buttoncycler.ino b/megaavr/libraries/tinyNeoPixel/examples/buttoncycler/buttoncycler.ino deleted file mode 100644 index c5e3645b..00000000 --- a/megaavr/libraries/tinyNeoPixel/examples/buttoncycler/buttoncycler.ino +++ /dev/null @@ -1,38 +0,0 @@ -// NeoPixel Ring simple sketch (c) 2013 Shae Erisson -// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library - -#include - -// Which pin on the Arduino is connected to the NeoPixels? -#define PIN 3 - -// How many NeoPixels are attached to the Arduino? -#define NUMPIXELS 16 - -// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. -// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest -// example for more information on possible values. -tinyNeoPixel pixels = tinyNeoPixel(NUMPIXELS, PIN, NEO_GRB); - -int delayval = 500; // delay for half a second - -void setup() { - - pixels.begin(); // This initializes the NeoPixel library. -} - -void loop() { - - // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. - - for(int i=0;i - - -// Which pin on the Arduino is connected to the NeoPixels? -#define PIN 3 - -// How many NeoPixels are attached to the Arduino? -#define NUMPIXELS 16 - -// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. -// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest -// example for more information on possible values. -tinyNeoPixel pixels = tinyNeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); - -int delayval = 500; // delay for half a second - -void setup() { - - pixels.begin(); // This initializes the NeoPixel library. -} - -void loop() { - - // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. - - for(int i=0;i - -#define PIN 6 - -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -tinyNeoPixel strip = tinyNeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); - -// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across -// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input -// and minimize distance between Arduino and first pixel. Avoid connecting -// on a live circuit...if you must, connect GND first. - -void setup() { - strip.begin(); - strip.show(); // Initialize all pixels to 'off' -} - -void loop() { - // Some example procedures showing how to display to the pixels: - colorWipe(strip.Color(255, 0, 0), 50); // Red - colorWipe(strip.Color(0, 255, 0), 50); // Green - colorWipe(strip.Color(0, 0, 255), 50); // Blue -//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW - // Send a theater pixel chase in... - theaterChase(strip.Color(127, 127, 127), 50); // White - theaterChase(strip.Color(127, 0, 0), 50); // Red - theaterChase(strip.Color(0, 0, 127), 50); // Blue - - rainbow(20); - rainbowCycle(20); - theaterChaseRainbow(50); -} - -// Fill the dots one after the other with a color -void colorWipe(uint32_t c, uint8_t wait) { - for(uint16_t i=0; i -sentence=Arduino library for controlling single-wire-based LED pixels and strip for ATtinyCore and megaTinyCore. -paragraph=This library is closely based on the original Adafruit_NeoPixel library. It has been modified to support the megaAVR architecture, clock speeds of 20MHz and 10MHz, and to use the port selected in the tools menu for speeds under 16MHz. -category=Display -url=https://github.com/SpenceKonde/megaTinyCore -architectures=megaavr, avr diff --git a/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.cpp b/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.cpp deleted file mode 100644 index 1c2f4e58..00000000 --- a/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.cpp +++ /dev/null @@ -1,825 +0,0 @@ -/*------------------------------------------------------------------------- - Arduino library to control a wide variety of WS2811- and WS2812-based RGB - LED devices such as Adafruit FLORA RGB Smart Pixels and NeoPixel strips. - Currently handles 400 and 800 KHz bitstreams on 8, 12 and 16 MHz ATmega - MCUs, with LEDs wired for various color orders. Handles most output pins - (possible exception with upper PORT registers on the Arduino Mega). - - Written by Phil Burgess / Paint Your Dragon for Adafruit Industries, - contributions by PJRC, Michael Miller and other members of the open - source community. - - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing products - from Adafruit! - - ------------------------------------------------------------------------- - This file is part of the Adafruit NeoPixel library. - - NeoPixel 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 3 of - the License, or (at your option) any later version. - - NeoPixel 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 NeoPixel. If not, see - . - -------------------------------------------------------------------------*/ - -#include "tinyNeoPixel.h" - -// Constructor when length, pin and type are known at compile-time: -tinyNeoPixel::tinyNeoPixel(uint16_t n, uint8_t p, neoPixelType t) : - begun(false), brightness(0), pixels(NULL), endTime(0) -{ - updateType(t); - updateLength(n); - setPin(p); -} - -// via Michael Vogt/neophob: empty constructor is used when strand length -// isn't known at compile-time; situations where program config might be -// read from internal flash memory or an SD card, or arrive via serial -// command. If using this constructor, MUST follow up with updateType(), -// updateLength(), etc. to establish the strand type, length and pin number! -tinyNeoPixel::tinyNeoPixel() : - begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0), pixels(NULL), - rOffset(1), gOffset(0), bOffset(2), wOffset(1), endTime(0) -{ -} - -tinyNeoPixel::~tinyNeoPixel() { - if(pixels) free(pixels); - if(pin >= 0) pinMode(pin, INPUT); -} - -void tinyNeoPixel::begin(void) { - if(pin >= 0) { - pinMode(pin, OUTPUT); - digitalWrite(pin, LOW); - } - begun = true; -} - -void tinyNeoPixel::updateLength(uint16_t n) { - if(pixels) free(pixels); // Free existing data (if any) - - // Allocate new data -- note: ALL PIXELS ARE CLEARED - numBytes = n * ((wOffset == rOffset) ? 3 : 4); - if((pixels = (uint8_t *)malloc(numBytes))) { - memset(pixels, 0, numBytes); - numLEDs = n; - } else { - numLEDs = numBytes = 0; - } -} - -void tinyNeoPixel::updateType(neoPixelType t) { - boolean oldThreeBytesPerPixel = (wOffset == rOffset); // false if RGBW - - wOffset = (t >> 6) & 0b11; // See notes in header file - rOffset = (t >> 4) & 0b11; // regarding R/G/B/W offsets - gOffset = (t >> 2) & 0b11; - bOffset = t & 0b11; -#ifdef NEO_KHZ400 - is800KHz = (t < 256); // 400 KHz flag is 1<<8 -#endif - - // If bytes-per-pixel has changed (and pixel data was previously - // allocated), re-allocate to new size. Will clear any data. - if(pixels) { - boolean newThreeBytesPerPixel = (wOffset == rOffset); - if(newThreeBytesPerPixel != oldThreeBytesPerPixel) updateLength(numLEDs); - } -} - -#ifdef ESP8266 -// ESP8266 show() is external to enforce ICACHE_RAM_ATTR execution -extern "C" void ICACHE_RAM_ATTR espShow( - uint8_t pin, uint8_t *pixels, uint32_t numBytes, uint8_t type); -#endif // ESP8266 - -void tinyNeoPixel::show(void) { - - if(!pixels) return; - - // Data latch = 50+ microsecond pause in the output stream. Rather than - // put a delay at the end of the function, the ending time is noted and - // the function will simply hold off (if needed) on issuing the - // subsequent round of data until the latch time has elapsed. This - // allows the mainline code to start generating the next frame of data - // rather than stalling for the latch. - while(!canShow()); - // endTime is a private member (rather than global var) so that multiple - // instances on different pins can be quickly issued in succession (each - // instance doesn't delay the next). - - // In order to make this code runtime-configurable to work with any pin, - // SBI/CBI instructions are eschewed in favor of full PORT writes via the - // OUT or ST instructions. It relies on two facts: that peripheral - // functions (such as PWM) take precedence on output pins, so our PORT- - // wide writes won't interfere, and that interrupts are globally disabled - // while data is being issued to the LEDs, so no other code will be - // accessing the PORT. The code takes an initial 'snapshot' of the PORT - // state, computes 'pin high' and 'pin low' values, and writes these back - // to the PORT register as needed. - - noInterrupts(); // Need 100% focus on instruction timing - -// AVR MCUs -- ATtiny and megaAVR ATtiny ------------------------------- - - volatile uint16_t - i = numBytes; // Loop counter - volatile uint8_t - *ptr = pixels, // Pointer to next byte - b = *ptr++, // Current byte value - hi, // PORT w/output bit set high - lo; // PORT w/output bit set low - - // Hand-tuned assembly code issues data to the LED drivers at a specific - // rate. There's separate code for different CPU speeds (8, 12, 16 MHz) - // for both the WS2811 (400 KHz) and WS2812 (800 KHz) drivers. The - // datastream timing for the LED drivers allows a little wiggle room each - // way (listed in the datasheets), so the conditions for compiling each - // case are set up for a range of frequencies rather than just the exact - // 8, 12 or 16 MHz values, permitting use with some close-but-not-spot-on - // devices (e.g. 16.5 MHz DigiSpark). The ranges were arrived at based - // on the datasheet figures and have not been extensively tested outside - // the canonical 8/12/16 MHz speeds; there's no guarantee these will work - // close to the extremes (or possibly they could be pushed further). - // Keep in mind only one CPU speed case actually gets compiled; the - // resulting program isn't as massive as it might look from source here. - -// 8 MHz(ish) AVR --------------------------------------------------------- -#if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) - - volatile uint8_t n1, n2 = 0; // First, next bits out - - // Squeezing an 800 KHz stream out of an 8 MHz chip requires code - // specific to each PORT register. At present this is only written - // to work with pins on PORTD or PORTB, the most likely use case -- - // this covers all the pins on the Adafruit Flora and the bulk of - // digital pins on the Arduino Pro 8 MHz (keep in mind, this code - // doesn't even get compiled for 16 MHz boards like the Uno, Mega, - // Leonardo, etc., so don't bother extending this out of hand). - // Additional PORTs could be added if you really need them, just - // duplicate the else and loop and change the PORT. Each add'l - // PORT will require about 150(ish) bytes of program space. - - // 10 instruction clocks per bit: HHxxxxxLLL - // OUT instructions: ^ ^ ^ (T=0,2,7) - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - n1 = lo; - if(b & 0x80) n1 = hi; - - // Dirty trick: RJMPs proceeding to the next instruction are used - // to delay two clock cycles in one instruction word (rather than - // using two NOPs). This was necessary in order to squeeze the - // loop down to exactly 64 words -- the maximum possible for a - // relative branch. - - asm volatile( - "headD:" "\n\t" // Clk Pseudocode - // Bit 7: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 6" "\n\t" // 1-2 if(b & 0x40) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 6: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 5" "\n\t" // 1-2 if(b & 0x20) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 5: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 4" "\n\t" // 1-2 if(b & 0x10) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 4: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 3" "\n\t" // 1-2 if(b & 0x08) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 3: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 2" "\n\t" // 1-2 if(b & 0x04) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 2: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 1" "\n\t" // 1-2 if(b & 0x02) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 1: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 0" "\n\t" // 1-2 if(b & 0x01) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "sbiw %[count], 1" "\n\t" // 2 i-- (don't act on Z flag yet) - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "brne headD" "\n" // 2 while(i) (Z flag set above) - : [byte] "+r" (b), - [n1] "+r" (n1), - [n2] "+r" (n2), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#elif (F_CPU >= 9500000UL) && (F_CPU <= 11100000UL) -/* - volatile uint8_t n1, n2 = 0; // First, next bits out - - // Squeezing an 800 KHz stream out of an 8 MHz chip requires code - // specific to each PORT register. At present this is only written - // to work with pins on PORTD or PORTB, the most likely use case -- - // this covers all the pins on the Adafruit Flora and the bulk of - // digital pins on the Arduino Pro 8 MHz (keep in mind, this code - // doesn't even get compiled for 16 MHz boards like the Uno, Mega, - // Leonardo, etc., so don't bother extending this out of hand). - // Additional PORTs could be added if you really need them, just - // duplicate the else and loop and change the PORT. Each add'l - // PORT will require about 150(ish) bytes of program space. - - // 13 instruction clocks per bit: HHHxxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,3,7) - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - n1 = lo; - if(b & 0x80) n1 = hi; - - // Dirty trick: RJMPs proceeding to the next instruction are used - // to delay two clock cycles in one instruction word (rather than - // using two NOPs). This was necessary in order to squeeze the - // loop down to exactly 64 words -- the maximum possible for a - // relative branch. - - asm volatile( - "headD:" "\n\t" // Clk Pseudocode - // Bit 7: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 6" "\n\t" // 1-2 if(b & 0x40) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 6: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 5" "\n\t" // 1-2 if(b & 0x20) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 5: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 4" "\n\t" // 1-2 if(b & 0x10) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 4: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 3" "\n\t" // 1-2 if(b & 0x08) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 3: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 2" "\n\t" // 1-2 if(b & 0x04) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 2: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 1" "\n\t" // 1-2 if(b & 0x02) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 1: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 0" "\n\t" // 1-2 if(b & 0x01) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "sbiw %[count], 1" "\n\t" // 2 i-- (don't act on Z flag yet) - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "brne headD" "\n" // 2 while(i) (Z flag set above) - : [byte] "+r" (b), - [n1] "+r" (n1), - [n2] "+r" (n2), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -*/ - - // 14 instruction clocks per bit: HHHHxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,4,7) - volatile uint8_t next; - - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - next = lo; - if(b & 0x80) next = hi; - - // Don't "optimize" the OUT calls into the bitTime subroutine; - // we're exploiting the RCALL and RET as 3- and 4-cycle NOPs! - asm volatile( - "headD:" "\n\t" // (T = 0) - "out %[port], %[hi]" "\n\t" // (T = 1) - "rcall bitTimeD" "\n\t" // Bit 7 (T = 14) - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 6 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 5 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 4 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 3 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 2 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 1 - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi (T = 1) - "rjmp .+0" "\n\t" // 2 nop nop (T = 3) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 5) - "out %[port] , %[next]" "\n\t" // 1 PORT = next (T = 6) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 7) - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next] , %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo (T = 10) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 12) - "brne headD" "\n\t" // 2 if(i != 0) -> (next byte) - "rjmp doneD" "\n\t" - "bitTimeD:" "\n\t" // nop nop nop (T = 4) - "out %[port], %[next]" "\n\t" // 1 PORT = next (T = 5) - "mov %[next], %[lo]" "\n\t" // 1 next = lo (T = 6) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 7) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 10) - "ret" "\n\t" // 4 nop nop nop nop (T = 14) - "doneD:" "\n" - : [byte] "+r" (b), - [next] "+r" (next), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - - - -// 12 MHz(ish) AVR -------------------------------------------------------- -#elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) - - // In the 12 MHz case, an optimized 800 KHz datastream (no dead time - // between bytes) requires a PORT-specific loop similar to the 8 MHz - // code (but a little more relaxed in this case). - - // 15 instruction clocks per bit: HHHHxxxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,4,10) - - volatile uint8_t next; - - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - next = lo; - if(b & 0x80) next = hi; - - // Don't "optimize" the OUT calls into the bitTime subroutine; - // we're exploiting the RCALL and RET as 3- and 4-cycle NOPs! - asm volatile( - "headD:" "\n\t" // (T = 0) - "out %[port], %[hi]" "\n\t" // (T = 1) - "rcall bitTimeD" "\n\t" // Bit 7 (T = 15) - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 6 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 5 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 4 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 3 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 2 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 1 - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi (T = 1) - "rjmp .+0" "\n\t" // 2 nop nop (T = 3) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 5) - "out %[port] , %[next]" "\n\t" // 1 PORT = next (T = 6) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 7) - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next] , %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "nop" "\n\t" // 1 (T = 10) - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo (T = 11) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 13) - "brne headD" "\n\t" // 2 if(i != 0) -> (next byte) - "rjmp doneD" "\n\t" - "bitTimeD:" "\n\t" // nop nop nop (T = 4) - "out %[port], %[next]" "\n\t" // 1 PORT = next (T = 5) - "mov %[next], %[lo]" "\n\t" // 1 next = lo (T = 6) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 7) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "nop" "\n\t" // 1 (T = 10) - "out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 11) - "ret" "\n\t" // 4 nop nop nop nop (T = 15) - "doneD:" "\n" - : [byte] "+r" (b), - [next] "+r" (next), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - - -// 16 MHz(ish) AVR -------------------------------------------------------- -#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) - - // WS2811 and WS2812 have different hi/lo duty cycles; this is - // similar but NOT an exact copy of the prior 400-on-8 code. - - // 20 inst. clocks per bit: HHHHHxxxxxxxxLLLLLLL - // ST instructions: ^ ^ ^ (T=0,5,13) - - volatile uint8_t next, bit; - - hi = *port | pinMask; - lo = *port & ~pinMask; - next = lo; - bit = 8; - - asm volatile( - "head20:" "\n\t" // Clk Pseudocode (T = 0) - "st %a[port], %[hi]" "\n\t" // 2 PORT = hi (T = 2) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 128) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 4) - "dec %[bit]" "\n\t" // 1 bit-- (T = 5) - "st %a[port], %[next]" "\n\t" // 2 PORT = next (T = 7) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 8) - "breq nextbyte20" "\n\t" // 1-2 if(bit == 0) (from dec above) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 10) - "rjmp .+0" "\n\t" // 2 nop nop (T = 12) - "nop" "\n\t" // 1 nop (T = 13) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 15) - "nop" "\n\t" // 1 nop (T = 16) - "rjmp .+0" "\n\t" // 2 nop nop (T = 18) - "rjmp head20" "\n\t" // 2 -> head20 (next bit out) (T=20) - "nextbyte20:" "\n\t" // (T = 10) - "ldi %[bit] , 8" "\n\t" // 1 bit = 8 (T = 11) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 13) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 15) - "nop" "\n\t" // 1 nop (T = 16) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 18) - "brne head20" "\n" // 2 if(i != 0) -> (next byte) (T=20) - : [port] "+e" (port), - [byte] "+r" (b), - [bit] "+r" (bit), - [next] "+r" (next), - [count] "+w" (i) - : [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#elif (F_CPU >= 19000000UL) && (F_CPU <= 22000000L) - - - // 25 inst. clocks per bit: HHHHHHHxxxxxxxxLLLLLLLLLL - // ST instructions: ^ ^ ^ (T=0,7,15) - - volatile uint8_t next, bit; - - hi = *port | pinMask; - lo = *port & ~pinMask; - next = lo; - bit = 8; - - asm volatile( - "head20:" "\n\t" // Clk Pseudocode (T = 0) - "st %a[port], %[hi]" "\n\t" // 2 PORT = hi (T = 2) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 128) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 4) - "dec %[bit]" "\n\t" // 1 bit-- (T = 5) - "rjmp .+0" "\n\t" // 2 nop nop (T = 7) - "st %a[port], %[next]" "\n\t" // 2 PORT = next (T = 9) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 10) - "breq nextbyte20" "\n\t" // 1-2 if(bit == 0) (from dec above) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 12) - "rjmp .+0" "\n\t" // 2 nop nop (T = 14) - "nop" "\n\t" // 1 nop (T = 15) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 17) - "rjmp .+0" "\n\t" // 2 nop nop (T = 19) - "rjmp .+0" "\n\t" // 2 nop nop (T = 21) - "rjmp .+0" "\n\t" // 2 nop nop (T = 23) - "rjmp head20" "\n\t" // 2 -> head20 (next bit out) - "nextbyte20:" "\n\t" // (T = 12) - "ldi %[bit] , 8" "\n\t" // 1 bit = 8 (T = 13) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 15) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 17) - "rjmp .+0" "\n\t" // 2 nop nop (T = 19) - "rjmp .+0" "\n\t" // 2 nop nop (T = 21) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 23) - "brne head20" "\n" // 2 if(i != 0) -> (next byte) () - : [port] "+e" (port), - [byte] "+r" (b), - [bit] "+r" (bit), - [next] "+r" (next), - [count] "+w" (i) - : [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#else - #error "CPU SPEED NOT SUPPORTED" -#endif - - -// END AVR ---------------------------------------------------------------- - - - - - - interrupts(); - #ifndef DISABLEMILLIS - endTime = micros(); // Save EOD time for latch on next call - #endif -} - -// Set the output pin number -void tinyNeoPixel::setPin(uint8_t p) { - if(begun && (pin >= 0)) pinMode(pin, INPUT); - pin = p; - if(begun) { - pinMode(p, OUTPUT); - digitalWrite(p, LOW); - } - port = portOutputRegister(digitalPinToPort(p)); - pinMask = digitalPinToBitMask(p); -} - -// Set pixel color from separate R,G,B components: -void tinyNeoPixel::setPixelColor( - uint16_t n, uint8_t r, uint8_t g, uint8_t b) { - - if(n < numLEDs) { - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - } - uint8_t *p; - if(wOffset == rOffset) { // Is an RGB-type strip - p = &pixels[n * 3]; // 3 bytes per pixel - } else { // Is a WRGB-type strip - p = &pixels[n * 4]; // 4 bytes per pixel - p[wOffset] = 0; // But only R,G,B passed -- set W to 0 - } - p[rOffset] = r; // R,G,B always stored - p[gOffset] = g; - p[bOffset] = b; - } -} - -void tinyNeoPixel::setPixelColor( - uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - - if(n < numLEDs) { - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - w = (w * brightness) >> 8; - } - uint8_t *p; - if(wOffset == rOffset) { // Is an RGB-type strip - p = &pixels[n * 3]; // 3 bytes per pixel (ignore W) - } else { // Is a WRGB-type strip - p = &pixels[n * 4]; // 4 bytes per pixel - p[wOffset] = w; // Store W - } - p[rOffset] = r; // Store R,G,B - p[gOffset] = g; - p[bOffset] = b; - } -} - -// Set pixel color from 'packed' 32-bit RGB color: -void tinyNeoPixel::setPixelColor(uint16_t n, uint32_t c) { - if(n < numLEDs) { - uint8_t *p, - r = (uint8_t)(c >> 16), - g = (uint8_t)(c >> 8), - b = (uint8_t)c; - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - } - if(wOffset == rOffset) { - p = &pixels[n * 3]; - } else { - p = &pixels[n * 4]; - uint8_t w = (uint8_t)(c >> 24); - p[wOffset] = brightness ? ((w * brightness) >> 8) : w; - } - p[rOffset] = r; - p[gOffset] = g; - p[bOffset] = b; - } -} - -// Convert separate R,G,B into packed 32-bit RGB color. -// Packed format is always RGB, regardless of LED strand color order. -uint32_t tinyNeoPixel::Color(uint8_t r, uint8_t g, uint8_t b) { - return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; -} - -// Convert separate R,G,B,W into packed 32-bit WRGB color. -// Packed format is always WRGB, regardless of LED strand color order. -uint32_t tinyNeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; -} - -// Query color from previously-set pixel (returns packed 32-bit RGB value) -uint32_t tinyNeoPixel::getPixelColor(uint16_t n) const { - if(n >= numLEDs) return 0; // Out of bounds, return no color. - - uint8_t *p; - - if(wOffset == rOffset) { // Is RGB-type device - p = &pixels[n * 3]; - if(brightness) { - // Stored color was decimated by setBrightness(). Returned value - // attempts to scale back to an approximation of the original 24-bit - // value used when setting the pixel color, but there will always be - // some error -- those bits are simply gone. Issue is most - // pronounced at low brightness levels. - return (((uint32_t)(p[rOffset] << 8) / brightness) << 16) | - (((uint32_t)(p[gOffset] << 8) / brightness) << 8) | - ( (uint32_t)(p[bOffset] << 8) / brightness ); - } else { - // No brightness adjustment has been made -- return 'raw' color - return ((uint32_t)p[rOffset] << 16) | - ((uint32_t)p[gOffset] << 8) | - (uint32_t)p[bOffset]; - } - } else { // Is RGBW-type device - p = &pixels[n * 4]; - if(brightness) { // Return scaled color - return (((uint32_t)(p[wOffset] << 8) / brightness) << 24) | - (((uint32_t)(p[rOffset] << 8) / brightness) << 16) | - (((uint32_t)(p[gOffset] << 8) / brightness) << 8) | - ( (uint32_t)(p[bOffset] << 8) / brightness ); - } else { // Return raw color - return ((uint32_t)p[wOffset] << 24) | - ((uint32_t)p[rOffset] << 16) | - ((uint32_t)p[gOffset] << 8) | - (uint32_t)p[bOffset]; - } - } -} - -// Returns pointer to pixels[] array. Pixel data is stored in device- -// native format and is not translated here. Application will need to be -// aware of specific pixel data format and handle colors appropriately. -uint8_t *tinyNeoPixel::getPixels(void) const { - return pixels; -} - -uint16_t tinyNeoPixel::numPixels(void) const { - return numLEDs; -} - -// Adjust output brightness; 0=darkest (off), 255=brightest. This does -// NOT immediately affect what's currently displayed on the LEDs. The -// next call to show() will refresh the LEDs at this level. However, -// this process is potentially "lossy," especially when increasing -// brightness. The tight timing in the WS2811/WS2812 code means there -// aren't enough free cycles to perform this scaling on the fly as data -// is issued. So we make a pass through the existing color data in RAM -// and scale it (subsequent graphics commands also work at this -// brightness level). If there's a significant step up in brightness, -// the limited number of steps (quantization) in the old data will be -// quite visible in the re-scaled version. For a non-destructive -// change, you'll need to re-render the full strip data. -void tinyNeoPixel::setBrightness(uint8_t b) { - // Stored brightness value is different than what's passed. - // This simplifies the actual scaling math later, allowing a fast - // 8x8-bit multiply and taking the MSB. 'brightness' is a uint8_t, - // adding 1 here may (intentionally) roll over...so 0 = max brightness - // (color values are interpreted literally; no scaling), 1 = min - // brightness (off), 255 = just below max brightness. - uint8_t newBrightness = b + 1; - if(newBrightness != brightness) { // Compare against prior value - // Brightness has changed -- re-scale existing data in RAM - uint8_t c, - *ptr = pixels, - oldBrightness = brightness - 1; // De-wrap old brightness value - uint16_t scale; - if(oldBrightness == 0) scale = 0; // Avoid /0 - else if(b == 255) scale = 65535 / oldBrightness; - else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness; - for(uint16_t i=0; i> 8; - } - brightness = newBrightness; - } -} - -//Return the brightness value -uint8_t tinyNeoPixel::getBrightness(void) const { - return brightness - 1; -} - -void tinyNeoPixel::clear() { - memset(pixels, 0, numBytes); -} diff --git a/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.h b/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.h deleted file mode 100644 index 0a543bad..00000000 --- a/megaavr/libraries/tinyNeoPixel/tinyNeoPixel.h +++ /dev/null @@ -1,172 +0,0 @@ -/*-------------------------------------------------------------------- - This file is part of the Adafruit NeoPixel library. - - NeoPixel 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 3 of - the License, or (at your option) any later version. - - NeoPixel 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 NeoPixel. If not, see - . - --------------------------------------------------------------------*/ - -#ifndef TINYNEOPIXEL -#define TINYNEOPIXEL - -#include - - -// The order of primary colors in the NeoPixel data stream can vary -// among device types, manufacturers and even different revisions of -// the same item. The third parameter to the Adafruit_NeoPixel -// constructor encodes the per-pixel byte offsets of the red, green -// and blue primaries (plus white, if present) in the data stream -- -// the following #defines provide an easier-to-use named version for -// each permutation. e.g. NEO_GRB indicates a NeoPixel-compatible -// device expecting three bytes per pixel, with the first byte -// containing the green value, second containing red and third -// containing blue. The in-memory representation of a chain of -// NeoPixels is the same as the data-stream order; no re-ordering of -// bytes is required when issuing data to the chain. - -// Bits 5,4 of this value are the offset (0-3) from the first byte of -// a pixel to the location of the red color byte. Bits 3,2 are the -// green offset and 1,0 are the blue offset. If it is an RGBW-type -// device (supporting a white primary in addition to R,G,B), bits 7,6 -// are the offset to the white byte...otherwise, bits 7,6 are set to -// the same value as 5,4 (red) to indicate an RGB (not RGBW) device. -// i.e. binary representation: -// 0bWWRRGGBB for RGBW devices -// 0bRRRRGGBB for RGB - -// RGB NeoPixel permutations; white and red offsets are always same -// Offset: W R G B -#define NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) -#define NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) -#define NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) -#define NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) -#define NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) -#define NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) - -// RGBW NeoPixel permutations; all 4 offsets are distinct -// Offset: W R G B -#define NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) -#define NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) -#define NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) -#define NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) -#define NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) -#define NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) - -#define NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) -#define NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) -#define NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) -#define NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) -#define NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) -#define NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) - -#define NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) -#define NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) -#define NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) -#define NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) -#define NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) -#define NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) - -#define NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) -#define NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) -#define NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) -#define NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) -#define NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) -#define NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) - -// Add NEO_KHZ400 to the color order value to indicate a 400 KHz -// device. All but the earliest v1 NeoPixels expect an 800 KHz data -// stream, this is the default if unspecified. Because flash space -// is very limited on ATtiny devices (e.g. Trinket, Gemma), v1 -// NeoPixels aren't handled by default on those chips, though it can -// be enabled by removing the ifndef/endif below -- but code will be -// bigger. Conversely, can disable the NEO_KHZ400 line on other MCUs -// to remove v1 support and save a little space. - -#define NEO_KHZ800 0x0000 // 800 KHz datastream - -// If 400 KHz support is enabled, the third parameter to the constructor -// requires a 16-bit value (in order to select 400 vs 800 KHz speed). -// If only 800 KHz is enabled (as is default on ATtiny), an 8-bit value -// is sufficient to encode pixel color order, saving some space. - - -typedef uint8_t neoPixelType; - -class tinyNeoPixel { - - public: - - // Constructor: number of LEDs, pin number, LED type - tinyNeoPixel(uint16_t n, uint8_t p=3, neoPixelType t=NEO_GRB + NEO_KHZ800); - tinyNeoPixel(void); - ~tinyNeoPixel(); - - void - begin(void), - show(void), - setPin(uint8_t p), - setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b), - setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w), - setPixelColor(uint16_t n, uint32_t c), - setBrightness(uint8_t), - clear(), - updateLength(uint16_t n), - updateType(neoPixelType t); - uint8_t - *getPixels(void) const, - getBrightness(void) const; - int8_t - getPin(void) { return pin; }; - uint16_t - numPixels(void) const; - static uint32_t - Color(uint8_t r, uint8_t g, uint8_t b), - Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w); - uint32_t - getPixelColor(uint16_t n) const; -#ifndef DISABLEMILLIS - inline bool - canShow(void) { return (micros() - endTime) >= 50L; } -#else - inline bool - canShow(void) {return 1;} //we don't have micros here; -#endif - - - private: - - boolean - begun; // true if begin() previously called - uint16_t - numLEDs, // Number of RGB LEDs in strip - numBytes; // Size of 'pixels' buffer below (3 or 4 bytes/pixel) - int8_t - pin; // Output pin number (-1 if not yet set) - uint8_t - brightness, - *pixels, // Holds LED color values (3 or 4 bytes each) - rOffset, // Index of red byte within each 3- or 4-byte pixel - gOffset, // Index of green byte - bOffset, // Index of blue byte - wOffset; // Index of white byte (same as rOffset if no white) - uint32_t - endTime; // Latch timing reference - volatile uint8_t - *port; // Output PORT register - uint8_t - pinMask; // Output PORT bitmask - -}; - -#endif // ADAFRUIT_NEOPIXEL_H diff --git a/megaavr/libraries/tinyNeoPixel_Static/COPYING b/megaavr/libraries/tinyNeoPixel_Static/COPYING deleted file mode 100644 index 7a225496..00000000 --- a/megaavr/libraries/tinyNeoPixel_Static/COPYING +++ /dev/null @@ -1,793 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - - -LGPL ADDENDUM: - - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/megaavr/libraries/tinyNeoPixel_Static/examples/buttoncycler/buttoncycler.ino b/megaavr/libraries/tinyNeoPixel_Static/examples/buttoncycler/buttoncycler.ino deleted file mode 100644 index 2a4756f5..00000000 --- a/megaavr/libraries/tinyNeoPixel_Static/examples/buttoncycler/buttoncycler.ino +++ /dev/null @@ -1,172 +0,0 @@ -// This is a demonstration on how to use an input device to trigger changes on your neo pixels. -// You should wire a momentary push button to connect from ground to a digital IO pin. When you -// press the button it will change to a new pixel animation. Note that you need to press the -// button once to start the first animation! - -#include - -#define BUTTON_PIN 2 // Digital IO pin connected to the button. This will be - // driven with a pull-up resistor so the switch should - // pull the pin to ground momentarily. On a high -> low - // transition the button press logic will execute. - -#define PIXEL_PIN 6 // Digital IO pin connected to the NeoPixels. - -#define PIXEL_COUNT 16 - - -// Since this is for the static version of the library, we need to supply the pixel array -// This saves space by eliminating use of malloc() and free(), and makes the RAM used for -// the frame buffer show up when the sketch is compiled. - -byte pixels[PIXEL_COUNT * 3]; - -// Parameter 1 = number of pixels in strip, neopixel stick has 8 -// Parameter 2 = pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_RGB Pixels are wired for RGB bitstream -// NEO_GRB Pixels are wired for GRB bitstream, correct for neopixel stick - -tinyNeoPixel strip = tinyNeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB, pixels); - -bool oldState = HIGH; -int showType = 0; - -void setup() { - pinMode(BUTTON_PIN, INPUT_PULLUP); - pinMode(PIXEL_PIN, OUTPUT); - //strip.begin(); - strip.show(); // Initialize all pixels to 'off' -} - -void loop() { - // Get current button state. - bool newState = digitalRead(BUTTON_PIN); - - // Check if state changed from high to low (button press). - if (newState == LOW && oldState == HIGH) { - // Short delay to debounce button. - delay(20); - // Check if button is still low after debounce. - newState = digitalRead(BUTTON_PIN); - if (newState == LOW) { - showType++; - if (showType > 9) - showType=0; - startShow(showType); - } - } - - // Set the last button state to the old state. - oldState = newState; -} - -void startShow(int i) { - switch(i){ - case 0: colorWipe(strip.Color(0, 0, 0), 50); // Black/off - break; - case 1: colorWipe(strip.Color(255, 0, 0), 50); // Red - break; - case 2: colorWipe(strip.Color(0, 255, 0), 50); // Green - break; - case 3: colorWipe(strip.Color(0, 0, 255), 50); // Blue - break; - case 4: theaterChase(strip.Color(127, 127, 127), 50); // White - break; - case 5: theaterChase(strip.Color(127, 0, 0), 50); // Red - break; - case 6: theaterChase(strip.Color( 0, 0, 127), 50); // Blue - break; - case 7: rainbow(20); - break; - case 8: rainbowCycle(20); - break; - case 9: theaterChaseRainbow(50); - break; - } -} - -// Fill the dots one after the other with a color -void colorWipe(uint32_t c, uint8_t wait) { - for(uint16_t i=0; i - - -// Which pin on the Arduino is connected to the NeoPixels? -// This example uses pin 3, which is on PORTA on all megaTinyCore boards, so default menu option will work. -#define PIN 3 - -// How many NeoPixels are attached to the Arduino? -#define NUMPIXELS 16 - -// Since this is for the static version of the library, we need to supply the pixel array -// This saves space by eliminating use of malloc() and free(), and makes the RAM used for -// the frame buffer show up when the sketch is compiled. - -byte pixels[NUMPIXELS * 3]; - -// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. -// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest -// example for more information on possible values. - -tinyNeoPixel leds = tinyNeoPixel(NUMPIXELS, PIN, NEO_GRB, pixels); - -int delayval = 500; // delay for half a second - -void setup() { - pinMode(PIN,OUTPUT); - //with tinyNeoPixel_Static, you need to set pinMode yourself. This means you can eliminate pinMode() - //and replace with direct port writes to save a couple hundred bytes in sketch size (note that this - //savings is only present when you eliminate *all* references to pinMode). - //leds.begin() not needed on tinyNeoPixel -} - -void loop() { - - // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. - - for(int i=0;i - -#define PIN 3 - -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// Parameter 4 = array to store pixel data in - -#define NUMPIXELS 60 - -// Since this is for the static version of the library, we need to supply the pixel array -// This saves space by eliminating use of malloc() and free(), and makes the RAM used for -// the frame buffer show up when the sketch is compiled. - -byte pixels[NUMPIXELS * 3]; - -// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. -// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest -// example for more information on possible values. Finally, for the 4th argument we pass the array we -// defined above. - -tinyNeoPixel strip = tinyNeoPixel(NUMPIXELS, PIN, NEO_GRB, pixels); - -// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across -// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input -// and minimize distance between Arduino and first pixel. Avoid connecting -// on a live circuit...if you must, connect GND first. - -void setup() { - pinMode(PIN,OUTPUT); //set pin output - this is not done internally by the library for Static version of library - //strip.begin(); //Static version does not use this. - strip.show(); // Initialize all pixels to 'off' -} - -void loop() { - // Some example procedures showing how to display to the pixels: - colorWipe(strip.Color(255, 0, 0), 50); // Red - colorWipe(strip.Color(0, 255, 0), 50); // Green - colorWipe(strip.Color(0, 0, 255), 50); // Blue - // Send a theater pixel chase in... - theaterChase(strip.Color(127, 127, 127), 50); // White - theaterChase(strip.Color(127, 0, 0), 50); // Red - theaterChase(strip.Color(0, 0, 127), 50); // Blue - - rainbow(20); - rainbowCycle(20); - theaterChaseRainbow(50); -} - -// Fill the dots one after the other with a color -void colorWipe(uint32_t c, uint8_t wait) { - for(uint16_t i=0; i -sentence=Arduino library for controlling single-wire-based LED pixels and strip for ATtinyCore and megaTinyCore. -paragraph=his library is closely based on the original Adafruit_NeoPixel library. It has been modified to support the megaAVR architecture, clock speeds of 20MHz and 10MHz, and to use the port selected in the tools menu for speeds under 16MHz. This version has been further modified; a statically defined buffer is passed to the constructor (and ability to change length removed), eliminating use of malloc/free, and ensuring that the memory used for the buffer is shown at compile time. See documentation for full description. -category=Display -url=https://github.com/SpenceKonde/megaTinyCore -architectures=megaavr, avr diff --git a/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.cpp b/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.cpp deleted file mode 100644 index 1e509987..00000000 --- a/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.cpp +++ /dev/null @@ -1,777 +0,0 @@ -/*------------------------------------------------------------------------- - Arduino library to control a wide variety of WS2811- and WS2812-based RGB - LED devices such as Adafruit FLORA RGB Smart Pixels and NeoPixel strips. - Currently handles 800 KHz bitstreams on 8, 10, 12, 16, and 20 MHz ATtiny - MCUs used with megaTinyCore 1.0.3+ and ATTinyCore 1.30+ with LEDs wired - for various color orders. - - Written by Phil Burgess / Paint Your Dragon for Adafruit Industries, - contributions by PJRC, Michael Miller and other members of the open - source community. - - Modified for megaAVR and 20MHz and 10MHz support by Spence Konde - - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing products - from Adafruit! - - ------------------------------------------------------------------------- - This file is part of the Adafruit NeoPixel library. - - NeoPixel 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 3 of - the License, or (at your option) any later version. - - NeoPixel 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 NeoPixel. If not, see - . - -------------------------------------------------------------------------*/ - -#include "tinyNeoPixel_Static.h" - -// Constructor when length, pin and type are known at compile-time: -tinyNeoPixel::tinyNeoPixel(uint16_t n, uint8_t p, neoPixelType t, uint8_t *pxl) : - brightness(0), pixels(pxl), endTime(0) -{ - //boolean oldThreeBytesPerPixel = (wOffset == rOffset); // false if RGBW - - wOffset = (t >> 6) & 0b11; // See notes in header file - rOffset = (t >> 4) & 0b11; // regarding R/G/B/W offsets - gOffset = (t >> 2) & 0b11; - bOffset = t & 0b11; - numBytes = n * ((wOffset == rOffset) ? 3 : 4); - numLEDs=n; - if(p >= 0) { - pin = p; -#ifdef __AVR__ - port = portOutputRegister(digitalPinToPort(p)); - pinMask = digitalPinToBitMask(p); -#endif - } -} - - - -tinyNeoPixel::~tinyNeoPixel() { - //if(pixels) free(pixels); - //if(pin >= 0) pinMode(pin, INPUT); -} - - -void tinyNeoPixel::show(void) { - - if(!pixels) return; - - // Data latch = 50+ microsecond pause in the output stream. Rather than - // put a delay at the end of the function, the ending time is noted and - // the function will simply hold off (if needed) on issuing the - // subsequent round of data until the latch time has elapsed. This - // allows the mainline code to start generating the next frame of data - // rather than stalling for the latch. - while(!canShow()); - // endTime is a private member (rather than global var) so that multiple - // instances on different pins can be quickly issued in succession (each - // instance doesn't delay the next). - - // In order to make this code runtime-configurable to work with any pin, - // SBI/CBI instructions are eschewed in favor of full PORT writes via the - // OUT or ST instructions. It relies on two facts: that peripheral - // functions (such as PWM) take precedence on output pins, so our PORT- - // wide writes won't interfere, and that interrupts are globally disabled - // while data is being issued to the LEDs, so no other code will be - // accessing the PORT. The code takes an initial 'snapshot' of the PORT - // state, computes 'pin high' and 'pin low' values, and writes these back - // to the PORT register as needed. - - noInterrupts(); // Need 100% focus on instruction timing - - -// AVR MCUs -- ATtiny and megaAVR ATtiny ------------------------------- - - volatile uint16_t - i = numBytes; // Loop counter - volatile uint8_t - *ptr = pixels, // Pointer to next byte - b = *ptr++, // Current byte value - hi, // PORT w/output bit set high - lo; // PORT w/output bit set low - - // Hand-tuned assembly code issues data to the LED drivers at a specific - // rate. There's separate code for different CPU speeds (8, 12, 16 MHz) - // for both the WS2811 (400 KHz) and WS2812 (800 KHz) drivers. The - // datastream timing for the LED drivers allows a little wiggle room each - // way (listed in the datasheets), so the conditions for compiling each - // case are set up for a range of frequencies rather than just the exact - // 8, 12 or 16 MHz values, permitting use with some close-but-not-spot-on - // devices (e.g. 16.5 MHz DigiSpark). The ranges were arrived at based - // on the datasheet figures and have not been extensively tested outside - // the canonical 8/12/16 MHz speeds; there's no guarantee these will work - // close to the extremes (or possibly they could be pushed further). - // Keep in mind only one CPU speed case actually gets compiled; the - // resulting program isn't as massive as it might look from source here. - -// 8 MHz(ish) AVR --------------------------------------------------------- -#if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) - - volatile uint8_t n1, n2 = 0; // First, next bits out - - // Squeezing an 800 KHz stream out of an 8 MHz chip requires code - // specific to each PORT register. At present this is only written - // to work with pins on PORTD or PORTB, the most likely use case -- - // this covers all the pins on the Adafruit Flora and the bulk of - // digital pins on the Arduino Pro 8 MHz (keep in mind, this code - // doesn't even get compiled for 16 MHz boards like the Uno, Mega, - // Leonardo, etc., so don't bother extending this out of hand). - // Additional PORTs could be added if you really need them, just - // duplicate the else and loop and change the PORT. Each add'l - // PORT will require about 150(ish) bytes of program space. - - // 10 instruction clocks per bit: HHxxxxxLLL - // OUT instructions: ^ ^ ^ (T=0,2,7) - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - n1 = lo; - if(b & 0x80) n1 = hi; - - // Dirty trick: RJMPs proceeding to the next instruction are used - // to delay two clock cycles in one instruction word (rather than - // using two NOPs). This was necessary in order to squeeze the - // loop down to exactly 64 words -- the maximum possible for a - // relative branch. - - asm volatile( - "headD:" "\n\t" // Clk Pseudocode - // Bit 7: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 6" "\n\t" // 1-2 if(b & 0x40) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 6: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 5" "\n\t" // 1-2 if(b & 0x20) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 5: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 4" "\n\t" // 1-2 if(b & 0x10) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 4: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 3" "\n\t" // 1-2 if(b & 0x08) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 3: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 2" "\n\t" // 1-2 if(b & 0x04) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 2: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 1" "\n\t" // 1-2 if(b & 0x02) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 1: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 0" "\n\t" // 1-2 if(b & 0x01) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "sbiw %[count], 1" "\n\t" // 2 i-- (don't act on Z flag yet) - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "brne headD" "\n" // 2 while(i) (Z flag set above) - : [byte] "+r" (b), - [n1] "+r" (n1), - [n2] "+r" (n2), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#elif (F_CPU >= 9500000UL) && (F_CPU <= 11100000UL) -/* - volatile uint8_t n1, n2 = 0; // First, next bits out - - // Squeezing an 800 KHz stream out of an 8 MHz chip requires code - // specific to each PORT register. At present this is only written - // to work with pins on PORTD or PORTB, the most likely use case -- - // this covers all the pins on the Adafruit Flora and the bulk of - // digital pins on the Arduino Pro 8 MHz (keep in mind, this code - // doesn't even get compiled for 16 MHz boards like the Uno, Mega, - // Leonardo, etc., so don't bother extending this out of hand). - // Additional PORTs could be added if you really need them, just - // duplicate the else and loop and change the PORT. Each add'l - // PORT will require about 150(ish) bytes of program space. - - // 13 instruction clocks per bit: HHHxxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,3,7) - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - n1 = lo; - if(b & 0x80) n1 = hi; - - // Dirty trick: RJMPs proceeding to the next instruction are used - // to delay two clock cycles in one instruction word (rather than - // using two NOPs). This was necessary in order to squeeze the - // loop down to exactly 64 words -- the maximum possible for a - // relative branch. - - asm volatile( - "headD:" "\n\t" // Clk Pseudocode - // Bit 7: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 6" "\n\t" // 1-2 if(b & 0x40) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 6: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 5" "\n\t" // 1-2 if(b & 0x20) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 5: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 4" "\n\t" // 1-2 if(b & 0x10) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 4: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 3" "\n\t" // 1-2 if(b & 0x08) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 3: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 2" "\n\t" // 1-2 if(b & 0x04) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 2: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 1" "\n\t" // 1-2 if(b & 0x02) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "rjmp .+0" "\n\t" // 2 nop nop - // Bit 1: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n2] , %[lo]" "\n\t" // 1 n2 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n1]" "\n\t" // 1 PORT = n1 - "rjmp .+0" "\n\t" // 2 nop nop - "sbrc %[byte] , 0" "\n\t" // 1-2 if(b & 0x01) - "mov %[n2] , %[hi]" "\n\t" // 0-1 n2 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "sbiw %[count], 1" "\n\t" // 2 i-- (don't act on Z flag yet) - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi - "mov %[n1] , %[lo]" "\n\t" // 1 n1 = lo - "nop" "\n\t" // 1 nop - "out %[port] , %[n2]" "\n\t" // 1 PORT = n2 - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) - "mov %[n1] , %[hi]" "\n\t" // 0-1 n1 = hi - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo - "rjmp .+0" "\n\t" // 2 nop nop - "brne headD" "\n" // 2 while(i) (Z flag set above) - : [byte] "+r" (b), - [n1] "+r" (n1), - [n2] "+r" (n2), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -*/ - - // 14 instruction clocks per bit: HHHHxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,4,7) - volatile uint8_t next; - - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - next = lo; - if(b & 0x80) next = hi; - - // Don't "optimize" the OUT calls into the bitTime subroutine; - // we're exploiting the RCALL and RET as 3- and 4-cycle NOPs! - asm volatile( - "headD:" "\n\t" // (T = 0) - "out %[port], %[hi]" "\n\t" // (T = 1) - "rcall bitTimeD" "\n\t" // Bit 7 (T = 14) - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 6 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 5 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 4 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 3 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 2 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 1 - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi (T = 1) - "rjmp .+0" "\n\t" // 2 nop nop (T = 3) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 5) - "out %[port] , %[next]" "\n\t" // 1 PORT = next (T = 6) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 7) - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next] , %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo (T = 10) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 12) - "brne headD" "\n\t" // 2 if(i != 0) -> (next byte) - "rjmp doneD" "\n\t" - "bitTimeD:" "\n\t" // nop nop nop (T = 4) - "out %[port], %[next]" "\n\t" // 1 PORT = next (T = 5) - "mov %[next], %[lo]" "\n\t" // 1 next = lo (T = 6) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 7) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 10) - "ret" "\n\t" // 4 nop nop nop nop (T = 14) - "doneD:" "\n" - : [byte] "+r" (b), - [next] "+r" (next), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - - - -// 12 MHz(ish) AVR -------------------------------------------------------- -#elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) - - // In the 12 MHz case, an optimized 800 KHz datastream (no dead time - // between bytes) requires a PORT-specific loop similar to the 8 MHz - // code (but a little more relaxed in this case). - - // 15 instruction clocks per bit: HHHHxxxxxxLLLLL - // OUT instructions: ^ ^ ^ (T=0,4,10) - - volatile uint8_t next; - - hi = NEOPIXELPORT | pinMask; - lo = NEOPIXELPORT & ~pinMask; - next = lo; - if(b & 0x80) next = hi; - - // Don't "optimize" the OUT calls into the bitTime subroutine; - // we're exploiting the RCALL and RET as 3- and 4-cycle NOPs! - asm volatile( - "headD:" "\n\t" // (T = 0) - "out %[port], %[hi]" "\n\t" // (T = 1) - "rcall bitTimeD" "\n\t" // Bit 7 (T = 15) - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 6 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 5 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 4 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 3 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 2 - "out %[port], %[hi]" "\n\t" - "rcall bitTimeD" "\n\t" // Bit 1 - // Bit 0: - "out %[port] , %[hi]" "\n\t" // 1 PORT = hi (T = 1) - "rjmp .+0" "\n\t" // 2 nop nop (T = 3) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 5) - "out %[port] , %[next]" "\n\t" // 1 PORT = next (T = 6) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 7) - "sbrc %[byte] , 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next] , %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "nop" "\n\t" // 1 (T = 10) - "out %[port] , %[lo]" "\n\t" // 1 PORT = lo (T = 11) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 13) - "brne headD" "\n\t" // 2 if(i != 0) -> (next byte) - "rjmp doneD" "\n\t" - "bitTimeD:" "\n\t" // nop nop nop (T = 4) - "out %[port], %[next]" "\n\t" // 1 PORT = next (T = 5) - "mov %[next], %[lo]" "\n\t" // 1 next = lo (T = 6) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 7) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 0x80) (T = 8) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 9) - "nop" "\n\t" // 1 (T = 10) - "out %[port], %[lo]" "\n\t" // 1 PORT = lo (T = 11) - "ret" "\n\t" // 4 nop nop nop nop (T = 15) - "doneD:" "\n" - : [byte] "+r" (b), - [next] "+r" (next), - [count] "+w" (i) - : [port] "I" (_SFR_IO_ADDR(NEOPIXELPORT)), - [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - - -// 16 MHz(ish) AVR -------------------------------------------------------- -#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) - - // WS2811 and WS2812 have different hi/lo duty cycles; this is - // similar but NOT an exact copy of the prior 400-on-8 code. - - // 20 inst. clocks per bit: HHHHHxxxxxxxxLLLLLLL - // ST instructions: ^ ^ ^ (T=0,5,13) - - volatile uint8_t next, bit; - - hi = *port | pinMask; - lo = *port & ~pinMask; - next = lo; - bit = 8; - - asm volatile( - "head20:" "\n\t" // Clk Pseudocode (T = 0) - "st %a[port], %[hi]" "\n\t" // 2 PORT = hi (T = 2) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 128) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 4) - "dec %[bit]" "\n\t" // 1 bit-- (T = 5) - "st %a[port], %[next]" "\n\t" // 2 PORT = next (T = 7) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 8) - "breq nextbyte20" "\n\t" // 1-2 if(bit == 0) (from dec above) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 10) - "rjmp .+0" "\n\t" // 2 nop nop (T = 12) - "nop" "\n\t" // 1 nop (T = 13) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 15) - "nop" "\n\t" // 1 nop (T = 16) - "rjmp .+0" "\n\t" // 2 nop nop (T = 18) - "rjmp head20" "\n\t" // 2 -> head20 (next bit out) (T=20) - "nextbyte20:" "\n\t" // (T = 10) - "ldi %[bit] , 8" "\n\t" // 1 bit = 8 (T = 11) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 13) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 15) - "nop" "\n\t" // 1 nop (T = 16) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 18) - "brne head20" "\n" // 2 if(i != 0) -> (next byte) (T=20) - : [port] "+e" (port), - [byte] "+r" (b), - [bit] "+r" (bit), - [next] "+r" (next), - [count] "+w" (i) - : [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#elif (F_CPU >= 19000000UL) && (F_CPU <= 22000000L) - - - // 25 inst. clocks per bit: HHHHHHHxxxxxxxxLLLLLLLLLL - // ST instructions: ^ ^ ^ (T=0,7,15) - - volatile uint8_t next, bit; - - hi = *port | pinMask; - lo = *port & ~pinMask; - next = lo; - bit = 8; - - asm volatile( - "head20:" "\n\t" // Clk Pseudocode (T = 0) - "st %a[port], %[hi]" "\n\t" // 2 PORT = hi (T = 2) - "sbrc %[byte], 7" "\n\t" // 1-2 if(b & 128) - "mov %[next], %[hi]" "\n\t" // 0-1 next = hi (T = 4) - "dec %[bit]" "\n\t" // 1 bit-- (T = 5) - "rjmp .+0" "\n\t" // 2 nop nop (T = 7) - "st %a[port], %[next]" "\n\t" // 2 PORT = next (T = 9) - "mov %[next] , %[lo]" "\n\t" // 1 next = lo (T = 10) - "breq nextbyte20" "\n\t" // 1-2 if(bit == 0) (from dec above) - "rol %[byte]" "\n\t" // 1 b <<= 1 (T = 12) - "rjmp .+0" "\n\t" // 2 nop nop (T = 14) - "nop" "\n\t" // 1 nop (T = 15) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 17) - "rjmp .+0" "\n\t" // 2 nop nop (T = 19) - "rjmp .+0" "\n\t" // 2 nop nop (T = 21) - "rjmp .+0" "\n\t" // 2 nop nop (T = 23) - "rjmp head20" "\n\t" // 2 -> head20 (next bit out) - "nextbyte20:" "\n\t" // (T = 12) - "ldi %[bit] , 8" "\n\t" // 1 bit = 8 (T = 13) - "ld %[byte] , %a[ptr]+" "\n\t" // 2 b = *ptr++ (T = 15) - "st %a[port], %[lo]" "\n\t" // 2 PORT = lo (T = 17) - "rjmp .+0" "\n\t" // 2 nop nop (T = 19) - "rjmp .+0" "\n\t" // 2 nop nop (T = 21) - "sbiw %[count], 1" "\n\t" // 2 i-- (T = 23) - "brne head20" "\n" // 2 if(i != 0) -> (next byte) () - : [port] "+e" (port), - [byte] "+r" (b), - [bit] "+r" (bit), - [next] "+r" (next), - [count] "+w" (i) - : [ptr] "e" (ptr), - [hi] "r" (hi), - [lo] "r" (lo)); - -#else - #error "CPU SPEED NOT SUPPORTED" -#endif - -// END AVR ---------------------------------------------------------------- - - - interrupts(); -#ifndef DISABLEMILLIS - endTime = micros(); // Save EOD time for latch on next call -#endif -} - -// Set the output pin number -void tinyNeoPixel::setPin(uint8_t p) { - pin = p; - port = portOutputRegister(digitalPinToPort(p)); - pinMask = digitalPinToBitMask(p); -} - -// Set pixel color from separate R,G,B components: -void tinyNeoPixel::setPixelColor( - uint16_t n, uint8_t r, uint8_t g, uint8_t b) { - - if(n < numLEDs) { - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - } - uint8_t *p; - if(wOffset == rOffset) { // Is an RGB-type strip - p = &pixels[n * 3]; // 3 bytes per pixel - } else { // Is a WRGB-type strip - p = &pixels[n * 4]; // 4 bytes per pixel - p[wOffset] = 0; // But only R,G,B passed -- set W to 0 - } - p[rOffset] = r; // R,G,B always stored - p[gOffset] = g; - p[bOffset] = b; - } -} - -void tinyNeoPixel::setPixelColor( - uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - - if(n < numLEDs) { - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - w = (w * brightness) >> 8; - } - uint8_t *p; - if(wOffset == rOffset) { // Is an RGB-type strip - p = &pixels[n * 3]; // 3 bytes per pixel (ignore W) - } else { // Is a WRGB-type strip - p = &pixels[n * 4]; // 4 bytes per pixel - p[wOffset] = w; // Store W - } - p[rOffset] = r; // Store R,G,B - p[gOffset] = g; - p[bOffset] = b; - } -} - -// Set pixel color from 'packed' 32-bit RGB color: -void tinyNeoPixel::setPixelColor(uint16_t n, uint32_t c) { - if(n < numLEDs) { - uint8_t *p, - r = (uint8_t)(c >> 16), - g = (uint8_t)(c >> 8), - b = (uint8_t)c; - if(brightness) { // See notes in setBrightness() - r = (r * brightness) >> 8; - g = (g * brightness) >> 8; - b = (b * brightness) >> 8; - } - if(wOffset == rOffset) { - p = &pixels[n * 3]; - } else { - p = &pixels[n * 4]; - uint8_t w = (uint8_t)(c >> 24); - p[wOffset] = brightness ? ((w * brightness) >> 8) : w; - } - p[rOffset] = r; - p[gOffset] = g; - p[bOffset] = b; - } -} - -// Convert separate R,G,B into packed 32-bit RGB color. -// Packed format is always RGB, regardless of LED strand color order. -uint32_t tinyNeoPixel::Color(uint8_t r, uint8_t g, uint8_t b) { - return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; -} - -// Convert separate R,G,B,W into packed 32-bit WRGB color. -// Packed format is always WRGB, regardless of LED strand color order. -uint32_t tinyNeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; -} - -// Query color from previously-set pixel (returns packed 32-bit RGB value) -uint32_t tinyNeoPixel::getPixelColor(uint16_t n) const { - if(n >= numLEDs) return 0; // Out of bounds, return no color. - - uint8_t *p; - - if(wOffset == rOffset) { // Is RGB-type device - p = &pixels[n * 3]; - if(brightness) { - // Stored color was decimated by setBrightness(). Returned value - // attempts to scale back to an approximation of the original 24-bit - // value used when setting the pixel color, but there will always be - // some error -- those bits are simply gone. Issue is most - // pronounced at low brightness levels. - return (((uint32_t)(p[rOffset] << 8) / brightness) << 16) | - (((uint32_t)(p[gOffset] << 8) / brightness) << 8) | - ( (uint32_t)(p[bOffset] << 8) / brightness ); - } else { - // No brightness adjustment has been made -- return 'raw' color - return ((uint32_t)p[rOffset] << 16) | - ((uint32_t)p[gOffset] << 8) | - (uint32_t)p[bOffset]; - } - } else { // Is RGBW-type device - p = &pixels[n * 4]; - if(brightness) { // Return scaled color - return (((uint32_t)(p[wOffset] << 8) / brightness) << 24) | - (((uint32_t)(p[rOffset] << 8) / brightness) << 16) | - (((uint32_t)(p[gOffset] << 8) / brightness) << 8) | - ( (uint32_t)(p[bOffset] << 8) / brightness ); - } else { // Return raw color - return ((uint32_t)p[wOffset] << 24) | - ((uint32_t)p[rOffset] << 16) | - ((uint32_t)p[gOffset] << 8) | - (uint32_t)p[bOffset]; - } - } -} - -// Returns pointer to pixels[] array. Pixel data is stored in device- -// native format and is not translated here. Application will need to be -// aware of specific pixel data format and handle colors appropriately. -uint8_t *tinyNeoPixel::getPixels(void) const { - return pixels; -} - -uint16_t tinyNeoPixel::numPixels(void) const { - return numLEDs; -} - -// Adjust output brightness; 0=darkest (off), 255=brightest. This does -// NOT immediately affect what's currently displayed on the LEDs. The -// next call to show() will refresh the LEDs at this level. However, -// this process is potentially "lossy," especially when increasing -// brightness. The tight timing in the WS2811/WS2812 code means there -// aren't enough free cycles to perform this scaling on the fly as data -// is issued. So we make a pass through the existing color data in RAM -// and scale it (subsequent graphics commands also work at this -// brightness level). If there's a significant step up in brightness, -// the limited number of steps (quantization) in the old data will be -// quite visible in the re-scaled version. For a non-destructive -// change, you'll need to re-render the full strip data. -void tinyNeoPixel::setBrightness(uint8_t b) { - // Stored brightness value is different than what's passed. - // This simplifies the actual scaling math later, allowing a fast - // 8x8-bit multiply and taking the MSB. 'brightness' is a uint8_t, - // adding 1 here may (intentionally) roll over...so 0 = max brightness - // (color values are interpreted literally; no scaling), 1 = min - // brightness (off), 255 = just below max brightness. - uint8_t newBrightness = b + 1; - if(newBrightness != brightness) { // Compare against prior value - // Brightness has changed -- re-scale existing data in RAM - uint8_t c, - *ptr = pixels, - oldBrightness = brightness - 1; // De-wrap old brightness value - uint16_t scale; - if(oldBrightness == 0) scale = 0; // Avoid /0 - else if(b == 255) scale = 65535 / oldBrightness; - else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness; - for(uint16_t i=0; i> 8; - } - brightness = newBrightness; - } -} - -//Return the brightness value -uint8_t tinyNeoPixel::getBrightness(void) const { - return brightness - 1; -} - -void tinyNeoPixel::clear() { - memset(pixels, 0, numBytes); -} diff --git a/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.h b/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.h deleted file mode 100644 index a89c058d..00000000 --- a/megaavr/libraries/tinyNeoPixel_Static/tinyNeoPixel_Static.h +++ /dev/null @@ -1,156 +0,0 @@ -/*-------------------------------------------------------------------- - This file is part of the Adafruit NeoPixel library. - - NeoPixel 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 3 of - the License, or (at your option) any later version. - - NeoPixel 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 NeoPixel. If not, see - . - --------------------------------------------------------------------*/ - -#ifndef TINYNEOPIXEL -#define TINYNEOPIXEL - -#include - -// The order of primary colors in the NeoPixel data stream can vary -// among device types, manufacturers and even different revisions of -// the same item. The third parameter to the Adafruit_NeoPixel -// constructor encodes the per-pixel byte offsets of the red, green -// and blue primaries (plus white, if present) in the data stream -- -// the following #defines provide an easier-to-use named version for -// each permutation. e.g. NEO_GRB indicates a NeoPixel-compatible -// device expecting three bytes per pixel, with the first byte -// containing the green value, second containing red and third -// containing blue. The in-memory representation of a chain of -// NeoPixels is the same as the data-stream order; no re-ordering of -// bytes is required when issuing data to the chain. - -// Bits 5,4 of this value are the offset (0-3) from the first byte of -// a pixel to the location of the red color byte. Bits 3,2 are the -// green offset and 1,0 are the blue offset. If it is an RGBW-type -// device (supporting a white primary in addition to R,G,B), bits 7,6 -// are the offset to the white byte...otherwise, bits 7,6 are set to -// the same value as 5,4 (red) to indicate an RGB (not RGBW) device. -// i.e. binary representation: -// 0bWWRRGGBB for RGBW devices -// 0bRRRRGGBB for RGB - -// RGB NeoPixel permutations; white and red offsets are always same -// Offset: W R G B -#define NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) -#define NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) -#define NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) -#define NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) -#define NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) -#define NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) - -// RGBW NeoPixel permutations; all 4 offsets are distinct -// Offset: W R G B -#define NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) -#define NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) -#define NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) -#define NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) -#define NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) -#define NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) - -#define NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) -#define NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) -#define NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) -#define NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) -#define NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) -#define NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) - -#define NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) -#define NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) -#define NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) -#define NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) -#define NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) -#define NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) - -#define NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) -#define NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) -#define NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) -#define NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) -#define NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) -#define NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) - - - -#define NEO_KHZ800 0x0000 // 800 KHz datastream - - -typedef uint8_t neoPixelType; - - -class tinyNeoPixel { - - public: - - // Constructor: number of LEDs, pin number, LED type - //Adafruit_NeoPixel(uint16_t n, uint8_t p=6, neoPixelType t=NEO_GRB + NEO_KHZ800,uint8_t *pxl); - tinyNeoPixel(uint16_t n, uint8_t p, neoPixelType t,uint8_t *pxl); - //Adafruit_NeoPixel(void); - ~tinyNeoPixel(); - - void - show(void), - setPin(uint8_t p), - setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b), - setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w), - setPixelColor(uint16_t n, uint32_t c), - setBrightness(uint8_t), - clear(); - uint8_t - *getPixels(void) const, - getBrightness(void) const; - int8_t - getPin(void) { return pin; }; - uint16_t - numPixels(void) const; - static uint32_t - Color(uint8_t r, uint8_t g, uint8_t b), - Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w); - uint32_t - getPixelColor(uint16_t n) const; -#ifndef DISABLEMILLIS - inline bool - canShow(void) { return (micros() - endTime) >= 50L; } -#else - inline bool - canShow(void) {return 1;} //we don't have micros here; -#endif - - private: - - //begun; // true if begin() previously called - uint16_t - numLEDs, // Number of RGB LEDs in strip - numBytes; // Size of 'pixels' buffer below (3 or 4 bytes/pixel) - int8_t - pin; // Output pin number (-1 if not yet set) - uint8_t - brightness, - *pixels, // Holds LED color values (3 or 4 bytes each) - rOffset, // Index of red byte within each 3- or 4-byte pixel - gOffset, // Index of green byte - bOffset, // Index of blue byte - wOffset; // Index of white byte (same as rOffset if no white) - uint32_t - endTime; // Latch timing reference - volatile uint8_t - *port; // Output PORT register - uint8_t - pinMask; // Output PORT bitmask - -}; - -#endif diff --git a/megaavr/variants/txy2/pins_arduino.h b/megaavr/variants/txy2/pins_arduino.h deleted file mode 100644 index 5d33ec23..00000000 --- a/megaavr/variants/txy2/pins_arduino.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - 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 -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include -#include "timers.h" - -#define NUM_DIGITAL_PINS 6 // -#define NUM_ANALOG_INPUTS 9 -//#define NUM_RESERVED_PINS 0 // (TOSC1/2, VREF, RESET, DEBUG USART Rx/Tx) -//#define NUM_INTERNALLY_USED_PINS 0 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin) -#define NUM_I2C_PINS 2 // (SDA / SCL) -#define NUM_SPI_PINS 3 // (MISO / MOSI / SCK) -#define NUM_TOTAL_FREE_PINS (NUM_DIGITAL_PINS) -#define NUM_TOTAL_PINS 6 - -#define EXTERNAL_NUM_INTERRUPTS 8 - - -#define digitalPinHasPWM(p) ((p) == 4) - -#define SPI_MUX (PORTMUX_SPI0_DEFAULT_gc) -#define PIN_SPI_MISO (3) -#define PIN_SPI_SCK (4) -#define PIN_SPI_MOSI (2) -#define PIN_SPI_SS (0) - -#define MUX_SPI (SPI_MUX) -#define SPI_INTERFACES_COUNT 1 - -static const uint8_t SS = PIN_SPI_SS; //We don't have an SS pin! -static const uint8_t MOSI = PIN_SPI_MOSI; -static const uint8_t MISO = PIN_SPI_MISO; -static const uint8_t SCK = PIN_SPI_SCK; - -#define PIN_WIRE_SDA (2) -#define PIN_WIRE_SCL (3) - -#define TWI_MUX 0 - -static const uint8_t SDA = PIN_WIRE_SDA; -static const uint8_t SCL = PIN_WIRE_SCL; - -// Mapped to HWSERIAL0 in Serial library -#define HWSERIAL0 (&USART0) -#define HWSERIAL0_DRE_VECTOR (USART0_DRE_vect) -#define HWSERIAL0_DRE_VECTOR_NUM (USART0_DRE_vect_num) -#define HWSERIAL0_RXC_VECTOR (USART0_RXC_vect) -#ifdef UARTREMAP -#define HWSERIAL0_MUX 0x01 -#define PIN_WIRE_HWSERIAL0_RX (3) -#define PIN_WIRE_HWSERIAL0_TX (2) -#else -#define HWSERIAL0_MUX 0x00 -#define PIN_WIRE_HWSERIAL0_RX (1) -#define PIN_WIRE_HWSERIAL0_TX (0) -#endif - - -#define LED_BUILTIN 1 - - -#define PIN_A0 (5) -#define PIN_A1 (2) -#define PIN_A2 (3) -#define PIN_A3 (4) -#define PIN_A6 (0) -#define PIN_A7 (1) - -static const uint8_t A0 = PIN_A0; -static const uint8_t A1 = PIN_A1; -static const uint8_t A2 = PIN_A2; -static const uint8_t A3 = PIN_A3; -static const uint8_t A6 = PIN_A6; -static const uint8_t A7 = PIN_A7; - -#define PINS_COUNT (6u) - -#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. - -// ATtiny412 / ARDUINO -// _____ -// VDD 1|* |20 GND -// (DAC) (AIN6) PA6 0 2| |19 4~ PA3 (AIN3)(SCK)(EXTCLK) -// (AIN7) PA7 1 3| |18 5 PA0 (nRESET/UPDI) -// (MOSI)(TXD)(SDA) (AIN1) PA1 2 4|_____|17 3 PA2 (AIN2)(MISO)(RXD)(SCL) -// -// - -/* -PIN# DESC Pin Name Other/Sp ADC0 ADC1 PTC AC0 AC1 AC2 DAC0 USART0 SPI0 TWI0 TCA(PWM) TCBn TCD0 CCL -0 A2 or DAC PA6 AIN6 AIN2 X2/Y2 AINN0 AINP1 AINP0 OUT RxD WOA -1 A3 PA7 AIN7 AIN3 X3/Y3 AINP0 AINP0 AINN0 TxD *WO0 WOB LUT1-OUT -2 MOSI PA1 AIN1 *TxD MOSI SDA WO1 LUT0-IN1 -3 MISO PA2 EVOUT0 AIN2 *RxD MISO SCL WO2 LUT0-IN2 -4 SCK PA3 EXTCLK AIN3 *XCK SCK WO3 TCB1 WO -5 UPDI PA0 RESET/ AIN0 LUT1-IN0 - UPDI - * alternative pin locations -*/ - -const uint8_t PROGMEM digital_pin_to_port[] = { - PA, // 0 PA6 - PA, // 1 PA7 - PA, // 2 PA1 - PA, // 3 PA2 - // skip PA0 UPDI - PA, // 4 PA3 - PA // 5 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_position[] = { - PIN6_bp, // 0 PA6 - PIN7_bp, // 1 PA7 - PIN1_bp, // 2 PA1 - PIN2_bp, // 3 PA2 - // skip PA0 UPDI - PIN3_bp, // 4 PA3 - PIN0_bp // 5 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_mask[] = { - PIN6_bm, // 0 PA6 - PIN7_bm, // 1 PA7 - PIN1_bm, // 2 PA1 - PIN2_bm, // 3 PA2 - // skip PA0 UPDI - PIN3_bm, // 4 PA3 - PIN0_bm // 5 PA0 -}; - -const uint8_t PROGMEM digital_pin_to_timer[] = { - #ifdef DAC0 - DACOUT, - #else - NOT_ON_TIMER, // 0 PA6 - #endif - TIMERA0, // 1 PA7 - TIMERA0, // 2 PA1 - TIMERA0, // 3 PA2 - // skip PA0 UPDI - TIMERA0, // 4 PA3 - NOT_ON_TIMER // 5 PA0 -}; - -/* -#define PIN_A0 (5) -#define PIN_A1 (2) -#define PIN_A2 (3) -#define PIN_A3 (4) -#define PIN_A6 (0) -#define PIN_A7 (1) - -*/ -#endif - -extern const uint8_t analog_pin_to_channel[]; -// #define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) -//#define digitalPinToAnalogInput(p) (((p) < 6 || (p) == 8 || (p) == 9 || (p) > 13) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN) -#define digitalPinToAnalogInput(p) ((p<2)?(p+6):(p<5?(p-1):(p==5?0:NOT_A_PIN))) - - -// 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_HARDWARE Serial - -#endif diff --git a/megaavr/variants/txy2/variant.c b/megaavr/variants/txy2/variant.c deleted file mode 100644 index e95e4bb5..00000000 --- a/megaavr/variants/txy2/variant.c +++ /dev/null @@ -1,100 +0,0 @@ -#include - -#include "pins_arduino.h" -#include "api/Common.h" - -#define FORCE_INLINE __attribute__((always_inline)) inline - -void setup_timers() { - - /* TYPE A TIMER */ - - /* PORTMUX setting for TCA - don't need to set because using default */ - //PORTMUX.CTRLA = PORTMUX_TCA00_DEFAULT_gc; - - /* Enable Split Mode */ - TCA0.SPLIT.CTRLD = TCA_SPLIT_SPLITM_bm; - - //Only 1 WGM so no need to specifically set up. - - /* Period setting, 8-bit register in SPLIT mode */ - TCA0.SPLIT.LPER = PWM_TIMER_PERIOD; - TCA0.SPLIT.HPER = PWM_TIMER_PERIOD; - - /* Default duty 50%, will re-assign in analogWrite() */ - //TODO: replace with for loop to make this smaller; - TCA0.SPLIT.LCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP2 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP2 = PWM_TIMER_COMPARE; - - /* Use DIV64 prescaler (giving 250kHz clock), enable TCA timer */ - TCA0.SPLIT.CTRLA = (TCA_SINGLE_CLKSEL_DIV64_gc) | (TCA_SINGLE_ENABLE_bm); - - - /* TYPE B TIMERS */ - - // No megaTinyCore parts need to change the port mapping. - - /* Start with TCB0 */ - TCB_t *timer_B = (TCB_t *)&TCB0; - - /* Timer B Setup loop for TCB[0:2] */ - #ifdef TCB1 - do{ - #endif - /* 8 bit PWM mode, but do not enable output yet, will do in analogWrite() */ - timer_B->CTRLB = (TCB_CNTMODE_PWM8_gc); - - /* Assign 8-bit period */ - timer_B->CCMPL = PWM_TIMER_PERIOD; - - /* default duty 50%, set when output enabled */ - timer_B->CCMPH = PWM_TIMER_COMPARE; - - /* Use TCA clock (250kHz) and enable */ - /* (sync update commented out, might try to synchronize later */ - timer_B->CTRLA = (TCB_CLKSEL_CLKTCA_gc) - //|(TCB_SYNCUPD_bm) - |(TCB_ENABLE_bm); - - /* Increment pointer to next TCB instance */ - timer_B++; - - /* Stop when pointing to TCB3 */ - // } while (timer_B < (TCB_t *)&TCB3); - - // ATtiny only uses up to TCB1 - /* Stop when pointing to TCB1 */ - #ifdef TCB1 - } while (timer_B <= (TCB_t *)&TCB1); - #endif - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TCD0.CMPBCLR=255; //Count to 255 (8-bit resolution) - TCD0.CTRLC=0x80; //WOD outputs PWM B, WOC outputs PWM A - TCD0.CTRLB=0x03; //dual slope - TCD0.CTRLA=0x10; //OSC20M prescaled by 32, gives ~1.2 khz PWM at 20MHz. - #endif - -} - -FORCE_INLINE bool isDoubleBondedActive(uint8_t pin) { - (void)pin; - - /* Check if TWI is operating on double bonded pin (Master Enable is high - in both Master and Slave mode for bus error detection, so this can - indicate an active state for Wire) */ - //if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return true; - - /* Special check for SPI_SS double bonded pin -- no action if SPI is active - (Using SPI Enable bit as indicator of SPI activity) */ - //if((pin == 10) && (SPI0.CTRLA & SPI_ENABLE_bm)) return true; - - return false; -} - -void initVariant() { - // NA -} diff --git a/megaavr/variants/txy4/pins_arduino.h b/megaavr/variants/txy4/pins_arduino.h deleted file mode 100644 index 04afaf33..00000000 --- a/megaavr/variants/txy4/pins_arduino.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - 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 -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include -#include "timers.h" - -#define NUM_DIGITAL_PINS 12 // -#define NUM_ANALOG_INPUTS 9 -//#define NUM_RESERVED_PINS 0 // (TOSC1/2, VREF, RESET, DEBUG USART Rx/Tx) -//#define NUM_INTERNALLY_USED_PINS 0 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin) -#define NUM_I2C_PINS 2 // (SDA / SCL) -#define NUM_SPI_PINS 3 // (MISO / MOSI / SCK) -#define NUM_TOTAL_FREE_PINS (NUM_DIGITAL_PINS) -#define NUM_TOTAL_PINS (NUM_DIGITAL_PINS) - -#define EXTERNAL_NUM_INTERRUPTS 12 - - -#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 5 || (p) == 6 || (p) == 7 || (p) == 10) - -#define SPI_MUX (PORTMUX_SPI0_DEFAULT_gc) -#define PIN_SPI_MISO (9) -#define PIN_SPI_SCK (10) -#define PIN_SPI_MOSI (8) -#define PIN_SPI_SS (0) - -#define MUX_SPI (SPI_MUX) -#define SPI_INTERFACES_COUNT 1 - -static const uint8_t SS = PIN_SPI_SS; -static const uint8_t MOSI = PIN_SPI_MOSI; -static const uint8_t MISO = PIN_SPI_MISO; -static const uint8_t SCK = PIN_SPI_SCK; - -#define PIN_WIRE_SDA (6) -#define PIN_WIRE_SCL (7) - -#define TWI_MUX (PORTMUX_TWI0_DEFAULT_gc) - -static const uint8_t SDA = PIN_WIRE_SDA; -static const uint8_t SCL = PIN_WIRE_SCL; - -// Mapped to HWSERIAL0 in Serial library -#define HWSERIAL0 (&USART0) -#define HWSERIAL0_DRE_VECTOR (USART0_DRE_vect) -#define HWSERIAL0_DRE_VECTOR_NUM (USART0_DRE_vect_num) -#define HWSERIAL0_RXC_VECTOR (USART0_RXC_vect) -#ifdef UARTREMAP -#define HWSERIAL0_MUX 0x01 -#define PIN_WIRE_HWSERIAL0_RX (9) -#define PIN_WIRE_HWSERIAL0_TX (8) -#else -#define HWSERIAL0_MUX 0x00 -#define PIN_WIRE_HWSERIAL0_RX (4) -#define PIN_WIRE_HWSERIAL0_TX (5) -#endif - - -#define LED_BUILTIN 3 //FIXME - - -#define PIN_A0 (11) -#define PIN_A1 (8) -#define PIN_A2 (9) -#define PIN_A3 (10) -#define PIN_A4 (0) -#define PIN_A5 (1) -#define PIN_A6 (2) -#define PIN_A7 (3) -#define PIN_A10 (6) -#define PIN_A11 (7) - -static const uint8_t A0 = PIN_A0; -static const uint8_t A1 = PIN_A1; -static const uint8_t A2 = PIN_A2; -static const uint8_t A3 = PIN_A3; -static const uint8_t A4 = PIN_A4; -static const uint8_t A5 = PIN_A5; -static const uint8_t A6 = PIN_A6; -static const uint8_t A7 = PIN_A7; -static const uint8_t A10 = PIN_A10; -static const uint8_t A11 = PIN_A11; - -#define PINS_COUNT (12u) - -#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. - -// ATtiny1614 / ARDUINO -// _____ -// VDD 1|* |14 GND -// (nSS) (AIN4) PA4 0~ 2| |13 10~ PA3 (AIN3)(SCK)(EXTCLK) -// (AIN5) PA5 1~ 3| |12 9 PA2 (AIN2)(MISO) -// (DAC) (AIN6) PA6 2 4| |11 8 PA1 (AIN1)(MOSI) -// (AIN7) PA7 3 5| |10 11 PA0 (nRESET/UPDI) -// (RXD) (TOSC1) PB3 4 6| |9 7~ PB0 (AIN11)(SCL) -// (TXD) (TOSC2) PB2 5~ 7|_____|8 6~ PB1 (AIN10)(SDA) -// -// - -/* -PIN# DESC Pin Name Other/Sp ADC0 ADC1 PTC AC0 AC1 AC2 DAC0 USART0 SPI0 TWI0 TCA(PWM) TCBn TCD0 CCL -0 A0 or SS PA4 AIN4 AIN0 X0/Y0 XDIR SS WO4 WOA LUT0-OUT -1 A1 PA5 VREFA AIN5 AIN1 X1/Y1 OUT AINN0 WO5 TCB0 WO WOB -2 A2 or DAC PA6 AIN6 AIN2 X2/Y2 AINN0 AINP1 AINP0 OUT -3 A3 PA7 AIN7 AIN3 X3/Y3 AINP0 AINP0 AINN0 LUT1-OUT -4 RX PB3 TOSC1 OUT RxD *WO0 -5 TX PB2 TOSC2 / OUT TxD WO2 - EVOUT1 -6 SDA PB1 AIN10 X4/Y4 AINP2 XCK SDA WO1 -7 SCL PB0 AIN11 X5/Y5 AINP2 AINP1 XDIR SCL WO0 -8 MOSI PA1 AIN1 *TxD MOSI *SDA LUT0-IN1 -9 MISO PA2 EVOUT0 AIN2 *RxD MISO *SCL LUT0-IN2 -10 SCK PA3 EXTCLK AIN3 *XCK SCK WO3 TCB1 WO -11 UPDI PA0 RESET/ AIN0 LUT1-IN0 - UPDI - * alternative pin locations -*/ - -const uint8_t PROGMEM digital_pin_to_port[] = { - // Left side, top to bottom - PA, // 0 PA4 - PA, // 1 PA5 - PA, // 2 PA6 - PA, // 3 PA7 - PB, // 4 PB3 - PB, // 5 PB2 - // Right side, bottom to top - PB, // 6 PB1 - PB, // 7 PB0 - // skip PA0 UPDI - PA, // 8 PA1 - PA, // 9 PA2 - PA, // 10 PA3 - PA // 11 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_position[] = { - // Left side, top to bottom - PIN4_bp, // 0 PA4 - PIN5_bp, // 1 PA5 - PIN6_bp, // 2 PA6 - PIN7_bp, // 3 PA7 - PIN3_bp, // 4 PB3 - PIN2_bp, // 5 PB2 - // Right side, bottom to top - PIN1_bp, // 6 PB1 - PIN0_bp, // 7 PB0 - //skip PA0 UPDI - PIN1_bp, // 8 PA1 - PIN2_bp, // 9 PA2 - PIN3_bp, // 10 PA3 - PIN0_bp // 11 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_mask[] = { - // Left side, top to bottom - PIN4_bm, // 0 PA4 - PIN5_bm, // 1 PA5 - PIN6_bm, // 2 PA6 - PIN7_bm, // 3 PA7 - PIN3_bm, // 4 PB3 - PIN2_bm, // 5 PB2 - // Right side, bottom to top - PIN1_bm, // 6 PB1 - PIN0_bm, // 7 PB0 - //skip PA0 UPDI - PIN1_bm, // 8 PA1 - PIN2_bm, // 9 PA2 - PIN3_bm, // 10 PA3 - PIN0_bm // 11 PA0 -}; - -const uint8_t PROGMEM digital_pin_to_timer[] = { - // Left side, top to bottom - TIMERA0, // 0 PA4 - TIMERA0, // 1 PA5 - #ifdef DAC0 - DACOUT, // 2 PA6 - #else - NOT_ON_TIMER, // 2 PA6 - #endif - NOT_ON_TIMER, // 3 PA7 - NOT_ON_TIMER, // 4 PB3 - TIMERA0, // 5 PB2 - // Right side, bottom to top - TIMERA0, // 6 PB1 - TIMERA0, // 7 PB0 - //skip PA0 UPDI - NOT_ON_TIMER, // 8 PA1 - TIMERA0, // 9 PA2 - NOT_ON_TIMER, // 10 PA3 - NOT_ON_TIMER // 11 PA3 - - -}; -/* -#define PIN_A0 (11) -#define PIN_A1 (8) -#define PIN_A2 (9) -#define PIN_A3 (10) -#define PIN_A4 (0) -#define PIN_A5 (1) -#define PIN_A6 (2) -#define PIN_A7 (3) -#define PIN_A10 (6) -#define PIN_A11 (7) - -*/ -#endif - -extern const uint8_t analog_pin_to_channel[]; -// #define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) -//#define digitalPinToAnalogInput(p) (((p) < 6 || (p) == 8 || (p) == 9 || (p) > 13) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN) -#define digitalPinToAnalogInput(p) ((p<4)?(p+4):(p==11?0:((p>7)?(p-7):((p==6)?10:(p==7?11:NOT_A_PIN))))) - - -// 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_HARDWARE Serial - -#endif diff --git a/megaavr/variants/txy4/variant.c b/megaavr/variants/txy4/variant.c deleted file mode 100644 index e95e4bb5..00000000 --- a/megaavr/variants/txy4/variant.c +++ /dev/null @@ -1,100 +0,0 @@ -#include - -#include "pins_arduino.h" -#include "api/Common.h" - -#define FORCE_INLINE __attribute__((always_inline)) inline - -void setup_timers() { - - /* TYPE A TIMER */ - - /* PORTMUX setting for TCA - don't need to set because using default */ - //PORTMUX.CTRLA = PORTMUX_TCA00_DEFAULT_gc; - - /* Enable Split Mode */ - TCA0.SPLIT.CTRLD = TCA_SPLIT_SPLITM_bm; - - //Only 1 WGM so no need to specifically set up. - - /* Period setting, 8-bit register in SPLIT mode */ - TCA0.SPLIT.LPER = PWM_TIMER_PERIOD; - TCA0.SPLIT.HPER = PWM_TIMER_PERIOD; - - /* Default duty 50%, will re-assign in analogWrite() */ - //TODO: replace with for loop to make this smaller; - TCA0.SPLIT.LCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP2 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP2 = PWM_TIMER_COMPARE; - - /* Use DIV64 prescaler (giving 250kHz clock), enable TCA timer */ - TCA0.SPLIT.CTRLA = (TCA_SINGLE_CLKSEL_DIV64_gc) | (TCA_SINGLE_ENABLE_bm); - - - /* TYPE B TIMERS */ - - // No megaTinyCore parts need to change the port mapping. - - /* Start with TCB0 */ - TCB_t *timer_B = (TCB_t *)&TCB0; - - /* Timer B Setup loop for TCB[0:2] */ - #ifdef TCB1 - do{ - #endif - /* 8 bit PWM mode, but do not enable output yet, will do in analogWrite() */ - timer_B->CTRLB = (TCB_CNTMODE_PWM8_gc); - - /* Assign 8-bit period */ - timer_B->CCMPL = PWM_TIMER_PERIOD; - - /* default duty 50%, set when output enabled */ - timer_B->CCMPH = PWM_TIMER_COMPARE; - - /* Use TCA clock (250kHz) and enable */ - /* (sync update commented out, might try to synchronize later */ - timer_B->CTRLA = (TCB_CLKSEL_CLKTCA_gc) - //|(TCB_SYNCUPD_bm) - |(TCB_ENABLE_bm); - - /* Increment pointer to next TCB instance */ - timer_B++; - - /* Stop when pointing to TCB3 */ - // } while (timer_B < (TCB_t *)&TCB3); - - // ATtiny only uses up to TCB1 - /* Stop when pointing to TCB1 */ - #ifdef TCB1 - } while (timer_B <= (TCB_t *)&TCB1); - #endif - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TCD0.CMPBCLR=255; //Count to 255 (8-bit resolution) - TCD0.CTRLC=0x80; //WOD outputs PWM B, WOC outputs PWM A - TCD0.CTRLB=0x03; //dual slope - TCD0.CTRLA=0x10; //OSC20M prescaled by 32, gives ~1.2 khz PWM at 20MHz. - #endif - -} - -FORCE_INLINE bool isDoubleBondedActive(uint8_t pin) { - (void)pin; - - /* Check if TWI is operating on double bonded pin (Master Enable is high - in both Master and Slave mode for bus error detection, so this can - indicate an active state for Wire) */ - //if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return true; - - /* Special check for SPI_SS double bonded pin -- no action if SPI is active - (Using SPI Enable bit as indicator of SPI activity) */ - //if((pin == 10) && (SPI0.CTRLA & SPI_ENABLE_bm)) return true; - - return false; -} - -void initVariant() { - // NA -} diff --git a/megaavr/variants/txy6/pins_arduino.h b/megaavr/variants/txy6/pins_arduino.h deleted file mode 100644 index eb116bfe..00000000 --- a/megaavr/variants/txy6/pins_arduino.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - 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 -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include -#include "timers.h" - -#define NUM_DIGITAL_PINS 18 -#define NUM_ANALOG_INPUTS 12 -//#define NUM_RESERVED_PINS 0 // (TOSC1/2, VREF, RESET, DEBUG USART Rx/Tx) -//#define NUM_INTERNALLY_USED_PINS 0 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin) -#define NUM_I2C_PINS 2 // (SDA / SCL) -#define NUM_SPI_PINS 3 // (MISO / MOSI / SCK) -#define NUM_TOTAL_PINS 18 - -#define EXTERNAL_NUM_INTERRUPTS 20 - -#if (defined(TCD0) && defined(USE_TIMERD0_PWM)) -#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 7 || (p) == 8 || (p) == 9 || (p)==10 || (p)==11 || (p) == 16 ) -#else -#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 7 || (p) == 8 || (p) == 9 || (p) == 16 ) -#endif - -#define SPI_MUX (PORTMUX_SPI0_DEFAULT_gc) -#define PIN_SPI_MISO (15) -#define PIN_SPI_SCK (16) -#define PIN_SPI_MOSI (14) -#define PIN_SPI_SS (0) - -#define MUX_SPI (SPI_MUX) -#define SPI_INTERFACES_COUNT 1 - -static const uint8_t SS = PIN_SPI_SS; -static const uint8_t MOSI = PIN_SPI_MOSI; -static const uint8_t MISO = PIN_SPI_MISO; -static const uint8_t SCK = PIN_SPI_SCK; - -#define PIN_WIRE_SDA (8) -#define PIN_WIRE_SCL (9) - -#define TWI_MUX (PORTMUX_TWI0_DEFAULT_gc) - -static const uint8_t SDA = PIN_WIRE_SDA; -static const uint8_t SCL = PIN_WIRE_SCL; - -// Mapped to HWSERIAL0 in Serial library -#define HWSERIAL0 (&USART0) -#define HWSERIAL0_DRE_VECTOR (USART0_DRE_vect) -#define HWSERIAL0_DRE_VECTOR_NUM (USART0_DRE_vect_num) -#define HWSERIAL0_RXC_VECTOR (USART0_RXC_vect) -#ifdef UARTREMAP -#define HWSERIAL0_MUX 0x01 -#define PIN_WIRE_HWSERIAL0_RX (15) -#define PIN_WIRE_HWSERIAL0_TX (14) -#else -#define HWSERIAL0_MUX 0x00 -#define PIN_WIRE_HWSERIAL0_RX (6) -#define PIN_WIRE_HWSERIAL0_TX (7) -#endif - - -#define LED_BUILTIN 3 - -#define PIN_A0 (17) -#define PIN_A1 (14) -#define PIN_A2 (15) -#define PIN_A3 (16) -#define PIN_A4 (0) -#define PIN_A5 (1) -#define PIN_A6 (2) -#define PIN_A7 (3) -#define PIN_A8 (4) -#define PIN_A9 (5) -#define PIN_A10 (10) -#define PIN_A11 (11) - -static const uint8_t A0 = PIN_A0; -static const uint8_t A1 = PIN_A1; -static const uint8_t A2 = PIN_A2; -static const uint8_t A3 = PIN_A3; -static const uint8_t A4 = PIN_A4; -static const uint8_t A5 = PIN_A5; -static const uint8_t A6 = PIN_A6; -static const uint8_t A7 = PIN_A7; -static const uint8_t A8 = PIN_A8; -static const uint8_t A9 = PIN_A9; -static const uint8_t A10 = PIN_A10; -static const uint8_t A11 = PIN_A11; - -#define PINS_COUNT (18u) - -#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. - -// ATtiny1616 / ARDUINO -// _____ -// VDD 1|* |20 GND -// (nSS) (AIN4) PA4 0~ 2| |19 16~ PA3 (AIN3)(SCK)(EXTCLK) -// (AIN5) PA5 1~ 3| |18 15 PA2 (AIN2)(MISO) -// (DAC) (AIN6) PA6 2 4| |17 14 PA1 (AIN1)(MOSI) -// (AIN7) PA7 3 5| |16 17 PA0 (AIN0/nRESET/UPDI) -// (AIN8) PB5 4 6| |15 13 PC3 -// (AIN9) PB4 5 7| |14 12 PC2 -// (RXD) (TOSC1) PB3 6 8| |13 11~ PC1 (PWM only on 1-series) -// (TXD) (TOSC2) PB2 7~ 9| |12 10~ PC0 (PWM only on 1-series) -// (SDA) (AIN10) PB1 8~ 10|_____|11 9~ PB0 (AIN11)(SCL) -// -// - -/* -PIN# DESC Pin Name Other/Sp ADC0 ADC1 PTC AC0 AC1 AC2 DAC0 USART0 SPI0 TWI0 TCA(PWM) TCBn TCD0 CCL -0 A0 or SS PA4 AIN4 AIN0 X0/Y0 XDIR SS WO4 WOA LUT0-OUT -1 A1 PA5 VREFA AIN5 AIN1 X1/Y1 OUT AINN0 WO5 TCB0 WO WOB -2 A2 or DAC PA6 AIN6 AIN2 X2/Y2 AINN0 AINP1 AINP0 OUT -3 A3 PA7 AIN7 AIN3 X3/Y3 AINP0 AINP0 AINN0 LUT1-OUT -4 LED PB5 CLKOUT AIN8 AINP1 AINP2 *WO2 -5 PB4 AIN9 AINN1 AINP3 *WO1 *LUT0-OUT -6 RX PB3 TOSC1 OUT RxD *WO0 -7 TX PB2 TOSC2 / OUT TxD WO2 - EVOUT1 -8 SDA PB1 AIN10 X4/Y4 AINP2 XCK SDA WO1 -9 SCL PB0 AIN11 X5/Y5 AINP2 AINP1 XDIR SCL WO0 -10 PC0 AIN6 *SCK TCB0 WO WOC -11 PC1 AIN7 *MISO WOD *LUT1-OUT -12 PC2 EVOUT2 AIN8 *MOSI -13 PC3 AIN9 *SS *WO3 LUT1-IN0 -14 MOSI PA1 AIN1 *TxD MOSI *SDA LUT0-IN1 -15 MISO PA2 EVOUT0 AIN2 *RxD MISO *SCL LUT0-IN2 -16 SCK PA3 EXTCLK AIN3 *XCK SCK WO3 TCB1 WO -17 UPDI PA0 RESET/ AIN0 LUT1-IN0 - UPDI - * alternative pin locations -*/ - - -const uint8_t PROGMEM digital_pin_to_port[] = { - // Left side, top to bottom - PA, // 0 PA4 - PA, // 1 PA5 - PA, // 2 PA6 - PA, // 3 PA7 - PB, // 4 PB5 - PB, // 5 PB4 - PB, // 6 PB3 - PB, // 7 PB2 - PB, // 8 PB1 - // Right side, bottom to top - PB, // 9 PB0 - PC, // 10 PC0 - PC, // 11 PC1 - PC, // 12 PC2 - PC, // 13 PC3 - // skip PA0 until the end - PA, // 14 PA1 - PA, // 15 PA2 - PA, // 16 PA3 - PA // 17 PA0 UPDI/RST -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_position[] = { - // Left side, top to bottom - PIN4_bp, // 0 PA4 - PIN5_bp, // 1 PA5 - PIN6_bp, // 2 PA6 - PIN7_bp, // 3 PA7 - PIN5_bp, // 4 PB5 - PIN4_bp, // 5 PB4 - PIN3_bp, // 6 PB3 - PIN2_bp, // 7 PB2 - PIN1_bp, // 8 PB1 - // Right side, bottom to top - PIN0_bp, // 9 PB0 - PIN0_bp, // 10 PC0 - PIN1_bp, // 11 PC1 - PIN2_bp, // 12 PC2 - PIN3_bp, // 13 PC3 - PIN1_bp, // 14 PA1 - PIN2_bp, // 15 PA2 - PIN3_bp, // 16 PA3 - PIN0_bp // 17 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_mask[] = { - // Left side, top to bottom - PIN4_bm, // 0 PA4 - PIN5_bm, // 1 PA5 - PIN6_bm, // 2 PA6 - PIN7_bm, // 3 PA7 - PIN5_bm, // 4 PB5 - PIN4_bm, // 5 PB4 - PIN3_bm, // 6 PB3 - PIN2_bm, // 7 PB2 - PIN1_bm, // 8 PB1 - // Right side, bottom to top - PIN0_bm, // 9 PB0 - PIN0_bm, // 10 PC0 - PIN1_bm, // 11 PC1 - PIN2_bm, // 12 PC2 - PIN3_bm, // 13 PC3 - PIN1_bm, // 14 PA1 - PIN2_bm, // 15 PA2 - PIN3_bm, // 16 PA3 - PIN0_bm // 17 PA0 -}; - - -const uint8_t PROGMEM digital_pin_to_timer[] = { - // Left side, top to bottom - TIMERA0, // 0 PA4 - TIMERA0, // 1 PA5 - #ifdef DAC0 - DACOUT, // 2 PA6 - #else - NOT_ON_TIMER, // 2 PA6 - #endif - NOT_ON_TIMER, // 3 PA7 - NOT_ON_TIMER, // 4 PB5 - NOT_ON_TIMER, // 5 PB4 - NOT_ON_TIMER, // 6 PB3 - TIMERA0, // 7 PB2 - TIMERA0, // 8 PB1 - // Right side, bottom to top - TIMERA0, // 9 PB0 - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TIMERD0, // 10 PC0 - TIMERD0, // 11 PC1 - #else - NOT_ON_TIMER, // 10 PC0 - NOT_ON_TIMER, // 11 PC1 - #endif - NOT_ON_TIMER, // 12 PC2 - NOT_ON_TIMER, // 13 PC3 - NOT_ON_TIMER, // 14 PA1 - NOT_ON_TIMER, // 15 PA2 - TIMERA0, // 16 PA3 - NOT_ON_TIMER // 17 PA0 - - -}; -/* -const uint8_t PROGMEM analog_pin_to_channel[] = { - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 1, - 2, - 3 -}; -*/ -#endif - -//extern const uint8_t analog_pin_to_channel[]; -// #define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) -//#define digitalPinToAnalogInput(p) (((p) < 6 || (p) == 8 || (p) == 9 || (p) > 13) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN) -#define digitalPinToAnalogInput(p) ((p<6)?(p+4):(p==17?0:((p>13)?(p-13):((p==8)?10:(p==9?11:NOT_A_PIN))))) - - -// 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_HARDWARE Serial - -#endif diff --git a/megaavr/variants/txy6/variant.c b/megaavr/variants/txy6/variant.c deleted file mode 100644 index e95e4bb5..00000000 --- a/megaavr/variants/txy6/variant.c +++ /dev/null @@ -1,100 +0,0 @@ -#include - -#include "pins_arduino.h" -#include "api/Common.h" - -#define FORCE_INLINE __attribute__((always_inline)) inline - -void setup_timers() { - - /* TYPE A TIMER */ - - /* PORTMUX setting for TCA - don't need to set because using default */ - //PORTMUX.CTRLA = PORTMUX_TCA00_DEFAULT_gc; - - /* Enable Split Mode */ - TCA0.SPLIT.CTRLD = TCA_SPLIT_SPLITM_bm; - - //Only 1 WGM so no need to specifically set up. - - /* Period setting, 8-bit register in SPLIT mode */ - TCA0.SPLIT.LPER = PWM_TIMER_PERIOD; - TCA0.SPLIT.HPER = PWM_TIMER_PERIOD; - - /* Default duty 50%, will re-assign in analogWrite() */ - //TODO: replace with for loop to make this smaller; - TCA0.SPLIT.LCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP2 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP2 = PWM_TIMER_COMPARE; - - /* Use DIV64 prescaler (giving 250kHz clock), enable TCA timer */ - TCA0.SPLIT.CTRLA = (TCA_SINGLE_CLKSEL_DIV64_gc) | (TCA_SINGLE_ENABLE_bm); - - - /* TYPE B TIMERS */ - - // No megaTinyCore parts need to change the port mapping. - - /* Start with TCB0 */ - TCB_t *timer_B = (TCB_t *)&TCB0; - - /* Timer B Setup loop for TCB[0:2] */ - #ifdef TCB1 - do{ - #endif - /* 8 bit PWM mode, but do not enable output yet, will do in analogWrite() */ - timer_B->CTRLB = (TCB_CNTMODE_PWM8_gc); - - /* Assign 8-bit period */ - timer_B->CCMPL = PWM_TIMER_PERIOD; - - /* default duty 50%, set when output enabled */ - timer_B->CCMPH = PWM_TIMER_COMPARE; - - /* Use TCA clock (250kHz) and enable */ - /* (sync update commented out, might try to synchronize later */ - timer_B->CTRLA = (TCB_CLKSEL_CLKTCA_gc) - //|(TCB_SYNCUPD_bm) - |(TCB_ENABLE_bm); - - /* Increment pointer to next TCB instance */ - timer_B++; - - /* Stop when pointing to TCB3 */ - // } while (timer_B < (TCB_t *)&TCB3); - - // ATtiny only uses up to TCB1 - /* Stop when pointing to TCB1 */ - #ifdef TCB1 - } while (timer_B <= (TCB_t *)&TCB1); - #endif - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TCD0.CMPBCLR=255; //Count to 255 (8-bit resolution) - TCD0.CTRLC=0x80; //WOD outputs PWM B, WOC outputs PWM A - TCD0.CTRLB=0x03; //dual slope - TCD0.CTRLA=0x10; //OSC20M prescaled by 32, gives ~1.2 khz PWM at 20MHz. - #endif - -} - -FORCE_INLINE bool isDoubleBondedActive(uint8_t pin) { - (void)pin; - - /* Check if TWI is operating on double bonded pin (Master Enable is high - in both Master and Slave mode for bus error detection, so this can - indicate an active state for Wire) */ - //if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return true; - - /* Special check for SPI_SS double bonded pin -- no action if SPI is active - (Using SPI Enable bit as indicator of SPI activity) */ - //if((pin == 10) && (SPI0.CTRLA & SPI_ENABLE_bm)) return true; - - return false; -} - -void initVariant() { - // NA -} diff --git a/megaavr/variants/txy7/pins_arduino.h b/megaavr/variants/txy7/pins_arduino.h deleted file mode 100644 index 69537491..00000000 --- a/megaavr/variants/txy7/pins_arduino.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - 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 -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include -#include "timers.h" - -#define NUM_DIGITAL_PINS 22 -#define NUM_ANALOG_INPUTS 12 -//#define NUM_RESERVED_PINS 0 // (TOSC1/2, VREF, RESET, DEBUG USART Rx/Tx) -//#define NUM_INTERNALLY_USED_PINS 0 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin) -#define NUM_I2C_PINS 2 // (SDA / SCL) -#define NUM_SPI_PINS 3 // (MISO / MOSI / SCK) -#define NUM_TOTAL_PINS 22 - -#define EXTERNAL_NUM_INTERRUPTS 22 -#if (defined(TCD0) && defined(USE_TIMERD0_PWM)) -#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 7 || (p) == 8 || (p) == 9 || (p)==12 || (p)==13 || (p) == 16 ) -#else -#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 11 || (p) == 10 || (p) == 9 || (p) == 20) -#endif - -#define SPI_MUX (PORTMUX_SPI0_DEFAULT_gc) -#define PIN_SPI_MISO (19) -#define PIN_SPI_SCK (20) -#define PIN_SPI_MOSI (18) -#define PIN_SPI_SS (0) - -#define MUX_SPI (SPI_MUX) -#define SPI_INTERFACES_COUNT 1 - -static const uint8_t SS = PIN_SPI_SS; -static const uint8_t MOSI = PIN_SPI_MOSI; -static const uint8_t MISO = PIN_SPI_MISO; -static const uint8_t SCK = PIN_SPI_SCK; - -#define PIN_WIRE_SDA (10) -#define PIN_WIRE_SCL (11) - -#define TWI_MUX (PORTMUX_TWI0_DEFAULT_gc) - -static const uint8_t SDA = PIN_WIRE_SDA; -static const uint8_t SCL = PIN_WIRE_SCL; - -// Mapped to HWSERIAL0 in Serial library -#define HWSERIAL0 (&USART0) -#define HWSERIAL0_DRE_VECTOR (USART0_DRE_vect) -#define HWSERIAL0_DRE_VECTOR_NUM (USART0_DRE_vect_num) -#define HWSERIAL0_RXC_VECTOR (USART0_RXC_vect) -#ifdef UARTREMAP -#define HWSERIAL0_MUX 0x01 -#define PIN_WIRE_HWSERIAL0_RX (19) -#define PIN_WIRE_HWSERIAL0_TX (18) -#else -#define HWSERIAL0_MUX 0x00 -#define PIN_WIRE_HWSERIAL0_RX (8) -#define PIN_WIRE_HWSERIAL0_TX (9) -#endif - - -#define LED_BUILTIN 3 - -#define PINS_COUNT (22u) - - -#define PIN_A0 (21) -#define PIN_A1 (18) -#define PIN_A2 (19) -#define PIN_A3 (20) -#define PIN_A4 (0) -#define PIN_A5 (1) -#define PIN_A6 (2) -#define PIN_A7 (3) -#define PIN_A8 (6) -#define PIN_A9 (7) -#define PIN_A10 (10) -#define PIN_A11 (11) - -static const uint8_t A0 = PIN_A0; -static const uint8_t A1 = PIN_A1; -static const uint8_t A2 = PIN_A2; -static const uint8_t A3 = PIN_A3; -static const uint8_t A4 = PIN_A4; -static const uint8_t A5 = PIN_A5; -static const uint8_t A6 = PIN_A6; -static const uint8_t A7 = PIN_A7; -static const uint8_t A8 = PIN_A8; -static const uint8_t A9 = PIN_A9; -static const uint8_t A10 = PIN_A10; -static const uint8_t A11 = PIN_A11; - -#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. - -// ATtiny1617 / ARDUINO -// (MOSI) (UPDI) -// (AIN1) (AIN0) -// PA1 PA0 PC5 PC4 PC3 PC2 -// 18 21 17 16 15 14 -// ______________________________________ -// |* 24 23 22 21 20 19 | -// | | -// (MISO)(AIN2) PA2 19 | 1 18| 13 PC1 (PWM only on 1-series) -// | | -// (EXTCLK)(SCK)(AIN3) PA3 20~| 2 17| 12 PC0 (PWM only on 1-series) -// | | -// GND | 3 16| 11~ PB0 (AIN11)(SCL) -// | | -// VDD | 4 15| 10~ PB1 (AIN10)(SDA) -// | | -// (nSS) (AIN4) PA4 0~ | 5 14| 9~ PB2 (TOSC2)(TXD) -// | | -// (AIN5) PA5 1~ | 6 13| 8 PB3 (TOSC1)(RXD) -// | 7 8 9 10 11 12 | -// |______________________________________| -// 2 3 4 5 6 7 -// PA6 PA7 PB7 PB6 PB5 PB4 -// (AIN6) (AIN7) (AIN8) (AIN9) -// (DAC) - -/* -PIN# DESC Pin Name Other/Sp ADC0 ADC1 PTC AC0 AC1 AC2 DAC0 USART0 SPI0 TWI0 TCA(PWM) TCBn TCD0 CCL -0 A0 or SS PA4 AIN4 AIN0 X0/Y0 XDIR SS WO4 WOA LUT0-OUT -1 A1 PA5 VREFA AIN5 AIN1 X1/Y1 OUT AINN0 WO5 TCB0 WO WOB -2 A2 or DAC PA6 AIN6 AIN2 X2/Y2 AINN0 AINP1 AINP0 OUT -3 A3 PA7 AIN7 AIN3 X3/Y3 AINP0 AINP0 AINN0 LUT1-OUT -4 PB7 -5 PB6 -6 LED PB5 CLKOUT AIN8 AINP1 AINP2 *WO2 -7 PB4 AIN9 AINN1 AINP3 *WO1 *LUT0-OUT -8 RX PB3 TOSC1 OUT RxD *WO0 -9 TX PB2 TOSC2 / OUT TxD WO2 - EVOUT1 -10 SDA PB1 AIN10 X4/Y4 AINP2 XCK SDA WO1 -11 SCL PB0 AIN11 X5/Y5 AINP2 AINP1 XDIR SCL WO0 -12 PC0 AIN6 *SCK TCB0 WO WOC -13 PC1 AIN7 *MISO WOD *LUT1-OUT -14 PC2 EVOUT2 AIN8 *MOSI -15 PC3 AIN9 *SS *WO3 LUT1-IN0 -16 PC4 -17 PC5 -18 MOSI PA1 AIN1 *TxD MOSI *SDA LUT0-IN1 -19 MISO PA2 EVOUT0 AIN2 *RxD MISO *SCL LUT0-IN2 -20 SCK PA3 EXTCLK AIN3 *XCK SCK WO3 TCB1 WO -21? UPDI PA0 RESET/ AIN0 LUT1-IN0 - UPDI - * alternative pin locations -*/ - -const uint8_t PROGMEM digital_pin_to_port[] = { - // Left side, top to bottom - PA, // 0 PA4 - PA, // 1 PA5 - PA, // 2 PA6 - PA, // 3 PA7 - PB, // 4 PB7 - PB, // 5 PB6 - PB, // 6 PB5 - PB, // 7 PB4 - PB, // 8 PB3 - PB, // 9 PB2 - PB, // 10 PB1 - PB, // 11 PB0 - PC, // 12 PC0 - PC, // 13 PC1 - PC, // 14 PC2 - PC, // 15 PC3 - PC, // 16 PC4 - PC, // 17 PC5 - // skip PA0 until the end - PA, // 18 PA1 - PA, // 19 PA2 - PA, // 20 PA3 - PA // 21 PA0 UPDI/RST -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_position[] = { - // Left side, top to bottom - PIN4_bp, // 0 PA4 - PIN5_bp, // 1 PA5 - PIN6_bp, // 2 PA6 - PIN7_bp, // 3 PA7 - PIN7_bp, // 4 PB7 - PIN6_bp, // 5 PB6 - PIN5_bp, // 6 PB5 - PIN4_bp, // 7 PB4 - PIN3_bp, // 8 PB3 - PIN2_bp, // 9 PB2 - PIN1_bp, // 10 PB1 - PIN0_bp, // 11 PB0 - PIN0_bp, // 12 PC0 - PIN1_bp, // 13 PC1 - PIN2_bp, // 14 PC2 - PIN3_bp, // 15 PC3 - PIN4_bp, // 16 PA4 - PIN5_bp, // 17 PA5 - PIN1_bp, // 18 PA1 - PIN2_bp, // 19 PA2 - PIN3_bp, // 20 PA3 - PIN0_bp // 21 PA0 -}; - -/* Use this for accessing PINnCTRL register */ -const uint8_t PROGMEM digital_pin_to_bit_mask[] = { - PIN4_bm, // 0 PA4 - PIN5_bm, // 1 PA5 - PIN6_bm, // 2 PA6 - PIN7_bm, // 3 PA7 - PIN7_bm, // 4 PB7 - PIN6_bm, // 5 PB6 - PIN5_bm, // 6 PB5 - PIN4_bm, // 7 PB4 - PIN3_bm, // 8 PB3 - PIN2_bm, // 9 PB2 - PIN1_bm, // 10 PB1 - PIN0_bm, // 11 PB0 - PIN0_bm, // 12 PC0 - PIN1_bm, // 13 PC1 - PIN2_bm, // 14 PC2 - PIN3_bm, // 15 PC3 - PIN4_bm, // 16 PA4 - PIN5_bm, // 17 PA5 - PIN1_bm, // 18 PA1 - PIN2_bm, // 19 PA2 - PIN3_bm, // 20 PA3 - PIN0_bm // 21 PA0 -}; - - -const uint8_t PROGMEM digital_pin_to_timer[] = { - // Left side, top to bottom - TIMERA0, // 0 PA4 - TIMERA0, // 1 PA5 - #ifdef DAC0 - DACOUT, // 2 PA6 - #else - NOT_ON_TIMER, // 2 PA6 - #endif - NOT_ON_TIMER, // 3 PA7 - NOT_ON_TIMER, // 4 PB7 - NOT_ON_TIMER, // 5 PB6 - NOT_ON_TIMER, // 6 PB5 - NOT_ON_TIMER, // 7 PB4 - NOT_ON_TIMER, // 8 PB3 - TIMERA0, // 9 PB2 - TIMERA0, // 10 PB1 - // Right side, bottom to top - TIMERA0, // 11 PB0 - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TIMERD0, // 12 PC0 - TIMERD0, // 13 PC1 - #else - NOT_ON_TIMER, // 12 PC0 - NOT_ON_TIMER, // 13 PC1 - #endif - NOT_ON_TIMER, // 14 PC2 - NOT_ON_TIMER, // 15 PC3 - NOT_ON_TIMER, // 16 PC4 - NOT_ON_TIMER, // 17 PC5 - NOT_ON_TIMER, // 18 PA1 - NOT_ON_TIMER, // 19 PA2 - TIMERA0, // 20 PA3 - NOT_ON_TIMER // 21 PA0 - - -}; -/* -#define PIN_A0 (21) -#define PIN_A1 (18) -#define PIN_A2 (19) -#define PIN_A3 (20) -#define PIN_A4 (0) -#define PIN_A5 (1) -#define PIN_A6 (2) -#define PIN_A7 (3) -#define PIN_A8 (6) -#define PIN_A9 (7) -#define PIN_A10 (10) -#define PIN_A11 (11) -*/ -#endif - -//extern const uint8_t analog_pin_to_channel[]; -// #define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) -//#define digitalPinToAnalogInput(p) (((p) < 6 || (p) == 8 || (p) == 9 || (p) > 13) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN) -#define digitalPinToAnalogInput(p) ((p<4)?(p+4):(p==21?0:((p>17)?(p-17):((p<8)?(p+2):(p<12?(p):NOT_A_PIN))))) - - -// 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_HARDWARE Serial - -#endif diff --git a/megaavr/variants/txy7/variant.c b/megaavr/variants/txy7/variant.c deleted file mode 100644 index e95e4bb5..00000000 --- a/megaavr/variants/txy7/variant.c +++ /dev/null @@ -1,100 +0,0 @@ -#include - -#include "pins_arduino.h" -#include "api/Common.h" - -#define FORCE_INLINE __attribute__((always_inline)) inline - -void setup_timers() { - - /* TYPE A TIMER */ - - /* PORTMUX setting for TCA - don't need to set because using default */ - //PORTMUX.CTRLA = PORTMUX_TCA00_DEFAULT_gc; - - /* Enable Split Mode */ - TCA0.SPLIT.CTRLD = TCA_SPLIT_SPLITM_bm; - - //Only 1 WGM so no need to specifically set up. - - /* Period setting, 8-bit register in SPLIT mode */ - TCA0.SPLIT.LPER = PWM_TIMER_PERIOD; - TCA0.SPLIT.HPER = PWM_TIMER_PERIOD; - - /* Default duty 50%, will re-assign in analogWrite() */ - //TODO: replace with for loop to make this smaller; - TCA0.SPLIT.LCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.LCMP2 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP0 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP1 = PWM_TIMER_COMPARE; - TCA0.SPLIT.HCMP2 = PWM_TIMER_COMPARE; - - /* Use DIV64 prescaler (giving 250kHz clock), enable TCA timer */ - TCA0.SPLIT.CTRLA = (TCA_SINGLE_CLKSEL_DIV64_gc) | (TCA_SINGLE_ENABLE_bm); - - - /* TYPE B TIMERS */ - - // No megaTinyCore parts need to change the port mapping. - - /* Start with TCB0 */ - TCB_t *timer_B = (TCB_t *)&TCB0; - - /* Timer B Setup loop for TCB[0:2] */ - #ifdef TCB1 - do{ - #endif - /* 8 bit PWM mode, but do not enable output yet, will do in analogWrite() */ - timer_B->CTRLB = (TCB_CNTMODE_PWM8_gc); - - /* Assign 8-bit period */ - timer_B->CCMPL = PWM_TIMER_PERIOD; - - /* default duty 50%, set when output enabled */ - timer_B->CCMPH = PWM_TIMER_COMPARE; - - /* Use TCA clock (250kHz) and enable */ - /* (sync update commented out, might try to synchronize later */ - timer_B->CTRLA = (TCB_CLKSEL_CLKTCA_gc) - //|(TCB_SYNCUPD_bm) - |(TCB_ENABLE_bm); - - /* Increment pointer to next TCB instance */ - timer_B++; - - /* Stop when pointing to TCB3 */ - // } while (timer_B < (TCB_t *)&TCB3); - - // ATtiny only uses up to TCB1 - /* Stop when pointing to TCB1 */ - #ifdef TCB1 - } while (timer_B <= (TCB_t *)&TCB1); - #endif - #if (defined(TCD0) && defined(USE_TIMERD0_PWM)) - TCD0.CMPBCLR=255; //Count to 255 (8-bit resolution) - TCD0.CTRLC=0x80; //WOD outputs PWM B, WOC outputs PWM A - TCD0.CTRLB=0x03; //dual slope - TCD0.CTRLA=0x10; //OSC20M prescaled by 32, gives ~1.2 khz PWM at 20MHz. - #endif - -} - -FORCE_INLINE bool isDoubleBondedActive(uint8_t pin) { - (void)pin; - - /* Check if TWI is operating on double bonded pin (Master Enable is high - in both Master and Slave mode for bus error detection, so this can - indicate an active state for Wire) */ - //if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return true; - - /* Special check for SPI_SS double bonded pin -- no action if SPI is active - (Using SPI Enable bit as indicator of SPI activity) */ - //if((pin == 10) && (SPI0.CTRLA & SPI_ENABLE_bm)) return true; - - return false; -} - -void initVariant() { - // NA -} diff --git a/megaavr/platform.txt b/platform.txt similarity index 100% rename from megaavr/platform.txt rename to platform.txt diff --git a/megaavr/programmers.txt b/programmers.txt similarity index 100% rename from megaavr/programmers.txt rename to programmers.txt