diff --git a/adafruit_avrprog.py b/adafruit_avrprog.py index 5952cba..f2a36aa 100644 --- a/adafruit_avrprog.py +++ b/adafruit_avrprog.py @@ -59,6 +59,14 @@ class AVRprog: """ Some well known board definitions """ + ATtiny13a = { + 'name': "ATtiny13a", + 'sig': [0x1E, 0x90, 0x07], + 'flash_size': 1024, + 'page_size': 32, + 'fuse_mask': (0xFF, 0xFF, 0x00, 0x03), + 'clock_speed': 100000 + } ATtiny85 = { 'name': "ATtiny85", 'sig': [0x1E, 0x93, 0x0B], diff --git a/examples/attiny13a_blink.hex b/examples/attiny13a_blink.hex new file mode 100644 index 0000000..33c6aca --- /dev/null +++ b/examples/attiny13a_blink.hex @@ -0,0 +1,6 @@ +:1000000009C00EC00DC00CC00BC00AC009C008C09A +:1000100007C006C011241FBECFE9CDBF02D012C059 +:10002000EFCF81E087BB18BA98E088B3892788BBF7 +:100030002FEF35EA8EE0215030408040E1F700C0DC +:080040000000F3CFF894FFCF9C +:00000001FF diff --git a/examples/avrprog_program_tiny13a.py b/examples/avrprog_program_tiny13a.py new file mode 100644 index 0000000..d8e90d5 --- /dev/null +++ b/examples/avrprog_program_tiny13a.py @@ -0,0 +1,44 @@ +""" +ATtiny13a programming example, be sure you have the '13a wired up so: + ATtiny13a GND to CircuitPython GND + ATtiny13a VCC to CircuitPython USB + Pin 2 -> CircuitPython SCK + Pin 1 -> CircuitPython MISO + Pin 0 -> CircuitPython MOSI + RESET -> CircuitPython D5 (or change the init() below to change it!) +Drag "attiny13a_blink.hex" onto the CircuitPython disk drive, then open REPL! +""" + +import board +import busio +import adafruit_avrprog + +spi = busio.SPI(board.SCK, board.MOSI, board.MISO) +avrprog = adafruit_avrprog.AVRprog() +avrprog.init(spi, board.D5) + +# Each chip has to have a definition so the script knows how to find it +attiny13 = avrprog.Boards.ATtiny13a + +def error(err): + """ Helper to print out errors for us and then halt """ + print("ERROR: "+err) + avrprog.end() + while True: + pass + +while input("Ready to GO, type 'G' here to start> ") != 'G': + pass + +if not avrprog.verify_sig(attiny13, verbose=True): + error("Signature read failure") +print("Found", attiny13['name']) + +avrprog.write_fuses(attiny13, low=0x7A, high=0xFF) +if not avrprog.verify_fuses(attiny13, low=0x7A, high=0xFF): + error("Failure verifying fuses!") + +print("Programming flash from file") +avrprog.program_file(attiny13, "attiny13a_blink.hex", verbose=True, verify=True) + +print("Done!")