diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst b/examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst new file mode 100644 index 00000000..53ac5a6a --- /dev/null +++ b/examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst @@ -0,0 +1,21 @@ +How to buid PlatformIO based project +==================================== + +1. `Install PlatformIO `_ +2. Download `source code with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platformio-develop/examples/atmelavr-and-arduino/arduino-adafruit-blink + + # Process example project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/platformio.ini b/examples/atmelavr-and-arduino/arduino-adafruit-blink/platformio.ini new file mode 100644 index 00000000..d5377cb8 --- /dev/null +++ b/examples/atmelavr-and-arduino/arduino-adafruit-blink/platformio.ini @@ -0,0 +1,33 @@ +# +# Project Configuration File +# +# A detailed documentation with the EXAMPLES is located here: +# http://docs.platformio.org/en/latest/projectconf.html +# + +# A sign `#` at the beginning of the line indicates a comment +# Comment lines are ignored. + +# Simple and base environment +# [env:mybaseenv] +# platform = %INSTALLED_PLATFORM_NAME_HERE% +# framework = +# board = +# +# Automatic targets - enable auto-uploading +# targets = upload + +[env:flora8] +platform = atmelavr +framework = arduino +board = flora8 + +[env:trinket3] +platform = atmelavr +framework = arduino +board = trinket3 + +[env:protrinket5] +platform = atmelavr +framework = arduino +board = protrinket5 diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/src/Blink.pde b/examples/atmelavr-and-arduino/arduino-adafruit-blink/src/Blink.pde new file mode 100644 index 00000000..6bfde7e0 --- /dev/null +++ b/examples/atmelavr-and-arduino/arduino-adafruit-blink/src/Blink.pde @@ -0,0 +1,33 @@ +/* + Blink + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + + To upload to your Gemma or Trinket: + 1) Select the proper board from the Tools->Board Menu + 2) Select USBtinyISP from the Tools->Programmer + 3) Plug in the Gemma/Trinket, make sure you see the green LED lit + 4) For windows, install the USBtiny drivers + 5) Press the button on the Gemma/Trinket - verify you see + the red LED pulse. This means it is ready to receive data + 6) Click the upload button above within 10 seconds +*/ + +int led = 1; // blink 'digital' pin 1 - AKA the built in red LED + +// the setup routine runs once when you press reset: +void setup() { + // initialize the digital pin as an output. + pinMode(led, OUTPUT); + +} + +// the loop routine runs over and over again forever: +void loop() { + digitalWrite(led, HIGH); + delay(1000); + digitalWrite(led, LOW); + delay(1000); +} + \ No newline at end of file diff --git a/platformio/boards/adafruit.json b/platformio/boards/adafruit.json new file mode 100644 index 00000000..2306825b --- /dev/null +++ b/platformio/boards/adafruit.json @@ -0,0 +1,129 @@ +{ + "flora8": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "8000000L", + "mcu": "atmega32u4", + "usb_product": "Adafruit Flora", + "pid": "0x8004", + "variant": "flora", + "vid": "0x239A" + }, + "name": "Adafruit Flora", + "platform": "atmelavr", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 2560, + "maximum_size": 28672, + "protocol": "avr109", + "speed": 57600, + "use_1200bps_touch": true, + "wait_for_upload_port": false + } + }, + + "trinket3": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "8000000L", + "mcu": "attiny85", + "variant": "tiny8" + }, + "name": "Adafruit Trinket 8MHz", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 512, + "maximum_size": 5310, + "protocol": "usbtiny" + } + }, + + "trinket5": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "attiny85", + "variant": "tiny8" + }, + "name": "Adafruit Trinket 16MHz", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 512, + "protocol": "usbtiny", + "maximum_size": 5310 + } + }, + + "protrinket3": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "12000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Pro Trinket 3V/12MHz (USB)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "usbtiny", + "speed": 115200 + } + }, + + "protrinket5": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Pro Trinket 5V/16MHz (USB)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "usbtiny", + "speed": 115200 + } + }, + "protrinket3ftdi": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Pro Trinket 3V/12MHz (FTDI)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "arduino", + "speed": 115200 + } + }, + "protrinket5ftdi": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "eightanaloginputs" + }, + "name": "Pro Trinket 5V/16MHz (USB)", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 28672, + "protocol": "arduino", + "speed": 115200 + } + } +} \ No newline at end of file diff --git a/platformio/boards/arduino.json b/platformio/boards/arduino.json index 88cbe334..c55b8843 100644 --- a/platformio/boards/arduino.json +++ b/platformio/boards/arduino.json @@ -553,8 +553,8 @@ "platform": "atmelsam", "upload": { "disable_flushing": true, - "maximum_ram_size": 524288, - "maximum_size": 28672, + "maximum_ram_size": 28672, + "maximum_size": 524288, "protocol": "sam-ba", "speed": 57600, "use_1200bps_touch": true, diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index aa3218d8..b1748a6a 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -65,16 +65,19 @@ env.Replace( "-q", # suppress progress output "-D", # disable auto erase for flash memory "-p", "$BOARD_MCU", - "-C", '"%s"' % join("$PIOPACKAGES_DIR", - "tool-avrdude", "avrdude.conf"), - "-c", "$UPLOAD_PROTOCOL", - "-b", "$UPLOAD_SPEED", - "-P", "$UPLOAD_PORT" + "-C", + '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"), + "-c", "$UPLOAD_PROTOCOL" ], UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i', UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i' ) +if "UPLOAD_SPEED" in env: + env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]) +if env.subst("$UPLOAD_PROTOCOL") != "usbtiny": + env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"]) + env.Append( BUILDERS=dict( ElfToEep=Builder( @@ -108,7 +111,7 @@ env.Append( ) -def before_upload(): +def before_upload(target, source, env_): # pylint: disable=W0613 def rpi_sysgpio(path, value): with open(path, "w") as f: @@ -173,7 +176,7 @@ AlwaysBuild(target_size) # upload = env.Alias(["upload", "uploadlazy"], target_hex, [ - lambda target, source, env: before_upload(), "$UPLOADHEXCMD"]) + before_upload, "$UPLOADHEXCMD"]) AlwaysBuild(upload) # @@ -181,7 +184,7 @@ AlwaysBuild(upload) # uploadeep = env.Alias("uploadeep", target_eep, [ - lambda target, source, env: before_upload(), "$UPLOADEEPCMD"]) + before_upload, "$UPLOADEEPCMD"]) AlwaysBuild(uploadeep) # @@ -191,7 +194,7 @@ AlwaysBuild(uploadeep) is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) & set(COMMAND_LINE_TARGETS)) -if is_uptarget: +if is_uptarget and env.subst("$UPLOAD_PROTOCOL") != "usbtiny": # try autodetect upload port if "UPLOAD_PORT" not in env: for item in get_serialports(): diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index f91eac62..2be3a30d 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -6,7 +6,6 @@ """ from os.path import isfile, join -from random import randint from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment) @@ -33,10 +32,6 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy": "-mmcu=$BOARD_MCU" ], - CPPDEFINES=[ - "SERIALNUM=-%d" % randint(1000000000, 2000000000) - ], - LINKFLAGS=[ "-mmcu=$BOARD_MCU" ],