aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-11-20 18:34:14 +0100
committerAyke van Laethem <[email protected]>2018-11-20 18:50:24 +0100
commit9392ef900d3709108f054f2ef48c79435a1f4efe (patch)
tree9870904b128c4fabf0f79f33e526f568da3d2a23 /tools
parenta96e2879b2a2d7fdb783e50b043424df41c5637e (diff)
downloadtinygo-9392ef900d3709108f054f2ef48c79435a1f4efe.tar.gz
tinygo-9392ef900d3709108f054f2ef48c79435a1f4efe.zip
avr: add support for the digispark
Blinking the on-board LED works. Nothing else has been tested yet.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/gen-device-avr.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/gen-device-avr.py b/tools/gen-device-avr.py
index 1b7efe3fd..00cf7ba1f 100755
--- a/tools/gen-device-avr.py
+++ b/tools/gen-device-avr.py
@@ -93,10 +93,16 @@ def readATDF(path):
continue
for bitfieldEl in regEl.getElementsByTagName('bitfield'):
+ mask = bitfieldEl.getAttribute('mask')
+ if len(mask) == 2:
+ # Two devices (ATtiny102 and ATtiny104) appear to have
+ # an error in the bitfields, leaving out the '0x'
+ # prefix.
+ mask = '0x' + mask
reg['bitfields'].append({
'name': regName + '_' + bitfieldEl.getAttribute('name'),
'description': bitfieldEl.getAttribute('caption'),
- 'value': int(bitfieldEl.getAttribute('mask'), 0),
+ 'value': int(mask, 0),
})
if regName in allRegisters:
@@ -112,6 +118,11 @@ def readATDF(path):
peripheral['registers'].append(reg)
+ ramSize = 0 # for devices with no RAM
+ for ramSegmentName in ['IRAM', 'INTERNAL_SRAM', 'SRAM']:
+ if ramSegmentName in memorySizes['data']['segments']:
+ ramSize = memorySizes['data']['segments'][ramSegmentName]
+
device.metadata = {
'file': os.path.basename(path),
'descriptorSource': 'http://packs.download.atmel.com/',
@@ -121,7 +132,7 @@ def readATDF(path):
'arch': arch,
'family': family,
'flashSize': memorySizes['prog']['size'],
- 'ramSize': memorySizes['data']['segments'].get('IRAM', memorySizes['data']['segments'].get('INTERNAL_SRAM')),
+ 'ramSize': ramSize,
'numInterrupts': len(device.interrupts),
}
@@ -228,15 +239,21 @@ __vector_default:
'''.format(**device.metadata))
num = 0
for intr in device.interrupts:
+ jmp = 'jmp'
+ if device.metadata['flashSize'] <= 8 * 1024:
+ # When a device has 8kB or less flash, rjmp (2 bytes) must be used
+ # instead of jmp (4 bytes).
+ # https://www.avrfreaks.net/forum/rjmp-versus-jmp
+ jmp = 'rjmp'
if intr['index'] < num:
# Some devices have duplicate interrupts, probably for historical
# reasons.
continue
while intr['index'] > num:
- out.write(' jmp __vector_default\n')
+ out.write(' {jmp} __vector_default\n'.format(jmp=jmp))
num += 1
num += 1
- out.write(' jmp __vector_{name}\n'.format(**intr))
+ out.write(' {jmp} __vector_{name}\n'.format(jmp=jmp, **intr))
out.write('''
; Define default implementations for interrupts, redirecting to