diff --git a/README.md b/README.md index 42a1f043c..c5a1cc02a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1 @@ -# Arduino AVR Boards - -[![Check Arduino status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/check-arduino.yml) -[![Compile Examples status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/compile-platform-examples.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/compile-platform-examples.yml) -[![Spell Check status](https://github.com/arduino/ArduinoCore-avr/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino/ArduinoCore-avr/actions/workflows/spell-check.yml) - -This repository contains the source code and configuration files of the Arduino AVR Boards -[platform](https://arduino.github.io/arduino-cli/latest/platform-specification/). +AVR Core to emulate a DS4 controller with compatible Arduino boards diff --git a/boards.txt b/boards.txt index b9add104a..e5e2a7d60 100644 --- a/boards.txt +++ b/boards.txt @@ -4,397 +4,23 @@ menu.cpu=Processor ############################################################## -yun.name=Arduino Yún -yun.upload.via_ssh=true - -yun.vid.0=0x2341 -yun.pid.0=0x0041 -yun.vid.1=0x2341 -yun.pid.1=0x8041 -yun.vid.2=0x2A03 -yun.pid.2=0x0041 -yun.vid.3=0x2A03 -yun.pid.3=0x8041 -yun.upload_port.0.vid=0x2341 -yun.upload_port.0.pid=0x0041 -yun.upload_port.1.vid=0x2341 -yun.upload_port.1.pid=0x8041 -yun.upload_port.2.vid=0x2A03 -yun.upload_port.2.pid=0x0041 -yun.upload_port.3.vid=0x2A03 -yun.upload_port.3.pid=0x8041 -yun.upload_port.4.board=yun - -yun.upload.tool=avrdude -yun.upload.tool.default=avrdude -yun.upload.tool.network=arduino_ota -yun.upload.protocol=avr109 -yun.upload.maximum_size=28672 -yun.upload.maximum_data_size=2560 -yun.upload.speed=57600 -yun.upload.disable_flushing=true -yun.upload.use_1200bps_touch=true -yun.upload.wait_for_upload_port=true - -yun.bootloader.tool=avrdude -yun.bootloader.tool.default=avrdude -yun.bootloader.low_fuses=0xff -yun.bootloader.high_fuses=0xd8 -yun.bootloader.extended_fuses=0xfb -yun.bootloader.file=caterina/Caterina-Yun.hex -yun.bootloader.noblink=caterina/Caterina-Yun-noblink.hex -yun.bootloader.unlock_bits=0x3F -yun.bootloader.lock_bits=0x2F - -yun.build.mcu=atmega32u4 -yun.build.f_cpu=16000000L -yun.build.vid=0x2341 -yun.build.pid=0x8041 -yun.build.usb_product="Arduino Yun" -yun.build.board=AVR_YUN -yun.build.core=arduino -yun.build.variant=yun -yun.build.extra_flags={build.usb_flags} - -############################################################## - -uno.name=Arduino UNO - -uno.vid.0=0x2341 -uno.pid.0=0x0043 -uno.vid.1=0x2341 -uno.pid.1=0x0001 -uno.vid.2=0x2A03 -uno.pid.2=0x0043 -uno.vid.3=0x2341 -uno.pid.3=0x0243 -uno.vid.4=0x2341 -uno.pid.4=0x006A -uno.upload_port.0.vid=0x2341 -uno.upload_port.0.pid=0x0043 -uno.upload_port.1.vid=0x2341 -uno.upload_port.1.pid=0x0001 -uno.upload_port.2.vid=0x2A03 -uno.upload_port.2.pid=0x0043 -uno.upload_port.3.vid=0x2341 -uno.upload_port.3.pid=0x0243 -uno.upload_port.4.vid=0x2341 -uno.upload_port.4.pid=0x006A -uno.upload_port.5.board=uno - -uno.upload.tool=avrdude -uno.upload.tool.default=avrdude -uno.upload.tool.network=arduino_ota -uno.upload.protocol=arduino -uno.upload.maximum_size=32256 -uno.upload.maximum_data_size=2048 -uno.upload.speed=115200 - -uno.bootloader.tool=avrdude -uno.bootloader.tool.default=avrdude -uno.bootloader.low_fuses=0xFF -uno.bootloader.high_fuses=0xDE -uno.bootloader.extended_fuses=0xFD -uno.bootloader.unlock_bits=0x3F -uno.bootloader.lock_bits=0x0F -uno.bootloader.file=optiboot/optiboot_atmega328.hex - -uno.build.mcu=atmega328p -uno.build.f_cpu=16000000L -uno.build.board=AVR_UNO -uno.build.core=arduino -uno.build.variant=standard - -############################################################## - -unomini.name=Arduino UNO Mini - -unomini.vid.0=0x2341 -unomini.pid.0=0x0062 -unomini.upload_port.0.vid=0x2341 -unomini.upload_port.0.pid=0x0062 -unomini.upload_port.4.board=unomini - -unomini.upload.tool=avrdude -unomini.upload.tool.default=avrdude -unomini.upload.tool.network=arduino_ota -unomini.upload.protocol=arduino -unomini.upload.maximum_size=32256 -unomini.upload.maximum_data_size=2048 -unomini.upload.speed=115200 - -unomini.bootloader.tool=avrdude -unomini.bootloader.tool.default=avrdude -unomini.bootloader.low_fuses=0xFF -unomini.bootloader.high_fuses=0xDE -unomini.bootloader.extended_fuses=0xFD -unomini.bootloader.unlock_bits=0x3F -unomini.bootloader.lock_bits=0x0F -unomini.bootloader.file=optiboot/optiboot_atmega328.hex - -unomini.build.mcu=atmega328p -unomini.build.f_cpu=16000000L -unomini.build.board=AVR_UNO -unomini.build.core=arduino -unomini.build.variant=standard - -############################################################## - -diecimila.name=Arduino Duemilanove or Diecimila - -diecimila.upload_port.0.board=diecimila - -diecimila.upload.tool=avrdude -diecimila.upload.tool.default=avrdude -diecimila.upload.tool.network=arduino_ota -diecimila.upload.protocol=arduino - -diecimila.bootloader.tool=avrdude -diecimila.bootloader.tool.default=avrdude -diecimila.bootloader.low_fuses=0xFF -diecimila.bootloader.unlock_bits=0x3F -diecimila.bootloader.lock_bits=0x0F - -diecimila.build.f_cpu=16000000L -diecimila.build.board=AVR_DUEMILANOVE -diecimila.build.core=arduino -diecimila.build.variant=standard - -## Arduino Duemilanove or Diecimila w/ ATmega328P -## ---------------------------------------------- -diecimila.menu.cpu.atmega328=ATmega328P - -diecimila.menu.cpu.atmega328.upload.maximum_size=30720 -diecimila.menu.cpu.atmega328.upload.maximum_data_size=2048 -diecimila.menu.cpu.atmega328.upload.speed=57600 - -diecimila.menu.cpu.atmega328.bootloader.high_fuses=0xDA -diecimila.menu.cpu.atmega328.bootloader.extended_fuses=0xFD -diecimila.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex - -diecimila.menu.cpu.atmega328.build.mcu=atmega328p - -## Arduino Duemilanove or Diecimila w/ ATmega168 -## --------------------------------------------- -diecimila.menu.cpu.atmega168=ATmega168 - -diecimila.menu.cpu.atmega168.upload.maximum_size=14336 -diecimila.menu.cpu.atmega168.upload.maximum_data_size=1024 -diecimila.menu.cpu.atmega168.upload.speed=19200 - -diecimila.menu.cpu.atmega168.bootloader.high_fuses=0xdd -diecimila.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -diecimila.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex - -diecimila.menu.cpu.atmega168.build.mcu=atmega168 - -############################################################## - -nano.name=Arduino Nano - -nano.upload_port.0.board=nano - -nano.upload.tool=avrdude -nano.upload.tool.default=avrdude -nano.upload.tool.network=arduino_ota -nano.upload.protocol=arduino - -nano.bootloader.tool=avrdude -nano.bootloader.tool.default=avrdude -nano.bootloader.unlock_bits=0x3F -nano.bootloader.lock_bits=0x0F - -nano.build.f_cpu=16000000L -nano.build.board=AVR_NANO -nano.build.core=arduino -nano.build.variant=eightanaloginputs - -## Arduino Nano w/ ATmega328P -## -------------------------- -nano.menu.cpu.atmega328=ATmega328P - -nano.menu.cpu.atmega328.upload.maximum_size=30720 -nano.menu.cpu.atmega328.upload.maximum_data_size=2048 -nano.menu.cpu.atmega328.upload.speed=115200 - -nano.menu.cpu.atmega328.bootloader.low_fuses=0xFF -nano.menu.cpu.atmega328.bootloader.high_fuses=0xDA -nano.menu.cpu.atmega328.bootloader.extended_fuses=0xFD -nano.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328.hex - -nano.menu.cpu.atmega328.build.mcu=atmega328p - -## Arduino Nano w/ ATmega328P (old bootloader) -## -------------------------- -nano.menu.cpu.atmega328old=ATmega328P (Old Bootloader) - -nano.menu.cpu.atmega328old.upload.maximum_size=30720 -nano.menu.cpu.atmega328old.upload.maximum_data_size=2048 -nano.menu.cpu.atmega328old.upload.speed=57600 - -nano.menu.cpu.atmega328old.bootloader.low_fuses=0xFF -nano.menu.cpu.atmega328old.bootloader.high_fuses=0xDA -nano.menu.cpu.atmega328old.bootloader.extended_fuses=0xFD -nano.menu.cpu.atmega328old.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex - -nano.menu.cpu.atmega328old.build.mcu=atmega328p - -## Arduino Nano w/ ATmega168 -## ------------------------- -nano.menu.cpu.atmega168=ATmega168 - -nano.menu.cpu.atmega168.upload.maximum_size=14336 -nano.menu.cpu.atmega168.upload.maximum_data_size=1024 -nano.menu.cpu.atmega168.upload.speed=19200 - -nano.menu.cpu.atmega168.bootloader.low_fuses=0xff -nano.menu.cpu.atmega168.bootloader.high_fuses=0xdd -nano.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -nano.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex - -nano.menu.cpu.atmega168.build.mcu=atmega168 - -############################################################## - -mega.name=Arduino Mega or Mega 2560 - -mega.vid.0=0x2341 -mega.pid.0=0x0010 -mega.vid.1=0x2341 -mega.pid.1=0x0042 -mega.vid.2=0x2A03 -mega.pid.2=0x0010 -mega.vid.3=0x2A03 -mega.pid.3=0x0042 -mega.vid.4=0x2341 -mega.pid.4=0x0210 -mega.vid.5=0x2341 -mega.pid.5=0x0242 -mega.upload_port.0.vid=0x2341 -mega.upload_port.0.pid=0x0010 -mega.upload_port.1.vid=0x2341 -mega.upload_port.1.pid=0x0042 -mega.upload_port.2.vid=0x2A03 -mega.upload_port.2.pid=0x0010 -mega.upload_port.3.vid=0x2A03 -mega.upload_port.3.pid=0x0042 -mega.upload_port.4.vid=0x2341 -mega.upload_port.4.pid=0x0210 -mega.upload_port.5.vid=0x2341 -mega.upload_port.5.pid=0x0242 -mega.upload_port.6.board=mega - -mega.upload.tool=avrdude -mega.upload.tool.default=avrdude -mega.upload.tool.network=arduino_ota -mega.upload.maximum_data_size=8192 - -mega.bootloader.tool=avrdude -mega.bootloader.tool.default=avrdude -mega.bootloader.low_fuses=0xFF -mega.bootloader.unlock_bits=0x3F -mega.bootloader.lock_bits=0x0F - -mega.build.f_cpu=16000000L -mega.build.core=arduino -mega.build.variant=mega -# default board may be overridden by the cpu menu -mega.build.board=AVR_MEGA2560 - -## Arduino Mega w/ ATmega2560 -## ------------------------- -mega.menu.cpu.atmega2560=ATmega2560 (Mega 2560) - -mega.menu.cpu.atmega2560.upload.protocol=wiring -mega.menu.cpu.atmega2560.upload.maximum_size=253952 -mega.menu.cpu.atmega2560.upload.speed=115200 - -mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8 -mega.menu.cpu.atmega2560.bootloader.extended_fuses=0xFD -mega.menu.cpu.atmega2560.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex - -mega.menu.cpu.atmega2560.build.mcu=atmega2560 -mega.menu.cpu.atmega2560.build.board=AVR_MEGA2560 - -## Arduino Mega w/ ATmega1280 -## ------------------------- -mega.menu.cpu.atmega1280=ATmega1280 - -mega.menu.cpu.atmega1280.upload.protocol=arduino -mega.menu.cpu.atmega1280.upload.maximum_size=126976 -mega.menu.cpu.atmega1280.upload.speed=57600 - -mega.menu.cpu.atmega1280.bootloader.high_fuses=0xDA -mega.menu.cpu.atmega1280.bootloader.extended_fuses=0xF5 -mega.menu.cpu.atmega1280.bootloader.file=atmega/ATmegaBOOT_168_atmega1280.hex - -mega.menu.cpu.atmega1280.build.mcu=atmega1280 -mega.menu.cpu.atmega1280.build.board=AVR_MEGA - -############################################################## - -megaADK.name=Arduino Mega ADK - -megaADK.vid.0=0x2341 -megaADK.pid.0=0x003f -megaADK.vid.1=0x2341 -megaADK.pid.1=0x0044 -megaADK.vid.2=0x2A03 -megaADK.pid.2=0x003f -megaADK.vid.3=0x2A03 -megaADK.pid.3=0x0044 -megaADK.upload_port.0.vid=0x2341 -megaADK.upload_port.0.pid=0x003f -megaADK.upload_port.1.vid=0x2341 -megaADK.upload_port.1.pid=0x0044 -megaADK.upload_port.2.vid=0x2A03 -megaADK.upload_port.2.pid=0x003f -megaADK.upload_port.3.vid=0x2A03 -megaADK.upload_port.3.pid=0x0044 -megaADK.upload_port.4.board=megaADK - -megaADK.upload.tool=avrdude -megaADK.upload.tool.default=avrdude -megaADK.upload.tool.network=arduino_ota -megaADK.upload.protocol=wiring -megaADK.upload.maximum_size=253952 -megaADK.upload.maximum_data_size=8192 -megaADK.upload.speed=115200 - -megaADK.bootloader.tool=avrdude -megaADK.bootloader.tool.default=avrdude -megaADK.bootloader.low_fuses=0xFF -megaADK.bootloader.high_fuses=0xD8 -megaADK.bootloader.extended_fuses=0xFD -megaADK.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex -megaADK.bootloader.unlock_bits=0x3F -megaADK.bootloader.lock_bits=0x0F - -megaADK.build.mcu=atmega2560 -megaADK.build.f_cpu=16000000L -megaADK.build.board=AVR_ADK -megaADK.build.core=arduino -megaADK.build.variant=mega - -############################################################## - -leonardo.name=Arduino Leonardo -leonardo.vid.0=0x2341 -leonardo.pid.0=0x0036 -leonardo.vid.1=0x2341 -leonardo.pid.1=0x8036 -leonardo.vid.2=0x2A03 -leonardo.pid.2=0x0036 -leonardo.vid.3=0x2A03 -leonardo.pid.3=0x8036 -leonardo.upload_port.0.vid=0x2341 -leonardo.upload_port.0.pid=0x0036 -leonardo.upload_port.1.vid=0x2341 -leonardo.upload_port.1.pid=0x8036 -leonardo.upload_port.2.vid=0x2A03 -leonardo.upload_port.2.pid=0x0036 -leonardo.upload_port.3.vid=0x2A03 -leonardo.upload_port.3.pid=0x8036 +leonardo.name=Arduino Leonardo as PS4 controller +leonardo.vid.0=0x1532 +leonardo.pid.0=0x0401 +leonardo.vid.1=0x1532 +leonardo.pid.1=0x0401 +leonardo.vid.2=0x1532 +leonardo.pid.2=0x0401 +leonardo.vid.3=0x1532 +leonardo.pid.3=0x0401 +leonardo.upload_port.0.vid=0x1532 +leonardo.upload_port.0.pid=0x0401 +leonardo.upload_port.1.vid=0x1532 +leonardo.upload_port.1.pid=0x0401 +leonardo.upload_port.2.vid=0x1532 +leonardo.upload_port.2.pid=0x0401 +leonardo.upload_port.3.vid=0x1532 +leonardo.upload_port.3.pid=0x0401 leonardo.upload_port.4.board=leonardo leonardo.upload.tool=avrdude @@ -419,8 +45,8 @@ leonardo.bootloader.lock_bits=0x2F leonardo.build.mcu=atmega32u4 leonardo.build.f_cpu=16000000L -leonardo.build.vid=0x2341 -leonardo.build.pid=0x8036 +leonardo.build.vid=0x1532 +leonardo.build.pid=0x0401 leonardo.build.usb_product="Arduino Leonardo" leonardo.build.board=AVR_LEONARDO leonardo.build.core=arduino @@ -429,15 +55,15 @@ leonardo.build.extra_flags={build.usb_flags} ############################################################## -leonardoeth.name=Arduino Leonardo ETH -leonardoeth.vid.0=0x2a03 -leonardoeth.pid.0=0x0040 -leonardoeth.vid.1=0x2a03 -leonardoeth.pid.1=0x8040 -leonardoeth.upload_port.0.vid=0x2a03 -leonardoeth.upload_port.0.pid=0x0040 -leonardoeth.upload_port.1.vid=0x2a03 -leonardoeth.upload_port.1.pid=0x8040 +leonardoeth.name=Arduino Leonardo ETH as PS4 controller +leonardoeth.vid.0=0x1532 +leonardoeth.pid.0=0x0401 +leonardoeth.vid.1=0x1532 +leonardoeth.pid.1=0x0401 +leonardoeth.upload_port.0.vid=0x1532 +leonardoeth.upload_port.0.pid=0x0401 +leonardoeth.upload_port.1.vid=0x1532 +leonardoeth.upload_port.1.pid=0x0401 leonardoeth.upload_port.2.board=leonardoeth leonardoeth.upload.tool=avrdude @@ -462,8 +88,8 @@ leonardoeth.bootloader.lock_bits=0x2F leonardoeth.build.mcu=atmega32u4 leonardoeth.build.f_cpu=16000000L -leonardoeth.build.vid=0x2a03 -leonardoeth.build.pid=0x8040 +leonardoeth.build.vid=0x1532 +leonardoeth.build.pid=0x0401 leonardoeth.build.usb_product="Arduino Leonardo ETH" leonardoeth.build.board=AVR_LEONARDO_ETH leonardoeth.build.core=arduino @@ -472,32 +98,32 @@ leonardoeth.build.extra_flags={build.usb_flags} ############################################################## -micro.name=Arduino Micro - -micro.vid.0=0x2341 -micro.pid.0=0x0037 -micro.vid.1=0x2341 -micro.pid.1=0x8037 -micro.vid.2=0x2A03 -micro.pid.2=0x0037 -micro.vid.3=0x2A03 -micro.pid.3=0x8037 -micro.vid.4=0x2341 -micro.pid.4=0x0237 -micro.vid.5=0x2341 -micro.pid.5=0x8237 -micro.upload_port.0.vid=0x2341 -micro.upload_port.0.pid=0x0037 -micro.upload_port.1.vid=0x2341 -micro.upload_port.1.pid=0x8037 -micro.upload_port.2.vid=0x2A03 -micro.upload_port.2.pid=0x0037 -micro.upload_port.3.vid=0x2A03 -micro.upload_port.3.pid=0x8037 -micro.upload_port.4.vid=0x2341 -micro.upload_port.4.pid=0x0237 -micro.upload_port.5.vid=0x2341 -micro.upload_port.5.pid=0x8237 +micro.name=Arduino Micro as PS4 controller + +micro.vid.0=0x1532 +micro.pid.0=0x0401 +micro.vid.1=0x1532 +micro.pid.1=0x0401 +micro.vid.2=0x1532 +micro.pid.2=0x0401 +micro.vid.3=0x1532 +micro.pid.3=0x0401 +micro.vid.4=0x1532 +micro.pid.4=0x0401 +micro.vid.5=0x1532 +micro.pid.5=0x0401 +micro.upload_port.0.vid=0x1532 +micro.upload_port.0.pid=0x0401 +micro.upload_port.1.vid=0x1532 +micro.upload_port.1.pid=0x0401 +micro.upload_port.2.vid=0x1532 +micro.upload_port.2.pid=0x0401 +micro.upload_port.3.vid=0x1532 +micro.upload_port.3.pid=0x0401 +micro.upload_port.4.vid=0x1532 +micro.upload_port.4.pid=0x0401 +micro.upload_port.5.vid=0x1532 +micro.upload_port.5.pid=0x0401 micro.upload_port.6.board=micro micro.upload.tool=avrdude @@ -522,8 +148,8 @@ micro.bootloader.lock_bits=0x2F micro.build.mcu=atmega32u4 micro.build.f_cpu=16000000L -micro.build.vid=0x2341 -micro.build.pid=0x8037 +micro.build.vid=0x1532 +micro.build.pid=0x0401 micro.build.usb_product="Arduino Micro" micro.build.board=AVR_MICRO micro.build.core=arduino @@ -532,23 +158,23 @@ micro.build.extra_flags={build.usb_flags} ############################################################## -esplora.name=Arduino Esplora -esplora.vid.0=0x2341 -esplora.pid.0=0x003C -esplora.vid.1=0x2341 -esplora.pid.1=0x803C -esplora.vid.2=0x2A03 -esplora.pid.2=0x003C -esplora.vid.3=0x2A03 -esplora.pid.3=0x803C -esplora.upload_port.0.vid=0x2341 -esplora.upload_port.0.pid=0x003C -esplora.upload_port.1.vid=0x2341 -esplora.upload_port.1.pid=0x803C -esplora.upload_port.2.vid=0x2A03 -esplora.upload_port.2.pid=0x003C -esplora.upload_port.3.vid=0x2A03 -esplora.upload_port.3.pid=0x803C +esplora.name=Arduino Esplora as PS4 controller +esplora.vid.0=0x1532 +esplora.pid.0=0x0401 +esplora.vid.1=0x1532 +esplora.pid.1=0x0401 +esplora.vid.2=0x1532 +esplora.pid.2=0x0401 +esplora.vid.3=0x1532 +esplora.pid.3=0x0401 +esplora.upload_port.0.vid=0x1532 +esplora.upload_port.0.pid=0x0401 +esplora.upload_port.1.vid=0x1532 +esplora.upload_port.1.pid=0x0401 +esplora.upload_port.2.vid=0x1532 +esplora.upload_port.2.pid=0x0401 +esplora.upload_port.3.vid=0x1532 +esplora.upload_port.3.pid=0x0401 esplora.upload_port.4.board=esplora esplora.upload.tool=avrdude @@ -573,740 +199,10 @@ esplora.bootloader.lock_bits=0x2F esplora.build.mcu=atmega32u4 esplora.build.f_cpu=16000000L -esplora.build.vid=0x2341 -esplora.build.pid=0x803c +esplora.build.vid=0x1532 +esplora.build.pid=0x0401 esplora.build.usb_product="Arduino Esplora" esplora.build.board=AVR_ESPLORA esplora.build.core=arduino esplora.build.variant=leonardo esplora.build.extra_flags={build.usb_flags} - -############################################################## - -mini.name=Arduino Mini - -mini.upload_port.0.board=mini - -mini.upload.tool=avrdude -mini.upload.tool.default=avrdude -mini.upload.tool.network=arduino_ota -mini.upload.protocol=arduino - -mini.bootloader.tool=avrdude -mini.bootloader.tool.default=avrdude -mini.bootloader.low_fuses=0xff -mini.bootloader.unlock_bits=0x3F -mini.bootloader.lock_bits=0x0F - -mini.build.f_cpu=16000000L -mini.build.board=AVR_MINI -mini.build.core=arduino -mini.build.variant=eightanaloginputs - -## Arduino Mini w/ ATmega328P -## -------------------------- -mini.menu.cpu.atmega328=ATmega328P - -mini.menu.cpu.atmega328.upload.maximum_size=28672 -mini.menu.cpu.atmega328.upload.maximum_data_size=2048 -mini.menu.cpu.atmega328.upload.speed=115200 - -mini.menu.cpu.atmega328.bootloader.high_fuses=0xd8 -mini.menu.cpu.atmega328.bootloader.extended_fuses=0xFD -mini.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328-Mini.hex - -mini.menu.cpu.atmega328.build.mcu=atmega328p - -## Arduino Mini w/ ATmega168 -## ------------------------- -mini.menu.cpu.atmega168=ATmega168 - -mini.menu.cpu.atmega168.upload.maximum_size=14336 -mini.menu.cpu.atmega168.upload.maximum_data_size=1024 -mini.menu.cpu.atmega168.upload.speed=19200 - -mini.menu.cpu.atmega168.bootloader.high_fuses=0xdd -mini.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -mini.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_ng.hex - -mini.menu.cpu.atmega168.build.mcu=atmega168 - -############################################################## - -ethernet.name=Arduino Ethernet - -ethernet.upload_port.0.board=ethernet - -ethernet.upload.tool=avrdude -ethernet.upload.tool.default=avrdude -ethernet.upload.tool.network=arduino_ota -ethernet.upload.protocol=arduino -ethernet.upload.maximum_size=32256 -ethernet.upload.maximum_data_size=2048 -ethernet.upload.speed=115200 - -ethernet.bootloader.tool=avrdude -ethernet.bootloader.tool.default=avrdude -ethernet.bootloader.low_fuses=0xff -ethernet.bootloader.high_fuses=0xde -ethernet.bootloader.extended_fuses=0xFD -ethernet.bootloader.file=optiboot/optiboot_atmega328.hex -ethernet.bootloader.unlock_bits=0x3F -ethernet.bootloader.lock_bits=0x0F - -ethernet.build.variant=ethernet -ethernet.build.mcu=atmega328p -ethernet.build.f_cpu=16000000L -ethernet.build.board=AVR_ETHERNET -ethernet.build.core=arduino - -############################################################## - -fio.name=Arduino Fio - -fio.upload_port.0.board=fio - -fio.upload.tool=avrdude -fio.upload.tool.default=avrdude -fio.upload.tool.network=arduino_ota -fio.upload.protocol=arduino -fio.upload.maximum_size=30720 -fio.upload.maximum_data_size=2048 -fio.upload.speed=57600 - -fio.bootloader.tool=avrdude -fio.bootloader.tool.default=avrdude -fio.bootloader.low_fuses=0xFF -fio.bootloader.high_fuses=0xDA -fio.bootloader.extended_fuses=0xFD -fio.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex -fio.bootloader.unlock_bits=0x3F -fio.bootloader.lock_bits=0x0F - -fio.build.mcu=atmega328p -fio.build.f_cpu=8000000L -fio.build.board=AVR_FIO -fio.build.core=arduino -fio.build.variant=eightanaloginputs - -############################################################## - -bt.name=Arduino BT - -bt.upload_port.0.board=bt - -bt.upload.tool=avrdude -bt.upload.tool.default=avrdude -bt.upload.tool.network=arduino_ota -bt.upload.protocol=arduino -bt.upload.speed=19200 -bt.upload.disable_flushing=true - -bt.bootloader.tool=avrdude -bt.bootloader.tool.default=avrdude -bt.bootloader.low_fuses=0xff -bt.bootloader.unlock_bits=0x3F -bt.bootloader.lock_bits=0x0F - -bt.build.f_cpu=16000000L -bt.build.board=AVR_BT -bt.build.core=arduino -bt.build.variant=eightanaloginputs - -## Arduino BT w/ ATmega328P -## ------------------------ -bt.menu.cpu.atmega328=ATmega328P -bt.menu.cpu.atmega328.upload.maximum_size=28672 -bt.menu.cpu.atmega328.upload.maximum_data_size=2048 - -bt.menu.cpu.atmega328.bootloader.high_fuses=0xd8 -bt.menu.cpu.atmega328.bootloader.extended_fuses=0xFD -bt.menu.cpu.atmega328.bootloader.file=bt/ATmegaBOOT_168_atmega328_bt.hex - -bt.menu.cpu.atmega328.build.mcu=atmega328p - -## Arduino BT w/ ATmega168 -## ----------------------- -bt.menu.cpu.atmega168=ATmega168 -bt.menu.cpu.atmega168.upload.maximum_size=14336 -bt.menu.cpu.atmega168.upload.maximum_data_size=1024 - -bt.menu.cpu.atmega168.bootloader.high_fuses=0xdd -bt.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -bt.menu.cpu.atmega168.bootloader.file=bt/ATmegaBOOT_168.hex - -bt.menu.cpu.atmega168.build.mcu=atmega168 - -############################################################## - -LilyPadUSB.name=LilyPad Arduino USB -LilyPadUSB.vid.0=0x1B4F -LilyPadUSB.pid.0=0x9207 -LilyPadUSB.vid.1=0x1B4F -LilyPadUSB.pid.1=0x9208 -LilyPadUSB.upload_port.0.vid=0x1B4F -LilyPadUSB.upload_port.0.pid=0x9207 -LilyPadUSB.upload_port.1.vid=0x1B4F -LilyPadUSB.upload_port.1.pid=0x9208 -LilyPadUSB.upload_port.2.board=LilyPadUSB - -LilyPadUSB.upload.tool=avrdude -LilyPadUSB.upload.tool.default=avrdude -LilyPadUSB.upload.tool.network=arduino_ota -LilyPadUSB.upload.protocol=avr109 -LilyPadUSB.upload.maximum_size=28672 -LilyPadUSB.upload.maximum_data_size=2560 -LilyPadUSB.upload.speed=57600 -LilyPadUSB.upload.disable_flushing=true -LilyPadUSB.upload.use_1200bps_touch=true -LilyPadUSB.upload.wait_for_upload_port=true - -LilyPadUSB.bootloader.tool=avrdude -LilyPadUSB.bootloader.tool.default=avrdude -LilyPadUSB.bootloader.low_fuses=0xff -LilyPadUSB.bootloader.high_fuses=0xd8 -LilyPadUSB.bootloader.extended_fuses=0xce -LilyPadUSB.bootloader.file=caterina-LilyPadUSB/Caterina-LilyPadUSB.hex -LilyPadUSB.bootloader.unlock_bits=0x3F -LilyPadUSB.bootloader.lock_bits=0x2F - -LilyPadUSB.build.mcu=atmega32u4 -LilyPadUSB.build.f_cpu=8000000L -LilyPadUSB.build.vid=0x1B4F -LilyPadUSB.build.pid=0x9208 -LilyPadUSB.build.usb_product="LilyPad USB" -LilyPadUSB.build.board=AVR_LILYPAD_USB -LilyPadUSB.build.core=arduino -LilyPadUSB.build.variant=leonardo -LilyPadUSB.build.extra_flags={build.usb_flags} - -############################################################## - -lilypad.name=LilyPad Arduino - -lilypad.upload_port.0.board=lilypad - -lilypad.upload.tool=avrdude -lilypad.upload.tool.default=avrdude -lilypad.upload.tool.network=arduino_ota -lilypad.upload.protocol=arduino - -lilypad.bootloader.tool=avrdude -lilypad.bootloader.tool.default=avrdude -lilypad.bootloader.unlock_bits=0x3F -lilypad.bootloader.lock_bits=0x0F - -lilypad.build.f_cpu=8000000L -lilypad.build.board=AVR_LILYPAD -lilypad.build.core=arduino -lilypad.build.variant=standard - -## LilyPad Arduino w/ ATmega328P -## ----------------------------- -lilypad.menu.cpu.atmega328=ATmega328P - -lilypad.menu.cpu.atmega328.upload.maximum_size=30720 -lilypad.menu.cpu.atmega328.upload.maximum_data_size=2048 -lilypad.menu.cpu.atmega328.upload.speed=57600 - -lilypad.menu.cpu.atmega328.bootloader.low_fuses=0xFF -lilypad.menu.cpu.atmega328.bootloader.high_fuses=0xDA -lilypad.menu.cpu.atmega328.bootloader.extended_fuses=0xFD -lilypad.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex - -lilypad.menu.cpu.atmega328.build.mcu=atmega328p - -## LilyPad Arduino w/ ATmega168 -## ---------------------------- -lilypad.menu.cpu.atmega168=ATmega168 - -lilypad.menu.cpu.atmega168.upload.maximum_size=14336 -lilypad.menu.cpu.atmega168.upload.maximum_data_size=1024 -lilypad.menu.cpu.atmega168.upload.speed=19200 - -lilypad.menu.cpu.atmega168.bootloader.low_fuses=0xe2 -lilypad.menu.cpu.atmega168.bootloader.high_fuses=0xdd -lilypad.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -lilypad.menu.cpu.atmega168.bootloader.file=lilypad/LilyPadBOOT_168.hex - -lilypad.menu.cpu.atmega168.build.mcu=atmega168 - -############################################################## - -pro.name=Arduino Pro or Pro Mini - -pro.upload_port.0.board=pro - -pro.upload.tool=avrdude -pro.upload.tool.default=avrdude -pro.upload.tool.network=arduino_ota -pro.upload.protocol=arduino - -pro.bootloader.tool=avrdude -pro.bootloader.tool.default=avrdude -pro.bootloader.unlock_bits=0x3F -pro.bootloader.lock_bits=0x0F - -pro.build.board=AVR_PRO -pro.build.core=arduino -pro.build.variant=eightanaloginputs - -## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328P -## -------------------------------------------------- -pro.menu.cpu.16MHzatmega328=ATmega328P (5V, 16 MHz) - -pro.menu.cpu.16MHzatmega328.upload.maximum_size=30720 -pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048 -pro.menu.cpu.16MHzatmega328.upload.speed=57600 - -pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF -pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA -pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0xFD -pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex - -pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p -pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L - -## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328P -## --------------------------------------------------- -pro.menu.cpu.8MHzatmega328=ATmega328P (3.3V, 8 MHz) - -pro.menu.cpu.8MHzatmega328.upload.maximum_size=30720 -pro.menu.cpu.8MHzatmega328.upload.maximum_data_size=2048 -pro.menu.cpu.8MHzatmega328.upload.speed=57600 - -pro.menu.cpu.8MHzatmega328.bootloader.low_fuses=0xFF -pro.menu.cpu.8MHzatmega328.bootloader.high_fuses=0xDA -pro.menu.cpu.8MHzatmega328.bootloader.extended_fuses=0xFD -pro.menu.cpu.8MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex - -pro.menu.cpu.8MHzatmega328.build.mcu=atmega328p -pro.menu.cpu.8MHzatmega328.build.f_cpu=8000000L - -## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168 -## ------------------------------------------------- -pro.menu.cpu.16MHzatmega168=ATmega168 (5V, 16 MHz) - -pro.menu.cpu.16MHzatmega168.upload.maximum_size=14336 -pro.menu.cpu.16MHzatmega168.upload.maximum_data_size=1024 -pro.menu.cpu.16MHzatmega168.upload.speed=19200 - -pro.menu.cpu.16MHzatmega168.bootloader.low_fuses=0xff -pro.menu.cpu.16MHzatmega168.bootloader.high_fuses=0xdd -pro.menu.cpu.16MHzatmega168.bootloader.extended_fuses=0xF8 -pro.menu.cpu.16MHzatmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex - -pro.menu.cpu.16MHzatmega168.build.mcu=atmega168 -pro.menu.cpu.16MHzatmega168.build.f_cpu=16000000L - -## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168 -## -------------------------------------------------- -pro.menu.cpu.8MHzatmega168=ATmega168 (3.3V, 8 MHz) - -pro.menu.cpu.8MHzatmega168.upload.maximum_size=14336 -pro.menu.cpu.8MHzatmega168.upload.maximum_data_size=1024 -pro.menu.cpu.8MHzatmega168.upload.speed=19200 - -pro.menu.cpu.8MHzatmega168.bootloader.low_fuses=0xc6 -pro.menu.cpu.8MHzatmega168.bootloader.high_fuses=0xdd -pro.menu.cpu.8MHzatmega168.bootloader.extended_fuses=0xF8 -pro.menu.cpu.8MHzatmega168.bootloader.file=atmega/ATmegaBOOT_168_pro_8MHz.hex - -pro.menu.cpu.8MHzatmega168.build.mcu=atmega168 -pro.menu.cpu.8MHzatmega168.build.f_cpu=8000000L - -############################################################## - -atmegang.name=Arduino NG or older - -atmegang.upload_port.0.board=atmegang - -atmegang.upload.tool=avrdude -atmegang.upload.tool.default=avrdude -atmegang.upload.tool.network=arduino_ota -atmegang.upload.protocol=arduino -atmegang.upload.speed=19200 - -atmegang.bootloader.tool=avrdude -atmegang.bootloader.tool.default=avrdude -atmegang.bootloader.unlock_bits=0x3F -atmegang.bootloader.lock_bits=0x0F - -atmegang.build.mcu=atmegang -atmegang.build.f_cpu=16000000L -atmegang.build.board=AVR_NG -atmegang.build.core=arduino -atmegang.build.variant=standard - -## Arduino NG or older w/ ATmega168 -## -------------------------------- -atmegang.menu.cpu.atmega168=ATmega168 - -atmegang.menu.cpu.atmega168.upload.maximum_size=14336 -atmegang.menu.cpu.atmega168.upload.maximum_data_size=1024 - -atmegang.menu.cpu.atmega168.bootloader.low_fuses=0xff -atmegang.menu.cpu.atmega168.bootloader.high_fuses=0xdd -atmegang.menu.cpu.atmega168.bootloader.extended_fuses=0xF8 -atmegang.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_ng.hex - -atmegang.menu.cpu.atmega168.build.mcu=atmega168 - -## Arduino NG or older w/ ATmega8 -## ------------------------------ -atmegang.menu.cpu.atmega8=ATmega8 - -atmegang.menu.cpu.atmega8.upload.maximum_size=7168 -atmegang.menu.cpu.atmega8.upload.maximum_data_size=1024 - -atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xdf -atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xca -atmegang.menu.cpu.atmega8.bootloader.extended_fuses= -atmegang.menu.cpu.atmega8.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex - -atmegang.menu.cpu.atmega8.build.mcu=atmega8 - -############################################################## - -robotControl.name=Arduino Robot Control -robotControl.vid.0=0x2341 -robotControl.pid.0=0x0038 -robotControl.vid.1=0x2341 -robotControl.pid.1=0x8038 -robotControl.vid.2=0x2A03 -robotControl.pid.2=0x0038 -robotControl.vid.3=0x2A03 -robotControl.pid.3=0x8038 -robotControl.upload_port.0.vid=0x2341 -robotControl.upload_port.0.pid=0x0038 -robotControl.upload_port.1.vid=0x2341 -robotControl.upload_port.1.pid=0x8038 -robotControl.upload_port.2.vid=0x2A03 -robotControl.upload_port.2.pid=0x0038 -robotControl.upload_port.3.vid=0x2A03 -robotControl.upload_port.3.pid=0x8038 -robotControl.upload_port.4.board=robotControl - -robotControl.upload.tool=avrdude -robotControl.upload.tool.default=avrdude -robotControl.upload.tool.network=arduino_ota -robotControl.upload.protocol=avr109 -robotControl.upload.maximum_size=28672 -robotControl.upload.maximum_data_size=2560 -robotControl.upload.speed=57600 -robotControl.upload.disable_flushing=true -robotControl.upload.use_1200bps_touch=true -robotControl.upload.wait_for_upload_port=true - -robotControl.bootloader.tool=avrdude -robotControl.bootloader.tool.default=avrdude -robotControl.bootloader.low_fuses=0xff -robotControl.bootloader.high_fuses=0xd8 -robotControl.bootloader.extended_fuses=0xcb -robotControl.bootloader.file=caterina-Arduino_Robot/Caterina-Robot-Control.hex -robotControl.bootloader.unlock_bits=0x3F -robotControl.bootloader.lock_bits=0x2F - -robotControl.build.mcu=atmega32u4 -robotControl.build.f_cpu=16000000L -robotControl.build.vid=0x2341 -robotControl.build.pid=0x8038 -robotControl.build.usb_product="Robot Control" -robotControl.build.board=AVR_ROBOT_CONTROL -robotControl.build.core=arduino -robotControl.build.variant=robot_control -robotControl.build.extra_flags={build.usb_flags} - -############################################################## - -robotMotor.name=Arduino Robot Motor -robotMotor.vid.0=0x2341 -robotMotor.pid.0=0x0039 -robotMotor.vid.1=0x2341 -robotMotor.pid.1=0x8039 -robotMotor.vid.2=0x2A03 -robotMotor.pid.2=0x0039 -robotMotor.vid.3=0x2A03 -robotMotor.pid.3=0x8039 -robotMotor.upload_port.0.vid=0x2341 -robotMotor.upload_port.0.pid=0x0039 -robotMotor.upload_port.1.vid=0x2341 -robotMotor.upload_port.1.pid=0x8039 -robotMotor.upload_port.2.vid=0x2A03 -robotMotor.upload_port.2.pid=0x0039 -robotMotor.upload_port.3.vid=0x2A03 -robotMotor.upload_port.3.pid=0x8039 -robotMotor.upload_port.4.board=robotMotor - -robotMotor.upload.tool=avrdude -robotMotor.upload.tool.default=avrdude -robotMotor.upload.tool.network=arduino_ota -robotMotor.upload.protocol=avr109 -robotMotor.upload.maximum_size=28672 -robotMotor.upload.maximum_data_size=2560 -robotMotor.upload.speed=57600 -robotMotor.upload.disable_flushing=true -robotMotor.upload.use_1200bps_touch=true -robotMotor.upload.wait_for_upload_port=true - -robotMotor.bootloader.tool=avrdude -robotMotor.bootloader.tool.default=avrdude -robotMotor.bootloader.low_fuses=0xff -robotMotor.bootloader.high_fuses=0xd8 -robotMotor.bootloader.extended_fuses=0xcb -robotMotor.bootloader.file=caterina-Arduino_Robot/Caterina-Robot-Motor.hex -robotMotor.bootloader.unlock_bits=0x3F -robotMotor.bootloader.lock_bits=0x2F - -robotMotor.build.mcu=atmega32u4 -robotMotor.build.f_cpu=16000000L -robotMotor.build.vid=0x2341 -robotMotor.build.pid=0x8039 -robotMotor.build.usb_product="Robot Motor" -robotMotor.build.board=AVR_ROBOT_MOTOR -robotMotor.build.core=arduino -robotMotor.build.variant=robot_motor -robotMotor.build.extra_flags={build.usb_flags} - -############################################################## - -gemma.vid.0=0x2341 -gemma.pid.0=0x0c9f -gemma.upload_port.0.vid=0x2341 -gemma.upload_port.0.pid=0x0c9f -gemma.upload_port.1.board=gemma - -gemma.name=Arduino Gemma - -gemma.bootloader.low_fuses=0xF1 -gemma.bootloader.high_fuses=0xD5 -gemma.bootloader.extended_fuses=0xFE -gemma.bootloader.tool=avrdude -gemma.bootloader.tool.default=avrdude -gemma.bootloader.lock_bits= -gemma.bootloader.unlock_bits= -gemma.bootloader.file=gemma/gemma_v1.hex - -gemma.build.mcu=attiny85 -gemma.build.f_cpu=8000000L -gemma.build.core=arduino -gemma.build.variant=gemma -gemma.build.board=AVR_GEMMA - -gemma.upload.tool=avrdude -gemma.upload.tool.default=avrdude -gemma.upload.tool.network=arduino_ota -gemma.upload.maximum_size=5310 - -############################################################## - -# Adafruit Circuit Playground 32u4 w/Caterina Configuration -circuitplay32u4cat.name=Adafruit Circuit Playground -circuitplay32u4cat.bootloader.low_fuses=0xff -circuitplay32u4cat.bootloader.high_fuses=0xd8 -circuitplay32u4cat.bootloader.extended_fuses=0xcb -circuitplay32u4cat.bootloader.file=caterina/Caterina-Circuitplay32u4.hex -circuitplay32u4cat.bootloader.unlock_bits=0x3F -circuitplay32u4cat.bootloader.lock_bits=0x2F -circuitplay32u4cat.bootloader.tool=avrdude -circuitplay32u4cat.bootloader.tool.default=avrdude -circuitplay32u4cat.build.mcu=atmega32u4 -circuitplay32u4cat.build.f_cpu=8000000L -circuitplay32u4cat.build.vid=0x239A -circuitplay32u4cat.build.pid=0x8011 -circuitplay32u4cat.build.core=arduino -circuitplay32u4cat.build.variant=circuitplay32u4 -circuitplay32u4cat.build.board=AVR_CIRCUITPLAY -circuitplay32u4cat.build.usb_product="Circuit Playground" -circuitplay32u4cat.build.usb_manufacturer="Adafruit" -circuitplay32u4cat.build.extra_flags={build.usb_flags} -circuitplay32u4cat.upload.protocol=avr109 -circuitplay32u4cat.upload.maximum_size=28672 -circuitplay32u4cat.upload.speed=57600 -circuitplay32u4cat.upload.disable_flushing=true -circuitplay32u4cat.upload.use_1200bps_touch=true -circuitplay32u4cat.upload.wait_for_upload_port=true -circuitplay32u4cat.upload.tool=avrdude -circuitplay32u4cat.upload.tool.default=avrdude -circuitplay32u4cat.upload.tool.network=arduino_ota -circuitplay32u4cat.vid.0=0x239A -circuitplay32u4cat.pid.0=0x8011 -circuitplay32u4cat.upload_port.0.vid=0x239A -circuitplay32u4cat.upload_port.0.pid=0x8011 -circuitplay32u4cat.upload_port.1.board=circuitplay32u4cat - -############################################################## - -yunmini.name=Arduino Yún Mini -yunmini.upload.via_ssh=true - -yunmini.vid.0=0x2a03 -yunmini.pid.0=0x0050 -yunmini.vid.1=0x2a03 -yunmini.pid.1=0x8050 -yunmini.upload_port.0.vid=0x2a03 -yunmini.upload_port.0.pid=0x0050 -yunmini.upload_port.1.vid=0x2a03 -yunmini.upload_port.1.pid=0x8050 -yunmini.upload_port.2.board=yunmini - -yunmini.upload.tool=avrdude -yunmini.upload.tool.default=avrdude -yunmini.upload.tool.network=arduino_ota -yunmini.upload.protocol=avr109 -yunmini.upload.maximum_size=28672 -yunmini.upload.maximum_data_size=2560 -yunmini.upload.speed=57600 -yunmini.upload.disable_flushing=true -yunmini.upload.use_1200bps_touch=true -yunmini.upload.wait_for_upload_port=true - -yunmini.bootloader.tool=avrdude -yunmini.bootloader.tool.default=avrdude -yunmini.bootloader.low_fuses=0xff -yunmini.bootloader.high_fuses=0xd8 -yunmini.bootloader.extended_fuses=0xfb -yunmini.bootloader.file=caterina/Caterina-YunMini.hex -yunmini.bootloader.unlock_bits=0x3F -yunmini.bootloader.lock_bits=0x2F - -yunmini.build.mcu=atmega32u4 -yunmini.build.f_cpu=16000000L -yunmini.build.vid=0x2a03 -yunmini.build.pid=0x8050 -yunmini.build.usb_product="Arduino Yún Mini" -yunmini.build.board=AVR_YUNMINI -yunmini.build.core=arduino -yunmini.build.variant=yun -yunmini.build.extra_flags={build.usb_flags} - -############################################################## - -chiwawa.name=Arduino Industrial 101 -chiwawa.upload.via_ssh=true - -chiwawa.vid.0=0x2a03 -chiwawa.pid.0=0x0056 -chiwawa.vid.1=0x2a03 -chiwawa.pid.1=0x8056 -chiwawa.upload_port.0.vid=0x2a03 -chiwawa.upload_port.0.pid=0x0056 -chiwawa.upload_port.1.vid=0x2a03 -chiwawa.upload_port.1.pid=0x8056 -chiwawa.upload_port.2.board=chiwawa - -chiwawa.upload.tool=avrdude -chiwawa.upload.tool.default=avrdude -chiwawa.upload.tool.network=arduino_ota -chiwawa.upload.protocol=avr109 -chiwawa.upload.maximum_size=28672 -chiwawa.upload.maximum_data_size=2560 -chiwawa.upload.speed=57600 -chiwawa.upload.disable_flushing=true -chiwawa.upload.use_1200bps_touch=true -chiwawa.upload.wait_for_upload_port=true - -chiwawa.bootloader.tool=avrdude -chiwawa.bootloader.tool.default=avrdude -chiwawa.bootloader.low_fuses=0xff -chiwawa.bootloader.high_fuses=0xd8 -chiwawa.bootloader.extended_fuses=0xfb -chiwawa.bootloader.file=caterina/Caterina-Industrial101.hex -chiwawa.bootloader.unlock_bits=0x3F -chiwawa.bootloader.lock_bits=0x2F - -chiwawa.build.mcu=atmega32u4 -chiwawa.build.f_cpu=16000000L -chiwawa.build.vid=0x2a03 -chiwawa.build.pid=0x8056 -chiwawa.build.usb_product="Arduino Industrial 101" -chiwawa.build.board=AVR_INDUSTRIAL101 -chiwawa.build.core=arduino -chiwawa.build.variant=yun -chiwawa.build.extra_flags={build.usb_flags} - -############################################################## - -one.name=Linino One -one.upload.via_ssh=true - -one.vid.0=0x2a03 -one.pid.0=0x0001 -one.vid.1=0x2a03 -one.pid.1=0x8001 -one.upload_port.0.vid=0x2a03 -one.upload_port.0.pid=0x0001 -one.upload_port.1.vid=0x2a03 -one.upload_port.1.pid=0x8001 -one.upload_port.2.board=one - -one.upload.tool=avrdude -one.upload.tool.default=avrdude -one.upload.tool.network=arduino_ota -one.upload.protocol=avr109 -one.upload.maximum_size=28672 -one.upload.maximum_data_size=2560 -one.upload.speed=57600 -one.upload.disable_flushing=true -one.upload.use_1200bps_touch=true -one.upload.wait_for_upload_port=true - -one.bootloader.tool=avrdude -one.bootloader.tool.default=avrdude -one.bootloader.low_fuses=0xff -one.bootloader.high_fuses=0xd8 -one.bootloader.extended_fuses=0xfb -one.bootloader.file=caterina/Caterina-LininoOne.hex -one.bootloader.unlock_bits=0x3F -one.bootloader.lock_bits=0x2F - -one.build.mcu=atmega32u4 -one.build.f_cpu=16000000L -one.build.vid=0x2a03 -one.build.pid=0x8001 -one.build.usb_product="Linino One" -one.build.board=AVR_LININO_ONE -one.build.core=arduino -one.build.variant=yun -one.build.extra_flags={build.usb_flags} - -############################################################## - -unowifi.name=Arduino UNO WiFi -unowifi.vid.0=0x2A03 -unowifi.pid.0=0x0057 -unowifi.upload_port.0.vid=0x2A03 -unowifi.upload_port.0.pid=0x0057 -unowifi.upload_port.1.board=unowifi - -unowifi.upload.tool=avrdude -unowifi.upload.tool.default=avrdude -unowifi.upload.tool.network=arduino_ota -unowifi.upload.protocol=arduino -unowifi.upload.maximum_size=32256 -unowifi.upload.maximum_data_size=2048 -unowifi.upload.speed=115200 -unowifi.upload.network.endpoint_upload=/pgm/upload -unowifi.upload.network.endpoint_sync=/pgm/sync -unowifi.upload.network.sync_return=204:SYNC -unowifi.upload.network.endpoint_reset=/log/reset -unowifi.upload.network.port=80 - -unowifi.bootloader.tool=avrdude -unowifi.bootloader.tool.default=avrdude -unowifi.bootloader.low_fuses=0xFF -unowifi.bootloader.high_fuses=0xDE -unowifi.bootloader.extended_fuses=0x05 -unowifi.bootloader.unlock_bits=0x3F -unowifi.bootloader.lock_bits=0x0F -unowifi.bootloader.file=optiboot/optiboot_atmega328.hex - -unowifi.build.mcu=atmega328p -unowifi.build.f_cpu=16000000L -unowifi.build.board=AVR_UNO_WIFI_DEV_ED -unowifi.build.core=arduino -unowifi.build.variant=standard -unowifi.build.esp_ch_uart_br=19200 -unowifi.build.extra_flags=-DESP_CH_UART -DESP_CH_UART_BR={build.esp_ch_uart_br} - -############################################################## diff --git a/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.cpp b/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.cpp new file mode 100644 index 000000000..cf11e928e --- /dev/null +++ b/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.cpp @@ -0,0 +1,62 @@ +/* + * Project ArduinoPS4 AVR core + * @author Flamethrower + * @link github.com/Flamethr0wer/ArduinoPS4_AVR + * @license MIT - Copyright (c) 2019 Flamethrower + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "ArduinoPS4_USBAPI.h" + +#ifdef ARDUINOPS4_USB + +void (*ArduinoPS4USB::RecvCallback)(void) = nullptr; +void (*ArduinoPS4USB::SendCallback)(void) = nullptr; + +boolean ArduinoPS4USB::connected() { + return USBDevice.configured(); +} + +uint8_t ArduinoPS4USB::available() { + return USB_Available(ARDUINOPS4_RX_ENDPOINT); +} + +int ArduinoPS4USB::recv(void *buffer, uint8_t nbytes) { + return USB_Recv(ARDUINOPS4_RX_ENDPOINT, buffer, nbytes); +} + +int ArduinoPS4USB::send(const void *buffer, uint8_t nbytes) { + int result = USB_Send(ARDUINOPS4_TX_ENDPOINT, buffer, nbytes); + if (result > 0) { + USB_Flush(ARDUINOPS4_TX_ENDPOINT); + } + return result; +} + +void ArduinoPS4USB::setRecvCallback(void(*callback)(void)) { + ArduinoPS4USB::RecvCallback = callback; +} + +void ArduinoPS4USB::setSendCallback(void(*callback)(void)) { + ArduinoPS4USB::SendCallback = callback; +} + +#endif diff --git a/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.h b/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.h new file mode 100644 index 000000000..ecbc7c542 --- /dev/null +++ b/cores/arduino/ArduinoDS4/ArduinoPS4_USBAPI.h @@ -0,0 +1,51 @@ +/* + * Project ArduinoPS4 AVR core + * @author Flamethrower + * @link github.com/Flamethr0wer/ArduinoPS4_AVR + * @license MIT - Copyright (c) 2019 Flamethrower + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "USBAPI.h" + +#ifndef ARDUINOPS4_USBAPI_H +#define ARDUINOPS4_USBAPI_H + +#ifdef USBCON + +#define ARDUINOPS4_USB + +class ArduinoPS4USB { +public: + static bool connected(void); + static uint8_t available(void); + static int send(const void *buffer, uint8_t nbytes); + static int recv(void *buffer, uint8_t nbytes); + static void setRecvCallback(void(*callback)(void)); + static void setSendCallback(void(*callback)(void)); + + static void (*RecvCallback)(void); + static void (*SendCallback)(void); +}; + +#endif + +#endif diff --git a/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.cpp b/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.cpp new file mode 100644 index 000000000..517ad9f45 --- /dev/null +++ b/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.cpp @@ -0,0 +1,393 @@ +/* + * Project ArduinoPS4 AVR core + * @author Flamethrower + * @link github.com/Flamethr0wer/ArduinoPS4_AVR + * @license MIT - Copyright (c) 2019 Flamethrower + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "ArduinoPS4_USBDesc.h" + +#if defined(USBCON) + +const DeviceDescriptor USB_DeviceDescriptor = { + 0x12, // bLength (18) + 0x01, // bDescriptorType (DEVICE) + 0x0200, // bcdUSB (2.0) + 0x00, // bDeviceClass + 0x00, // bDeviceSubClass + 0x00, // bDeviceProtocol + 0x40, // bMaxPacketSize0 + 0x1532, // idEVendor + 0x0401, // idProduct + 0x0100, // bcdDevice + 0x01, // iManufacturer + 0x02, // iProduct + 0x00, // iSerialNumber + 0x01, // bNumConfigurations +}; + +const u8 USB_ConfigDescriptor[] = { + // Configuration Descriptor + 0x09, // bLength + 0x02, // bDescriptorType (CONFIGURATION) + 0x29, 0x00, // wTotalLength (41) + 0x01, // bNumInterfaces + 0x01, // bConfigurationValue + 0x00, // iConfiguration + 0x80, // bmAttributes + 0xFA, // bMaxPower + + /* ---------------------------------------------------- */ + // Interface 0: Control Data + 0x09, // bLength + 0x04, // bDescriptorType (INTERFACE) + 0x00, // bInterfaceNumber + 0x00, // bAlternateSetting + 0x02, // bNumEndpoints + 0x03, // bInterfaceClass + 0x00, // bInterfaceSubClass + 0x00, // bInterfaceProtocol + 0x00, // iInterface + + // Human Interface Device (HID) Descriptor + 0x09, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID 1.17 + 0x00, // bCountryCode + 0x01, // bNumDescriptors + 0x22, // bDescriptorType + 0xE1, 0x01, // DescriptorLength + + // Endpoint 1: Control Surface Send + 0x07, // bLength + 0x05, // bDescriptorType (ENDPOINT) + 0x81, // bEndpointAddress (IN, 1) + 0x03, // bmAttributes + 0x40, 0x00, // wMaxPacketSize + 0x05, // bInterval + + // Endpoint 1: Control Surface Receive + 0x07, // bLength + 0x05, // bDescriptorType (ENDPOINT) + 0x03, // bEndpointAddress (OUT, 2) + 0x03, // bmAttributes + 0x40, 0x00, // wMaxPacketSize + 0x05, // bInterval +}; + +const u16 USB_ConfigDescriptorSize = sizeof(USB_ConfigDescriptor); + +const u8 STRING_SERIAL[] = "Arduino PS4 AVR"; +const u8 STRING_SECURITY[] = "PS4 protocol"; + +const u8 hidDescriptor[] = { +0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x05, // Usage (Game Pad) + 0xA1, 0x01, // Collection (Application) + 0x85, 0x01, // Report ID (1) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x09, 0x32, // Usage (Z) + 0x09, 0x35, // Usage (Rz) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x75, 0x08, // Report Size (8) + 0x95, 0x04, // Report Count (4) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + + 0x09, 0x39, // Usage (Hat switch) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x07, // Logical Maximum (7) + 0x35, 0x00, // Physical Minimum (0) + 0x46, 0x3B, 0x01, // Physical Maximum (315) + 0x65, 0x14, // Unit (System: English Rotation, Length: Centimeter) + 0x75, 0x04, // Report Size (4) + 0x95, 0x01, // Report Count (1) + 0x81, 0x42, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State) + + 0x65, 0x00, // Unit (None) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (0x01) + 0x29, 0x0E, // Usage Maximum (0x0E) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x75, 0x01, // Report Size (1) + 0x95, 0x0E, // Report Count (14) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + + 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00) + 0x09, 0x20, // Usage (0x20) + 0x75, 0x06, // Report Size (6) + 0x95, 0x01, // Report Count (1) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x33, // Usage (Rx) + 0x09, 0x34, // Usage (Ry) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical Maximum (255) + 0x75, 0x08, // Report Size (8) + 0x95, 0x02, // Report Count (2) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + + 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00) + 0x09, 0x21, // Usage (0x21) + 0x95, 0x36, // Report Count (54) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + + 0x85, 0x05, // Report ID (5) + 0x09, 0x22, // Usage (0x22) + 0x95, 0x1F, // Report Count (31) + 0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + + 0x85, 0x03, // Report ID (3) + 0x0A, 0x21, 0x27, // Usage (0x2721) + 0x95, 0x2F, // Report Count (47) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + + 0x85, 0x02, // Report ID (2) + 0x09, 0x24, // Usage (0x24) + 0x95, 0x24, // Report Count (36) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x08, // Report ID (8) + 0x09, 0x25, // Usage (0x25) + 0x95, 0x03, // Report Count (3) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x10, // Report ID (16) + 0x09, 0x26, // Usage (0x26) + 0x95, 0x04, // Report Count (4) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x11, // Report ID (17) + 0x09, 0x27, // Usage (0x27) + 0x95, 0x02, // Report Count (2) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x12, // Report ID (18) + 0x06, 0x02, 0xFF, // Usage Page (Vendor Defined 0xFF02) + 0x09, 0x21, // Usage (0x21) + 0x95, 0x0F, // Report Count (15) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x13, // Report ID (19) + 0x09, 0x22, // Usage (0x22) + 0x95, 0x16, // Report Count (22) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x14, // Report ID (20) + 0x06, 0x05, 0xFF, // Usage Page (Vendor Defined 0xFF05) + 0x09, 0x20, // Usage (0x20) + 0x95, 0x10, // Report Count (16) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x15, // Report ID (21) + 0x09, 0x21, // Usage (0x21) + 0x95, 0x2C, // Report Count (44) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x06, 0x80, 0xFF, // Usage Page (Vendor Defined 0xFF80) + 0x85, 0x80, // Report ID (128) + 0x09, 0x20, // Usage (0x20) + 0x95, 0x06, // Report Count (6) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x81, // Report ID (129) + 0x09, 0x21, // Usage (0x21) + 0x95, 0x06, // Report Count (6) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x82, // Report ID (130) + 0x09, 0x22, // Usage (0x22) + 0x95, 0x05, // Report Count (5) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x83, // Report ID (131) + 0x09, 0x23, // Usage (0x23) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x84, // Report ID (132) + 0x09, 0x24, // Usage (0x24) + 0x95, 0x04, // Report Count (4) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x85, // Report ID (133) + 0x09, 0x25, // Usage (0x25) + 0x95, 0x06, // Report Count (6) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x86, // Report ID (134) + 0x09, 0x26, // Usage (0x26) + 0x95, 0x06, // Report Count (6) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x87, // Report ID (135) + 0x09, 0x27, // Usage (0x27) + 0x95, 0x23, // Report Count (35) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x88, // Report ID (136) + 0x09, 0x28, // Usage (0x28) + 0x95, 0x22, // Report Count (34) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x89, // Report ID (137) + 0x09, 0x29, // Usage (0x29) + 0x95, 0x02, // Report Count (2) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x90, // Report ID (144) + 0x09, 0x30, // Usage (0x30) + 0x95, 0x05, // Report Count (5) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x91, // Report ID (145) + 0x09, 0x31, // Usage (0x31) + 0x95, 0x03, // Report Count (3) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x92, // Report ID (146) + 0x09, 0x32, // Usage (0x32) + 0x95, 0x03, // Report Count (3) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0x93, // Report ID (147) + 0x09, 0x33, // Usage (0x33) + 0x95, 0x0C, // Report Count (12) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA0, // Report ID (160) + 0x09, 0x40, // Usage (0x40) + 0x95, 0x06, // Report Count (6) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA1, // Report ID (161) + 0x09, 0x41, // Usage (0x41) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA2, // Report ID (162) + 0x09, 0x42, // Usage (0x42) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA3, // Report ID (163) + 0x09, 0x43, // Usage (0x43) + 0x95, 0x30, // Report Count (48) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA4, // Report ID (164) + 0x09, 0x44, // Usage (0x44) + 0x95, 0x0D, // Report Count (13) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA5, // Report ID (165) + 0x09, 0x45, // Usage (0x45) + 0x95, 0x15, // Report Count (21) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA6, // Report ID (166) + 0x09, 0x46, // Usage (0x46) + 0x95, 0x15, // Report Count (21) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA7, // Report ID (247) + 0x09, 0x4A, // Usage (0x4A) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA8, // Report ID (250) + 0x09, 0x4B, // Usage (0x4B) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xA9, // Report ID (251) + 0x09, 0x4C, // Usage (0x4C) + 0x95, 0x08, // Report Count (8) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAA, // Report ID (252) + 0x09, 0x4E, // Usage (0x4E) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAB, // Report ID (253) + 0x09, 0x4F, // Usage (0x4F) + 0x95, 0x39, // Report Count (57) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAC, // Report ID (254) + 0x09, 0x50, // Usage (0x50) + 0x95, 0x39, // Report Count (57) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAD, // Report ID (255) + 0x09, 0x51, // Usage (0x51) + 0x95, 0x0B, // Report Count (11) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAE, // Report ID (256) + 0x09, 0x52, // Usage (0x52) + 0x95, 0x01, // Report Count (1) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xAF, // Report ID (175) + 0x09, 0x53, // Usage (0x53) + 0x95, 0x02, // Report Count (2) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xB0, // Report ID (176) + 0x09, 0x54, // Usage (0x54) + 0x95, 0x3F, // Report Count (63) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0xC0, // End Collection + + 0x06, 0xF0, 0xFF, // Usage Page (Vendor Defined 0xFFF0) + 0x09, 0x40, // Usage (0x40) + 0xA1, 0x01, // Collection (Application) + 0x85, 0xF0, // Report ID (-16) AUTH F0 + 0x09, 0x47, // Usage (0x47) + 0x95, 0x3F, // Report Count (63) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xF1, // Report ID (-15) AUTH F1 + 0x09, 0x48, // Usage (0x48) + 0x95, 0x3F, // Report Count (63) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xF2, // Report ID (-14) AUTH F2 + 0x09, 0x49, // Usage (0x49) + 0x95, 0x0F, // Report Count (15) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x85, 0xF3, // Report ID (-13) Auth F3 (Reset) + 0x0A, 0x01, 0x47, // Usage (0x4701) + 0x95, 0x07, // Report Count (7) + 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0xC0, // End Collection +}; + +const u16 hidDescriptorSize = sizeof(hidDescriptor); + +const u8 output_0x02[] = { + 0xfe, 0xff, 0x0e, 0x00, 0x04, 0x00, 0xd4, 0x22, + 0x2a, 0xdd, 0xbb, 0x22, 0x5e, 0xdd, 0x81, 0x22, + 0x84, 0xdd, 0x1c, 0x02, 0x1c, 0x02, 0x85, 0x1f, + 0xb0, 0xe0, 0xc6, 0x20, 0xb5, 0xe0, 0xb1, 0x20, + 0x83, 0xdf, 0x0c, 0x00 +}; +const u16 output_0x02_size = sizeof(output_0x02); + +const u8 output_0x03[] = { + 0x21, 0x27, 0x04, 0xcf, 0x00, 0x2c, 0x56, + 0x08, 0x00, 0x3d, 0x00, 0xe8, 0x03, 0x04, 0x00, + 0xff, 0x7f, 0x0d, 0x0d, 0x00, 0x00, 0x00, 0x00, + 0x0D, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const u16 output_0x03_size = sizeof(output_0x03); + +const u8 output_0x12[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // device MAC address + 0x08, 0x25, 0x00, // BT device class + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // host MAC address +}; +const u16 output_0x12_size = sizeof(output_0x12); + +const u8 output_0xa3[] = { + 0x4a, 0x75, 0x6e, 0x20, 0x20, 0x39, 0x20, 0x32, + 0x30, 0x31, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x31, 0x32, 0x3a, 0x33, 0x36, 0x3a, 0x34, 0x31, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x08, 0xb4, 0x01, 0x00, 0x00, 0x00, + 0x07, 0xa0, 0x10, 0x20, 0x00, 0xa0, 0x02, 0x00 +}; +const u16 output_0xa3_size = sizeof(output_0xa3); + +const u8 output_0xf3[] = { + 0x0, 0x38, 0x38, 0, 0, 0, 0 +}; +const u16 output_0xf3_size = sizeof(output_0xf3); + +#endif diff --git a/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.h b/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.h new file mode 100644 index 000000000..86f68dc21 --- /dev/null +++ b/cores/arduino/ArduinoDS4/ArduinoPS4_USBDesc.h @@ -0,0 +1,68 @@ +/* + * Project ArduinoPS4 AVR core + * @author Flamethrower + * @link github.com/Flamethr0wer/ArduinoPS4_AVR + * @license MIT - Copyright (c) 2019 Flamethrower + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "USBAPI.h" + +#ifndef ARDUINOPS4_USBDESC_H +#define ARDUINOPS4_USBDESC_H + +#if defined(USBCON) + +extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM; + +extern const u8 hidDescriptor[] PROGMEM; +extern const u16 hidDescriptorSize PROGMEM; + +extern const u8 USB_ConfigDescriptor[] PROGMEM; +extern const u16 USB_ConfigDescriptorSize PROGMEM; + +extern const u8 output_0x02[] PROGMEM; +extern const u16 output_0x02_size PROGMEM; + +extern const u8 output_0x03[] PROGMEM; +extern const u16 output_0x03_size PROGMEM; + +extern const u8 output_0x12[] PROGMEM; +extern const u16 output_0x12_size PROGMEM; + +extern const u8 output_0xa3[] PROGMEM; +extern const u16 output_0xa3_size PROGMEM; + +extern const u8 output_0xf3[] PROGMEM; +extern const u16 output_0xf3_size PROGMEM; + + +extern const u8 STRING_SERIAL[] PROGMEM; +extern const u8 STRING_SECURITY[] PROGMEM; + +#define ISECURITY 4 + +#define ARDUINOPS4_TX_ENDPOINT 1 +#define ARDUINOPS4_RX_ENDPOINT 3 + +#endif + +#endif diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp index 4fe3bf5e5..a6bce17d7 100644 --- a/cores/arduino/CDC.cpp +++ b/cores/arduino/CDC.cpp @@ -17,294 +17,9 @@ */ #include "USBAPI.h" -#include -#include #if defined(USBCON) -#ifndef CDC_ENABLED - -#warning "! Disabled serial console via USB (CDC)!" -#warning "! With this change you'll have to use the Arduino's reset button/pin to flash (upload)!" - -#else // CDC not disabled - -typedef struct -{ - u32 dwDTERate; - u8 bCharFormat; - u8 bParityType; - u8 bDataBits; - u8 lineState; -} LineInfo; - -static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 }; -static volatile int32_t breakValue = -1; - -static u8 wdtcsr_save; - -#define WEAK __attribute__ ((weak)) - -extern const CDCDescriptor _cdcInterface PROGMEM; -const CDCDescriptor _cdcInterface = -{ - D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), - - // CDC communication interface - D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), - D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd) - D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not) - D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported - D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 - D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40), - - // CDC data interface - D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), - D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0), - D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0) -}; - -bool isLUFAbootloader() -{ - return pgm_read_word(FLASHEND - 1) == NEW_LUFA_SIGNATURE; -} - -int CDC_GetInterface(u8* interfaceNum) -{ - interfaceNum[0] += 2; // uses 2 - return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface)); -} - -bool CDC_Setup(USBSetup& setup) -{ - u8 r = setup.bRequest; - u8 requestType = setup.bmRequestType; - - if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType) - { - if (CDC_GET_LINE_CODING == r) - { - USB_SendControl(0,(void*)&_usbLineInfo,7); - return true; - } - } - - if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType) - { - if (CDC_SEND_BREAK == r) - { - breakValue = ((uint16_t)setup.wValueH << 8) | setup.wValueL; - } - - if (CDC_SET_LINE_CODING == r) - { - USB_RecvControl((void*)&_usbLineInfo,7); - } - - if (CDC_SET_CONTROL_LINE_STATE == r) - { - _usbLineInfo.lineState = setup.wValueL; - - // auto-reset into the bootloader is triggered when the port, already - // open at 1200 bps, is closed. this is the signal to start the watchdog - // with a relatively long period so it can finish housekeeping tasks - // like servicing endpoints before the sketch ends - - uint16_t magic_key_pos = MAGIC_KEY_POS; - -// If we don't use the new RAMEND directly, check manually if we have a newer bootloader. -// This is used to keep compatible with the old leonardo bootloaders. -// You are still able to set the magic key position manually to RAMEND-1 to save a few bytes for this check. -#if MAGIC_KEY_POS != (RAMEND-1) - // For future boards save the key in the inproblematic RAMEND - // Which is reserved for the main() return value (which will never return) - if (isLUFAbootloader()) { - // hooray, we got a new bootloader! - magic_key_pos = (RAMEND-1); - } -#endif - - // We check DTR state to determine if host port is open (bit 0 of lineState). - if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0) - { -#if MAGIC_KEY_POS != (RAMEND-1) - // Backup ram value if its not a newer bootloader and it hasn't already been saved. - // This should avoid memory corruption at least a bit, not fully - if (magic_key_pos != (RAMEND-1) && *(uint16_t *)magic_key_pos != MAGIC_KEY) { - *(uint16_t *)(RAMEND-1) = *(uint16_t *)magic_key_pos; - } -#endif - // Store boot key - *(uint16_t *)magic_key_pos = MAGIC_KEY; - // Save the watchdog state in case the reset is aborted. - wdtcsr_save = WDTCSR; - wdt_enable(WDTO_120MS); - } - else if (*(uint16_t *)magic_key_pos == MAGIC_KEY) - { - // Most OSs do some intermediate steps when configuring ports and DTR can - // twiggle more than once before stabilizing. - // To avoid spurious resets we set the watchdog to 120ms and eventually - // cancel if DTR goes back high. - // Cancellation is only done if an auto-reset was started, which is - // indicated by the magic key having been set. - - wdt_reset(); - // Restore the watchdog state in case the sketch was using it. - WDTCSR |= (1<= 0) { - return 1 + USB_Available(CDC_RX); - } - return USB_Available(CDC_RX); -} - -int Serial_::peek(void) -{ - if (peek_buffer < 0) - peek_buffer = USB_Recv(CDC_RX); - return peek_buffer; -} - -int Serial_::read(void) -{ - if (peek_buffer >= 0) { - int c = peek_buffer; - peek_buffer = -1; - return c; - } - return USB_Recv(CDC_RX); -} - -int Serial_::availableForWrite(void) -{ - return USB_SendSpace(CDC_TX); -} - -void Serial_::flush(void) -{ - USB_Flush(CDC_TX); -} - -size_t Serial_::write(uint8_t c) -{ - return write(&c, 1); -} - -size_t Serial_::write(const uint8_t *buffer, size_t size) -{ - /* only try to send bytes if the high-level CDC connection itself - is open (not just the pipe) - the OS should set lineState when the port - is opened and clear lineState when the port is closed. - bytes sent before the user opens the connection or after - the connection is closed are lost - just like with a UART. */ - - // TODO - ZE - check behavior on different OSes and test what happens if an - // open connection isn't broken cleanly (cable is yanked out, host dies - // or locks up, or host virtual serial port hangs) - if (_usbLineInfo.lineState > 0) { - int r = USB_Send(CDC_TX,buffer,size); - if (r > 0) { - return r; - } else { - setWriteError(); - return 0; - } - } - setWriteError(); - return 0; -} - -// This operator is a convenient way for a sketch to check whether the -// port has actually been configured and opened by the host (as opposed -// to just being connected to the host). It can be used, for example, in -// setup() before printing to ensure that an application on the host is -// actually ready to receive and display the data. -// We add a short delay before returning to fix a bug observed by Federico -// where the port is configured (lineState != 0) but not quite opened. -Serial_::operator bool() { - bool result = false; - if (_usbLineInfo.lineState > 0) - result = true; - delay(10); - return result; -} - -unsigned long Serial_::baud() { - // Disable interrupts while reading a multi-byte value - uint32_t baudrate; - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { - baudrate = _usbLineInfo.dwDTERate; - } - return baudrate; -} - -uint8_t Serial_::stopbits() { - return _usbLineInfo.bCharFormat; -} - -uint8_t Serial_::paritytype() { - return _usbLineInfo.bParityType; -} - -uint8_t Serial_::numbits() { - return _usbLineInfo.bDataBits; -} - -bool Serial_::dtr() { - return _usbLineInfo.lineState & 0x1; -} - -bool Serial_::rts() { - return _usbLineInfo.lineState & 0x2; -} - -int32_t Serial_::readBreak() { - int32_t ret; - // Disable IRQs while reading and clearing breakValue to make - // sure we don't overwrite a value just set by the ISR. - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { - ret = breakValue; - breakValue = -1; - } - return ret; -} - Serial_ Serial; -#endif /* if defined(CDC_ENABLED) */ #endif /* if defined(USBCON) */ diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index 3ff145916..3a1b71d12 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -43,6 +43,8 @@ typedef unsigned long u32; #include "USBDesc.h" #include "USBCore.h" +#include "ArduinoDS4/ArduinoDS4_USBDesc.h" + //================================================================================ //================================================================================ // USB @@ -92,24 +94,20 @@ class Serial_ : public Stream private: int peek_buffer; public: - Serial_() { peek_buffer = -1; }; - void begin(unsigned long); - void begin(unsigned long, uint8_t); - void end(void); - - virtual int available(void); - virtual int peek(void); - virtual int read(void); - virtual int availableForWrite(void); - virtual void flush(void); - virtual size_t write(uint8_t); - virtual size_t write(const uint8_t*, size_t); + Serial_() {}; + void begin(unsigned long) {} + void begin(unsigned long, uint8_t) {} + void end(void) {} + + virtual int available(void) { return -1; } + virtual int peek(void) { return -1; } + virtual int read(void) { return -1; } + virtual int availableForWrite(void) { return -1; } + virtual void flush(void) {} + virtual size_t write(uint8_t) { return -1; } + virtual size_t write(const uint8_t*, size_t n) { return n; } using Print::write; // pull in write(str) and write(buf, size) from Print - operator bool(); - - volatile uint8_t _rx_buffer_head; - volatile uint8_t _rx_buffer_tail; - unsigned char _rx_buffer[SERIAL_BUFFER_SIZE]; + operator bool() { return true; } // This method allows processing "SEND_BREAK" requests sent by // the USB host. Those requests indicate that the host wants to @@ -126,17 +124,17 @@ class Serial_ : public Stream // first request is lost. // Note that the value returned is a long, so it can return // 0-0xffff as well as -1. - int32_t readBreak(); + int32_t readBreak() { return -1; }; // These return the settings specified by the USB host for the // serial port. These aren't really used, but are offered here // in case a sketch wants to act on these settings. - uint32_t baud(); - uint8_t stopbits(); - uint8_t paritytype(); - uint8_t numbits(); - bool dtr(); - bool rts(); + uint32_t baud() { return 0; } + uint8_t stopbits() { return 1; } + uint8_t paritytype() { return 0; } + uint8_t numbits() { return 8; } + bool dtr() { return true; } + bool rts() { return true; } enum { ONE_STOP_BIT = 0, ONE_AND_HALF_STOP_BIT = 1, @@ -169,26 +167,6 @@ typedef struct uint16_t wLength; } USBSetup; -//================================================================================ -//================================================================================ -// MSC 'Driver' - -int MSC_GetInterface(uint8_t* interfaceNum); -int MSC_GetDescriptor(int i); -bool MSC_Setup(USBSetup& setup); -bool MSC_Data(uint8_t rx,uint8_t tx); - -//================================================================================ -//================================================================================ -// CSC 'Driver' - -int CDC_GetInterface(uint8_t* interfaceNum); -int CDC_GetDescriptor(int i); -bool CDC_Setup(USBSetup& setup); - -//================================================================================ -//================================================================================ - #define TRANSFER_PGM 0x80 #define TRANSFER_RELEASE 0x40 #define TRANSFER_ZERO 0x20 @@ -204,6 +182,8 @@ int USB_Recv(uint8_t ep, void* data, int len); // non-blocking int USB_Recv(uint8_t ep); // non-blocking void USB_Flush(uint8_t ep); +#include "ArduinoDS4/ArduinoDS4_USBAPI.h" + #endif #endif /* if defined(USBCON) */ diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 933523873..c29701606 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -1,5 +1,3 @@ - - /* Copyright (c) 2010, Peter Barrett ** Sleep/Wakeup support added by Michael Dreher ** @@ -34,7 +32,6 @@ volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ extern const u16 STRING_LANGUAGE[] PROGMEM; extern const u8 STRING_PRODUCT[] PROGMEM; extern const u8 STRING_MANUFACTURER[] PROGMEM; -extern const DeviceDescriptor USB_DeviceDescriptorIAD PROGMEM; const u16 STRING_LANGUAGE[2] = { (3<<8) | (2+2), @@ -66,22 +63,6 @@ const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT; const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER; -#define DEVICE_CLASS 0x02 - -// DEVICE DESCRIPTOR - -#ifdef CDC_ENABLED -const DeviceDescriptor USB_DeviceDescriptorIAD = - D_DEVICE(0xEF,0x02,0x01,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1); -#else // CDC_DISABLED -// The default descriptor uses USB class OxEF, subclass 0x02 with protocol 1 -// which means "Interface Association Descriptor" - that's needed for the CDC, -// but doesn't make much sense as a default for custom devices when CDC is disabled. -// (0x00 means "Use class information in the Interface Descriptors" which should be generally ok) -const DeviceDescriptor USB_DeviceDescriptorIAD = - D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1); -#endif - //================================================================== //================================================================== @@ -335,24 +316,21 @@ int USB_Send(u8 ep, const void* d, int len) return r; } -u8 _initEndpoints[USB_ENDPOINTS] = -{ - 0, // Control Endpoint - -#ifdef CDC_ENABLED - EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM - EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT - EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN -#endif - - // Following endpoints are automatically initialized to 0 -}; - #define EP_SINGLE_64 0x32 // EP0 #define EP_DOUBLE_64 0x36 // Other endpoints #define EP_SINGLE_16 0x12 -static +static inline +u8 BankSizeMask(const uint8_t nbytes) { + uint8_t mask = 0; + for (uint8_t size = 8; size < 64; size <<= 1) { + if (nbytes <= size) break; + mask++; + } + return (mask << EPSIZE0); +} +static inline + void InitEP(u8 index, u8 type, u8 size) { UENUM = index; @@ -361,41 +339,27 @@ void InitEP(u8 index, u8 type, u8 size) UECFG1X = size; } -static -void InitEndpoints() -{ - for (u8 i = 1; i < sizeof(_initEndpoints) && _initEndpoints[i] != 0; i++) - { - UENUM = i; - UECONX = (1<= USB_ENDPOINTS) return false; + uint8_t size = ((1 << ALLOC) | ((nbanks > 1) ? (1 << EPBK0) : 0) | BankSizeMask(banksize)); + InitEP(index, type, size); + return UESTA0X & (1 << CFGOK); // Success } - -// Handle CLASS_INTERFACE requests static -bool ClassInterfaceRequest(USBSetup& setup) -{ -#ifdef CDC_ENABLED - u8 i = setup.wIndex; +void InitEndpoints() { + InitEPSize(ARDUINOPS4_TX_ENDPOINT, EP_TYPE_INTERRUPT_IN, 2, 64); // Control Data Send + InitEPSize(ARDUINOPS4_RX_ENDPOINT, EP_TYPE_INTERRUPT_OUT, 2, 64); // Control Data Receive + InitEPSize(5, EP_TYPE_INTERRUPT_IN, 2, 64); // Expansion Interface NACK (avoid config reset) - if (CDC_ACM_INTERFACE == i) - return CDC_Setup(setup); -#endif + UERST = 0x7E; // Reset endpoints + UERST = 0; // End reset -#ifdef PLUGGABLE_USB_ENABLED - return PluggableUSB().setup(setup); -#endif - return false; + SetEP(ARDUINOPS4_TX_ENDPOINT); + UEIENX |= (1 << TXINE); + + SetEP(ARDUINOPS4_RX_ENDPOINT); + UEIENX |= (1 << RXOUTE); } static int _cmark; @@ -476,36 +440,14 @@ int USB_RecvControl(void* d, int len) return len; } -static u8 SendInterfaces() -{ - u8 interfaces = 0; - -#ifdef CDC_ENABLED - CDC_GetInterface(&interfaces); -#endif - -#ifdef PLUGGABLE_USB_ENABLED - PluggableUSB().getInterface(&interfaces); -#endif - - return interfaces; -} - // Construct a dynamic configuration descriptor // This really needs dynamic endpoint allocation etc // TODO static bool SendConfiguration(int maxlen) { - // Count and measure interfaces - InitControl(0); - u8 interfaces = SendInterfaces(); - ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces); - - // Now send them InitControl(maxlen); - USB_SendControl(0,&config,sizeof(ConfigDescriptor)); - SendInterfaces(); + USB_SendControl(TRANSFER_PGM, &USB_ConfigDescriptor, USB_ConfigDescriptorSize); return true; } @@ -524,10 +466,14 @@ bool SendDescriptor(USBSetup& setup) } #endif + if (t == 0x22) { // HID Report descriptor request + return USB_SendControl(TRANSFER_PGM, hidDescriptor, hidDescriptorSize) > 0; + } + const u8* desc_addr = 0; if (USB_DEVICE_DESCRIPTOR_TYPE == t) { - desc_addr = (const u8*)&USB_DeviceDescriptorIAD; + desc_addr = (const u8*) &USB_DeviceDescriptor; } else if (USB_STRING_DESCRIPTOR_TYPE == t) { @@ -545,8 +491,13 @@ bool SendDescriptor(USBSetup& setup) char name[ISERIAL_MAX_LEN]; PluggableUSB().getShortName(name); return USB_SendStringDescriptor((uint8_t*)name, strlen(name), 0); +#else + return USB_SendStringDescriptor(STRING_SERIAL, strlen((char*)STRING_SERIAL), TRANSFER_PGM); #endif } + else if (setup.wValueL == ISECURITY) { + return USB_SendStringDescriptor(STRING_SECURITY, strlen((char*)STRING_SECURITY), TRANSFER_PGM); + } else return false; } @@ -559,9 +510,24 @@ bool SendDescriptor(USBSetup& setup) return true; } -// Endpoint 0 interrupt +// Endpoint interrupt ISR(USB_COM_vect) { + SetEP(ARDUINOPS4_TX_ENDPOINT); + if (UEINTX & (1 << TXINI)) { // If TX buffer is ready + UEINTX &= ~(1 << TXINI); // Clear interrupt flag + if (ArduinoPS4USB::SendCallback != nullptr) { + ArduinoPS4USB::SendCallback(); // Call callback function if it exists + } + } + + SetEP(ARDUINOPS4_RX_ENDPOINT); + if (UEINTX & (1 << RXOUTI)) { // If data received... + UEINTX &= ~(1 << RXOUTI); // Clear interrupt flag + if (ArduinoPS4USB::RecvCallback != nullptr) { + ArduinoPS4USB::RecvCallback(); // Call callback function if it exists + } + } SetEP(0); if (!ReceivedSetupInt()) return; @@ -648,8 +614,98 @@ ISR(USB_COM_vect) } else { - InitControl(setup.wLength); // Max length of transfer - ok = ClassInterfaceRequest(setup); + // Handle HID class requests + if ((requestType & REQUEST_TYPE) == REQUEST_CLASS) + { + // HID class requests (0x01 = GET_REPORT, 0x09 = SET_REPORT) + if (setup.bRequest == 0x01) // HID_GET_REPORT + { + if (setup.wValueH == 0x03) // Feature report type + { + uint8_t reportId = setup.wValueL; + const u8* featureData = nullptr; + u16 featureLen = 0; + + // Handle different report IDs + switch(reportId) { + case 0x02: // Calibration + featureData = output_0x02; + featureLen = output_0x02_size; + break; + case 0x03: // Controller descriptor + featureData = output_0x03; + featureLen = output_0x03_size; + break; + case 0x12: // MAC address + featureData = output_0x12; + featureLen = output_0x12_size; + break; + case 0xA3: // Version/date + featureData = output_0xa3; + featureLen = output_0xa3_size; + break; + case 0xF3: // Reset auth + featureData = output_0xf3; + featureLen = output_0xf3_size; + break; + case 0xF1: + case 0xF2: + ok = false; + break; + default: + ok = false; + break; + } + + if (featureData && featureLen > 0) { + InitControl(min(featureLen + 1, setup.wLength)); + SendControl(reportId); + USB_SendControl(TRANSFER_PGM, featureData, min(featureLen, setup.wLength)); + ok = true; + } + } + } + else if (setup.bRequest == 0x09) // HID_SET_REPORT + { + if (setup.wValueH == 0x03) // Feature report type + { + // For basic PS4 support, we can mostly ignore SET_REPORT + // Just acknowledge it was received + uint8_t buffer[64]; + int len = USB_RecvControl(buffer, min(sizeof(buffer), setup.wLength)); + ok = (len >= 0); + } + else if (setup.wValueH == 0x02) // Output report type + { + // Handle rumble/LED data if needed + uint8_t buffer[64]; + int len = USB_RecvControl(buffer, min(sizeof(buffer), setup.wLength)); + ok = (len >= 0); + } + else { + ok = true; + } + ClearIN(); + } + else if (setup.bRequest == 0x0A || setup.bRequest == 0x0B){ + ClearIN(); + ok = true; + } + else if (setup.bRequest == 0x02) // HID_GET_IDLE + { + Send8(0); + ok = true; + } + else if (setup.bRequest == 0x03) // HID_GET_PROTOCOL + { + Send8(0); + ok = true; + } + } + else + { + ok = true; // Default behavior for vendor requests etc + } } if (ok) @@ -770,7 +826,6 @@ ISR(USB_GEN_vect) // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too if (udint & (1<> 8) & 0xFF) -#define CDC_V1_10 0x0110 -#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02 - -#define CDC_CALL_MANAGEMENT 0x01 -#define CDC_ABSTRACT_CONTROL_MODEL 0x02 -#define CDC_HEADER 0x00 -#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02 -#define CDC_UNION 0x06 -#define CDC_CS_INTERFACE 0x24 -#define CDC_CS_ENDPOINT 0x25 -#define CDC_DATA_INTERFACE_CLASS 0x0A - -#define MSC_SUBCLASS_SCSI 0x06 -#define MSC_PROTOCOL_BULK_ONLY 0x50 - #ifndef USB_VERSION #define USB_VERSION 0x200 #endif @@ -190,82 +165,6 @@ typedef struct u8 interval; } EndpointDescriptor; -// Interface Association Descriptor -// Used to bind 2 interfaces together in CDC composite device -typedef struct -{ - u8 len; // 8 - u8 dtype; // 11 - u8 firstInterface; - u8 interfaceCount; - u8 functionClass; - u8 funtionSubClass; - u8 functionProtocol; - u8 iInterface; -} IADDescriptor; - -// CDC CS interface descriptor -typedef struct -{ - u8 len; // 5 - u8 dtype; // 0x24 - u8 subtype; - u8 d0; - u8 d1; -} CDCCSInterfaceDescriptor; - -typedef struct -{ - u8 len; // 4 - u8 dtype; // 0x24 - u8 subtype; - u8 d0; -} CDCCSInterfaceDescriptor4; - -typedef struct -{ - u8 len; - u8 dtype; // 0x24 - u8 subtype; // 1 - u8 bmCapabilities; - u8 bDataInterface; -} CMFunctionalDescriptor; - -typedef struct -{ - u8 len; - u8 dtype; // 0x24 - u8 subtype; // 1 - u8 bmCapabilities; -} ACMFunctionalDescriptor; - -typedef struct -{ - // IAD - IADDescriptor iad; // Only needed on compound device - - // Control - InterfaceDescriptor cif; // - CDCCSInterfaceDescriptor header; - CMFunctionalDescriptor callManagement; // Call Management - ACMFunctionalDescriptor controlManagement; // ACM - CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION - EndpointDescriptor cifin; - - // Data - InterfaceDescriptor dif; - EndpointDescriptor in; - EndpointDescriptor out; -} CDCDescriptor; - -typedef struct -{ - InterfaceDescriptor msc; - EndpointDescriptor in; - EndpointDescriptor out; -} MSCDescriptor; - - #define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \ { 18, 1, USB_VERSION, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs } @@ -278,12 +177,6 @@ typedef struct #define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \ { 7, 5, _addr,_attr,_packetSize, _interval } -#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \ - { 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 } - -#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 } -#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } - // Bootloader related fields // Old Caterina bootloader places the MAGIC key into unsafe RAM locations (it can be rewritten // by the running sketch before to actual reboot). diff --git a/cores/arduino/USBDesc.h b/cores/arduino/USBDesc.h index b55ac20bc..1f1e7037a 100644 --- a/cores/arduino/USBDesc.h +++ b/cores/arduino/USBDesc.h @@ -16,7 +16,7 @@ SOFTWARE. */ -#define PLUGGABLE_USB_ENABLED +//#define PLUGGABLE_USB_ENABLED #if defined(EPRST6) #define USB_ENDPOINTS 7 // AtMegaxxU4 @@ -24,40 +24,6 @@ #define USB_ENDPOINTS 5 // AtMegaxxU2 #endif -#define ISERIAL_MAX_LEN 20 - -// Uncomment the following line or pass -DCDC_DISABLED to the compiler -// to disable CDC (serial console via USB). -// That's useful if you want to create an USB device (like an USB Boot Keyboard) -// that works even with problematic devices (like KVM switches). -// Keep in mind that with this change you'll have to use the Arduino's -// reset button to be able to flash it. -//#define CDC_DISABLED - -#ifndef CDC_DISABLED -#define CDC_ENABLED -#endif - -#ifdef CDC_ENABLED -#define CDC_INTERFACE_COUNT 2 -#define CDC_ENPOINT_COUNT 3 -#else // CDC_DISABLED -#define CDC_INTERFACE_COUNT 0 -#define CDC_ENPOINT_COUNT 0 -#endif - -#define CDC_ACM_INTERFACE 0 // CDC ACM -#define CDC_DATA_INTERFACE 1 // CDC Data -#define CDC_FIRST_ENDPOINT 1 -#define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First -#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1) -#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2) - -#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT) - -#define CDC_RX CDC_ENDPOINT_OUT -#define CDC_TX CDC_ENDPOINT_IN - #define IMANUFACTURER 1 #define IPRODUCT 2 -#define ISERIAL 3 \ No newline at end of file +#define ISERIAL 3