Permalink
Please
sign in to comment.
Browse files
Add µduino port
This is essentially a clone of the itsybitsy5v code with the name changed and the SPI pins disabled as they aren't available on this device. Signed-off-by: Keith Packard <keithp@keithp.com>
- Loading branch information
Showing
with
340 additions
and 10 deletions.
- +20 −9 doc/snek.adoc
- +5 −0 ports/µduino/.gitignore
- +67 −0 ports/µduino/Makefile
- +95 −0 ports/µduino/ao-pins.h
- +52 −0 ports/µduino/snek-µduino-install.1
- +62 −0 ports/µduino/snek-µduino-install.in
- +37 −0 ports/µduino/snek-µduino.builtin
- +2 −1 snek-install.defs
| @@ -0,0 +1,5 @@ | ||
| snek-µduino-*.elf | ||
| snek-µduino-*.hex | ||
| snek-µduino-*.map | ||
| snek-µduino-install | ||
| ao-product.h |
| @@ -0,0 +1,67 @@ | ||
| # | ||
| # Copyright © 2019 Keith Packard <keithp@keithp.com> | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but | ||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # General Public License for more details. | ||
| # | ||
|
|
||
| SNEK_ROOT = ../.. | ||
| SNEK_AVR = $(SNEK_ROOT)/chips/avr | ||
|
|
||
| PROGNAME=snek-µduino | ||
| PRODUCT_NAME=snek-µduino | ||
|
|
||
| AVR_CLOCK=16000000UL | ||
|
|
||
| include $(SNEK_AVR)/snek-avr.defs | ||
|
|
||
| SNEK_LOCAL_SRC = \ | ||
| $(SNEK_AVR_SRC) | ||
|
|
||
| SNEK_LOCAL_INC = \ | ||
| $(SNEK_AVR_INC) | ||
|
|
||
| SNEK_LOCAL_BUILTINS = \ | ||
| $(SNEK_AVR_BUILTINS) \ | ||
| snek-µduino.builtin | ||
|
|
||
| include $(SNEK_ROOT)/snek-install.defs | ||
|
|
||
| all: $(ELF) $(HEX) snek-µduino-install | ||
|
|
||
| $(PROG): Makefile $(SNEK_OBJ) | ||
| $(CC) $(CFLAGS) -o $@ $(SNEK_OBJ) $(LDFLAGS) | ||
| @awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP) | ||
|
|
||
| snek-µduino-install: snek-µduino-install.in | ||
| $(SNEK_SED) $^ > $@ | ||
| chmod +x $@ | ||
|
|
||
| install:: $(HEX) | ||
| install -d $(DESTDIR)$(SHAREDIR) | ||
| install -m 0644 $(HEX) $(DESTDIR)$(SHAREDIR) | ||
|
|
||
| install:: snek-µduino-install snek-µduino-install.1 | ||
| install -d $(DESTDIR)$(BINDIR) | ||
| install snek-µduino-install $(DESTDIR)$(BINDIR) | ||
| install -d $(DESTDIR)$(MANDIR)/man1 | ||
| install -m 0644 snek-µduino-install.1 $(DESTDIR)$(MANDIR)/man1 | ||
|
|
||
| clean:: | ||
| rm -f snek-µduino-install | ||
| rm -f *.hex *.elf *.map | ||
| rm -f ao-product.h | ||
|
|
||
| uninstall:: | ||
|
|
||
| ISP=avrisp2 | ||
|
|
||
| load: $(HEX) snek-µduino-install | ||
| ./snek-µduino-install -quick -isp $(ISP) -hex $(HEX) load |
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| * Copyright © 2019 Keith Packard <keithp@keithp.com> | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but | ||
| * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, write to the Free Software Foundation, Inc., | ||
| * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| */ | ||
|
|
||
| #ifndef _AO_PINS_H_ | ||
| #define _AO_PINS_H_ | ||
|
|
||
| #define HAS_USB 1 | ||
| #define HAS_BEEP 0 | ||
| #define AO_FIFO_SIZE 64 | ||
|
|
||
| #define AVR_VCC_5V 1 | ||
| #define AVR_VCC_3V3 0 | ||
|
|
||
| #define SNEK_IO_GETC(file) ao_usb_getc() | ||
| #define SNEK_GETC() (snek_avr_file.get(stdin)) | ||
| #define fflush(x) ao_usb_flush(x) | ||
|
|
||
| #define PIN_MAP { \ | ||
| [0] = MAKE_MAP(PD, 2), \ | ||
| [1] = MAKE_MAP(PD, 3), \ | ||
| [2] = MAKE_MAP(PD, 1), \ | ||
| [3] = MAKE_MAP(PD, 0), \ | ||
| [4] = MAKE_MAP(PD, 4), \ | ||
| [5] = MAKE_MAP(PC, 6), \ | ||
| [6] = MAKE_MAP(PD, 7), \ | ||
| [7] = MAKE_MAP(PE, 6), \ | ||
| [8] = MAKE_MAP(PB, 4), \ | ||
| [9] = MAKE_MAP(PB, 5), \ | ||
| [10] = MAKE_MAP(PB, 6), \ | ||
| [11] = MAKE_MAP(PB, 7), \ | ||
| [12] = MAKE_MAP(PD, 6), \ | ||
| [13] = MAKE_MAP(PC, 7), \ | ||
| [14] = MAKE_MAP(PF, 7), \ | ||
| [15] = MAKE_MAP(PF, 6), \ | ||
| [16] = MAKE_MAP(PF, 5), \ | ||
| [17] = MAKE_MAP(PF, 4), \ | ||
| [18] = MAKE_MAP(PF, 1), \ | ||
| [19] = MAKE_MAP(PF, 0), \ | ||
| } | ||
|
|
||
| #define ADC_MAP { \ | ||
| [14 - FIRST_ADC] = 7, \ | ||
| [15 - FIRST_ADC] = 6, \ | ||
| [16 - FIRST_ADC] = 5, \ | ||
| [17 - FIRST_ADC] = 4, \ | ||
| [18 - FIRST_ADC] = 1, \ | ||
| [19 - FIRST_ADC] = 0, \ | ||
| } | ||
|
|
||
| #define OCR_REG_ADDRS { \ | ||
| [3] = (uint8_t) (uintptr_t) &OCR0B, \ | ||
| [5] = (uint8_t) (uintptr_t) &OCR3AL, \ | ||
| [6] = (uint8_t) (uintptr_t) &OCR4D, \ | ||
| [9] = (uint8_t) (uintptr_t) &OCR1AL, \ | ||
| [10] = (uint8_t) (uintptr_t) &OCR1BL, \ | ||
| [11] = (uint8_t) (uintptr_t) &OCR0A, \ | ||
| [13] = (uint8_t) (uintptr_t) &OCR4A, \ | ||
| } | ||
|
|
||
| #define TCC_REG_ADDRS { \ | ||
| [3] = (uint8_t) (uintptr_t) &TCCR0A, \ | ||
| [5] = (uint8_t) (uintptr_t) &TCCR3A, \ | ||
| [6] = (uint8_t) (uintptr_t) &TCCR4A, \ | ||
| [9] = (uint8_t) (uintptr_t) &TCCR1A, \ | ||
| [10] = (uint8_t) (uintptr_t) &TCCR1A, \ | ||
| [11] = (uint8_t) (uintptr_t) &TCCR0A, \ | ||
| [13] = (uint8_t) (uintptr_t) &TCCR4A, \ | ||
| } | ||
|
|
||
| #define TCC_REG_VALS { \ | ||
| [3] = 1 << COM0B1, \ | ||
| [5] = 1 << COM3A1, \ | ||
| [6] = 1 << COM4D1, \ | ||
| [9] = 1 << COM1A1, \ | ||
| [10] = 1 << COM1B1, \ | ||
| [11] = 1 << COM0A1, \ | ||
| [13] = 1 << COM4A1, \ | ||
| } | ||
|
|
||
| #endif /* _AO_PINS_H_ */ |
| @@ -0,0 +1,52 @@ | ||
| .\" | ||
| .\" Copyright © 2019 Keith Packard <keithp@keithp.com> | ||
| .\" | ||
| .\" This program is free software; you can redistribute it and/or modify | ||
| .\" it under the terms of the GNU General Public License as published by | ||
| .\" the Free Software Foundation, either version 3 of the License, or | ||
| .\" (at your option) any later version. | ||
| .\" | ||
| .\" This program is distributed in the hope that it will be useful, but | ||
| .\" WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| .\" General Public License for more details. | ||
| .\" | ||
| .TH SNEK-ITSYBITSY-INSTALL 1 "snek-itsybitsy-install" "" | ||
| .SH NAME | ||
| snek-itsybitsy-install \- Install Snek to Adafruit ItsyBitsy board | ||
| .SH SYNOPSIS | ||
| .B "snek-itsybitsy-install" [OPTION]... [COMMAND] | ||
| .SH DESCRIPTION | ||
| .I snek-itsybitsy-install | ||
| installs the Snek programming language on an Adafruit ItsyBitsy board | ||
| with an ATmega32u4. | ||
| .SH OPTIONS | ||
| .TP | ||
| \-isp <ISP model> | ||
| Specifies the programmer to use, common options are 'usbtiny' | ||
| and 'avrisp2'. The default is 'usbtiny'. | ||
| .TP | ||
| \-hex <snek.hex> | ||
| Specifies the hex file to load to the board. The default is the | ||
| currently installed version of Snek. | ||
| .TP | ||
| \-3v | ||
| Use the 3v binary instead of the default 5v binary. | ||
| .SH COMMANDS | ||
| .TP | ||
| fuseload | ||
| Sets the target fuse bits for Snek usage and then loads Snek to the | ||
| device. This is the default command | ||
| .TP | ||
| load | ||
| Loads Snek to the device without first setting the fuse bits. Snek | ||
| will not work correctly if the fuse bits are not set correctly, so | ||
| only do this if the target has already had the fuse bits set correctly. | ||
| .TP | ||
| fuse | ||
| Sets the target fuse bits suitable for Snek usage. You must do this | ||
| before Snek will work on the target device, although you may do it | ||
| before or after loading the Snek system. You only need to do this once | ||
| per board. | ||
| .SH AUTHOR | ||
| Keith Packard |
| @@ -0,0 +1,62 @@ | ||
| #!/bin/sh | ||
|
|
||
| SHAREDIR="@SHAREDIR@" | ||
|
|
||
| SNEKUDUINOBASE="$SHAREDIR/snek-µduino" | ||
| SNEKUDUINOREST="-@SNEK_VERSION@.hex" | ||
| SNEKUDUINO="$SNEKUDUINOBASE""$SNEKUDUINOREST" | ||
|
|
||
| action="fuseload" | ||
|
|
||
| ISP=usbtiny | ||
|
|
||
| mode=arg | ||
|
|
||
| verify="" | ||
|
|
||
| for i in "$@"; do | ||
| case "$mode" in | ||
| arg) | ||
| case "$i" in | ||
| fuse|load|fuseload) | ||
| action="$i" | ||
| ;; | ||
| -isp|--isp) | ||
| mode=isp | ||
| ;; | ||
| -hex|--hex) | ||
| mode=hex | ||
| ;; | ||
| -quick) | ||
| verify="-V" | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 {-isp usbtiny} {-isp avrisp2} {-hex snek-µduino.hex} {fuseload|load|fuse}" 1>&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| ;; | ||
| isp) | ||
| ISP="$i" | ||
| mode=arg | ||
| ;; | ||
| hex) | ||
| SNEKUDUINO="$i" | ||
| mode=arg | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| FUSES="-U lfuse:w:0xff:m -U hfuse:w:0x91:m -U efuse:w:0xfd:m" | ||
|
|
||
| case "$action" in | ||
| fuse) | ||
| avrdude -V -c $ISP -p m32u4 -u $FUSES | ||
| ;; | ||
| fuseload) | ||
| avrdude -V -c $ISP -p m32u4 -u $FUSES && avrdude $verify -c $ISP -p m32u4 -U flash:w:"${SNEKUDUINO}" | ||
| ;; | ||
| load) | ||
| avrdude $verify -c $ISP -p m32u4 -U flash:w:"${SNEKUDUINO}" | ||
| ;; | ||
| esac |
| @@ -0,0 +1,37 @@ | ||
| # | ||
| # Copyright © 2019 Keith Packard <keithp@keithp.com> | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but | ||
| # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # General Public License for more details. | ||
| # | ||
| D0, -2, 0 | ||
| D1, -2, 1 | ||
| D2, -2, 2 | ||
| D3, -2, 3 | ||
| D4, -2, 4 | ||
| D5, -2, 5 | ||
| D6, -2, 6 | ||
| D7, -2, 7 | ||
| D8, -2, 8 | ||
| D9, -2, 9 | ||
| D10, -2, 10 | ||
| D11, -2, 11 | ||
| D12, -2, 12 | ||
| D13, -2, 13 | ||
| A0, -2, 14 | ||
| A1, -2, 15 | ||
| A2, -2, 16 | ||
| A3, -2, 17 | ||
| A4, -2, 18 | ||
| A5, -2, 19 | ||
| #include <ao.h> | ||
| #include <snek-avr.h> | ||
| #define SNEK_POOL 1088 | ||
| #define SNEK_MAX_TOKEN 63 |
0 comments on commit
139efe5