2014-06-07 13:34:31 +03:00
|
|
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
|
|
|
|
# See LICENSE for details.
|
|
|
|
|
|
2014-07-30 22:40:11 +03:00
|
|
|
from platformio.platforms.base import BasePlatform
|
2015-02-23 22:36:21 +02:00
|
|
|
from platformio.util import get_boards
|
2014-06-07 13:34:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AtmelavrPlatform(BasePlatform):
|
2015-02-23 22:36:21 +02:00
|
|
|
|
2014-06-12 23:29:47 +03:00
|
|
|
"""
|
2015-03-11 18:12:58 +02:00
|
|
|
Atmel AVR 8- and 32-bit MCUs deliver a unique combination of
|
|
|
|
|
performance, power efficiency and design flexibility. Optimized to
|
|
|
|
|
speed time to market-and easily adapt to new ones-they are based on
|
|
|
|
|
the industrys most code-efficient architecture for C and assembly
|
|
|
|
|
programming.
|
|
|
|
|
|
|
|
|
|
http://www.atmel.com/products/microcontrollers/avr/default.aspx
|
2014-06-12 23:29:47 +03:00
|
|
|
"""
|
2014-06-07 13:34:31 +03:00
|
|
|
|
|
|
|
|
PACKAGES = {
|
|
|
|
|
|
|
|
|
|
"toolchain-atmelavr": {
|
2014-07-30 22:41:07 +03:00
|
|
|
"alias": "toolchain",
|
2014-06-07 13:34:31 +03:00
|
|
|
"default": True
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"tool-avrdude": {
|
2015-02-23 22:36:21 +02:00
|
|
|
"default": True
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"tool-micronucleus": {
|
2014-07-30 22:41:07 +03:00
|
|
|
"default": True
|
2014-06-07 13:34:31 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"framework-arduinoavr": {
|
2014-06-14 12:35:37 +03:00
|
|
|
"default": True
|
2014-06-07 13:34:31 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 14:15:57 +02:00
|
|
|
def get_name(self):
|
|
|
|
|
return "Atmel AVR"
|
|
|
|
|
|
2015-02-15 23:53:15 +02:00
|
|
|
def on_run_err(self, line): # pylint: disable=R0201
|
2014-06-07 13:34:31 +03:00
|
|
|
# fix STDERR "flash written" for avrdude
|
2015-02-23 01:06:50 +02:00
|
|
|
if "avrdude" in line:
|
2015-02-15 23:53:15 +02:00
|
|
|
self.on_run_out(line)
|
|
|
|
|
else:
|
|
|
|
|
BasePlatform.on_run_err(self, line)
|
2015-02-23 22:36:21 +02:00
|
|
|
|
|
|
|
|
def run(self, variables, targets):
|
|
|
|
|
for v in variables:
|
|
|
|
|
if "BOARD=" not in v:
|
|
|
|
|
continue
|
|
|
|
|
tuploader = "tool-avrdude"
|
|
|
|
|
_, board = v.split("=")
|
|
|
|
|
bdata = get_boards(board)
|
|
|
|
|
if "digispark" in bdata['build']['core']:
|
|
|
|
|
tuploader = "tool-micronucleus"
|
|
|
|
|
self.PACKAGES[tuploader]['alias'] = "uploader"
|
|
|
|
|
break
|
|
|
|
|
return BasePlatform.run(self, variables, targets)
|