├── COPYING ├── Makefile ├── NEWS ├── README.md ├── configs ├── addconfig-64k ├── config-arm2iec1 ├── config-cbmSDmini ├── config-example ├── config-larsp ├── config-mbed ├── config-petSD ├── config-petSD+ ├── config-sw1 ├── config-sw2 ├── config-uIEC └── config-uIEC3 ├── doc ├── actionreplay.txt ├── buffers.txt ├── dreamload.txt ├── eload.txt ├── epyxfastload.txt ├── fc3-protocol.txt ├── geos-protocol.txt ├── gijoe.txt ├── mbed-pinout.txt ├── nippon-loader.txt ├── uloadm3.txt └── wheels-protocol.txt ├── lcd-i2c-menu ├── Makefile ├── Makefile.main ├── README.md ├── config ├── config.h ├── encoder.c ├── encoder.h ├── lcd.c ├── lcd.h ├── main.c ├── menu.c ├── menu.h └── timer.c ├── lcd-i2c-pwm-io ├── COPYING ├── Makefile ├── README.md ├── i2c-lcd-pwm-io-config.h ├── main.c ├── usi_twi_slave.c └── usi_twi_slave.h ├── scripts ├── Makefile.main ├── avr │ ├── crcgen-avr.pl │ ├── make-ff.sh │ ├── targets.mk │ └── variables.mk ├── configparser.pl ├── doxygen.conf ├── gcctest.pl ├── last-commit.sh ├── lpc17xx │ ├── crcgen-lpc.pl │ ├── lpc1768.ld │ ├── lpc_checksum.pl │ ├── targets.mk │ └── variables.mk └── src2doxy.pl └── src ├── ata.h ├── avr ├── arch-config.h ├── arch-eeprom.h ├── arch-timer.c ├── arch-timer.h ├── ata.c ├── atn-ack-petsd+.S ├── atn-ack-petsd.S ├── atn-ack-xs1541.S ├── atomic.h ├── avrcompat.h ├── crc.h ├── crc7asm.S ├── fastloader-ll.S ├── lcd.c ├── lcd.h ├── progmem.h ├── readbuttons.inc ├── softi2c.c ├── softrtc.c ├── spi.c ├── spi.h ├── system.c ├── timerint.S ├── uart.c └── uartint.S ├── buffers.c ├── buffers.h ├── bus.h ├── config.h ├── d64ops.c ├── d64ops.h ├── diagnose.c ├── diagnose.h ├── dirent.h ├── diskchange.c ├── diskchange.h ├── diskio.c ├── diskio.h ├── display.c ├── display.h ├── doscmd.c ├── doscmd.h ├── ds1307-3231.c ├── ds1307-3231.h ├── eefs-ops.c ├── eefs-ops.h ├── eeprom-conf.c ├── eeprom-conf.h ├── eeprom-fs.c ├── eeprom-fs.h ├── enc28j60.c ├── enc28j60.h ├── errormsg.c ├── errormsg.h ├── fastloader-ll.h ├── fastloader.c ├── fastloader.h ├── fatops.c ├── fatops.h ├── ff.c ├── ff.h ├── fileops.c ├── fileops.h ├── filesystem.h ├── fl-ar6.c ├── fl-dolphin.c ├── fl-dreamload.c ├── fl-eload.c ├── fl-epyxcart.c ├── fl-fc3exos.c ├── fl-geos.c ├── fl-gijoe.c ├── fl-mmzak.c ├── fl-n0sdos.c ├── fl-nippon.c ├── fl-samsjourney.c ├── fl-turbodisk.c ├── fl-ulm3.c ├── flags.h ├── i2c.h ├── iec-bus.h ├── iec.c ├── iec.h ├── ieee.c ├── ieee.h ├── integer.h ├── led.c ├── led.h ├── lpc17xx ├── arch-config.h ├── arch-eeprom.c ├── arch-eeprom.h ├── arch-timer.c ├── arch-timer.h ├── atomic.h ├── bootinfo.S ├── crc.S ├── crc.h ├── i2c_lpc17xx.c ├── iec-bus.c ├── llfl-ar6.c ├── llfl-common.c ├── llfl-common.h ├── llfl-dreamload.c ├── llfl-epyxcart.c ├── llfl-fc3exos.c ├── llfl-geos.c ├── llfl-jiffydos.c ├── llfl-n0sdos.c ├── llfl-parallel.c ├── llfl-turbodisk.c ├── llfl-ulm3.c ├── printf.c ├── progmem.h ├── pseudoboot.S ├── rtc_lpc17xx.c ├── spi.c ├── spi.h ├── startup.S ├── system.c └── uart.c ├── main.c ├── menu.c ├── menu.h ├── p00cache.c ├── p00cache.h ├── parser.c ├── parser.h ├── pcf8583.c ├── pcf8583.h ├── rtc.c ├── rtc.h ├── rtc_lpc17xx.h ├── sdcard.c ├── sdcard.h ├── softrtc.h ├── system.h ├── time.h ├── timer.c ├── timer.h ├── uart.h ├── ustring.h ├── utils.c ├── utils.h └── wrapops.h /Makefile: -------------------------------------------------------------------------------- 1 | # Hey Emacs, this is a -*- makefile -*- 2 | 3 | ifndef CONFIG 4 | CONFIG = config 5 | endif 6 | 7 | CONFDATA := $(shell perl scripts/configparser.pl --confdata $(CONFIG)) 8 | CONFIGSUFFIX := $(word 1,$(CONFDATA)) 9 | OBJDIR := obj-$(CONFIGSUFFIX) 10 | CONFFILES := $(wordlist 2,99,$(CONFDATA)) 11 | 12 | export CONFIGSUFFIX CONFIG OBJDIR 13 | 14 | # Enable verbose compilation with "make V=1" 15 | ifdef V 16 | Q := 17 | E := @: 18 | else 19 | Q := @ 20 | E := @echo 21 | endif 22 | 23 | all: $(OBJDIR) $(OBJDIR)/make.inc 24 | $(Q)$(MAKE) --no-print-directory -f scripts/Makefile.main 25 | 26 | $(OBJDIR)/make.inc: $(CONFFILES) | $(OBJDIR) 27 | $(E) " CONFIG $(CONFFILES)" 28 | $(Q)perl scripts/configparser.pl --genfiles --makeinc $(OBJDIR)/make.inc --header $(OBJDIR)/autoconf.h $(CONFIG) 29 | 30 | $(OBJDIR): 31 | $(E) " MKDIR $(OBJDIR)" 32 | -$(Q)mkdir $(OBJDIR) 33 | 34 | copy clean fuses program delete-eeprom: FORCE | $(OBJDIR) $(OBJDIR)/make.inc 35 | $(Q)$(MAKE) --no-print-directory -f scripts/Makefile.main $@ 36 | 37 | FORCE: ; 38 | -------------------------------------------------------------------------------- /configs/addconfig-64k: -------------------------------------------------------------------------------- 1 | # This is not actually a -*- makefile -*- but it looks nicer 2 | # if it uses the same syntax-highlighting ;) 3 | # 4 | # configuration addon for atmega644 chips with a few features disabled 5 | 6 | CONFIG_MCU=atmega644p 7 | CONFIG_REMOTE_DISPLAY=n 8 | CONFIG_P00CACHE=n 9 | NAME_OVERRIDE=mini 10 | CONFIG_HAVE_EEPROMFS=n 11 | -------------------------------------------------------------------------------- /configs/config-arm2iec1: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-arm2iec: NODISKEMU configuration for arm2iec V1.x boards 26 | # 27 | # 28 | # This file is included in the main NODISKEMU Makefile and also parsed 29 | # into autoconf.h. 30 | 31 | CONFIG_ARCH=lpc17xx 32 | CONFIG_MCU=lpc1768 33 | CONFIG_MCU_FREQ=100000000 34 | CONFIG_BOOTLOADER=y 35 | CONFIG_BOOT_DEVID=0x31693261 36 | CONFIG_UART_DEBUG=y 37 | CONFIG_UART_BAUDRATE=115200 38 | CONFIG_UART_TX_BUF_SHIFT=8 39 | CONFIG_COMMAND_CHANNEL_DUMP=y 40 | CONFIG_LOADER_TURBODISK=y 41 | CONFIG_LOADER_FC3=y 42 | CONFIG_LOADER_DREAMLOAD=y 43 | CONFIG_LOADER_ULOAD3=y 44 | CONFIG_LOADER_GIJOE=y 45 | CONFIG_LOADER_EPYXCART=y 46 | CONFIG_LOADER_GEOS=y 47 | CONFIG_LOADER_WHEELS=y 48 | CONFIG_LOADER_NIPPON=y 49 | CONFIG_LOADER_AR6=y 50 | CONFIG_LOADER_ELOAD1=y 51 | CONFIG_HARDWARE_VARIANT=101 52 | CONFIG_HARDWARE_NAME=NODISKEMU-a2i1 53 | CONFIG_SD_AUTO_RETRIES=10 54 | CONFIG_SD_DATACRC=y 55 | CONFIG_SD_BLOCKTRANSFER=y 56 | CONFIG_ERROR_BUFFER_SIZE=100 57 | CONFIG_COMMAND_BUFFER_SIZE=250 58 | CONFIG_BUFFER_COUNT=15 59 | CONFIG_MAX_PARTITIONS=4 60 | CONFIG_RTC_LPC17XX=y 61 | CONFIG_RTC_PCF8583=y 62 | CONFIG_RTC_DSRTC=y 63 | #CONFIG_REMOTE_DISPLAY=y 64 | CONFIG_DISPLAY_BUFFER_SIZE=80 65 | CONFIG_HAVE_IEC=y 66 | CONFIG_P00CACHE=y 67 | CONFIG_P00CACHE_SIZE=32768 68 | CONFIG_PARALLEL_DOLPHIN=y 69 | CONFIG_HAVE_EEPROMFS=y 70 | -------------------------------------------------------------------------------- /configs/config-cbmSDmini: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-cbmSD-mini: NODISKEMU configuration for Steve Grey's cbmSD mini 26 | # 27 | # 28 | # This file is included in the main NODISKEMU Makefile and also parsed 29 | # into autoconf.h. 30 | 31 | CONFIG_ARCH=avr 32 | CONFIG_HARDWARE_NAME=cbmSD-mini 33 | CONFIG_HARDWARE_VARIANT=10 34 | CONFIG_MCU=atmega1284p 35 | CONFIG_LINKER_RELAX=y 36 | # The cbmSD mini runs at 8 MHz in IEC mode and 16 MHz in IEEE-488 mode 37 | # We set 8 MHz here to get the timings right for the IEC code 38 | CONFIG_MCU_FREQ=8000000 39 | CONFIG_BOOTLOADER=y 40 | CONFIG_BOOT_DEVID=0x44536243 41 | # UART TxD shares the port pin with the busy LED, so you'd usually 42 | # prefer to disable debug output 43 | CONFIG_UART_DEBUG=n 44 | # This baud rate setting is ignored. The actual values for the cbmSD mini 45 | # are set in src/avr/uart.c. 0xdeadbeef disables the computation of 46 | # values for the UBBR registers. 47 | CONFIG_UART_BAUDRATE=0xdeadbeef 48 | CONFIG_UART_BUF_SHIFT=8 49 | CONFIG_COMMAND_CHANNEL_DUMP=y 50 | CONFIG_SD_AUTO_RETRIES=10 51 | CONFIG_SD_DATACRC=y 52 | CONFIG_ERROR_BUFFER_SIZE=100 53 | CONFIG_COMMAND_BUFFER_SIZE=120 54 | CONFIG_BUFFER_COUNT=32 55 | CONFIG_MAX_PARTITIONS=2 56 | CONFIG_RTC_PCF8583=n 57 | CONFIG_RTC_DSRTC=n 58 | CONFIG_HAVE_IEEE=y 59 | CONFIG_HAVE_IEC=y 60 | CONFIG_LOADER_TURBODISK=y 61 | CONFIG_LOADER_FC3=y 62 | CONFIG_LOADER_DREAMLOAD=y 63 | CONFIG_LOADER_ULOAD3=y 64 | CONFIG_LOADER_GIJOE=y 65 | CONFIG_LOADER_EPYXCART=y 66 | CONFIG_LOADER_GEOS=y 67 | CONFIG_LOADER_WHEELS=y 68 | CONFIG_LOADER_NIPPON=y 69 | CONFIG_LOADER_AR6=y 70 | CONFIG_LOADER_ELOAD1=y 71 | # A remote LCD with dedicated controller is not supported because 72 | # the cbmSD mini lacks an interrupt port pin for it 73 | CONFIG_REMOTE_DISPLAY=n 74 | CONFIG_ONBOARD_DISPLAY=y 75 | CONFIG_P00CACHE=y 76 | CONFIG_P00CACHE_SIZE=4000 77 | CONFIG_HAVE_EEPROMFS=y 78 | # 2048 words boot section, Brown-out detection level at Vcc=4.3V 79 | CONFIG_EFUSE=0xFC 80 | CONFIG_HFUSE=0xD2 81 | CONFIG_LFUSE=0xF7 82 | # This device uses some signal lines either for buttons to control 83 | # a menu system or to set the device address by jumpers: 84 | CONFIG_HW_ADDR_OR_BUTTONS=y 85 | CONFIG_IGNORE_CARD_DETECT=y 86 | -------------------------------------------------------------------------------- /configs/config-larsp: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-larsp: NODISKEMU configuration for Lars Pontoppidan's MMC2IEC 26 | # 27 | # 28 | # This file is included in the main NODISKEMU Makefile and also parsed 29 | # into autoconf.h. 30 | 31 | CONFIG_ARCH=avr 32 | CONFIG_MCU=atmega1284p 33 | CONFIG_LINKER_RELAX=y 34 | CONFIG_MCU_FREQ=8000000 35 | CONFIG_BOOTLOADER=y 36 | CONFIG_BOOT_DEVID=0x5053524c 37 | CONFIG_COMMAND_CHANNEL_DUMP=y 38 | # In case someone added a crystal to his board 39 | CONFIG_LOADER_TURBODISK=y 40 | CONFIG_LOADER_FC3=y 41 | CONFIG_LOADER_DREAMLOAD=y 42 | CONFIG_LOADER_ULOAD3=y 43 | CONFIG_LOADER_GIJOE=y 44 | CONFIG_LOADER_EPYXCART=y 45 | CONFIG_LOADER_GEOS=y 46 | CONFIG_LOADER_WHEELS=y 47 | CONFIG_LOADER_NIPPON=y 48 | CONFIG_LOADER_AR6=y 49 | CONFIG_LOADER_ELOAD1=y 50 | CONFIG_HARDWARE_VARIANT=3 51 | CONFIG_HARDWARE_NAME=mmc2iec 52 | CONFIG_SD_AUTO_RETRIES=10 53 | CONFIG_SD_DATACRC=y 54 | CONFIG_ERROR_BUFFER_SIZE=100 55 | CONFIG_COMMAND_BUFFER_SIZE=120 56 | CONFIG_BUFFER_COUNT=6 57 | CONFIG_MAX_PARTITIONS=2 58 | CONFIG_RTC_PCF8583=y 59 | CONFIG_RTC_DSRTC=y 60 | CONFIG_REMOTE_DISPLAY=y 61 | CONFIG_DISPLAY_BUFFER_SIZE=40 62 | CONFIG_HAVE_IEC=y 63 | CONFIG_P00CACHE=y 64 | CONFIG_P00CACHE_SIZE=12000 65 | CONFIG_HAVE_EEPROMFS=y 66 | -------------------------------------------------------------------------------- /configs/config-mbed: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-mbed: EXPERIMENTAL NODISKEMU configuration 26 | # for mbed LPC1768 modules (needs external stuff!) 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=lpc17xx 33 | CONFIG_MCU=lpc1768 34 | CONFIG_MCU_FREQ=100000000 35 | CONFIG_UART_DEBUG=y 36 | CONFIG_UART_BAUDRATE=115200 37 | CONFIG_UART_TX_BUF_SHIFT=8 38 | CONFIG_COMMAND_CHANNEL_DUMP=y 39 | CONFIG_LOADER_TURBODISK=y 40 | CONFIG_LOADER_FC3=y 41 | CONFIG_LOADER_DREAMLOAD=y 42 | CONFIG_LOADER_ULOAD3=y 43 | CONFIG_LOADER_GIJOE=y 44 | CONFIG_LOADER_EPYXCART=y 45 | CONFIG_LOADER_GEOS=y 46 | CONFIG_LOADER_WHEELS=y 47 | CONFIG_LOADER_NIPPON=y 48 | CONFIG_LOADER_AR6=y 49 | CONFIG_LOADER_ELOAD1=y 50 | CONFIG_HARDWARE_VARIANT=100 51 | CONFIG_HARDWARE_NAME=NODISKEMU-mbed 52 | CONFIG_SD_AUTO_RETRIES=10 53 | CONFIG_SD_DATACRC=y 54 | CONFIG_SD_BLOCKTRANSFER=y 55 | CONFIG_ERROR_BUFFER_SIZE=100 56 | CONFIG_COMMAND_BUFFER_SIZE=250 57 | CONFIG_BUFFER_COUNT=15 58 | CONFIG_MAX_PARTITIONS=4 59 | CONFIG_RTC_LPC178x=y 60 | CONFIG_REMOTE_DISPLAY=y 61 | CONFIG_DISPLAY_BUFFER_SIZE=80 62 | CONFIG_HAVE_IEC=y 63 | -------------------------------------------------------------------------------- /configs/config-petSD: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-petSD: NODISKEMU configuration for Nils Eilers' petSD 26 | # and Dave Curran's pet microSD 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=avr 33 | CONFIG_HARDWARE_NAME=petSD 34 | CONFIG_HARDWARE_VARIANT=8 35 | CONFIG_MCU=atmega1284p 36 | CONFIG_LINKER_RELAX=y 37 | CONFIG_MCU_FREQ=18432000 38 | CONFIG_BOOTLOADER=y 39 | CONFIG_BOOT_DEVID=0x44537470 40 | CONFIG_UART_DEBUG=n 41 | CONFIG_UART_BAUDRATE=115200 42 | CONFIG_UART_BUF_SHIFT=8 43 | CONFIG_COMMAND_CHANNEL_DUMP=y 44 | CONFIG_SD_AUTO_RETRIES=10 45 | CONFIG_SD_DATACRC=y 46 | CONFIG_ERROR_BUFFER_SIZE=100 47 | CONFIG_COMMAND_BUFFER_SIZE=120 48 | CONFIG_BUFFER_COUNT=15 49 | CONFIG_MAX_PARTITIONS=2 50 | CONFIG_RTC_PCF8583=y 51 | CONFIG_RTC_DSRTC=y 52 | CONFIG_HAVE_IEEE=y 53 | CONFIG_REMOTE_DISPLAY=y 54 | CONFIG_DISPLAY_BUFFER_SIZE=40 55 | CONFIG_P00CACHE=y 56 | CONFIG_P00CACHE_SIZE=9000 57 | CONFIG_HAVE_EEPROMFS=y 58 | CONFIG_EFUSE=0xFC 59 | CONFIG_HFUSE=0xD2 60 | CONFIG_LFUSE=0xF7 61 | CONFIG_IGNORE_CARD_DETECT=n 62 | -------------------------------------------------------------------------------- /configs/config-petSD+: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-petSD+: NODISKEMU configuration for Nils Eilers' petSD+ 26 | # 27 | # 28 | # This file is included in the main NODISKEMU Makefile and also parsed 29 | # into autoconf.h. 30 | 31 | CONFIG_ARCH=avr 32 | CONFIG_HARDWARE_NAME=petSD+ 33 | CONFIG_HARDWARE_VARIANT=9 34 | CONFIG_MCU=atmega1284p 35 | CONFIG_LINKER_RELAX=y 36 | # The petSD+ runs at 8 MHz in IEC mode and 16 MHz in IEEE-488 mode 37 | # We set 8 MHz here to get the timings right for the IEC code 38 | CONFIG_MCU_FREQ=8000000 39 | CONFIG_BOOTLOADER=y 40 | CONFIG_BOOT_DEVID=0x2b445370 41 | # UART TxD shares the port pin with the busy LED, so you'd usually 42 | # prefer to disable debug output 43 | CONFIG_UART_DEBUG=n 44 | # This baud rate setting is ignored. The actual values for the petSD+ 45 | # are set in src/avr/uart.c. 0xdeadbeef disables the computation of 46 | # values for the UBBR registers. 47 | CONFIG_UART_BAUDRATE=0xdeadbeef 48 | CONFIG_UART_BUF_SHIFT=8 49 | CONFIG_COMMAND_CHANNEL_DUMP=y 50 | CONFIG_SD_AUTO_RETRIES=10 51 | CONFIG_SD_DATACRC=y 52 | CONFIG_ERROR_BUFFER_SIZE=100 53 | CONFIG_COMMAND_BUFFER_SIZE=120 54 | CONFIG_BUFFER_COUNT=32 55 | CONFIG_MAX_PARTITIONS=2 56 | CONFIG_RTC_PCF8583=y 57 | CONFIG_RTC_DSRTC=y 58 | CONFIG_HAVE_IEEE=y 59 | CONFIG_HAVE_IEC=y 60 | CONFIG_LOADER_TURBODISK=y 61 | CONFIG_LOADER_FC3=y 62 | CONFIG_LOADER_DREAMLOAD=y 63 | CONFIG_LOADER_ULOAD3=y 64 | CONFIG_LOADER_GIJOE=y 65 | CONFIG_LOADER_EPYXCART=y 66 | CONFIG_LOADER_GEOS=y 67 | CONFIG_LOADER_WHEELS=y 68 | CONFIG_LOADER_NIPPON=y 69 | CONFIG_LOADER_AR6=y 70 | CONFIG_LOADER_ELOAD1=y 71 | # A remote LCD with dedicated controller is not supported because 72 | # the petSD+ lacks an interrupt port pin for it 73 | CONFIG_REMOTE_DISPLAY=n 74 | CONFIG_ONBOARD_DISPLAY=y 75 | CONFIG_P00CACHE=y 76 | CONFIG_P00CACHE_SIZE=4000 77 | CONFIG_HAVE_EEPROMFS=y 78 | # 2048 words boot section, Brown-out detection level at Vcc=4.3V 79 | CONFIG_EFUSE=0xFC 80 | CONFIG_HFUSE=0xD2 81 | CONFIG_LFUSE=0xF7 82 | # This device uses some signal lines either for buttons to control 83 | # a menu system or to set the device address by jumpers: 84 | CONFIG_HW_ADDR_OR_BUTTONS=y 85 | CONFIG_IGNORE_CARD_DETECT=n 86 | -------------------------------------------------------------------------------- /configs/config-sw1: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-sw1: NODISKEMU configuration for Shadowolf's MMC2IEC PCBs 26 | # version 1.0-1.9 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=avr 33 | CONFIG_MCU=atmega1284p 34 | CONFIG_LINKER_RELAX=y 35 | CONFIG_MCU_FREQ=8000000 36 | CONFIG_BOOTLOADER=y 37 | CONFIG_BOOT_DEVID=0x49454321 38 | CONFIG_UART_DEBUG=n 39 | CONFIG_COMMAND_CHANNEL_DUMP=n 40 | # Turbodisk requires a crystal which is usually only present on 1.8 or later 41 | CONFIG_LOADER_TURBODISK=y 42 | CONFIG_LOADER_FC3=y 43 | CONFIG_LOADER_DREAMLOAD=y 44 | CONFIG_LOADER_ULOAD3=y 45 | CONFIG_LOADER_GIJOE=y 46 | CONFIG_LOADER_EPYXCART=y 47 | CONFIG_LOADER_GEOS=y 48 | CONFIG_LOADER_WHEELS=y 49 | CONFIG_LOADER_NIPPON=y 50 | CONFIG_LOADER_AR6=y 51 | CONFIG_LOADER_ELOAD1=y 52 | CONFIG_HARDWARE_VARIANT=2 53 | CONFIG_HARDWARE_NAME=sd2iec-sw1 54 | CONFIG_SD_AUTO_RETRIES=10 55 | CONFIG_SD_DATACRC=y 56 | CONFIG_ERROR_BUFFER_SIZE=100 57 | CONFIG_COMMAND_BUFFER_SIZE=120 58 | CONFIG_BUFFER_COUNT=6 59 | CONFIG_MAX_PARTITIONS=2 60 | CONFIG_HAVE_IEC=y 61 | CONFIG_P00CACHE=y 62 | CONFIG_P00CACHE_SIZE=12000 63 | CONFIG_HAVE_EEPROMFS=y 64 | -------------------------------------------------------------------------------- /configs/config-sw2: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config-sw2: NODISKEMU configuration for Shadowolf's sd2iec PCBs 26 | # version 1.x 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=avr 33 | CONFIG_MCU=atmega1284p 34 | CONFIG_LINKER_RELAX=y 35 | CONFIG_MCU_FREQ=8000000 36 | CONFIG_BOOTLOADER=y 37 | CONFIG_BOOT_DEVID=0x31434549 38 | CONFIG_COMMAND_CHANNEL_DUMP=y 39 | CONFIG_LOADER_TURBODISK=y 40 | CONFIG_LOADER_FC3=y 41 | CONFIG_LOADER_DREAMLOAD=y 42 | CONFIG_LOADER_ULOAD3=y 43 | CONFIG_LOADER_GIJOE=y 44 | CONFIG_LOADER_EPYXCART=y 45 | CONFIG_LOADER_GEOS=y 46 | CONFIG_LOADER_WHEELS=y 47 | CONFIG_LOADER_NIPPON=y 48 | CONFIG_LOADER_AR6=y 49 | CONFIG_LOADER_ELOAD1=y 50 | CONFIG_HARDWARE_VARIANT=5 51 | CONFIG_HARDWARE_NAME=sd2iec-sw2 52 | CONFIG_SD_AUTO_RETRIES=10 53 | CONFIG_SD_DATACRC=y 54 | CONFIG_ERROR_BUFFER_SIZE=100 55 | CONFIG_COMMAND_BUFFER_SIZE=120 56 | CONFIG_BUFFER_COUNT=6 57 | CONFIG_MAX_PARTITIONS=4 58 | CONFIG_RTC_PCF8583=y 59 | CONFIG_RTC_DSRTC=y 60 | CONFIG_REMOTE_DISPLAY=y 61 | CONFIG_DISPLAY_BUFFER_SIZE=40 62 | CONFIG_HAVE_IEC=y 63 | CONFIG_P00CACHE=y 64 | CONFIG_P00CACHE_SIZE=12000 65 | CONFIG_HAVE_EEPROMFS=y 66 | -------------------------------------------------------------------------------- /configs/config-uIEC: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config: User-configurable options to simplify hardware changes and/or 26 | # reduce the code/ram requirements of the code. 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=avr 33 | CONFIG_MCU=atmega1281 34 | CONFIG_LINKER_RELAX=y 35 | CONFIG_MCU_FREQ=8000000 36 | CONFIG_BOOTLOADER=y 37 | CONFIG_BOOT_DEVID=0x32304955 38 | CONFIG_UART_DEBUG=y 39 | CONFIG_UART_BAUDRATE=38400 40 | CONFIG_UART_BUF_SHIFT=6 41 | CONFIG_DEADLOCK_ME_HARDER=n 42 | CONFIG_COMMAND_CHANNEL_DUMP=y 43 | CONFIG_LOADER_TURBODISK=y 44 | CONFIG_LOADER_FC3=y 45 | CONFIG_LOADER_DREAMLOAD=y 46 | CONFIG_LOADER_ULOAD3=y 47 | CONFIG_LOADER_GIJOE=y 48 | CONFIG_LOADER_EPYXCART=y 49 | CONFIG_LOADER_GEOS=y 50 | CONFIG_LOADER_WHEELS=y 51 | CONFIG_LOADER_NIPPON=y 52 | CONFIG_LOADER_AR6=y 53 | CONFIG_LOADER_ELOAD1=y 54 | CONFIG_HARDWARE_VARIANT=4 55 | CONFIG_HARDWARE_NAME=uIEC 56 | CONFIG_SD_AUTO_RETRIES=10 57 | CONFIG_SD_DATACRC=y 58 | CONFIG_ERROR_BUFFER_SIZE=100 59 | CONFIG_COMMAND_BUFFER_SIZE=254 60 | CONFIG_BUFFER_COUNT=15 61 | CONFIG_MAX_PARTITIONS=20 62 | CONFIG_RTC_SOFTWARE=y 63 | CONFIG_ADD_ATA=1 64 | CONFIG_REMOTE_DISPLAY=y 65 | CONFIG_DISPLAY_BUFFER_SIZE=40 66 | CONFIG_HAVE_IEC=y 67 | CONFIG_HAVE_EEPROMFS=y 68 | -------------------------------------------------------------------------------- /configs/config-uIEC3: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2018 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config: User-configurable options to simplify hardware changes and/or 26 | # reduce the code/ram requirements of the code. 27 | # 28 | # 29 | # This file is included in the main NODISKEMU Makefile and also parsed 30 | # into autoconf.h. 31 | 32 | CONFIG_ARCH=avr 33 | CONFIG_MCU=atmega1281 34 | CONFIG_LINKER_RELAX=y 35 | CONFIG_MCU_FREQ=8000000 36 | CONFIG_BOOTLOADER=y 37 | CONFIG_BOOT_DEVID=0x33304955 38 | CONFIG_UART_DEBUG=y 39 | CONFIG_UART_BAUDRATE=38400 40 | CONFIG_UART_BUF_SHIFT=6 41 | CONFIG_DEADLOCK_ME_HARDER=n 42 | CONFIG_COMMAND_CHANNEL_DUMP=y 43 | CONFIG_LOADER_TURBODISK=y 44 | CONFIG_LOADER_FC3=y 45 | CONFIG_LOADER_DREAMLOAD=y 46 | CONFIG_LOADER_ULOAD3=y 47 | CONFIG_LOADER_GIJOE=y 48 | CONFIG_LOADER_EPYXCART=y 49 | CONFIG_LOADER_GEOS=y 50 | CONFIG_LOADER_WHEELS=y 51 | CONFIG_LOADER_NIPPON=y 52 | CONFIG_LOADER_AR6=y 53 | CONFIG_LOADER_ELOAD1=y 54 | CONFIG_HARDWARE_VARIANT=7 55 | CONFIG_HARDWARE_NAME=uIEC 56 | CONFIG_TWINSD=n 57 | CONFIG_SD_AUTO_RETRIES=10 58 | CONFIG_SD_DATACRC=y 59 | CONFIG_ERROR_BUFFER_SIZE=100 60 | CONFIG_COMMAND_BUFFER_SIZE=254 61 | CONFIG_BUFFER_COUNT=15 62 | CONFIG_MAX_PARTITIONS=20 63 | CONFIG_RTC_SOFTWARE=y 64 | CONFIG_HAVE_IEC=y 65 | CONFIG_HAVE_EEPROMFS=y 66 | -------------------------------------------------------------------------------- /doc/actionreplay.txt: -------------------------------------------------------------------------------- 1 | Action Replay fast loader/saver protocols 2 | ========================================= 3 | 4 | Documented by Ingo Korb 5 | 6 | Note 1: This document is currently incomplete, many of the loaders 7 | supported by the AR6 are missing. 8 | 9 | Note 2: The contents of this document have been tested only on a PAL 10 | system, because the author currently has no NTSC Action Replay 11 | cartridge. 12 | 13 | Note 3: An Action Replay 6 cartridge has been used as reference, other 14 | versions may or may not use different fast loaders. 15 | 16 | 1541 fastloader 17 | --------------- 18 | The default 1541 fast loader is a track loader that does the file name 19 | matching on the C64 instead of the drive. It has not been further 20 | analyzed due to this limitation. 21 | 22 | 1581 fastloader 23 | --------------- 24 | The 1581 fastloader opens the target file on secondary address 0 to 25 | read the start address. When the loader is uploaded, it will pull the 26 | clock line low and the data line high to signal that it's currently 27 | busy processing. It is recommended to add a short delay (one 28 | millisecond is sufficient) at this point because the C64 will miss the 29 | drive becoming ready if the time between M-E and the first byte 30 | transmission is too short. 31 | 32 | Bytes are transmitted according to this timing, synchronized by the 33 | low-to-high transision of the data line initated by the C64: 34 | 35 | Time Clock Data 36 | ---------------- 37 | 0us 1 0->1 (timing reference) 38 | 5us b0 b1 39 | 13us b2 b3 40 | 21us b4 b5 41 | 29us b6 b7 42 | 37.5us 0 1 43 | ~47us 0 1 (bus settle delay) 44 | 45 | Each sector of the file is transferred by sending the number of valid 46 | bytes in the current sector (i.e. 254 for a full sector or the second 47 | byte minus one for the last one on a D64-style disk) followed by the 48 | data bytes of the sector in forward order. 49 | 50 | After transmitting the last sector a single byte with value 0 is sent 51 | to the computer to mark the end of the transmission. There is no way 52 | to signal read errors to the computer. The computer will send a 53 | command to close the file itself. 54 | 55 | Note: The final bus settle delay doesn't need to be explicit if your 56 | CPU is slow enough, but a fast processor might see its own data high 57 | as start condition because of the slow rise times of the 58 | open-collector serial bus. 59 | 60 | 1581 fastsaver 61 | -------------- 62 | Note: This fastsaver is known to use different timing on PAL and NTSC. 63 | 64 | The 1581 fastsaver opens the target file on secondary address 1 for 65 | writing. When the loader is uploaded, it will pull the clock line low 66 | and the data line high. The original code waits approximately 800 67 | microseonds at this point. 68 | 69 | For every sector of the file (254 bytes of data), 256(!) bytes are 70 | received in forward order. The first two bytes of this data block are 71 | not part of file contents. If the first byte is non-zero, more sectors 72 | will follow. If the first byte is zero, the second byte is the offset 73 | in the received data buffer (including the two initial bytes) of the 74 | first byte that is not part of the file anymore (0 if everything is 75 | part of the file). 76 | 77 | The timing for receiving a single byte in the PAL version is: 78 | 79 | Time Clock Data 80 | ---------------- 81 | setup 1 1 (set lines high on the drive side) 82 | 0us 1 0->1 (wait for change, not level! - timing reference) 83 | 12us !b7 !b5 84 | 22us !b6 !b4 85 | 38us !b3 !b1 86 | 48us !b2 !b0 87 | 53us 0 1 (set by drive) 88 | 89 | -------------------------------------------------------------------------------- /doc/buffers.txt: -------------------------------------------------------------------------------- 1 | Notes on buffer_t and its use 2 | ----------------------------- 3 | 4 | buffer_t is the struct holding all information for the dynamically allocated 5 | buffers in NODISKEMU. Usually they are associated with a secondary address, 6 | but they can also be used for internal purposes, e.g. to read the file 7 | names in a swaplist or to store the BAM of a mounted disk image. 8 | 9 | If you allocate a temporary buffer or do an early return from a function 10 | that has allocated a buffer for some purpose you do not need to do 11 | anything - every buffer returned from alloc_buffer or alloc_system_buffer 12 | is maked as "not sticky" which means that it will get freed without calling 13 | the cleanup function at the end of the IEC mainloop. 14 | 15 | If you do need a buffer that should stay around for longer than that 16 | (e.g. for a buffer associated with a file), call stick_buffer(buffer_t *) 17 | on it. After doing this you need to make sure that free_buffer(buffer_t *) 18 | is called on the buffer when it isn't needed anymore. 19 | 20 | Another independent distinction in buffer types is system buffers vs. 21 | user buffers. alloc_system_buffer will return a buffer with the secondary 22 | field set to BUFFER_SEC_SYSTEM while alloc_buffer returns a buffer 23 | with the secondary field set to 0. This difference is used when updating 24 | the device LEDs - the number of allocated user buffers is tracked in 25 | active_buffers and the BUSY LED will be turned on by alloc_buffer 26 | and off by free_buffer as long as at least one user buffer is allocated. 27 | Similiar to that the DIRTY LED is controlled by mark_write_buffer and 28 | free_buffer - please do not call mark_write_buffer on a system buffer. 29 | 30 | free_multiple_buffers takes a flag parameter which specifies which buffer(s) 31 | should be freed. It is a bit field with the following base values: 32 | - FMB_CLEAN 33 | Call the cleanup callback before freeing the buffer. If this is 34 | specified, the return value of free_multiple_buffers will be 1 if 35 | any of the called cleanup functions returned a non-zero value 36 | or 0 otherwise. 37 | - FMB_FREE_STICKY 38 | Free sticky buffers too (will free only not-sticky buffers otherwise) 39 | - FMB_FREE_SYSTEM 40 | Free system buffers too (will free only non-system buffers otherwise) 41 | 42 | For convenience there are a few macros for common use cases: 43 | - FMB_ALL 44 | free all buffers, no cleanups 45 | - FMB_ALL_CLEAN 46 | free all buffers and call their cleanup functions 47 | - FMB_USER 48 | free all non-system buffers, no cleanups 49 | - FMB_USER_CLEAN 50 | free all non-system buffers and call their cleanup functions 51 | - FMB_UNSTICKY 52 | free all non-sticky buffers, no cleanups 53 | - FMB_UNSTICKY_CLEAN 54 | free all non-sticky buffers and call their cleanup functions 55 | -------------------------------------------------------------------------------- /doc/eload.txt: -------------------------------------------------------------------------------- 1 | ELoad Version 1 Protocol 2 | ======================== 3 | 4 | Eload Version 1 by Thomas Giesel, http://www.skoe.de/easyflash 5 | documented by Ingo Korb, Thomas Giesel 6 | 7 | ELoad Version 1 is based on ULoad Model 3, it uses a very similar protocol. 8 | It is a 2-bit byte-synchronizing fast loader that doesn't use ATN. 9 | 10 | Files are opened using the standard DOS procedure with secondary address 0. 11 | It opens the file and reads the first byte to check if the file exists and 12 | is readable. It does not close the file before starting the fast loader, so 13 | it just starts with the last sector loaded. 14 | 15 | ELoad detects sd2iec or uIEC directly by examining the ID string. 16 | 17 | ELoad has its own "idle loop" that reads a command byte and reacts 18 | accordingly. It aborts when the ATN line is low while waiting for 19 | synchronization in the byte receive or send subroutine. 20 | Version 1 supports "Load a file" only. 21 | 22 | "Idle loop" 23 | ----------- 24 | 1) Receive a byte 25 | 2) If byte is 1, call "Load a file" 26 | 5) Otherwise send a 0xff byte 27 | 6) Go to 1 28 | 29 | Load a file (command code 1) 30 | ---------------------------- 31 | 1) Start with the last file opened 32 | 2) Read sector into buffer (up to 254 data bytes) 33 | If reading failed: Send 0xff, return to Idle loop 34 | If no data left (EOF): Send 0, return to Idle loop 35 | Otherwise: Send number of bytes used in this sector 36 | 3) Send that many data bytes 37 | 4) Go to 2 38 | 39 | 40 | Low level 41 | ========= 42 | 43 | Receiving a byte 44 | ---------------- 45 | 1) set clock low, data high 46 | 2) wait until data is low; if ATN is low return to the standard bus loop 47 | 3) set clock high, data high 48 | 4) wait until data is high 49 | 5) transfer data (see table below) 50 | 6) invert resulting byte 51 | 7) delay for about 20 microseconds to make sure the C64 has returned 52 | the bus to clock high/data high, otherwise the next send/receive 53 | call can fail 54 | 55 | Sampling times for reception: 56 | 57 | Time Clk Data 58 | ------------- 59 | 0us (1) 0->1 (data low -> high transition in step 4 is the timing reference) 60 | 14us b7 b5 61 | 24us b6 b4 62 | 38us b3 b1 63 | 48us b2 b0 64 | 65 | The original transfer code reads the first data sample between 11us and 17us 66 | after the data line transition. 67 | 68 | Sending a byte 69 | -------------- 70 | 1) set clock high, data low 71 | 2) wait until clock is low; if ATN is low return to the standard bus loop 72 | 3) set clock high, data high 73 | 4) wait until clock is high 74 | 5) transfer data (see table below) 75 | 6) set clock high, data high 76 | 77 | Timing for transmission: 78 | 79 | Time Clk Data 80 | ------------- 81 | 0us 0->1 (1) (clock low -> high transition in step 4 is the timing reference) 82 | 14us b0 b1 83 | 22us b2 b3 84 | 30us b4 b5 85 | 38us b6 b7 86 | 48us 1 1 (step 6) 87 | 88 | Note: Bits are sent without inversion, i.e. low for a 0-bit, high for a 1-bit. 89 | 90 | The original transfer code sends the first bit pair between 12us and 15us 91 | after the clock line transition. 92 | -------------------------------------------------------------------------------- /doc/epyxfastload.txt: -------------------------------------------------------------------------------- 1 | Epyx Fast Load Cartridge Protocol 2 | ================================= 3 | 4 | Documented by Ingo Korb 5 | 6 | This document describes the fast loader protocol used by the 7 | Epyx Fast Load cartridge. The cartridge has some other options that also 8 | upload custom drive code, but those are beyond the scope of this file. 9 | 10 | General 11 | ------- 12 | The Epyx Fast Load cartridge (EFL) uses a two-stage upload process. The 13 | first stage is sent using M-E and executes at 0x1a9. This first stage 14 | receives another 256 bytes from the computer and jumpts to that code. 15 | 16 | First stage protocol 17 | -------------------- 18 | The first stage sets data high and clock low and waits until data is low. 19 | It then releases clock and reads 256 bytes using the same protocol as 20 | G.I.Joe (see that document). There are at least two versions of the 21 | second stage, but they are protocol-compatible. Both don't need the 22 | full 256 bytes that are uploaded - only 237/238 bytes are actually 23 | used during execution. XORing the first 237 bytes together yields a 24 | result of 0x91 and 0x5b respectively. 25 | 26 | Second stage protocol 27 | --------------------- 28 | The second stage also uses the same byte reception protocol as the G.I.Joe 29 | loader. It first receives one byte which is the length of the file name 30 | to be read and then receives that many bytes for the file name, starting 31 | with the last character of the name. 32 | 33 | After receiving the file name, clock is pulled low and the file is opened. 34 | If opening fails, set clock high and return to the standard dos idle loop. 35 | 36 | Every sector of the file is transferred in order. First data and clock 37 | are released, then the actual number of bytes following is sent 38 | (byte transfer protocol described below), then the data bytes of 39 | the sector. If another sector is following, pull clock low, read the 40 | data from the storage medium and repeat this process. 41 | 42 | After the last sector is transferred, set clock and data high and 43 | return to the standard dos idle loop. 44 | 45 | Sending a byte 46 | -------------- 47 | To send a byte, set clock and data high, wait until data is low and send 48 | the inverted bits as shown in this table: 49 | 50 | Time Clk Data 51 | ------------- 52 | 0us (1) 0->1 (data low -> high transition is the timing reference) 53 | 10us !b7 !b5 54 | 20us !b6 !b4 55 | 30us !b3 !b1 56 | 40us !b2 !b0 57 | 60us - - 58 | 59 | The final delay is used to ensure that the C64 has time to read bit 2/0. 60 | The original drive code needs about 20-30 cycles to prepare the next 61 | byte for transmission. 62 | -------------------------------------------------------------------------------- /doc/gijoe.txt: -------------------------------------------------------------------------------- 1 | G.I. Joe Loader Protocol 2 | ======================== 3 | 4 | Documented by Ingo Korb 5 | 6 | Said to be the most-ripped IRQ loader, although only three programs using 7 | it have been located yet: 8 | - G.I. Joe 9 | - Crown (cracked by Sharks) 10 | - Cucumber Juice II by Hitmen (switch to IRQ loader mode manually) 11 | 12 | Each of these uploads the drive code with M-W statements of different 13 | length, but all of them send the commands in increasing memory address 14 | order. A CRC-based detection scheme may need to compare the CRC after 15 | every byte instead of every command to trigger reliably. 16 | 17 | The protocol used in this loader is completely synchronous, triggered 18 | by both edges of the CLK line; ATN is unused but may change anyway 19 | in some implementations of the C64 side. 20 | 21 | High Level 22 | ========== 23 | 24 | After the M-E command has been received, set both DATA and CLK high 25 | and disable ATN acknowledge. The original drive code uses a slightly 26 | weird loop to wait until the bus is completely idle at this point, 27 | simply waiting 10 milliseconds and then looping until both DATA and 28 | CLK are high seems to be sufficient. 29 | 30 | Main loop 31 | --------- 32 | 1) Set CLK low 33 | 2) Wait until DATA is low 34 | 3) Set CLK high 35 | 4) Read a byte, discard it 36 | 5) Read two bytes 37 | 6) Set CLK low 38 | 7) Try to open a file whose name starts with the two bytes received in step 5 39 | 8) If not successful, send error and restart main loop 40 | 9) Send file contents 41 | 10) Send 0xac 0xff 42 | 11) (Close file if neccessary) 43 | 12) Restart main loop 44 | 45 | Sending file contents 46 | --------------------- 47 | 1) Send file in blocks of 254 bytes (or less for the last block): 48 | 2) Set CLK high 49 | 3) Send all bytes in file order - if byte is 0xac, send twice 50 | 4) If another block is available to send: 51 | 5) Send 0xac 0xc3 52 | 6) Set CLK low 53 | 5) Send 0xac 0xff as end marker 54 | 6) (Close file if necessary) 55 | 56 | If a read error is encountered while sending the file contents, 57 | send error and return to main loop. 58 | 59 | Sending error 60 | ------------- 61 | 1) Set CLK high 62 | 2) Send 0xfe 0xfe 0xac 0xf7 63 | 3) (Close file if neccessary) 64 | 65 | Low Level 66 | ========= 67 | 68 | Receiving a byte 69 | ---------------- 70 | 1) byte = 0 71 | 2) Repeat 4 times: 72 | 3) Wait until CLK is low 73 | 4) delay ~2-5 microseconds 74 | 5) byte = byte >> 1 75 | 6) Read DATA 76 | 7) If DATA was low in step 6: byte = byte | 0x80 77 | 8) Wait until CLK is high 78 | 9) delay ~2-5 microseconds 79 | 10) byte = byte >> 1 80 | 11) Read DATA 81 | 12) If DATA was low in step 11: byte = byte | 0x80 82 | 83 | Note: The delays in step 4 and 9 are recommended because the C64 sets 84 | both the clock and data line at the same time. A small 85 | difference in propagation time between the two lines can easily 86 | cause data corruption when the delay is too small. 87 | 88 | Sending a byte 89 | -------------- 90 | 1) Repeat 4 times: 91 | 2) Wait until CLK is high 92 | 3) Set data to (byte & 1) 93 | 4) byte = byte >> 1 94 | 5) Wait until CLK is low 95 | 6) Set data to (byte & 1) 96 | 7) byte = byte >> 1 97 | 98 | -------------------------------------------------------------------------------- /doc/mbed-pinout.txt: -------------------------------------------------------------------------------- 1 | Quick notes on using sd2iec with an mbed LPC1768: 2 | - if in any doubt, wait until someone has designed a nice PCB for this 3 | - this information can become obsolete faster than you expect, so 4 | don't complain if you need to rewire your device 5 | - an XPresso LPC1768 should also work, but I haven't tested that 6 | - UART 0 is the debug serial port (USB-connected on mbed) 7 | - an external 24C02 or similiar EEPROM is required for the 8 | configuration settings - steal one from an old DIMM ;) 9 | - an external 3.3V regulator may or may not be required 10 | (I'm using one, but VOUT of the mbed may be sufficient) 11 | - SD card interface: 12 | - p11 DI 13 | - p12 DO 14 | - p13 CLK 15 | - p14 SD card CS 16 | - p17 card detect switch (grounded if card inserted) 17 | - p18 write protect switch (grounded if write protection disabled) 18 | - I2C interface to the EEPROM (and display - untested!) 19 | - p9 SDA 20 | - p10 SCL 21 | - use external 4k7 pullups to 3.3V! 22 | - address selection 23 | - p21 8/9 24 | - p22 8/10 25 | - buttons 26 | - p23 Next 27 | - p24 Previous 28 | - serial bus 29 | - inputs connected via a 74HCT14 (LS is ok too, HC is NOT) 30 | - outputs connected via a 74HCT06 (LS is ok too, HC is NOT) 31 | - inputs: 32 | - p15 ATN 33 | - p30 Clock 34 | - p29 Data 35 | - p16 SRQ 36 | - outputs: 37 | - p6 ATN 38 | - p8 Clock 39 | - p7 Data 40 | - p5 SRQ 41 | -------------------------------------------------------------------------------- /lcd-i2c-menu/Makefile: -------------------------------------------------------------------------------- 1 | # Hey Emacs, this is a -*- makefile -*- 2 | 3 | ifndef CONFIG 4 | CONFIG = config 5 | endif 6 | 7 | CONFDATA := $(shell perl ../scripts/configparser.pl --confdata $(CONFIG)) 8 | CONFIGSUFFIX := $(word 1,$(CONFDATA)) 9 | OBJDIR := obj-$(CONFIGSUFFIX) 10 | CONFFILES := $(wordlist 2,99,$(CONFDATA)) 11 | 12 | export CONFIGSUFFIX CONFIG OBJDIR 13 | 14 | # Enable verbose compilation with "make V=1" 15 | ifdef V 16 | Q := 17 | E := @: 18 | else 19 | Q := @ 20 | E := @echo 21 | endif 22 | 23 | all: $(OBJDIR) $(OBJDIR)/make.inc 24 | $(Q)$(MAKE) --no-print-directory -f Makefile.main 25 | 26 | $(OBJDIR)/make.inc: $(CONFFILES) | $(OBJDIR) 27 | $(E) " CONFIG $(CONFFILES)" 28 | $(Q)perl ../scripts/configparser.pl --genfiles --makeinc $(OBJDIR)/make.inc --header $(OBJDIR)/autoconf.h $(CONFIG) 29 | 30 | $(OBJDIR): 31 | $(E) " MKDIR $(OBJDIR)" 32 | -$(Q)mkdir $(OBJDIR) 33 | 34 | copy clean fuses program delete-eeprom lst: FORCE | $(OBJDIR) $(OBJDIR)/make.inc 35 | $(Q)$(MAKE) --no-print-directory -f Makefile.main $@ 36 | 37 | FORCE: ; 38 | -------------------------------------------------------------------------------- /lcd-i2c-menu/config: -------------------------------------------------------------------------------- 1 | # This may not look like it, but it's a -*- makefile -*- 2 | # 3 | # NODISKEMU - SD/MMC to IEEE-488 interface/controller 4 | # Copyright (C) 2007-2012 Ingo Korb 5 | # 6 | # NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 7 | # 8 | # Inspired by MMC2IEC by Lars Pontoppidan et al. 9 | # 10 | # FAT filesystem access based on code from ChaN, see tff.c|h. 11 | # 12 | # This program is free software; you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation; version 2 of the License only. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | # 25 | # config: User-configurable options to simplify hardware changes and/or 26 | # reduce the code/ram requirements of the code. 27 | # 28 | # This is the config-example file for the display. 29 | # 30 | # 31 | # This file is included in the main Makefile and also parsed 32 | # into autoconf.h. 33 | 34 | # MCU to compile for 35 | CONFIG_MCU=atmega1284p 36 | 37 | # Use the -relax parameter when linking? 38 | # Passing -O9 and -relax to the linker saves a bit of flash, 39 | # but the option is broken in certain binutils versions. 40 | # (known troublemakers: binutils 2.17, 2.18 seems fine) 41 | CONFIG_LINKER_RELAX=n 42 | 43 | # MCU frequency in Hz 44 | CONFIG_MCU_FREQ=8000000 45 | 46 | # Display buffer size 47 | # This buffer is used during reception of I2C messages, 48 | # data that doesn't fit will be silently dropped. 49 | CONFIG_I2C_BUFFER_SIZE=40 50 | 51 | # Maximum number of menu entries 52 | # This is the maximum number of menu entries that can 53 | # be used. Further entries are silently dropped, 54 | # the actual number of menu entries may be lower than this 55 | # limit if there isn't enough free ram to store the text. 56 | CONFIG_MAX_MENU_ENTRIES=250 57 | 58 | # Encoder-type. 1 for half-step encoder, 2 for full-step. 59 | # If the menu scrolls 2 entries per step, set to 2. 60 | # ALPS STEC12E08 for example requires CONFIG_ENCODER_TYPE=2 61 | CONFIG_ENCODER_TYPE=2 62 | 63 | -------------------------------------------------------------------------------- /lcd-i2c-menu/encoder.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2012 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | encoder.c: Encoder and button polling 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include 30 | #include 31 | #include "timer.h" 32 | #include "encoder.h" 33 | 34 | volatile int8_t encoder_position; 35 | volatile uint8_t button_state; 36 | volatile tick_t last_button_change; 37 | 38 | static uint8_t laststate; 39 | static tick_t debounce_timer; 40 | 41 | /* Encoder gets its own on-change ISR, polling would require ~1000Hz */ 42 | ISR(ENCODER_INT_VECT) { 43 | uint8_t curstate; 44 | 45 | curstate = ENCODER_PIN & (ENCODER_A | ENCODER_B); 46 | 47 | // Encoder 48 | if ((laststate & ENCODER_A) ^ (curstate & ENCODER_A)) { 49 | if (!!(curstate & ENCODER_A) == !!(curstate & ENCODER_B)) { 50 | encoder_position--; 51 | } else { 52 | encoder_position++; 53 | } 54 | laststate = curstate; 55 | } 56 | } 57 | 58 | /* Polling is easier for debouncing a button and works fine at 100Hz */ 59 | void encoder_buttonisr(void) { 60 | uint8_t curstate; 61 | 62 | // Button 63 | curstate = !(ENCODER_PIN & ENCODER_BUTTON); 64 | if (curstate != button_state) { 65 | if (last_button_change != debounce_timer) { 66 | if (time_after(ticks,debounce_timer + HZ/20)) { 67 | last_button_change = ticks; 68 | debounce_timer = ticks; 69 | button_state = curstate; 70 | } 71 | } else { 72 | debounce_timer = ticks; 73 | } 74 | } else { 75 | // bounced - reset timer 76 | debounce_timer = last_button_change; 77 | } 78 | } 79 | 80 | void encoder_init(void) { 81 | ENCODER_DDR &= (uint8_t)~(ENCODER_A | ENCODER_B | ENCODER_BUTTON); 82 | ENCODER_PORT |= ENCODER_A | ENCODER_B | ENCODER_BUTTON; 83 | _delay_ms(5); // long wires... 84 | laststate = ENCODER_PIN & (ENCODER_A | ENCODER_B); 85 | 86 | encoder_position = 0; 87 | button_state = !(ENCODER_PIN & ENCODER_BUTTON); 88 | last_button_change = 0; 89 | debounce_timer = 0; 90 | 91 | ENCODER_PCMSK |= ENCODER_A; /* No B! */ 92 | ENCODER_INT_SETUP(); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /lcd-i2c-menu/encoder.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2012 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | encoder.h: Encoder and button polling 25 | 26 | */ 27 | 28 | #ifndef ENCODER_H 29 | #define ENCODER_H 30 | 31 | #include "timer.h" 32 | 33 | void encoder_init(void); 34 | void encoder_buttonisr(void); 35 | 36 | extern volatile int8_t encoder_position; 37 | extern volatile uint8_t button_state; 38 | extern volatile tick_t last_button_change; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lcd-i2c-menu/lcd.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2012 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; version 2 of the License only. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | 20 | lcd.h: HD44780-compatible display access 21 | 22 | */ 23 | 24 | #ifndef LCD_H 25 | #define LCD_H 26 | 27 | #define LCD_CURSOR_NONE 0x00 28 | #define LCD_CURSOR_LINE 0x02 29 | #define LCD_CURSOR_BLOCK 0x01 30 | 31 | #define LCD_ROWS (LCD_ROWS_TOP+LCD_ROWS_BOTTOM) 32 | 33 | void lcd_init(void); 34 | void lcd_clrscr(void); 35 | void lcd_putxy_P(uint8_t xpos, uint8_t ypos, char *text); 36 | void lcd_putxy(uint8_t xpos, uint8_t ypos, char *text); 37 | void lcd_puts_P(char *text); 38 | void lcd_puts(char *text); 39 | void lcd_setcursormode(uint8_t mode); 40 | void lcd_gotoxy(uint8_t x, uint8_t y); 41 | void lcd_putch(char c); 42 | void lcd_customchar(uint8_t num, uint8_t b0, uint8_t b1, 43 | uint8_t b2, uint8_t b3, uint8_t b4, 44 | uint8_t b5, uint8_t b6, uint8_t b7); 45 | 46 | #ifdef USE_LCD_STDOUT 47 | # include 48 | int lcd_putc(char c, FILE *stream); 49 | #endif 50 | 51 | extern uint8_t cursor_x; 52 | extern uint8_t cursor_y; 53 | extern uint8_t cursor_mode; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lcd-i2c-menu/menu.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2012 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; version 2 of the License only. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | 20 | menu.h: Generic menu code 21 | 22 | */ 23 | 24 | #ifndef MENU_H 25 | #define MENU_H 26 | 27 | extern char *menulines[CONFIG_MAX_MENU_ENTRIES]; 28 | 29 | void menu_init(void); 30 | uint8_t menu_display(uint8_t init, uint8_t startentry); 31 | void menu_resetlines(void); 32 | uint8_t menu_addline(char *line); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lcd-i2c-menu/timer.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2012 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; version 2 of the License only. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | 20 | timer.c: System timer 21 | 22 | */ 23 | 24 | #include "config.h" 25 | #include 26 | #include 27 | #include "avrcompat.h" 28 | #include "encoder.h" 29 | #include "timer.h" 30 | 31 | volatile tick_t ticks; 32 | 33 | /* The main timer interrupt */ 34 | ISR(TIMER1_COMPA_vect) { 35 | ticks++; 36 | encoder_buttonisr(); 37 | } 38 | 39 | void timer_init(void) { 40 | /* Count F_CPU/8 in timer 0 */ 41 | TCCR0B = _BV(CS01); 42 | 43 | /* Set up a 100Hz interrupt using timer 1 */ 44 | OCR1A = 1250*((float)F_CPU/8000000.0) -1; 45 | TCNT1 = 0; 46 | TCCR1A = 0; 47 | TCCR1B = _BV(WGM12) | _BV(CS10) | _BV(CS11); 48 | TIMSK1 |= _BV(OCIE1A); 49 | } 50 | -------------------------------------------------------------------------------- /lcd-i2c-pwm-io/README.md: -------------------------------------------------------------------------------- 1 | I²C-LCD-PWM-I/O 2 | =============== 3 | 4 | 5 | The petSD+ rev. 2.x boards come with a further Atmel ATtiny slave MCU to support the main MCU. 6 | It serves three purposes: 7 | 8 | - output a PWM signal to adjust the LCD contrast 9 | - output a PWM signal to adjust the background display's brightness 10 | - output a digital signal to switch between IEEE-488 and IEC bus 11 | 12 | 13 | ATtiny 25 Pinout: 14 | ``` 15 | ATtiny 25 16 | +------ ------+ 17 | /RESET | 1 \__/ 8 | Vcc 18 | PB3 / DIGI | 2 7 | SCL 19 | PB4 / OC1B | 3 6 | PB1 / OC0B 20 | GND | 4 5 | SDA 21 | +----------------+ 22 | ``` 23 | 24 | The MCUs communicate over the I²C bus, the slave uses address 0x4C (that is 0x26 unshifted). 25 | 26 | These registers are provided: 27 | 28 | | Register | Read | Write | 29 | |----------|------------------|--------------------------------------------------------------------------| 30 | | 1 | Software Version | PWM value LCD contrast (0..255) | 31 | | 2 | -- | PWM value brightness of LCD background display (0: brightest, 255: dark) | 32 | | 3 | -- | Digital Output: 0=IEC bus, 1=IEEE-488 bus | 33 | -------------------------------------------------------------------------------- /lcd-i2c-pwm-io/i2c-lcd-pwm-io-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | ATtiny 25 3 | +------ ------+ 4 | /RESET | 1 \__/ 8 | Vcc 5 | PB3 / DIGI | 2 7 | SCL 6 | PB4 / OC1B | 3 6 | PB1 / OC0B 7 | GND | 4 5 | SDA 8 | +----------------+ 9 | 10 | This configuration file is shared by slave and master MCU 11 | 12 | */ 13 | 14 | #pragma once 15 | 16 | 17 | #define I2C_SLAVE_ADDRESS 0x4C 18 | 19 | // Write registers 20 | #define PWM_CONTRAST 1 21 | #define PWM_BRIGHTNESS 2 22 | #define IO_IEC 3 23 | 24 | // Read registers 25 | #define I2C_SOFTWARE_VERSION 1 26 | 27 | // Software version 28 | #define CONFIG_VERSION 0x4E 29 | 30 | // LCD contrast 31 | #define PWM0_DEFAULT 2 32 | 33 | // LCD brightness (0: brightest, 0xFF: dark) 34 | #define PWM1_DEFAULT 0 35 | 36 | // Default to IEEE-488 37 | #define DIGI_DEFAULT 1 38 | -------------------------------------------------------------------------------- /lcd-i2c-pwm-io/main.c: -------------------------------------------------------------------------------- 1 | /* lcd-i2c-pwm-io 2 | Copyright (C) 2017 Nils Eilers 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . 16 | 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "usi_twi_slave.h" 25 | #include "i2c-lcd-pwm-io-config.h" 26 | 27 | 28 | static inline void set_io(uint8_t value); 29 | 30 | 31 | void usiTwiWriteReg(uint8_t i2c_register, uint8_t value) { 32 | switch (i2c_register) { 33 | case PWM_CONTRAST: OCR0B = value; break; // PWM 0 34 | case PWM_BRIGHTNESS: OCR1B = value; break; // PWM 1 35 | case IO_IEC: set_io(value); // digital output 36 | default: 37 | break; // ignore writes to non-existent registers 38 | 39 | } 40 | } 41 | 42 | static inline void init_timer0(void) 43 | { 44 | DDRB |= _BV(PB1); // Define pin as output 45 | TCCR0B = _BV(CS01); // Prescaler = 8 46 | OCR0B = PWM0_DEFAULT; 47 | // Fast PWM mode 48 | TCCR0A = _BV(COM0B1) | _BV(COM0B0) | _BV(WGM01) | _BV(WGM00); 49 | } 50 | 51 | static inline void init_timer1(void) 52 | { 53 | DDRB |= _BV(PB4); // Define pin as output 54 | TCCR1 = (1 << CS13) | (1 << CS10); 55 | 56 | TCCR1 |= (1 << COM1A1) | (1 << COM1A0); 57 | GTCCR = (1 << COM1B1) | (1 << COM1B0); 58 | OCR1B = PWM1_DEFAULT; 59 | GTCCR |= (1 << PWM1B); // enable PWMB 60 | } 61 | 62 | static inline void init_io(void) 63 | { 64 | DDRB |= _BV(PB3); // Define pin as output 65 | PORTB |= _BV(PB3); // Default: output hi 66 | set_io(DIGI_DEFAULT); 67 | } 68 | 69 | static inline void set_io(uint8_t value) 70 | { 71 | if (value > 0) 72 | PORTB |= _BV(PB3); 73 | else 74 | PORTB &= ~_BV(PB3); 75 | } 76 | 77 | int main(void) 78 | { 79 | // Init 80 | usiTwiSlaveInit(I2C_SLAVE_ADDRESS); 81 | init_timer0(); 82 | init_timer1(); 83 | init_io(); 84 | 85 | // Main loop: do nothing 86 | while (1) 87 | { 88 | set_sleep_mode(SLEEP_MODE_IDLE); 89 | sei(); // Enable interrupts 90 | sleep_cpu(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lcd-i2c-pwm-io/usi_twi_slave.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | 3 | Header file for the USI TWI Slave driver 4 | 5 | Created by Donald R. Blake 6 | Modified by Nils Eilers 7 | 8 | 9 | Created from Atmel source files for Application Note 10 | AVR312: Using the USI Module as an I2C slave. 11 | 12 | This program is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 2 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program; if not, see . 24 | 25 | ************************************************************************/ 26 | 27 | 28 | #pragma once 29 | 30 | void usiTwiSlaveInit(uint8_t); 31 | void usiTwiWriteReg(uint8_t reg, uint8_t value); 32 | -------------------------------------------------------------------------------- /scripts/avr/make-ff.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | rm -f ff.bin 3 | i=1 4 | #EESIZE=4096 5 | EESIZE=$1 6 | while [ $i -le $EESIZE ]; do 7 | printf "\377" >> ff.bin 8 | i=$((i+1)) 9 | done 10 | -------------------------------------------------------------------------------- /scripts/avr/targets.mk: -------------------------------------------------------------------------------- 1 | # architecture-dependent additional targets and manual dependencies 2 | 3 | # Program the device. 4 | program: bin hex eep 5 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) 6 | 7 | # Set fuses of the device 8 | fuses: $(CONFIG) 9 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FUSES) 10 | 11 | # Reset EEPROM memory to check defaults 12 | # 13 | # AVRDUDE's "chip erase" won't erase the EEPROM if the EESAVE fuse bit is set 14 | # Starts with reading back the EEPROM contents to determine the size of 15 | # the EEPROM memory, then generates a size filled with 0xFF with the same 16 | # size and writes this generated temporary file. 17 | delete-eeprom: 18 | $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:rb.bin:r 19 | scripts/avr/make-ff.sh `wc -c < rb.bin` 20 | $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:w:ff.bin:r 21 | rm -f ff.bin rb.bin 22 | 23 | # Manual dependency for the assembler module 24 | $(OBJDIR)/src/avr/fastloader-ll.o: src/config.h src/fastloader.h $(OBJDIR)/autoconf.h 25 | 26 | -------------------------------------------------------------------------------- /scripts/gcctest.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | use feature ':5.10'; 6 | 7 | my $found_4_3 = 0; 8 | 9 | while (<>) { 10 | next unless /gcc\s+\([^)]+\)\s+(\d+)\.(\d+)\./i; 11 | my $major = 0+$1; 12 | my $minor = 0+$2; 13 | if ($major > 4 || ($major == 4 && $minor > 2)) { 14 | $found_4_3 = 1; 15 | } 16 | } 17 | 18 | say "YES" if $found_4_3; 19 | -------------------------------------------------------------------------------- /scripts/last-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # -d : print date of latest git commit 3 | # -h : print short hash of latest commit 4 | # If we're lost in something that isn't a git repo or git is 5 | # not installed, output these replacements: 6 | # -d : current date as YYMMDD 7 | # -h : NOGIT 8 | 9 | if [ $# -eq 0 ] ; then 10 | printf "Info about the latest commit:\n\t-d\tDate\n\t-h\tHash value\n" 11 | exit 1 12 | fi 13 | case "$1" in 14 | -d) git --version >/dev/null 2>&1 || { date "+%Y%m%d"; exit 0; } 15 | if git rev-parse --git-dir > /dev/null 2>&1; then 16 | git log --pretty=format:"%ai" | head -n1 | cut -c 1-4,6-7,9-10 17 | else 18 | date "+%Y%m%d" 19 | fi 20 | ;; 21 | 22 | -h) git --version >/dev/null 2>&1 || { echo NOGIT; exit 0; } 23 | if git rev-parse --git-dir > /dev/null 2>&1; then 24 | git log --pretty=format:"%h" | head -n1 | awk '{print toupper($0)}' 25 | else 26 | echo NOGIT 27 | fi 28 | ;; 29 | *) echo "Illegal option '$1'" 30 | ;; 31 | esac 32 | -------------------------------------------------------------------------------- /scripts/lpc17xx/lpc_checksum.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | if (scalar(@ARGV) != 1) { 6 | print "Usage: $0 binfile\n"; 7 | exit 1; 8 | } 9 | 10 | open FD,"+<",$ARGV[0] or die "Can't open $ARGV[0]: $!"; 11 | 12 | my $buffer; 13 | if (sysread(FD, $buffer, 4*7) != 4*7) { 14 | die "Short read from file: $!"; 15 | } 16 | 17 | my @vecs = unpack("V*", $buffer); 18 | my $checksum = 0; 19 | 20 | while (scalar(@vecs) > 0) { 21 | $checksum += pop(@vecs); 22 | } 23 | 24 | $checksum = (-$checksum) & 0xffffffff; 25 | 26 | if (syswrite(FD, pack("V", $checksum), 4) != 4) { 27 | die "Short write to file: $!"; 28 | } 29 | 30 | close FD; 31 | -------------------------------------------------------------------------------- /scripts/lpc17xx/targets.mk: -------------------------------------------------------------------------------- 1 | # architecture-dependent additional targets and manual dependencies 2 | 3 | # A little helper target for the maintainer =) 4 | copy: 5 | cp $(TARGET).bin /mbed 6 | 7 | bin: 8 | $(E) " CHKSUM $(TARGET).bin" 9 | $(Q)scripts/lpc17xx/lpc_checksum.pl $(TARGET).bin 10 | 11 | program: bin 12 | $(E) " FLASH $(TARGET).bin" 13 | $(Q)openocd -f .openocd-lpc.cfg -c init -c "flash_bin $(TARGET).bin" -c shutdown 14 | 15 | # example cfg file for program target: 16 | # set CCLK 100000 17 | # source [find interface/openocd-usb.cfg] 18 | # source [find target/lpc1768.cfg] 19 | # 20 | # jtag_khz 1000 21 | # 22 | # proc wdtreset {} { 23 | # mww 0x40000004 0x100 24 | # mww 0x40000010 0x80000000 25 | # mww 0x40000000 3 26 | # mww 0x40000008 0xaa 27 | # mww 0x40000008 0x55 28 | # } 29 | # 30 | # proc flash_bin { fname } { 31 | # halt 32 | # wait_halt 33 | # flash write_image erase unlock $fname 34 | # sleep 200 35 | # wdtreset 36 | # } 37 | 38 | # Manual dependencies for the bootinfo include 39 | $(OBJDIR)/src/lpc17xx/startup.o: src/lpc17xx/bootinfo.S 40 | 41 | $(OBJDIR)/src/lpc17xx/pseudoboot.o: src/lpc17xx/bootinfo.S 42 | -------------------------------------------------------------------------------- /scripts/lpc17xx/variables.mk: -------------------------------------------------------------------------------- 1 | # architecture-dependent variables 2 | 3 | #---------------- Source code ---------------- 4 | ASMSRC = lpc17xx/pseudoboot.S lpc17xx/startup.S lpc17xx/crc.S 5 | 6 | SRC += lpc17xx/iec-bus.c 7 | SRC += lpc17xx/llfl-common.c 8 | SRC += lpc17xx/llfl-jiffydos.c 9 | SRC += lpc17xx/llfl-turbodisk.c 10 | SRC += lpc17xx/llfl-fc3exos.c 11 | SRC += lpc17xx/llfl-ar6.c 12 | SRC += lpc17xx/llfl-dreamload.c 13 | SRC += lpc17xx/llfl-ulm3.c 14 | SRC += lpc17xx/llfl-epyxcart.c 15 | SRC += lpc17xx/llfl-geos.c 16 | SRC += lpc17xx/llfl-parallel.c 17 | SRC += lpc17xx/llfl-n0sdos.c 18 | 19 | ifeq ($(CONFIG_UART_DEBUG),y) 20 | SRC += lpc17xx/printf.c 21 | endif 22 | 23 | # Various RTC implementations 24 | ifeq ($(CONFIG_RTC_LPC17XX),y) 25 | SRC += rtc.c lpc17xx/rtc_lpc17xx.c 26 | endif 27 | 28 | # I2C is always needed for the config EEPROM 29 | NEED_I2C := y 30 | SRC += lpc17xx/i2c_lpc17xx.c lpc17xx/arch-eeprom.c 31 | 32 | #---------------- Toolchain ---------------- 33 | CC = arm-none-eabi-gcc 34 | OBJCOPY = arm-none-eabi-objcopy 35 | OBJDUMP = arm-none-eabi-objdump 36 | SIZE = arm-none-eabi-size 37 | NM = arm-none-eabi-nm 38 | 39 | 40 | #---------------- Bootloader ---------------- 41 | BINARY_LENGTH = 0x80000 42 | CRCGEN = scripts/lpc17xx/crcgen-lpc.pl 43 | 44 | 45 | #---------------- Architecture variables ---------------- 46 | ARCH_CFLAGS = -mthumb -mcpu=cortex-m3 -nostartfiles 47 | ARCH_ASFLAGS = -mthumb -mcpu=cortex-m3 48 | ARCH_LDFLAGS = -Tscripts/lpc17xx/$(CONFIG_MCU).ld 49 | 50 | #---------------- Config ---------------- 51 | # currently no stack tracking supported 52 | -------------------------------------------------------------------------------- /scripts/src2doxy.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w -i~ 2 | 3 | # src2doxy.pl - create doxygen-compatible comments from readable C source 4 | # Copyright (C) 2008 Ingo Korb 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; version 2 of the License only. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | # 19 | # This script parses a subset of kernel-doc style comments and rewrites 20 | # them as something doxygen will understand. 21 | use strict; 22 | 23 | my $incomment = 0; 24 | my $inspecialcomment = 0; 25 | my @postcomment = (); 26 | my @outputstack; 27 | 28 | while (<>) { 29 | my $filename; 30 | ($filename = $ARGV) =~ s!.*/!!; 31 | 32 | chomp; 33 | s/\r$//; 34 | s/\s+$//; 35 | 36 | # doxygen is too stupid to understand after-the-variable comments 37 | # without external help. WARNING: Will substitute within strings! 38 | s!([^ \t]\s+)/// !$1///< !; 39 | 40 | $incomment = 1 if m!^/\*!; 41 | if (m!^/\*\*$!) { 42 | $inspecialcomment = 1; 43 | # Kill output 44 | $_ = ""; 45 | next; 46 | } 47 | 48 | if ($incomment) { 49 | if (m!\*/$!) { 50 | # End of comment 51 | $incomment = 0; 52 | $inspecialcomment = 0; 53 | @outputstack = @postcomment; 54 | @postcomment = (); 55 | } elsif (/$filename:\s+(.*).?\s*$/) { 56 | # Add file description 57 | push @postcomment, "\n/*! \\file $ARGV\n * \\brief $1. */\n"; 58 | } 59 | if ($inspecialcomment == 1) { 60 | # First line of special comment: Brief description 61 | $inspecialcomment = 2; 62 | m/^\s*\*\s*((struct |union )?[^: \t]+):?\s+-?\s*(.*)\s*$/; 63 | $_ = "/*! \\brief $3\n *"; 64 | } elsif ($inspecialcomment == 2) { 65 | # Modify parameters 66 | s/\@([^: \t]+)\s*:\s+(.*)\s*$/\\param $1 $2/; 67 | } 68 | } 69 | } continue { 70 | print "$_\n"; 71 | while (scalar(@outputstack)) { 72 | print shift @outputstack,"\n"; 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/ata.h: -------------------------------------------------------------------------------- 1 | #ifndef ATA_H_ 2 | #define ATA_H_ 3 | 4 | /* ATA command */ 5 | #define ATA_CMD_RESET 0x08 /* DEVICE RESET */ 6 | #define ATA_CMD_READ 0x20 /* READ SECTOR(S) */ 7 | #define ATA_CMD_WRITE 0x30 /* WRITE SECTOR(S) */ 8 | #define ATA_CMD_IDENTIFY 0xec /* DEVICE IDENTIFY */ 9 | #define ATA_CMD_SETFEATURES 0xef /* SET FEATURES */ 10 | #define ATA_CMD_SPINDOWN 0xe0 11 | #define ATA_CMD_SPINUP 0xe1 12 | #define ATA_CMD_READ_EXT 0x24 13 | #define ATA_CMD_WRITE_EXT 0x34 14 | 15 | /* ATA register bit definitions */ 16 | #define ATA_LBA3_LBA 0x40 17 | 18 | #define ATA_STATUS_BSY 0x80 19 | #define ATA_STATUS_DRDY 0x40 20 | #define ATA_STATUS_DRQ 0x08 21 | #define ATA_STATUS_ERR 0x01 22 | 23 | #define ATA_DEVCTRL_SRST 0x40 24 | #define ATA_DEVCTRL_NIEN 0x20 25 | 26 | /* Control Ports */ 27 | #define ATA_PORT_CTRL_OUT PORTF 28 | #define ATA_PORT_CTRL_DDR DDRF 29 | #define ATA_PORT_DATA_HI_OUT PORTC 30 | #define ATA_PORT_DATA_HI_DDR DDRC 31 | #define ATA_PORT_DATA_HI_IN PINC 32 | #define ATA_PORT_DATA_LO_OUT PORTA 33 | #define ATA_PORT_DATA_LO_DDR DDRA 34 | #define ATA_PORT_DATA_LO_IN PINA 35 | 36 | /* Bit definitions for Control Port */ 37 | 38 | #define ATA_PIN_RESET (1< 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | arch-eeprom.h: Wrapper for EEPROM functions 25 | 26 | */ 27 | 28 | #ifndef ARCH_EEPROM_H 29 | #define ARCH_EEPROM_H 30 | 31 | #include 32 | 33 | /* AVR: Set EEPROM address pointer to the dummy entry */ 34 | static inline void eeprom_safety(void) { 35 | EEAR = 0; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/avr/arch-timer.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | timer-init.c: System timer initialisation (AVR version) 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "timer.h" 30 | #include "bus.h" 31 | 32 | void timer_init(void) { 33 | /* Count F_CPU/8 in timer 0 */ 34 | TCCR0B = _BV(CS01); 35 | 36 | 37 | /* Set up a 100Hz interrupt using timer 1 38 | 39 | The petSD+ runs at 8 MHz in IEC mode and at 16 MHz in IEEE-488 mode 40 | so after switching modes we need to re-init the timer interrupt 41 | to keep the interrupt occuring 100 times per second 42 | */ 43 | 44 | #ifdef IEC_SLOW_IEEE_FAST 45 | if (active_bus == IEC) 46 | OCR1A = F_CPU / 64 / 100 - 1; 47 | else 48 | OCR1A = (F_CPU * 2) / 64 / 100 - 1; 49 | #else 50 | OCR1A = F_CPU / 64 / 100 - 1; 51 | #endif 52 | 53 | TCNT1 = 0; 54 | TCCR1A = 0; 55 | TCCR1B = _BV(WGM12) | _BV(CS10) | _BV(CS11); 56 | TIMSK1 |= _BV(OCIE1A); 57 | } 58 | -------------------------------------------------------------------------------- /src/avr/arch-timer.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | arch-timer.h: Architecture-specific system timer definitions 25 | 26 | */ 27 | 28 | #ifndef ARCH_TIMER_H 29 | #define ARCH_TIMER_H 30 | 31 | #include 32 | 33 | #define delay_ms(x) _delay_ms(x) 34 | #define delay_us(x) _delay_us(x) 35 | 36 | /* Types for unsigned and signed tick values */ 37 | typedef uint16_t tick_t; 38 | typedef int16_t stick_t; 39 | 40 | /** 41 | * start_timeout - start a timeout using timer0 42 | * @usecs: number of microseconds before timeout (maximum 256 for 8MHz clock) 43 | * 44 | * This function sets timer 0 so it will time out after the specified number 45 | * of microseconds. DON'T use a variable as parameter because it would cause 46 | * run-time floating point calculations (slow and huge). 47 | */ 48 | static inline __attribute__((always_inline)) void start_timeout(uint16_t usecs) { 49 | TCNT0 = 256 - ((float)F_CPU/8000000.0) * usecs; 50 | TIFR0 |= _BV(TOV0); 51 | } 52 | 53 | /** 54 | * has_timed_out - returns true if timeout was reached 55 | * 56 | * This function returns true if the overflow flag of timer 0 is set which 57 | * (together with start_timeout and TIMEOUT_US) will happen when the 58 | * specified time has elapsed. 59 | */ 60 | static inline uint8_t has_timed_out(void) { 61 | return TIFR0 & _BV(TOV0); 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/avr/atn-ack-petsd.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #include 30 | 31 | .global INT0_vect 32 | .extern ieee488_ATN_received 33 | 34 | 35 | #define SAVE_SREG r2 36 | #define TMP r16 37 | 38 | #define IO_SREG 0x3F 39 | #define IO_DDR_EOI 0x0A 40 | #define IO_PORT_NRFD 0x08 41 | #define IO_PORT_NDAC 0x08 42 | #define IO_DDR_NRFD 0x07 43 | #define IO_DDR_NDAC 0x07 44 | #define IO_PORT_TE 0x05 45 | #define IO_DDR_DAV 0x04 46 | #define IO_DDR_DATA 0x01 47 | 48 | #define NRFD 7 49 | #define NDAC 6 50 | #define EOI 7 51 | #define DAV 2 52 | #define TE 0 53 | 54 | INT0_vect: 55 | 56 | ; save registers 57 | push SAVE_SREG 58 | in SAVE_SREG, IO_SREG 59 | push TMP 60 | 61 | ; switch all ports to input to avoid conflicting with bus drivers 62 | 63 | clr TMP ; switch data lines to input 64 | out IO_DDR_DATA, TMP 65 | 66 | cbi IO_DDR_NRFD, NRFD ; NRFD as input 67 | cbi IO_DDR_NDAC, NDAC ; NDAC as input 68 | cbi IO_DDR_EOI, EOI ; EOI as input 69 | cbi IO_DDR_DAV, DAV ; DAV as input 70 | 71 | ; switch bus drivers to listen mode (TE=0) 72 | 73 | cbi IO_PORT_TE, TE 74 | 75 | ; switch port directions that are outputs in listen mode 76 | 77 | sbi IO_DDR_NRFD, NRFD ; NRFD as output 78 | sbi IO_DDR_NDAC, NDAC ; NDAC as output 79 | 80 | ; acknowledge ATN 81 | 82 | cbi IO_PORT_NRFD, NRFD ; pull NRFD low 83 | sbi IO_PORT_NDAC, NDAC ; release NDAC 84 | 85 | ; Set ATN received flag 86 | 87 | ser TMP ; set all bits in register 88 | sts ieee488_ATN_received, TMP 89 | 90 | ; restore registers 91 | pop TMP 92 | out IO_SREG, SAVE_SREG 93 | pop SAVE_SREG 94 | 95 | reti 96 | -------------------------------------------------------------------------------- /src/avr/atn-ack-xs1541.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | 32 | .global PCINT3_vect 33 | .extern ieee488_ATN_received 34 | 35 | 36 | PCINT3_vect: 37 | 38 | ; interrupt caused by rising or falling edge of ATN? 39 | sbic _SFR_IO_ADDR(PIND), PD3 ; skip next instruction if ATN is low 40 | reti ; ATN is high --> return from interrupt 41 | 42 | ; save registers 43 | push r2 44 | in r2, _SFR_IO_ADDR(SREG) 45 | push r16 46 | 47 | ; acknowledge ATN by pulling NRFD low and releasing NDAC 48 | ; switch ports to listen mode 49 | 50 | ; configure EOI(PC7) + DAV(PC6) as inputs 51 | ; NDAC(PC4) is actually an output, but is configured for input also 52 | ; because the high state is achieved by enabling the pull-up resistor 53 | ; in input mode 54 | in r16, _SFR_IO_ADDR(DDRC) 55 | andi r16, 255 - _BV(PC7) - _BV(PC6) - _BV(PC4); 56 | ori r16, _BV(PC5) ; NRFD as output 57 | out _SFR_IO_ADDR(DDRC), r16 58 | 59 | cbi _SFR_IO_ADDR(PORTC), PC5 ; NRFD low 60 | 61 | ; enable pull-up resistors for EOI(PC7), DAV(PC6) and NDAC(PC4) 62 | in r16, _SFR_IO_ADDR(PORTC) 63 | ori r16, _BV(PC7) + _BV(PC6) + _BV(PC4) 64 | out _SFR_IO_ADDR(PORTC), r16 65 | 66 | clr r16 ; switch data lines to input 67 | out _SFR_IO_ADDR(DDRA), r16 68 | ser r16 ; set all bits in register 69 | out _SFR_IO_ADDR(PORTA), r16 ; enable all pull-ups for data lines 70 | 71 | ; Set ATN received flag 72 | 73 | ser r16 ; set all bits in register 74 | sts ieee488_ATN_received, r16 75 | 76 | ; restore registers 77 | pop r16 78 | out _SFR_IO_ADDR(SREG), r2 79 | pop r2 80 | 81 | reti 82 | -------------------------------------------------------------------------------- /src/avr/atomic.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | atomic.h: Wrapper for atomic blocks 25 | 26 | */ 27 | 28 | #ifndef ATOMIC_H 29 | #define ATOMIC_H 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/avr/crc.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | crc.h: Definitions for CRC calculation routines (AVR version) 25 | 26 | */ 27 | 28 | #ifndef CRC_H 29 | #define CRC_H 30 | 31 | #include 32 | 33 | uint8_t crc7update(uint8_t crc, uint8_t data); 34 | 35 | #define crc_xmodem_update(crc, data) _crc_xmodem_update(crc, data) 36 | #define crc16_update(crc, data) _crc16_update(crc, data) 37 | 38 | /* Calculate a CRC over a block of data - more efficient if inlined */ 39 | static inline uint16_t crc_xmodem_block(uint16_t crc, const uint8_t *data, unsigned int length) { 40 | while (length--) { 41 | crc = _crc_xmodem_update(crc, *data++); 42 | } 43 | return crc; 44 | } 45 | 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /src/avr/crc7asm.S: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN, see tff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | crc7asm.S: space-efficient CRC7 implementation for AVR 25 | 26 | */ 27 | 28 | .section .text 29 | 30 | .global crc7update 31 | ;; uint8_t crc7update(uint8_t crc, uint8_t data) 32 | ;; 33 | ;; input : r24: crc, r22: data 34 | ;; output: r24: new crc 35 | crc7update: 36 | ldi r18, 8 ; number of bits to process 37 | ldi r19, 0x09 ; CRC7 polynomial 38 | ldi r20, 0x80 ; constant for inverting the top bit of the CRC 39 | 40 | loop: lsl r24 ; shift CRC 41 | lsl r22 ; shift data byte 42 | brcc 0f ; jump if top data bit was 0 43 | eor r24, r20 ; invert top bit of CRC if not 44 | 0: bst r24, 7 ; read top bit of CRC 45 | brtc 1f ; skip if top bit of CRC is now clear 46 | eor r24, r19 ; apply polynomial 47 | 1: dec r18 ; decrement bit counter 48 | brne loop ; loop for next bit 49 | andi r24, 0x7f ; clear top bit of CRC 50 | ret ; return 51 | 52 | .end 53 | -------------------------------------------------------------------------------- /src/avr/lcd.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #pragma once 30 | #include "config.h" 31 | #include 32 | 33 | #define lcd_printf(fmt, ...) lcd_printf_P(PSTR(fmt), ##__VA_ARGS__) 34 | 35 | #ifdef CONFIG_ONBOARD_DISPLAY 36 | 37 | extern uint8_t lcd_x; // 0..LCD_COLS-1 38 | extern uint8_t lcd_y; // 0..LCD_LINES-1 39 | extern uint8_t lcd_contrast; 40 | extern uint8_t lcd_brightness; 41 | 42 | void lcd_init(void); 43 | void lcd_clear(void); 44 | void lcd_home(void); 45 | void lcd_locate(uint8_t x, uint8_t y); 46 | void lcd_send_command(uint8_t cmd); 47 | void lcd_putc(char c); 48 | void lcd_puts(const char *s); 49 | void lcd_puts_P(const char *progmem_s); 50 | void lcd_printf_P(const char *fmt, ...); 51 | void lcd_cursor(bool on); 52 | void lcd_clrlines(uint8_t from, uint8_t to); 53 | uint8_t lcd_set_contrast(uint8_t contrast); 54 | uint8_t lcd_set_brightness(uint8_t contrast); 55 | 56 | #else 57 | 58 | static inline void lcd_init(void) {} 59 | static inline void lcd_clear(void) {} 60 | static inline void lcd_home(void) {} 61 | static inline void lcd_locate(uint8_t x, uint8_t y) {} 62 | static inline void lcd_send_command(uint8_t cmd) {} 63 | static inline void lcd_putc(char c) {} 64 | static inline void lcd_puts(const char *s) {} 65 | static inline void lcd_puts_P(const char *progmem_s) {} 66 | static inline void lcd_printf_P(const char *fmt, ...) {} 67 | static inline void lcd_cursor(bool on) {} 68 | static inline void lcd_clrlines(uint8_t from, uint8_t to) {} 69 | static inline uint8_t lcd_set_contrast(uint8_t contrast) { return 1; } 70 | static inline uint8_t lcd_set_brightness(uint8_t contrast) { return 1; } 71 | #endif 72 | -------------------------------------------------------------------------------- /src/avr/progmem.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | progmem.h: avr/pgmspace.h wrapper header 25 | 26 | */ 27 | 28 | #ifndef PROGMEM_H 29 | #define PROGMEM_H 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/avr/spi.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | spi.h: Definitions for the low-level SPI routines - AVR version 25 | 26 | */ 27 | #ifndef SPI_H 28 | #define SPI_H 29 | 30 | #include "config.h" 31 | 32 | /* Low speed 400kHz for init, fast speed <=20MHz (MMC limit) */ 33 | typedef enum { SPI_SPEED_FAST, SPI_SPEED_SLOW } spi_speed_t; 34 | 35 | /* Available SPI devices - special case to select all SD cards during init */ 36 | /* Note: SD cards must be 1 and 2 */ 37 | /* AVR note: The code assumes that spi_device_t can be used as bit field of selected cards */ 38 | typedef enum { SPIDEV_NONE = 0, 39 | SPIDEV_CARD0 = 1, 40 | SPIDEV_CARD1 = 2, 41 | SPIDEV_ALLCARDS = 3 } spi_device_t; 42 | 43 | /* Initialize SPI interface */ 44 | void spi_init(spi_speed_t speed); 45 | 46 | /* select device */ 47 | static inline void spi_select_device(spi_device_t dev) { 48 | if (dev & 1) 49 | sdcard_set_ss(0); 50 | else 51 | sdcard_set_ss(1); 52 | #ifdef CONFIG_TWINSD 53 | if (dev & 2) 54 | sdcard2_set_ss(0); 55 | else 56 | sdcard2_set_ss(1); 57 | #endif 58 | } 59 | 60 | /* Transmit a single byte */ 61 | void spi_tx_byte(uint8_t data); 62 | 63 | /* Exchange a data block - internal API only! */ 64 | void spi_exchange_block(void *data, unsigned int length, uint8_t write); 65 | 66 | /* Receive a data block */ 67 | static inline void spi_tx_block(const void *data, unsigned int length) { 68 | spi_exchange_block((void *)data, length, 0); 69 | } 70 | 71 | /* Receive a single byte */ 72 | uint8_t spi_rx_byte(void); 73 | 74 | /* Receive a data block */ 75 | static inline void spi_rx_block(void *data, unsigned int length) { 76 | spi_exchange_block(data, length, 1); 77 | } 78 | 79 | /* Switch speed of SPI interface */ 80 | void spi_set_speed(spi_speed_t speed); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/d64ops.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | d64ops.h: Definitions for the D64 operations 25 | 26 | */ 27 | 28 | #ifndef D64OPS_H 29 | #define D64OPS_H 30 | 31 | #include "wrapops.h" 32 | 33 | /* Offsets in a D64 directory entry, also needed for raw dirs */ 34 | #define DIR_OFS_FILE_TYPE 2 35 | #define DIR_OFS_TRACK 3 36 | #define DIR_OFS_SECTOR 4 37 | #define DIR_OFS_FILE_NAME 5 38 | #define DIR_OFS_YEAR 0x19 39 | #define DIR_OFS_MONTH 0x1a 40 | #define DIR_OFS_DAY 0x1b 41 | #define DIR_OFS_HOUR 0x1c 42 | #define DIR_OFS_MINUTE 0x1d 43 | #define DIR_OFS_SIZE_LOW 0x1e 44 | #define DIR_OFS_SIZE_HI 0x1f 45 | 46 | /* Disk image types - values must match G-P partition type byte */ 47 | #define D64_TYPE_MASK 0x7f 48 | #define D64_TYPE_NONE 0 49 | #define D64_TYPE_DNP 1 50 | #define D64_TYPE_D41 2 51 | #define D64_TYPE_D71 3 52 | #define D64_TYPE_D81 4 53 | #define D64_TYPE_D80 8 54 | #define D64_TYPE_D82 16 55 | #define D64_HAS_ERRORINFO 128 56 | 57 | extern const fileops_t d64ops; 58 | 59 | uint8_t d64_mount(path_t *path, uint8_t *name); 60 | void d64_unmount(uint8_t part); 61 | 62 | /* commit BAM buffer contents to storage medium */ 63 | uint8_t d64_bam_commit(void); 64 | 65 | void d64_raw_directory(path_t *path, buffer_t *buf); 66 | void d64_invalidate(void); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/diagnose.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | void board_diagnose(void); 29 | 30 | -------------------------------------------------------------------------------- /src/diskchange.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | diskchange.h: Disk image changer 25 | 26 | */ 27 | 28 | #ifndef DISKCHANGE_H 29 | #define DISKCHANGE_H 30 | 31 | #include "dirent.h" 32 | 33 | void change_init(void); 34 | void change_disk(void); 35 | void set_changelist(path_t *path, uint8_t *filename); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/doscmd.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | doscmd.h: Definitions for the command channel parser 25 | 26 | */ 27 | 28 | #ifndef DOSCMD_H 29 | #define DOSCMD_H 30 | 31 | extern uint8_t command_buffer[CONFIG_COMMAND_BUFFER_SIZE+2]; 32 | extern uint8_t command_length; 33 | extern date_t date_match_start; 34 | extern date_t date_match_end; 35 | 36 | extern uint16_t datacrc; 37 | 38 | void parse_doscommand(void); 39 | void do_chdir(uint8_t *parsestr); 40 | uint8_t day_of_week(uint16_t y, uint8_t m, uint8_t d); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/ds1307-3231.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | ds1307-3231.h: RTC support for DS1307/DS3231 chips 25 | 26 | */ 27 | 28 | #ifndef DS1307_3231_H 29 | #define DS1307_3231_H 30 | 31 | #include "time.h" 32 | 33 | void dsrtc_init(void); 34 | void dsrtc_read(struct tm *time); 35 | void dsrtc_set(struct tm *time); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/eefs-ops.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | eefs-ops.h: eepromfs operations 25 | 26 | */ 27 | 28 | #ifndef EEFS_OPS_H 29 | #define EEFS_OPS_H 30 | 31 | #include "wrapops.h" 32 | 33 | /* number of the partition that eefs took, 255 if none */ 34 | extern uint8_t eefs_partition; 35 | 36 | extern const fileops_t eefs_ops; 37 | 38 | void eefsops_init(void); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/eeprom-conf.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | eeprom-conf.h: Persistent configuration storage 25 | 26 | */ 27 | 28 | #ifndef EEPROM_CONF_H 29 | #define EEPROM_CONF_H 30 | 31 | #define ROM_NAME_LENGTH 16 32 | 33 | extern uint8_t rom_filename[ROM_NAME_LENGTH+1]; 34 | 35 | void read_configuration(void); 36 | void write_configuration(void); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/eeprom-fs.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | eeprom-fs.h: Tiny file system in the unused EEPROM space 25 | 26 | */ 27 | 28 | #ifndef EEPROM_FS_H 29 | #define EEPROM_FS_H 30 | 31 | #include 32 | 33 | // NOTE: Not tested with anything but 16 34 | #define EEFS_NAME_LENGTH 16 35 | 36 | /* flags for eepromfs_open */ 37 | #define EEFS_MODE_READ 0 38 | #define EEFS_MODE_WRITE 1 39 | #define EEFS_MODE_APPEND 2 40 | 41 | /* error return values */ 42 | typedef enum { 43 | EEFS_ERROR_OK = 0, 44 | EEFS_ERROR_FILENOTFOUND, 45 | EEFS_ERROR_FILEEXISTS, 46 | EEFS_ERROR_DIRFULL, 47 | EEFS_ERROR_DISKFULL, 48 | EEFS_ERROR_INVALID, 49 | EEFS_ERROR_UNIMPLEMENTED, 50 | } eefs_error_t; 51 | 52 | typedef struct { 53 | uint8_t entry; 54 | } eefs_dir_t; 55 | 56 | typedef struct { 57 | uint16_t size; 58 | uint8_t name[EEFS_NAME_LENGTH+1]; // note: last byte is not touched 59 | uint8_t flags; 60 | } eefs_dirent_t; 61 | 62 | typedef struct { 63 | uint16_t size; // current file size 64 | uint16_t cur_offset; // current offset within file 65 | uint8_t entry; // (first) directory entry of the file 66 | uint8_t cur_sector; // current sector 67 | uint8_t cur_soffset; // current offset in the sector, points "next" byte on read+write 68 | uint8_t cur_entry; // index of the current directory entry 69 | uint8_t cur_sindex; // index of the current sector in the entry 70 | uint8_t filemode; // read/write/append - FIXME: read-only? 71 | } eefs_fh_t; 72 | 73 | void eepromfs_init(void); 74 | void eepromfs_format(void); 75 | uint8_t eepromfs_free_sectors(void); 76 | void eepromfs_opendir(eefs_dir_t *dh); 77 | uint8_t eepromfs_readdir(eefs_dir_t *dh, eefs_dirent_t *entry); 78 | eefs_error_t eepromfs_open(uint8_t *name, eefs_fh_t *fh, uint8_t flags); 79 | eefs_error_t eepromfs_write(eefs_fh_t *fh, void *data, uint16_t length, uint16_t *bytes_written); 80 | eefs_error_t eepromfs_read(eefs_fh_t *fh, void *data, uint16_t length, uint16_t *bytes_read); 81 | void eepromfs_close(eefs_fh_t *fh); 82 | eefs_error_t eepromfs_rename(uint8_t *oldname, uint8_t *newname); 83 | eefs_error_t eepromfs_delete(uint8_t *name); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/enc28j60.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | 32 | #include "spi.h" 33 | #include "uart.h" 34 | #include "enc28j60.h" 35 | 36 | 37 | static uint8_t enc28j60_bank; 38 | 39 | 40 | static uint8_t enc28j60_rd(uint8_t op, uint8_t address) { 41 | uint8_t data; 42 | 43 | enc28j60_set_ss(0); 44 | spi_tx_byte(op | (address & ADDR_MASK)); // send read cmd 45 | data = spi_rx_byte(); // receive data byte 46 | if (address & 0x80) data = spi_rx_byte(); 47 | enc28j60_set_ss(1); 48 | return data; 49 | } 50 | 51 | 52 | static void enc28j60_wr(uint8_t op, uint8_t address, uint8_t data) { 53 | enc28j60_set_ss(0); 54 | spi_tx_byte(op | (address & ADDR_MASK)); // send write cmd 55 | spi_tx_byte(data); // send data byte 56 | enc28j60_set_ss(1); 57 | } 58 | 59 | 60 | static void enc28j60_set_bank(uint8_t address) { 61 | // set the bank (if needed) 62 | if((address & BANK_MASK) != enc28j60_bank) { 63 | enc28j60_wr(ENC28J60_BIT_FIELD_CLR, ECON1, (ECON1_BSEL1|ECON1_BSEL0)); 64 | enc28j60_wr(ENC28J60_BIT_FIELD_SET, ECON1, (address & BANK_MASK)>>5); 65 | enc28j60_bank = (address & BANK_MASK); 66 | } 67 | } 68 | 69 | 70 | uint8_t enc28j60_read(uint8_t address) { 71 | enc28j60_set_bank(address); 72 | return enc28j60_rd(ENC28J60_READ_CTRL_REG, address); 73 | } 74 | -------------------------------------------------------------------------------- /src/enc28j60.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #pragma once 30 | 31 | #include "config.h" 32 | 33 | 34 | uint8_t enc28j60_read(uint8_t address); 35 | 36 | #define ENC28J60_READ_CTRL_REG 0x00 37 | #define ENC28J60_BIT_FIELD_SET 0x80 38 | #define ENC28J60_BIT_FIELD_CLR 0xA0 39 | #define ENC28J60_SOFT_RESET 0xFF 40 | 41 | #define ADDR_MASK 0x1F 42 | #define BANK_MASK 0x60 43 | 44 | #define ECON1 0x1F 45 | #define ECON1_BSEL0 0x01 46 | #define ECON1_BSEL1 0x02 47 | #define EREVID (0x12|0x60) 48 | -------------------------------------------------------------------------------- /src/errormsg.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | errormsg.h: Definitions for the error message generator 25 | 26 | */ 27 | 28 | #ifndef ERRORMSG_H 29 | #define ERRORMSG_H 30 | 31 | #include 32 | #include "buffers.h" 33 | #include "progmem.h" 34 | 35 | extern uint8_t current_error; 36 | extern uint8_t error_buffer[CONFIG_ERROR_BUFFER_SIZE]; 37 | 38 | 39 | void set_error_ts(uint8_t errornum, uint8_t track, uint8_t sector); 40 | void set_error(uint8_t errornum); 41 | uint8_t set_ok_message(buffer_t *buf); 42 | 43 | // Commodore DOS error codes 44 | #define ERROR_OK 0 45 | #define ERROR_SCRATCHED 1 46 | #define ERROR_PARTITION_SELECTED 2 47 | #define ERROR_STATUS 3 48 | #define ERROR_LONGVERSION 9 49 | #define ERROR_READ_NOHEADER 20 50 | #define ERROR_READ_NOSYNC 21 51 | #define ERROR_READ_NODATA 22 52 | #define ERROR_READ_CHECKSUM 23 53 | #define ERROR_WRITE_VERIFY 25 54 | #define ERROR_WRITE_PROTECT 26 55 | #define ERROR_READ_HDRCHECKSUM 27 56 | #define ERROR_DISK_ID_MISMATCH 29 57 | #define ERROR_SYNTAX_UNKNOWN 30 58 | #define ERROR_SYNTAX_UNABLE 31 59 | #define ERROR_SYNTAX_TOOLONG 32 60 | #define ERROR_SYNTAX_JOKER 33 61 | #define ERROR_SYNTAX_NONAME 34 62 | #define ERROR_FILE_NOT_FOUND_39 39 63 | #define ERROR_RECORD_MISSING 50 64 | #define ERROR_RECORD_OVERFLOW 51 65 | #define ERROR_FILE_TOO_LARGE 52 66 | #define ERROR_WRITE_FILE_OPEN 60 67 | #define ERROR_FILE_NOT_OPEN 61 68 | #define ERROR_FILE_NOT_FOUND 62 69 | #define ERROR_FILE_EXISTS 63 70 | #define ERROR_FILE_TYPE_MISMATCH 64 71 | #define ERROR_NO_BLOCK 65 72 | #define ERROR_ILLEGAL_TS_COMMAND 66 73 | #define ERROR_ILLEGAL_TS_LINK 67 74 | #define ERROR_NO_CHANNEL 70 75 | #define ERROR_DIR_ERROR 71 76 | #define ERROR_DISK_FULL 72 77 | #define ERROR_DOSVERSION 73 78 | #define ERROR_DRIVE_NOT_READY 74 79 | #define ERROR_PARTITION_ILLEGAL 77 80 | #define ERROR_BUFFER_TOO_SMALL 78 81 | #define ERROR_IMAGE_INVALID 79 82 | #define ERROR_UNKNOWN_DRIVECODE 98 83 | #define ERROR_CLOCK_UNSTABLE 99 84 | 85 | /// Version number string, will be added to message 73 86 | extern const char PROGMEM versionstr[]; 87 | 88 | /// Long version string, used for message 9 89 | extern const char PROGMEM longverstr[]; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/fastloader-ll.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | fastloader-ll.h: Definitions for low-level fastloader routines 25 | 26 | */ 27 | 28 | #ifndef FASTLOADERLL_H 29 | #define FASTLOADERLL_H 30 | 31 | #ifdef CONFIG_HAVE_IEC 32 | void turbodisk_byte(uint8_t value); 33 | void turbodisk_buffer(uint8_t *data, uint8_t length); 34 | 35 | uint8_t jiffy_receive(iec_bus_t *busstate); 36 | uint8_t jiffy_send(uint8_t value, uint8_t eoi, uint8_t loadflags); 37 | 38 | void clk_data_handshake(void); 39 | void fastloader_fc3_send_block(uint8_t *data); 40 | uint8_t fc3_get_byte(void); 41 | uint8_t fc3_oldfreeze_pal_send(uint8_t byte); 42 | uint8_t fc3_oldfreeze_ntsc_send(uint8_t byte); 43 | 44 | uint8_t dreamload_get_byte(void); 45 | void dreamload_send_byte(uint8_t byte); 46 | 47 | int16_t uload3_get_byte(void); 48 | void uload3_send_byte(uint8_t byte); 49 | 50 | uint8_t epyxcart_send_byte(uint8_t byte); 51 | 52 | uint8_t geos_get_byte_1mhz(void); 53 | uint8_t geos_get_byte_2mhz(void); 54 | uint8_t geos_send_byte_1mhz(uint8_t byte); 55 | uint8_t geos_send_byte_2mhz(uint8_t byte); 56 | uint8_t geos_send_byte_1581_21(uint8_t byte); 57 | 58 | uint8_t wheels_send_byte_1mhz(uint8_t byte); 59 | uint8_t wheels_get_byte_1mhz(void); 60 | 61 | uint8_t wheels44_get_byte_1mhz(void); 62 | uint8_t wheels44_get_byte_2mhz(void); 63 | uint8_t wheels44_send_byte_2mhz(uint8_t byte); 64 | 65 | void ar6_1581_send_byte(uint8_t byte); 66 | uint8_t ar6_1581p_get_byte(void); 67 | 68 | void n0sdos_send_byte(uint8_t byte); 69 | 70 | typedef enum { PARALLEL_DIR_IN = 0, 71 | PARALLEL_DIR_OUT } parallel_dir_t; 72 | 73 | uint8_t parallel_read(void); 74 | void parallel_write(uint8_t value); 75 | void parallel_send_handshake(void); 76 | 77 | #ifdef HAVE_PARALLEL 78 | void parallel_set_dir(parallel_dir_t direction); 79 | #else 80 | # define parallel_set_dir(x) do {} while (0) 81 | #endif 82 | 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/fatops.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | fatops.h: Definitions for the FAT operations 25 | 26 | */ 27 | 28 | #ifndef FATOPS_H 29 | #define FATOPS_H 30 | 31 | #include "buffers.h" 32 | #include "dirent.h" 33 | #include "wrapops.h" 34 | #include "ff.h" 35 | 36 | /* API */ 37 | void fatops_init(uint8_t preserve_dir); 38 | void parse_error(FRESULT res, uint8_t readflag); 39 | uint8_t fat_delete(path_t *path, cbmdirent_t *dent); 40 | uint8_t fat_chdir(path_t *path, cbmdirent_t *dent); 41 | void fat_mkdir(path_t *path, uint8_t *dirname); 42 | void fat_open_read(path_t *path, cbmdirent_t *filename, buffer_t *buf); 43 | void fat_open_write(path_t *path, cbmdirent_t *filename, uint8_t type, buffer_t *buf, uint8_t append); 44 | uint8_t fat_getdirlabel(path_t *path, uint8_t *label); 45 | uint8_t fat_getid(path_t *path, uint8_t *id); 46 | uint16_t fat_freeblocks(uint8_t part); 47 | uint8_t fat_opendir(dh_t *dh, path_t *dir); 48 | int8_t fat_readdir(dh_t *dh, cbmdirent_t *dent); 49 | void fat_read_sector(buffer_t *buf, uint8_t part, uint8_t track, uint8_t sector); 50 | void fat_write_sector(buffer_t *buf, uint8_t part, uint8_t track, uint8_t sector); 51 | void format_dummy(uint8_t drive, uint8_t *name, uint8_t *id); 52 | 53 | extern const fileops_t fatops; 54 | extern uint8_t file_extension_mode; 55 | 56 | /* Generic helpers */ 57 | uint8_t image_unmount(uint8_t part); 58 | uint8_t image_chdir(path_t *path, cbmdirent_t *dent); 59 | void image_mkdir(path_t *path, uint8_t *dirname); 60 | uint8_t image_read(uint8_t part, DWORD offset, void *buffer, uint16_t bytes); 61 | uint8_t image_write(uint8_t part, DWORD offset, void *buffer, uint16_t bytes, uint8_t flush); 62 | 63 | typedef enum { IMG_UNKNOWN, IMG_IS_DISK } imgtype_t; 64 | 65 | imgtype_t check_imageext(uint8_t *name); 66 | 67 | 68 | void pet2asc(uint8_t *buf); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/fileops.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | fileops.h: Definitions for file operations 25 | 26 | */ 27 | 28 | #ifndef FILEOPS_H 29 | #define FILEOPS_H 30 | 31 | #include "buffers.h" 32 | #include "dirent.h" 33 | #include "progmem.h" 34 | 35 | enum open_modes { OPEN_READ, OPEN_WRITE, OPEN_APPEND, OPEN_MODIFY }; 36 | extern const PROGMEM uint8_t filetypes[]; 37 | 38 | /* saved dirent of the last opened file */ 39 | extern cbmdirent_t previous_file_dirent; 40 | 41 | /* Refill-callback for large buffers, only used for comparision */ 42 | uint8_t directbuffer_refill(buffer_t *buf); 43 | 44 | /* reopen the last opened file on secondary 0 */ 45 | void file_open_previous(void); 46 | 47 | /* Parses a filename in command_buffer and opens that file */ 48 | void file_open(uint8_t secondary); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/filesystem.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | filesystem.h: small abstractions for multi-filesystem support 25 | 26 | */ 27 | 28 | #ifndef FILESYSTEM_H 29 | #define FILESYSTEM_H 30 | 31 | #include "fatops.h" 32 | #include "eefs-ops.h" 33 | 34 | // FIXME: Move d64_invalidate and maybe p00cache_invalidate out of fatops.c? 35 | 36 | #ifdef CONFIG_HAVE_EEPROMFS 37 | /* initialize both fatops and eefs */ 38 | static inline void filesystem_init(uint8_t preserve_dir) { 39 | fatops_init(preserve_dir); 40 | eefsops_init(); 41 | } 42 | #else 43 | /* just fatops */ 44 | static inline void filesystem_init(uint8_t preserve_dir) { 45 | fatops_init(preserve_dir); 46 | } 47 | #endif 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/fl-ar6.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Final Cartridge III, DreamLoad, ELoad fastloader support: 7 | Copyright (C) 2008-2011 Thomas Giesel 8 | Nippon Loader support: 9 | Copyright (C) 2010 Joerg Jungermann 10 | 11 | Inspired by MMC2IEC by Lars Pontoppidan et al. 12 | 13 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 14 | 15 | This program is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU General Public License as published by 17 | the Free Software Foundation; version 2 of the License only. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | 28 | 29 | fl-ar6.c: High level handling of AR6 fastloader/-saver 30 | 31 | */ 32 | 33 | #include 34 | #include 35 | #include "config.h" 36 | #include "buffers.h" 37 | #include "fastloader-ll.h" 38 | #include "iec-bus.h" 39 | #include "iec.h" 40 | #include "timer.h" 41 | #include "fastloader.h" 42 | 43 | 44 | /* 1581 loader */ 45 | void load_ar6_1581(UNUSED_PARAMETER) { 46 | buffer_t *buf; 47 | uint16_t i; 48 | 49 | buf = find_buffer(0); 50 | if (!buf) { 51 | /* The file should've been open? */ 52 | return; 53 | } 54 | 55 | set_clock(0); 56 | set_data(1); 57 | delay_ms(1); 58 | 59 | while (1) { 60 | /* Send number of bytes in sector */ 61 | ar6_1581_send_byte(buf->lastused-1); 62 | 63 | /* Send bytes in sector */ 64 | for (i=2; i<=buf->lastused; i++) 65 | ar6_1581_send_byte(buf->data[i]); 66 | 67 | /* Check for end of file */ 68 | if (buf->sendeoi) 69 | break; 70 | 71 | /* Read next sector */ 72 | if (buf->refill(buf)) { 73 | /* Error, end transmission */ 74 | break; 75 | } 76 | } 77 | 78 | /* Send end marker */ 79 | ar6_1581_send_byte(0); 80 | delay_ms(1); 81 | set_clock(1); 82 | set_data(1); 83 | } 84 | 85 | /* 1581 saver */ 86 | void save_ar6_1581(UNUSED_PARAMETER) { 87 | buffer_t *buf; 88 | uint8_t i; 89 | 90 | buf = find_buffer(1); 91 | 92 | if (!buf) { 93 | /* File isn't open */ 94 | return; 95 | } 96 | 97 | set_clock(0); 98 | set_data(1); 99 | delay_ms(1); 100 | 101 | do { 102 | mark_buffer_dirty(buf); 103 | 104 | /* Receive sector */ 105 | i = 0; 106 | do { 107 | buf->data[i] = ar6_1581p_get_byte(); 108 | i++; 109 | } while (i != 0); 110 | 111 | /* Set end */ 112 | // FIXME: Although this works, it is not exactly clean: 113 | // The code here should update lastused and mustflush. 114 | if (buf->data[0] == 0) { 115 | buf->position = buf->data[1]; 116 | } else 117 | buf->position = 0; 118 | 119 | /* Write data */ 120 | if (buf->refill(buf)) 121 | break; 122 | } while (buf->data[0] != 0); 123 | 124 | cleanup_and_free_buffer(buf); 125 | } 126 | -------------------------------------------------------------------------------- /src/fl-eload.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Final Cartridge III, DreamLoad, ELoad fastloader support: 7 | Copyright (C) 2008-2011 Thomas Giesel 8 | Nippon Loader support: 9 | Copyright (C) 2010 Joerg Jungermann 10 | 11 | Inspired by MMC2IEC by Lars Pontoppidan et al. 12 | 13 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 14 | 15 | This program is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU General Public License as published by 17 | the Free Software Foundation; version 2 of the License only. 18 | 19 | This program is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with this program; if not, write to the Free Software 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | 28 | 29 | fl-eload.c: High level handling of eload 30 | 31 | */ 32 | 33 | #include 34 | #include 35 | #include "config.h" 36 | #include "buffers.h" 37 | #include "fastloader-ll.h" 38 | #include "iec-bus.h" 39 | #include "iec.h" 40 | #include "fastloader.h" 41 | 42 | 43 | 44 | /* 45 | * 46 | * eload 47 | * 48 | */ 49 | void load_eload1(UNUSED_PARAMETER) { 50 | buffer_t *buf; 51 | int16_t cmd; 52 | uint8_t count, pos, end; 53 | 54 | while (1) { 55 | /* read command */ 56 | cmd = uload3_get_byte(); 57 | if (cmd < 0) { 58 | /* ATN received */ 59 | break; 60 | } 61 | 62 | switch (cmd) { 63 | case 1: /* load a file */ 64 | buf = find_buffer(0); 65 | 66 | if (!buf) { 67 | if (!IEC_ATN) 68 | return; 69 | uload3_send_byte(0xff); /* error */ 70 | return; 71 | } 72 | 73 | end = 0; 74 | do { 75 | count = buf->lastused - 1; 76 | if (!IEC_ATN) 77 | return; 78 | uload3_send_byte(count); 79 | pos = 2; 80 | while (count--) { 81 | if (!IEC_ATN) 82 | return; 83 | uload3_send_byte(buf->data[pos++]); 84 | } 85 | if (buf->sendeoi) { 86 | uload3_send_byte(0); /* EOF */ 87 | end = 1; 88 | } 89 | else if (buf->refill(buf)) { 90 | uload3_send_byte(0xff); /* error */ 91 | end = 1; 92 | } 93 | } while (!end); 94 | break; 95 | 96 | default: 97 | /* unknown command */ 98 | uload3_send_byte(0xff); 99 | break; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/flags.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | flags.h: Definitions for some global flags 25 | 26 | */ 27 | 28 | #ifndef FLAGS_H 29 | #define FLAGS_H 30 | 31 | #ifdef __AVR__ 32 | /* GPIOR0 is a bit-addressable register reserved for user data */ 33 | # define globalflags (GPIOR0) 34 | #else 35 | /* Global flags, variable defined in doscmd.c */ 36 | extern uint8_t globalflags; 37 | #endif 38 | 39 | /** flag values **/ 40 | /* transient flags */ 41 | #define VC20MODE (1<<0) 42 | #define AUTOSWAP_ACTIVE (1<<2) 43 | #define SWAPLIST_ASCII (1<<5) 44 | 45 | /* permanent (EEPROM-saved) flags */ 46 | /* 1<<1 was JIFFY_ENABLED */ 47 | #define EXTENSION_HIDING (1<<3) 48 | #define POSTMATCH (1<<4) 49 | 50 | /* Disk image-as-directory mode, defined in fileops.c */ 51 | extern uint8_t image_as_dir; 52 | 53 | #define IMAGE_DIR_NORMAL 0 54 | #define IMAGE_DIR_DIR 1 55 | #define IMAGE_DIR_BOTH 2 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/i2c.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | i2c.h: Definitions for I2C transfers 25 | 26 | There is no i2c.c, the functions defined here are currently implemented 27 | by softi2c.c. An additional implementation using the hardware I2C/TWI 28 | peripheral should implement the same functions so either implementation 29 | can be used. 30 | 31 | */ 32 | 33 | #ifndef I2C_H 34 | #define I2C_H 35 | 36 | #ifdef HAVE_I2C 37 | 38 | typedef struct i2cblock_s { 39 | unsigned int length; 40 | void *data; 41 | struct i2cblock_s *next; 42 | } i2cblock_t; 43 | 44 | void i2c_init(void); 45 | uint8_t i2c_write_register(uint8_t address, uint8_t reg, uint8_t val); 46 | uint8_t i2c_write_registers(uint8_t address, uint8_t startreg, uint8_t count, const void *data); 47 | int16_t i2c_read_register(uint8_t address, uint8_t reg); 48 | uint8_t i2c_read_registers(uint8_t address, uint8_t startreg, uint8_t count, void *data); 49 | 50 | /* send a chain of i2cblock_t over the bus */ 51 | uint8_t i2c_write_blocks(uint8_t address, i2cblock_t *head); 52 | 53 | /* write @writeblocks i2cblock_t over the bus, switch to read mode and fill the remaining ones */ 54 | uint8_t i2c_read_blocks(uint8_t address, i2cblock_t *head, unsigned char writeblocks); 55 | 56 | #else 57 | # define i2c_init() do {} while (0) 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/iec-bus.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | iec-bus.h: A few wrappers around the port definitions 25 | 26 | */ 27 | 28 | #ifndef IEC_BUS_H 29 | #define IEC_BUS_H 30 | 31 | /* output functions are defined in arch-config.h */ 32 | 33 | /*** Input definitions (generic versions) ***/ 34 | #ifndef IEC_ATN 35 | # define IEC_ATN (IEC_INPUT & IEC_BIT_ATN) 36 | # define IEC_DATA (IEC_INPUT & IEC_BIT_DATA) 37 | # define IEC_CLOCK (IEC_INPUT & IEC_BIT_CLOCK) 38 | # define IEC_SRQ (IEC_INPUT & IEC_BIT_SRQ) 39 | #endif 40 | 41 | #ifdef IEC_INPUTS_INVERTED 42 | static inline iec_bus_t iec_bus_read(void) { 43 | return (~IEC_INPUT) & (IEC_BIT_ATN | IEC_BIT_DATA | IEC_BIT_CLOCK | IEC_BIT_SRQ); 44 | } 45 | #else 46 | static inline iec_bus_t iec_bus_read(void) { 47 | return IEC_INPUT & (IEC_BIT_ATN | IEC_BIT_DATA | IEC_BIT_CLOCK | IEC_BIT_SRQ); 48 | } 49 | #endif 50 | 51 | void iec_interface_init(void); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/iec.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | iec.h: Definitions for the IEC handling code 25 | 26 | */ 27 | 28 | #ifndef IEC_H 29 | #define IEC_H 30 | 31 | /** 32 | * struct iecflags_t - Bitfield of various flags, mostly IEC-related 33 | * @eoi_recvd : Received EOI with the last byte read 34 | * @command_recvd : Command or filename received 35 | * @jiffy_active : JiffyDOS-capable master detected 36 | * @jiffy_load : JiffyDOS LOAD operation detected 37 | * @dolphin_active : DolphinDOS parallel mode active 38 | * 39 | * NOTE: This was converted from a struct with bitfields to 40 | * a single variable with macros because the struct 41 | * version created worse code on AVR. 42 | * 43 | * This is a bitfield for a number of boolean variables used 44 | * (FIXME: This seems to be truncated) 45 | */ 46 | 47 | #define EOI_RECVD (1<<0) 48 | #define COMMAND_RECVD (1<<1) 49 | #define JIFFY_ACTIVE (1<<2) 50 | #define JIFFY_LOAD (1<<3) 51 | 52 | #ifdef CONFIG_PARALLEL_DOLPHIN 53 | # define DOLPHIN_ACTIVE (1<<4) 54 | #else 55 | # define DOLPHIN_ACTIVE 0 56 | #endif 57 | 58 | typedef struct { 59 | uint8_t iecflags; 60 | enum { BUS_IDLE = 0, BUS_ATNACTIVE, BUS_FOUNDATN, BUS_FORME, BUS_NOTFORME, BUS_ATNFINISH, BUS_ATNPROCESS, BUS_CLEANUP, BUS_SLEEP } bus_state; 61 | enum { DEVICE_IDLE = 0, DEVICE_LISTEN, DEVICE_TALK } device_state; 62 | uint8_t secondary_address; 63 | } iec_data_t; 64 | 65 | extern iec_data_t iec_data; 66 | 67 | uint8_t iec_check_atn(void); 68 | void iec_init(void); 69 | void iec_mainloop(void); 70 | void iec_sleep(bool sleep); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/ieee.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | ieee.h: Definitions for the IEEE-488 handling code 25 | 26 | */ 27 | 28 | #ifndef IEEE_H 29 | #define IEEE_H 30 | 31 | 32 | void ieee488_Init(void); 33 | void ieee488_BusSleep(bool sleep); 34 | void ieee_mainloop(void); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/integer.h: -------------------------------------------------------------------------------- 1 | /* Integer definitions for ff, based on example code from ChaN */ 2 | 3 | #ifndef _INTEGER 4 | 5 | #include 6 | 7 | /* These types are assumed as 16-bit or larger integer */ 8 | typedef int16_t INT; 9 | typedef uint16_t UINT; 10 | 11 | /* These types are assumed as 8-bit integer */ 12 | typedef int8_t CHAR; 13 | typedef uint8_t UCHAR; 14 | typedef uint8_t BYTE; 15 | 16 | /* These types are assumed as 16-bit integer */ 17 | typedef int16_t SHORT; 18 | typedef uint16_t USHORT; 19 | typedef uint16_t WORD; 20 | 21 | /* These types are assumed as 32-bit integer */ 22 | typedef int32_t LONG; 23 | typedef uint32_t ULONG; 24 | typedef uint32_t DWORD; 25 | 26 | /* Boolean type */ 27 | typedef enum { FALSE = 0, TRUE } BOOL; 28 | 29 | #define _INTEGER 30 | #endif 31 | -------------------------------------------------------------------------------- /src/led.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | led.c: Overdesigned LED handling 25 | 26 | */ 27 | 28 | #include "config.h" 29 | #include "buffers.h" 30 | #include "led.h" 31 | 32 | volatile uint8_t led_state; 33 | 34 | /* Notice: leds_init() is in config.h because it's hardware-specific */ 35 | 36 | /** 37 | * update_leds - set LEDs to correspond to the buffer status 38 | * 39 | * This function sets the busy/dirty LEDs to correspond to the current state 40 | * of the buffers, i.e. busy on of at least one non-system buffer is 41 | * allocated and dirty on if at least one buffer is dirty. 42 | * Call if you have manually changed the LEDs and you want to restore the 43 | * "default" state. 44 | */ 45 | void update_leds(void) { 46 | set_busy_led(active_buffers != 0); 47 | set_dirty_led(get_dirty_buffer_count() != 0); 48 | } 49 | -------------------------------------------------------------------------------- /src/led.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | led.h: Definitions for the LEDs 25 | 26 | */ 27 | 28 | #ifndef LED_H 29 | #define LED_H 30 | 31 | #include "config.h" 32 | #include "uart.h" 33 | 34 | /* LED-to-bit mapping - BUSY/DIRTY are only used for SINGLE_LED */ 35 | /* The AVR assembler code relies on LED_ERROR stored in bit 0, bit value 1 */ 36 | #define LED_ERROR 1 37 | #define LED_BUSY 2 38 | #define LED_DIRTY 4 39 | 40 | extern volatile uint8_t led_state; 41 | 42 | /* Update the LEDs to match the buffer state */ 43 | void update_leds(void); 44 | 45 | /* Wrapped in do..while to avoid "ambigious else" warnings */ 46 | #ifdef SINGLE_LED 47 | # define set_dirty_led(x) do{if (x) { led_state |= LED_DIRTY; } else { led_state &= (uint8_t)~LED_DIRTY; }}while(0) 48 | # define set_busy_led(x) do{if (x) { led_state |= LED_BUSY ; } else { led_state &= (uint8_t)~LED_BUSY ; }}while(0) 49 | # define set_error_led(x) do{if (x) { led_state |= LED_ERROR; } else { led_state &= (uint8_t)~LED_ERROR; }}while(0) 50 | #else 51 | static inline __attribute__((always_inline)) void set_error_led(uint8_t state) { 52 | if (state) { 53 | led_state |= LED_ERROR; 54 | } else { 55 | led_state &= ~LED_ERROR; 56 | update_leds(); 57 | } 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/lpc17xx/arch-eeprom.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | arch-eeprom.h: EEPROM access functions 25 | 26 | */ 27 | 28 | #ifndef ARCH_EEPROM_H 29 | #define ARCH_EEPROM_H 30 | 31 | /* EEPROM structure hack, section is mapped to 0x80000000 in the linker script */ 32 | #define EEMEM __attribute__((section(".eeprom"))) 33 | 34 | /* No safety required */ 35 | #define eeprom_safety() do {} while (0) 36 | 37 | uint8_t eeprom_read_byte(void *addr); 38 | uint16_t eeprom_read_word(void *addr); 39 | void eeprom_read_block(void *destptr, void *addr, unsigned int length); 40 | void eeprom_write_byte(void *addr, uint8_t value); 41 | void eeprom_write_word(void *addr, uint16_t value); 42 | void eeprom_write_block(void *srcptr, void *addr, unsigned int length); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/lpc17xx/arch-timer.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | arch-timer.h: Architecture-specific system timer definitions 25 | 26 | */ 27 | 28 | #ifndef ARCH_TIMER_H 29 | #define ARCH_TIMER_H 30 | 31 | /* Types for unsigned and signed tick values */ 32 | typedef uint32_t tick_t; 33 | typedef int32_t stick_t; 34 | 35 | /* Delay functions */ 36 | // FIXME: Is delay_us accurate enough as function? 37 | void delay_us(unsigned int time); 38 | void delay_ms(unsigned int time); 39 | 40 | /* Timeout functions */ 41 | // FIXME: Accurate enough as function? 42 | void start_timeout(unsigned int usecs); 43 | unsigned int has_timed_out(void); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/lpc17xx/bootinfo.S: -------------------------------------------------------------------------------- 1 | /* LPC176x SD boot loader info block 2 | * 3 | * Written 2012 by Ingo Korb, no copyright claimed 4 | */ 5 | #include "asmconfig.h" 6 | 7 | .syntax unified 8 | 9 | /* this is an empty info block, it will be filled by an external script */ 10 | .word 0xffffffff /* CONFIG_BOOT_DEVID */ 11 | .short 0xffff /* BOOT_VERSION */ 12 | .short 0xffff /* CRC16 CCITT */ 13 | -------------------------------------------------------------------------------- /src/lpc17xx/crc.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | crc.h: Definitions for CRC calculation routines (ARM version) 25 | 26 | */ 27 | 28 | #ifndef CRC_H 29 | #define CRC_H 30 | 31 | uint8_t crc7update(uint8_t crc, uint8_t data); 32 | uint16_t crc_xmodem_update(uint16_t crc, uint8_t data); 33 | uint16_t crc_xmodem_block(uint16_t crc, const uint8_t *data, uint32_t length); 34 | uint16_t crc16_update(uint16_t crc, uint8_t data); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/lpc17xx/iec-bus.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | iec-bus.c: Architecture-specific IEC bus initialisation 25 | 26 | This is not in arch-config.h becaue using the set_* functions 27 | from iec-bus.h simplifies the code and the ARM version isn't 28 | space-constrained yet. 29 | */ 30 | 31 | #include "config.h" 32 | #include "iec-bus.h" 33 | 34 | void iec_interface_init(void) { 35 | /* Set up outputs before switching the pins */ 36 | set_atn(1); 37 | set_data(1); 38 | set_clock(1); 39 | set_srq(1); 40 | 41 | iec_pins_connect(); 42 | parallel_init(); 43 | } 44 | void bus_interface_init(void) __attribute__ ((weak, alias("iec_interface_init"))); 45 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-ar6.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-ar6.c: Low level handling of AR6 fastloader 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "llfl-common.h" 31 | #include "system.h" 32 | #include "timer.h" 33 | #include "fastloader-ll.h" 34 | 35 | 36 | static const generic_2bit_t ar6_1581_send_def = { 37 | .pairtimes = {50, 130, 210, 290}, 38 | .clockbits = {0, 2, 4, 6}, 39 | .databits = {1, 3, 5, 7}, 40 | .eorvalue = 0 41 | }; 42 | 43 | static const generic_2bit_t ar6_1581p_get_def = { 44 | .pairtimes = {120, 220, 380, 480}, 45 | .clockbits = {7, 6, 3, 2}, 46 | .databits = {5, 4, 1, 0}, 47 | .eorvalue = 0xff 48 | }; 49 | 50 | void ar6_1581_send_byte(uint8_t byte) { 51 | llfl_setup(); 52 | disable_interrupts(); 53 | 54 | /* wait for handshake */ 55 | set_clock(1); 56 | llfl_wait_data(1, NO_ATNABORT); 57 | 58 | /* transmit data */ 59 | llfl_generic_load_2bit(&ar6_1581_send_def, byte); 60 | 61 | /* exit with clock low, data high */ 62 | llfl_set_clock_at(375, 0, NO_WAIT); 63 | llfl_set_data_at( 375, 1, WAIT); 64 | 65 | /* short delay to make sure bus has settled */ 66 | delay_us(10); 67 | 68 | enable_interrupts(); 69 | llfl_teardown(); 70 | } 71 | 72 | uint8_t ar6_1581p_get_byte(void) { 73 | uint8_t result; 74 | 75 | llfl_setup(); 76 | disable_interrupts(); 77 | 78 | set_clock(1); 79 | 80 | /* wait for handshake */ 81 | while (IEC_DATA) ; 82 | llfl_wait_data(1, NO_ATNABORT); 83 | 84 | /* receive data */ 85 | result = llfl_generic_save_2bit(&ar6_1581p_get_def); 86 | 87 | /* exit with clock low */ 88 | llfl_set_clock_at(530, 0, WAIT); 89 | 90 | enable_interrupts(); 91 | llfl_teardown(); 92 | return result; 93 | } 94 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-common.h: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-common.h: Definition for common routines in low-level fastloader impl 23 | 24 | */ 25 | 26 | #ifndef LLFL_COMMON_H 27 | #define LLFL_COMMON_H 28 | 29 | // FIXME: Add a constant for the timer rate (currently 10 ticks per us) 30 | 31 | typedef enum { NO_ATNABORT, ATNABORT } llfl_atnabort_t; 32 | typedef enum { NO_WAIT, WAIT } llfl_wait_t; 33 | 34 | typedef struct { 35 | uint32_t pairtimes[4]; 36 | uint8_t clockbits[4]; 37 | uint8_t databits[4]; 38 | uint8_t eorvalue; 39 | } generic_2bit_t; 40 | 41 | extern uint32_t llfl_reference_time; 42 | 43 | void llfl_setup(void); 44 | void llfl_teardown(void); 45 | void llfl_wait_atn(unsigned int state); 46 | void llfl_wait_clock(unsigned int state, llfl_atnabort_t atnabort); 47 | void llfl_wait_data(unsigned int state, llfl_atnabort_t atnabort); 48 | void llfl_set_clock_at(uint32_t time, unsigned int state, llfl_wait_t wait); 49 | void llfl_set_data_at(uint32_t time, unsigned int state, llfl_wait_t wait); 50 | void llfl_set_srq_at(uint32_t time, unsigned int state, llfl_wait_t wait); 51 | uint32_t llfl_read_bus_at(uint32_t time); 52 | uint32_t llfl_now(void); 53 | void llfl_generic_load_2bit(const generic_2bit_t *def, uint8_t byte); 54 | uint8_t llfl_generic_save_2bit(const generic_2bit_t *def); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-epyxcart.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-epyxcart.c: Low level handling of Epyx Fastload Cart loader 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "llfl-common.h" 31 | #include "system.h" 32 | #include "timer.h" 33 | #include "fastloader-ll.h" 34 | 35 | 36 | static const generic_2bit_t epyxcart_send_def = { 37 | .pairtimes = {100, 200, 300, 400}, 38 | .clockbits = {7, 6, 3, 2}, 39 | .databits = {5, 4, 1, 0}, 40 | .eorvalue = 0xff 41 | }; 42 | 43 | uint8_t epyxcart_send_byte(uint8_t byte) { 44 | uint8_t result = 0; 45 | 46 | llfl_setup(); 47 | disable_interrupts(); 48 | 49 | /* clear bus */ 50 | set_data(1); 51 | set_clock(1); 52 | delay_us(3); 53 | 54 | /* wait for start signal */ 55 | llfl_wait_data(1, ATNABORT); 56 | if (!IEC_ATN) { 57 | result = 1; 58 | goto exit; 59 | } 60 | 61 | /* transmit data */ 62 | llfl_generic_load_2bit(&epyxcart_send_def, byte); 63 | 64 | /* data hold time */ 65 | delay_us(20); 66 | 67 | exit: 68 | disable_interrupts(); 69 | llfl_teardown(); 70 | return result; 71 | } 72 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-n0sdos.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-n0sdos.c: Low level handling of N0stalgia fastloaders 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "llfl-common.h" 31 | #include "system.h" 32 | #include "timer.h" 33 | #include "fastloader-ll.h" 34 | 35 | static const generic_2bit_t n0sdos_send_def = { 36 | .pairtimes = {90, 170, 250, 330}, 37 | .clockbits = {0, 2, 4, 6}, 38 | .databits = {1, 3, 5, 7}, 39 | .eorvalue = 0xff 40 | }; 41 | 42 | void n0sdos_send_byte(uint8_t byte) { 43 | llfl_setup(); 44 | disable_interrupts(); 45 | 46 | /* wait for handshake */ 47 | set_clock(1); 48 | set_data(1); 49 | llfl_wait_clock(1, NO_ATNABORT); 50 | 51 | /* transmit data */ 52 | llfl_generic_load_2bit(&n0sdos_send_def, byte); 53 | 54 | /* exit with clock high, data low */ 55 | llfl_set_clock_at(380, 1, NO_WAIT); 56 | llfl_set_data_at( 380, 0, WAIT); 57 | 58 | /* C64 sets clock low at 42.5us, make sure we exit later than that */ 59 | delay_us(6); 60 | 61 | enable_interrupts(); 62 | llfl_teardown(); 63 | } 64 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-parallel.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-parallel.c: Low level handling of parallel port transfers 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "timer.h" 31 | #include "fastloader-ll.h" 32 | 33 | 34 | uint8_t parallel_read(void) { 35 | return (PARALLEL_PGPIO->FIOPIN >> PARALLEL_PSTARTBIT) & 0xff; 36 | } 37 | 38 | void parallel_write(uint8_t value) { 39 | PARALLEL_PGPIO->FIOPIN = 40 | (PARALLEL_PGPIO->FIOPIN & ~(0xff << PARALLEL_PSTARTBIT)) | 41 | (value << PARALLEL_PSTARTBIT); 42 | delay_us(1); 43 | } 44 | 45 | void parallel_set_dir(parallel_dir_t direction) { 46 | if (direction == PARALLEL_DIR_IN) { 47 | /* set all lines high - FIODIR is not used in open drain mode */ 48 | PARALLEL_PGPIO->FIOSET |= 0xff << PARALLEL_PSTARTBIT; 49 | } 50 | } 51 | 52 | void parallel_send_handshake(void) { 53 | PARALLEL_HGPIO->FIOCLR = BV(PARALLEL_HSK_OUT_BIT); 54 | delay_us(2); 55 | PARALLEL_HGPIO->FIOSET = BV(PARALLEL_HSK_OUT_BIT); 56 | } 57 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-turbodisk.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-turbodisk.c: Low level handling of Turbodisk fastloader 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "llfl-common.h" 31 | #include "timer.h" 32 | #include "fastloader-ll.h" 33 | 34 | static const generic_2bit_t turbodisk_byte_def = { 35 | .pairtimes = {310, 600, 890, 1180}, 36 | .clockbits = {7, 5, 3, 1}, 37 | .databits = {6, 4, 2, 0}, 38 | .eorvalue = 0 39 | }; 40 | 41 | void turbodisk_byte(uint8_t value) { 42 | llfl_setup(); 43 | 44 | /* wait for handshake */ 45 | while (IEC_DATA) ; 46 | set_clock(1); 47 | llfl_wait_data(1, NO_ATNABORT); 48 | 49 | /* transmit data */ 50 | llfl_generic_load_2bit(&turbodisk_byte_def, value); 51 | 52 | /* exit with clock low, data high */ 53 | llfl_set_clock_at(1470, 0, NO_WAIT); 54 | llfl_set_data_at( 1470, 1, WAIT); 55 | delay_us(5); 56 | 57 | llfl_teardown(); 58 | } 59 | 60 | void turbodisk_buffer(uint8_t *data, uint8_t length) { 61 | unsigned int pair; 62 | uint32_t ticks; 63 | 64 | llfl_setup(); 65 | 66 | /* wait for handshake */ 67 | while (IEC_DATA) ; 68 | set_clock(1); 69 | llfl_wait_data(1, NO_ATNABORT); 70 | 71 | ticks = 70; 72 | while (length--) { 73 | uint8_t byte = *data++; 74 | 75 | ticks += 120; 76 | for (pair = 0; pair < 4; pair++) { 77 | ticks += 240; 78 | llfl_set_clock_at(ticks, byte & 0x80, NO_WAIT); 79 | llfl_set_data_at (ticks, byte & 0x40, WAIT); 80 | ticks += 50; 81 | byte <<= 2; 82 | } 83 | ticks += 100; 84 | } 85 | 86 | ticks += 110; 87 | 88 | llfl_set_clock_at(ticks, 0, NO_WAIT); 89 | llfl_set_data_at( ticks, 1, WAIT); 90 | delay_us(5); 91 | 92 | llfl_teardown(); 93 | } 94 | -------------------------------------------------------------------------------- /src/lpc17xx/llfl-ulm3.c: -------------------------------------------------------------------------------- 1 | /* sd2iec - SD/MMC to Commodore serial bus interface/controller 2 | Copyright (C) 2007-2017 Ingo Korb 3 | 4 | Inspired by MMC2IEC by Lars Pontoppidan et al. 5 | 6 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; version 2 of the License only. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | 22 | llfl-ulm3.c: Low level handling of ULoad Model 3 fastloader 23 | 24 | */ 25 | 26 | #include "config.h" 27 | #include 28 | #include 29 | #include "iec-bus.h" 30 | #include "llfl-common.h" 31 | #include "system.h" 32 | #include "timer.h" 33 | #include "fastloader-ll.h" 34 | 35 | 36 | static const generic_2bit_t uload3_get_def = { 37 | .pairtimes = {140, 240, 380, 480}, 38 | .clockbits = {7, 6, 3, 2}, 39 | .databits = {5, 4, 1, 0}, 40 | .eorvalue = 0xff 41 | }; 42 | 43 | static const generic_2bit_t uload3_send_def = { 44 | .pairtimes = {140, 220, 300, 380}, 45 | .clockbits = {0, 2, 4, 6}, 46 | .databits = {1, 3, 5, 7}, 47 | .eorvalue = 0 48 | }; 49 | 50 | int16_t uload3_get_byte(void) { 51 | uint8_t result; 52 | 53 | /* initial handshake */ 54 | set_clock(0); 55 | while (IEC_DATA && IEC_ATN) ; 56 | if (!IEC_ATN) 57 | return -1; 58 | 59 | llfl_setup(); 60 | disable_interrupts(); 61 | 62 | /* wait for start signal */ 63 | set_clock(1); 64 | llfl_wait_data(1, NO_ATNABORT); 65 | 66 | /* receive data */ 67 | result = llfl_generic_save_2bit(&uload3_get_def); 68 | 69 | /* wait until the C64 releases the bus */ 70 | delay_us(20); 71 | 72 | enable_interrupts(); 73 | llfl_teardown(); 74 | return result; 75 | } 76 | 77 | void uload3_send_byte(uint8_t byte) { 78 | llfl_setup(); 79 | disable_interrupts(); 80 | 81 | /* initial handshake */ 82 | set_data(0); 83 | while (IEC_CLOCK && IEC_ATN) ; 84 | if (!IEC_ATN) 85 | goto exit; 86 | 87 | /* wait for start signal */ 88 | set_data(1); 89 | llfl_wait_clock(1, ATNABORT); 90 | if (!IEC_ATN) 91 | goto exit; 92 | 93 | /* transmit data */ 94 | llfl_generic_load_2bit(&uload3_send_def, byte); 95 | 96 | /* exit with clock+data high */ 97 | llfl_set_clock_at(480, 1, NO_WAIT); 98 | llfl_set_data_at (480, 1, WAIT); 99 | 100 | exit: 101 | enable_interrupts(); 102 | llfl_teardown(); 103 | } 104 | -------------------------------------------------------------------------------- /src/lpc17xx/progmem.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | progmem.h: avr/pgmspace.h wrapper header 25 | 26 | */ 27 | 28 | #ifndef PROGMEM_H 29 | #define PROGMEM_H 30 | 31 | /* No-op wrappers for AVR progmem functions */ 32 | #define PROGMEM const 33 | #define PSTR(x) (x) 34 | #define pgm_read_word(x) (*(x)) 35 | #define pgm_read_byte(x) (*(x)) 36 | 37 | #define memcpy_P(dest,src,n) memcpy(dest,src,n) 38 | #define memcmp_P(s1,s2,n) memcmp(s1,s2,n) 39 | #define strcpy_P(dest,src) strcpy(dest,src) 40 | #define strcmp_P(s1,s2) strcmp(s1,s2) 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/lpc17xx/pseudoboot.S: -------------------------------------------------------------------------------- 1 | /* pre-startup code for LPC17xx 2 | * 3 | * Written 2012 by Ingo Korb, no copyright claimed 4 | */ 5 | #include "asmconfig.h" 6 | 7 | /* address definitions */ 8 | /* CMSIS only provides C structs, nothing assembler-friendly */ 9 | #define VTOR_Offset 8 10 | 11 | .syntax unified 12 | 13 | .section .bootvectors 14 | 15 | .macro except label 16 | .word __unhandled_exception 17 | .endm 18 | 19 | /* Cortex M3 standard except vectors */ 20 | .word __stack 21 | .word _trampoline_start 22 | except NMI_Handler 23 | except HardFault_Handler /* 2 */ 24 | except MemManage_Handler 25 | except BusFault_Handler /* 4 */ 26 | except UsageFault_Handler 27 | .word 0 28 | .word 0 29 | .word 0 30 | .word 0 31 | except SVC_Handler /* 10 */ 32 | except DebugMon_Handler 33 | .word 0 34 | except PendSV_Handler 35 | except SysTick_Handler 36 | 37 | /* External interrupt vectors */ 38 | except WDT_IRQHandler 39 | except TIMER0_IRQHandler 40 | except TIMER1_IRQHandler 41 | except TIMER2_IRQHandler 42 | except TIMER3_IRQHandler 43 | except UART0_IRQHandler /* 20 */ 44 | except UART1_IRQHandler 45 | except UART2_IRQHandler 46 | except UART3_IRQHandler 47 | except PWM1_IRQHandler 48 | except I2C0_IRQHandler 49 | except I2C1_IRQHandler 50 | except I2C2_IRQHandler /* 27 */ 51 | except SPI_IRQHandler 52 | except SSP0_IRQHandler 53 | except SSP1_IRQHandler 54 | except PLL0_IRQHandler 55 | except RTC_IRQHandler 56 | except EINT0_IRQHandler 57 | except EINT1_IRQHandler 58 | except EINT2_IRQHandler 59 | except EINT3_IRQHandler 60 | except ADC_IRQHandler 61 | except BOD_IRQHandler 62 | except USB_IRQHandler 63 | except CAN_IRQHandler 64 | except DMA_IRQHandler 65 | except I2S_IRQHandler 66 | except ENET_IRQHandler 67 | except RIT_IRQHandler 68 | except MCPWM_IRQHandler 69 | except QEI_IRQHandler 70 | except PLL1_IRQHandler 71 | 72 | 73 | /* include the bootloader information block */ 74 | .section .bootinfo 75 | 76 | #include "lpc17xx/bootinfo.S" 77 | 78 | /* ASCII string with additional information, zero-terminated */ 79 | .ascii "NODISKEMU " VERSION LONGVERSION 80 | .byte 0 81 | 82 | 83 | .section .boottrampoline, "x" 84 | 85 | .global _trampoline_start 86 | .thumb_func 87 | 88 | _trampoline_start: 89 | /* change vector table offset */ 90 | ldr r0, =0x4000 91 | ldr r1, =SCB_BASE 92 | str r0, [r1, #VTOR_Offset] 93 | 94 | /* load start address */ 95 | ldr r1, [r0, #4] 96 | 97 | /* jump to main code */ 98 | bx r1 99 | 100 | .end 101 | -------------------------------------------------------------------------------- /src/lpc17xx/rtc_lpc17xx.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | rtc_lpc17xx.c: RTC support for the LPC17xx internal RTC 25 | 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include "config.h" 32 | #include "time.h" 33 | #include "uart.h" 34 | #include "rtc.h" 35 | #include "rtc_lpc17xx.h" 36 | 37 | #define SIGNATURE_GPREG0 0xdeadbeef 38 | #define SIGNATURE_GPREG1 0xfce2ea31 39 | 40 | #define CLKEN 0 41 | #define CTCRST 1 42 | 43 | void lpcrtc_init(void) { 44 | if (LPC_RTC->CCR & BV(CLKEN)) { 45 | /* Check for signature in battery-backed bytes to determine if RTC was set*/ 46 | if (LPC_RTC->GPREG0 == SIGNATURE_GPREG0 && 47 | LPC_RTC->GPREG1 == SIGNATURE_GPREG1) { 48 | uart_puts_P(PSTR("LPC RTC ok")); 49 | rtc_state = RTC_OK; 50 | } else { 51 | uart_puts_P(PSTR("LPC RTC invalid (signature)")); 52 | rtc_state = RTC_INVALID; 53 | } 54 | } else { 55 | uart_puts_P(PSTR("LPC RTC invalid (disabled)")); 56 | rtc_state = RTC_INVALID; 57 | } 58 | uart_putcrlf(); 59 | } 60 | void rtc_init(void) __attribute__ ((weak, alias("lpcrtc_init"))); 61 | 62 | void lpcrtc_read(struct tm *time) { 63 | if (rtc_state != RTC_OK) { 64 | memcpy(time, &rtc_default_date, sizeof(struct tm)); 65 | return; 66 | } 67 | 68 | do { 69 | time->tm_sec = LPC_RTC->SEC; 70 | time->tm_min = LPC_RTC->MIN; 71 | time->tm_hour = LPC_RTC->HOUR; 72 | time->tm_mday = LPC_RTC->DOM; 73 | time->tm_mon = LPC_RTC->MONTH; 74 | time->tm_year = LPC_RTC->YEAR - 1900; 75 | time->tm_wday = LPC_RTC->DOW; 76 | } while (time->tm_sec != LPC_RTC->SEC); 77 | } 78 | void read_rtc(struct tm *time) __attribute__ ((weak, alias("lpcrtc_read"))); 79 | 80 | void lpcrtc_set(struct tm *time) { 81 | LPC_RTC->CCR = BV(CTCRST); 82 | LPC_RTC->SEC = time->tm_sec; 83 | LPC_RTC->MIN = time->tm_min; 84 | LPC_RTC->HOUR = time->tm_hour; 85 | LPC_RTC->DOM = time->tm_mday; 86 | LPC_RTC->MONTH = time->tm_mon; 87 | LPC_RTC->YEAR = time->tm_year + 1900; 88 | LPC_RTC->DOW = time->tm_wday; 89 | LPC_RTC->CCR = BV(CLKEN); 90 | LPC_RTC->GPREG0 = SIGNATURE_GPREG0; 91 | LPC_RTC->GPREG1 = SIGNATURE_GPREG1; 92 | rtc_state = RTC_OK; 93 | } 94 | void set_rtc(struct tm *time) __attribute__ ((weak, alias("lpcrtc_set"))); 95 | -------------------------------------------------------------------------------- /src/lpc17xx/spi.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | spi.h: Definitions for the low-level SPI routines - ARM version 25 | 26 | */ 27 | #ifndef SPI_H 28 | #define SPI_H 29 | 30 | /* Low speed 400kHz for init, fast speed <=20MHz (MMC limit) */ 31 | typedef enum { SPI_SPEED_FAST, SPI_SPEED_SLOW } spi_speed_t; 32 | 33 | /* Available SPI devices - special case to select all SD cards for initialisation */ 34 | /* Note: SD cards must be 1 and 2 */ 35 | typedef enum { SPIDEV_NONE = 0, 36 | SPIDEV_CARD0 = 1, 37 | SPIDEV_CARD1 = 2, 38 | SPIDEV_ALLCARDS = 3 } spi_device_t; 39 | 40 | /* Initialize SPI interface */ 41 | void spi_init(spi_speed_t speed); 42 | 43 | /* Select device */ 44 | void spi_select_device(spi_device_t dev); 45 | 46 | /* Transmit a single byte */ 47 | void spi_tx_byte(uint8_t data); 48 | 49 | /* Receive a data block */ 50 | void spi_tx_block(const void *data, unsigned int length); 51 | 52 | /* Receive a single byte */ 53 | uint8_t spi_rx_byte(void); 54 | 55 | /* Receive a data block */ 56 | void spi_rx_block(void *data, unsigned int length); 57 | 58 | /* Switch speed of SPI interface */ 59 | void spi_set_speed(spi_speed_t speed); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/lpc17xx/startup.S: -------------------------------------------------------------------------------- 1 | /* startup code for LPC17xx 2 | * 3 | * Written 2010 by Ingo Korb, no copyright claimed 4 | */ 5 | #include "asmconfig.h" 6 | 7 | .syntax unified 8 | 9 | .section .vectors 10 | 11 | .macro except label 12 | .weak \label 13 | .set \label, __unhandled_exception 14 | .word \label 15 | .endm 16 | 17 | /* Cortex M3 standard except vectors */ 18 | .word __stack 19 | .word _start 20 | except NMI_Handler 21 | except HardFault_Handler /* 2 */ 22 | except MemManage_Handler 23 | except BusFault_Handler /* 4 */ 24 | except UsageFault_Handler 25 | .word 0 26 | .word 0 27 | .word 0 28 | .word 0 29 | except SVC_Handler /* 10 */ 30 | except DebugMon_Handler 31 | .word 0 32 | except PendSV_Handler 33 | except SysTick_Handler 34 | 35 | /* External interrupt vectors */ 36 | except WDT_IRQHandler 37 | except TIMER0_IRQHandler 38 | except TIMER1_IRQHandler 39 | except TIMER2_IRQHandler 40 | except TIMER3_IRQHandler 41 | except UART0_IRQHandler /* 20 */ 42 | except UART1_IRQHandler 43 | except UART2_IRQHandler 44 | except UART3_IRQHandler 45 | except PWM1_IRQHandler 46 | except I2C0_IRQHandler 47 | except I2C1_IRQHandler 48 | except I2C2_IRQHandler /* 27 */ 49 | except SPI_IRQHandler 50 | except SSP0_IRQHandler 51 | except SSP1_IRQHandler 52 | except PLL0_IRQHandler 53 | except RTC_IRQHandler 54 | except EINT0_IRQHandler 55 | except EINT1_IRQHandler 56 | except EINT2_IRQHandler 57 | except EINT3_IRQHandler 58 | except ADC_IRQHandler 59 | except BOD_IRQHandler 60 | except USB_IRQHandler 61 | except CAN_IRQHandler 62 | except DMA_IRQHandler 63 | except I2S_IRQHandler 64 | except ENET_IRQHandler 65 | except RIT_IRQHandler 66 | except MCPWM_IRQHandler 67 | except QEI_IRQHandler 68 | except PLL1_IRQHandler 69 | 70 | 71 | /* include the bootloader information block */ 72 | .section .mainbootinfo 73 | 74 | #include "lpc17xx/bootinfo.S" 75 | 76 | 77 | .section .text 78 | 79 | .global _start 80 | .thumb_func 81 | _start: 82 | /* copy data section to ram */ 83 | ldr r0, =__data_load_start 84 | ldr r1, =__data_load_end 85 | ldr r2, =__data_start 86 | dataloop: 87 | ldr.w r3, [r0], #4 88 | str.w r3, [r2], #4 89 | cmp r0, r1 90 | blo dataloop 91 | 92 | /* clear bss section */ 93 | ldr r0, =__bss_start__ 94 | ldr r1, =__bss_end__ 95 | ldr r2, =0 96 | bssloop: 97 | str.w r2, [r0], #4 98 | cmp r0, r1 99 | blo bssloop 100 | 101 | /* start main() */ 102 | b main 103 | 104 | 105 | /* dummy exception handler: endless loop */ 106 | .weak __unhandled_exception 107 | .thumb_func 108 | __unhandled_exception: 109 | /* turn on LED 4 on an mbed module */ 110 | //ldr r0, =0x2009c038 111 | //ldr r1, =0x800000 112 | //str r1, [r0] 113 | b __unhandled_exception 114 | 115 | .end 116 | -------------------------------------------------------------------------------- /src/menu.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Nils Eilers. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #pragma once 30 | #include 31 | #include "config.h" 32 | 33 | 34 | enum { 35 | SCRN_SPLASH = 1, // Software version info, hardware name 36 | SCRN_STATUS // Disk status, device number, clock 37 | }; 38 | 39 | 40 | #ifdef CONFIG_ONBOARD_DISPLAY 41 | 42 | extern uint8_t menu_system_enabled; 43 | 44 | void lcd_splashscreen(void); 45 | void lcd_draw_screen(uint16_t screen); 46 | void lcd_refresh(void); 47 | void lcd_update_device_addr(void); 48 | void lcd_update_disk_status(void); 49 | void handle_lcd(void); 50 | bool handle_buttons(void); 51 | bool menu(void); 52 | void menu_adjust_contrast(void); 53 | void menu_adjust_brightness(void); 54 | 55 | static inline void lcd_bootscreen(void) { 56 | lcd_draw_screen(SCRN_SPLASH); 57 | } 58 | 59 | #else 60 | 61 | #define menu_system_enabled (0) 62 | 63 | static inline void lcd_bootscreen(void) {} 64 | static inline void lcd_splashscreen(void) {} 65 | static inline void lcd_draw_screen(uint16_t screen) {} 66 | static inline void lcd_refresh(void) {} 67 | static inline void lcd_update_device_addr(void) {} 68 | static inline void handle_lcd(void) {} 69 | static inline bool handle_buttons(void) { return false; } 70 | static inline void lcd_update_disk_status(void) {} 71 | static inline bool menu(void) { return false; } 72 | static inline void menu_adjust_contrast(void) {} 73 | static inline void menu_adjust_brightness(void) {} 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/p00cache.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | p00cache.c: [PSUR]00 name cache 25 | 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include "config.h" 32 | #include "dirent.h" 33 | #include "p00cache.h" 34 | 35 | #include "uart.h" 36 | 37 | typedef struct { 38 | uint32_t cluster; 39 | uint8_t name[CBM_NAME_LENGTH]; 40 | } p00name_t; 41 | 42 | static P00CACHE_ATTRIB p00name_t p00cache[CONFIG_P00CACHE_SIZE / sizeof(p00name_t)]; 43 | static uint8_t cache_part; 44 | static unsigned int entries; 45 | 46 | void p00cache_invalidate(void) { 47 | cache_part = -1; 48 | entries = 0; 49 | } 50 | 51 | uint8_t *p00cache_lookup(uint8_t part, uint32_t cluster) { 52 | /* fail if it's for a different partition */ 53 | if (part != cache_part) 54 | return NULL; 55 | 56 | /* linear search for the correct cluster number */ 57 | /* (binary search was only 6-8% faster overall) */ 58 | for (unsigned int i=0; i 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | p00cache.h: Data structures for the [PSUR]00 name cache 25 | 26 | */ 27 | 28 | #ifndef P00CACHE_H 29 | #define P00CACHE_H 30 | 31 | #include 32 | 33 | #ifdef CONFIG_P00CACHE 34 | 35 | void p00cache_invalidate(void); 36 | uint8_t *p00cache_lookup(uint8_t part, uint32_t cluster); 37 | void p00cache_add(uint8_t part, uint32_t cluster, uint8_t *name); 38 | 39 | #else 40 | 41 | # define p00cache_invalidate() do {} while (0) 42 | # define p00cache_lookup(p,c) NULL 43 | # define p00cache_add(p,c,n) do {} while (0) 44 | 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/parser.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | parser.h: Definitions for the common file name parsers 25 | 26 | */ 27 | 28 | #ifndef PARSER_H 29 | #define PARSER_H 30 | 31 | #include "dirent.h" 32 | #include "ff.h" 33 | 34 | extern partition_t partition[CONFIG_MAX_PARTITIONS]; 35 | extern uint8_t current_part; 36 | extern uint8_t max_part; 37 | 38 | /* Non-zero after any directory change */ 39 | /* Used for disk (image) change detection in some fastloaders */ 40 | /* Must be reset by its user */ 41 | extern uint8_t dir_changed; 42 | 43 | /* Update current_dir in partition array */ 44 | void update_current_dir(path_t *path); 45 | 46 | /* Parse a partition number */ 47 | uint8_t parse_partition(uint8_t **buf); 48 | 49 | /* Performs CBM DOS pattern matching */ 50 | uint8_t match_name(uint8_t *matchstr, cbmdirent_t *dent, uint8_t ignorecase); 51 | 52 | /* Returns the next matching dirent */ 53 | int8_t next_match(dh_t *dh, uint8_t *matchstr, date_t *start, date_t *end, uint8_t type, cbmdirent_t *dent); 54 | 55 | /* Returns the first matching dirent */ 56 | int8_t first_match(path_t *path, uint8_t *matchstr, uint8_t type, cbmdirent_t *dent); 57 | 58 | /* Parses CMD-style directory specifications */ 59 | uint8_t parse_path(uint8_t *in, path_t *path, uint8_t **name, uint8_t parse_always); 60 | 61 | /* Check for invalid characters in a name */ 62 | uint8_t check_invalid_name(uint8_t *name); 63 | 64 | /* Parse a decimal number at str and return a pointer to the following char */ 65 | uint16_t parse_number(uint8_t **str); 66 | 67 | /* parse CMD-style dates */ 68 | uint8_t parse_date(date_t *date, uint8_t **str); 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/pcf8583.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | pcf8583.h: RTC support for PCF8583 chips 25 | 26 | */ 27 | 28 | #ifndef PCF8583_H 29 | #define PCF8583_H 30 | 31 | #include "time.h" 32 | 33 | void pcf8583_init(void); 34 | void pcf8583_read(struct tm *time); 35 | void pcf8583_set(struct tm *time); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/rtc.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | rtc.h: Definitions for RTC support 25 | 26 | rtc.c contains wrapper functions around the best available RTC at 27 | runtime: an interrupt driven softrtc can act as fallback, if the clock 28 | chip wasn't found. The main functions for a particular clock chip are 29 | defined in device-specific .c files, e.g. pcf8583.c. 30 | 31 | */ 32 | 33 | #ifndef RTC_H 34 | #define RTC_H 35 | 36 | #include "time.h" 37 | 38 | typedef enum { 39 | RTC_NOT_FOUND, /* No RTC present */ 40 | RTC_INVALID, /* RTC present, but contents invalid */ 41 | RTC_OK /* RTC present and working */ 42 | } rtcstate_t; 43 | 44 | # ifdef HAVE_RTC 45 | 46 | extern const /* PROGMEM */ struct tm rtc_default_date; 47 | extern rtcstate_t rtc_state; 48 | 49 | /* detect and initialize RTC */ 50 | void rtc_init(void); 51 | 52 | /* Return current time in struct tm */ 53 | void read_rtc(struct tm *time); 54 | 55 | /* Set time from struct tm */ 56 | void set_rtc(struct tm *time); 57 | 58 | # else // HAVE_RTC 59 | 60 | # define rtc_state RTC_NOT_FOUND 61 | 62 | # define rtc_init() do {} while(0) 63 | 64 | # endif // HAVE_RTC 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/rtc_lpc17xx.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | rtc_lpc17xx.h: RTC support for the LPC17xx internal RTC 25 | 26 | */ 27 | 28 | #ifndef RTC_LPC17XX_H 29 | #define RTC_LPC17XX_H 30 | 31 | #include "time.h" 32 | 33 | void lpcrtc_init(void); 34 | void lpcrtc_read(struct tm *time); 35 | void lpcrtc_set(struct tm *time); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/sdcard.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | sdcard.h: Definitions for the SD/MMC access routines 25 | 26 | */ 27 | 28 | #ifndef SDCARD_H 29 | #define SDCARD_H 30 | 31 | #include "diskio.h" 32 | 33 | /* These functions are weak-aliased to disk_... */ 34 | void sd_init(void); 35 | DSTATUS sd_status(BYTE drv); 36 | DSTATUS sd_initialize(BYTE drv); 37 | DRESULT sd_read(BYTE drv, BYTE *buffer, DWORD sector, BYTE count); 38 | DRESULT sd_write(BYTE drv, const BYTE *buffer, DWORD sector, BYTE count); 39 | DRESULT sd_getinfo(BYTE drv, BYTE page, void *buffer); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/softrtc.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | softrtc.h: software RTC emulation 25 | 26 | */ 27 | 28 | #ifndef SOFTRTC_H 29 | #define SOFTRTC_H 30 | 31 | #include "time.h" 32 | 33 | void softrtc_read(struct tm *time); 34 | void softrtc_set(struct tm *time); 35 | void softrtc_init(void); 36 | 37 | #ifdef CONFIG_RTC_SOFTWARE 38 | void softrtc_tick(void); 39 | #else 40 | # define softrtc_tick() do {} while (0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/system.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | system.h: System-specific initialisation 25 | 26 | */ 27 | 28 | #ifndef SYSTEM_H 29 | #define SYSTEM_H 30 | 31 | /* Early initialisation, called immediately in main() */ 32 | void system_init_early(void); 33 | 34 | /* Late initialisation, called after all hardware is set up */ 35 | void system_init_late(void); 36 | 37 | /* Put MCU into low-power mode until the next interrupt */ 38 | void system_sleep(void); 39 | 40 | /* Reset MCU */ 41 | __attribute__((noreturn)) void system_reset(void); 42 | 43 | 44 | 45 | /* AVR Inline Code */ 46 | 47 | #ifdef __AVR__ 48 | 49 | /* Disable interrupts */ 50 | static inline void disable_interrupts(void) { 51 | cli(); 52 | } 53 | 54 | /* Enable interrupts */ 55 | static inline void enable_interrupts(void) { 56 | sei(); 57 | } 58 | 59 | #else 60 | 61 | /* Enable/disable interrupts */ 62 | void disable_interrupts(void); 63 | void enable_interrupts(void); 64 | 65 | #endif 66 | #endif 67 | -------------------------------------------------------------------------------- /src/time.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | time.h: Time structure definition 25 | 26 | */ 27 | 28 | #ifndef TIME_H 29 | #define TIME_H 30 | 31 | typedef uint32_t softtime_t; 32 | struct tm { 33 | uint8_t tm_sec; // 0..59 34 | uint8_t tm_min; // 0..59 35 | uint8_t tm_hour; // 0..23 36 | uint8_t tm_mday; // 1..[28..31] 37 | uint8_t tm_mon; // 0..11 38 | uint8_t tm_year; // since 1900, i.e. 2000 is 100 39 | uint8_t tm_wday; // 0 to 6, sunday is 0 40 | // A Unix struct tm has a few more fields we don't need in this application 41 | }; 42 | 43 | #endif /* TIME_H */ 44 | -------------------------------------------------------------------------------- /src/uart.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | uart.h: Definitions for the UART access routines 25 | 26 | */ 27 | 28 | #ifndef UART_H 29 | #define UART_H 30 | 31 | #ifdef CONFIG_UART_DEBUG 32 | 33 | #include "progmem.h" 34 | 35 | void uart_init(void); 36 | unsigned char uart_getc(void); 37 | void uart_putc(char c); 38 | void uart_puthex(uint8_t num); 39 | void uart_trace(void *ptr, uint16_t start, uint16_t len); 40 | void uart_flush(void); 41 | void uart_puts_P(const char *text); 42 | void uart_putcrlf(void); 43 | 44 | #ifdef __AVR__ 45 | # define printf(str,...) printf_P(PSTR(str), ##__VA_ARGS__) 46 | #endif 47 | 48 | #else 49 | 50 | #define uart_init() do {} while(0) 51 | #define uart_getc() 0 52 | #define uart_putc(x) do {} while(0) 53 | #define uart_puthex(x) do {} while(0) 54 | #define uart_flush() do {} while(0) 55 | #define uart_puts_P(x) do {} while(0) 56 | #define uart_putcrlf() do {} while(0) 57 | #define uart_trace(a,b,c) do {} while(0) 58 | 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/ustring.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | ustring.h: uint8_t wrappers for string.h-functions 25 | 26 | */ 27 | 28 | #ifndef USTRING_H 29 | #define USTRING_H 30 | 31 | #include 32 | 33 | #define ustrcasecmp_P(s1,s2) (strcasecmp_P((char *)(s1), (s2))) 34 | #define ustrchr(s,c) ((uint8_t *)strchr((char *)(s), (c))) 35 | #define ustrcmp(s1,s2) (strcmp((char *)(s1), (char *)(s2))) 36 | #define ustrcmp_P(s1,s2) (strcmp_P((char *)(s1), (s2))) 37 | #define ustrcpy(s1,s2) (strcpy((char *)(s1), (char *)(s2))) 38 | #define ustrcpy_P(s1,s2) (strcpy_P((char *)(s1), (s2))) 39 | #define ustrncpy(s1,s2,n) (strncpy((char *)(s1), (char *)(s2),(n))) 40 | #define ustrncpy_P(s1,s2,n) (strncpy_P((char *)(s1), (char *)(s2), (n))) 41 | #define ustrlen(s) (strlen((char *)(s))) 42 | #define ustrrchr(s,c) ((uint8_t *)strrchr((char *)(s), (c))) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/utils.c: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | utils.c: Misc. utility functions that didn't fit elsewhere 25 | 26 | */ 27 | 28 | #include 29 | #include 30 | #include "utils.h" 31 | 32 | /* Append a decimal number to a string */ 33 | uint8_t *appendnumber(uint8_t *msg, uint8_t value) { 34 | if (value >= 100) { 35 | *msg++ = '0' + value/100; 36 | value %= 100; 37 | } 38 | 39 | *msg++ = '0' + value/10; 40 | *msg++ = '0' + value%10; 41 | 42 | return msg; 43 | } 44 | 45 | /* Convert a one-byte BCD value to a normal integer */ 46 | uint8_t bcd2int(uint8_t value) { 47 | return (value & 0x0f) + 10*(value >> 4); 48 | } 49 | 50 | /* Convert a uint8_t into a BCD value */ 51 | uint8_t int2bcd(uint8_t value) { 52 | return (value % 10) + 16*(value/10); 53 | } 54 | 55 | /* Similiar to strtok_r, but only a single delimiting character */ 56 | uint8_t *ustr1tok(uint8_t *str, const uint8_t delim, uint8_t **saveptr) { 57 | uint8_t *tmp; 58 | 59 | if (str == NULL) 60 | str = *saveptr; 61 | 62 | /* Skip leading delimiters */ 63 | while (*str == delim) str++; 64 | 65 | /* If there is anything left... */ 66 | if (*str) { 67 | /* Search for the next delimiter */ 68 | tmp = str; 69 | while (*tmp && *tmp != delim) tmp++; 70 | 71 | /* Terminate the string there */ 72 | if (*tmp != 0) 73 | *tmp++ = 0; 74 | 75 | *saveptr = tmp; 76 | 77 | return str; 78 | } else 79 | return NULL; 80 | } 81 | 82 | /** 83 | * asc2pet - convert string from ASCII to PETSCII 84 | * @buf: pointer to the string to be converted 85 | * 86 | * This function converts the string in the given buffer from ASCII to 87 | * PETSCII in-place. 88 | */ 89 | void asc2pet(uint8_t *buf) { 90 | uint8_t ch; 91 | while (*buf) { 92 | ch = *buf; 93 | if (ch > 64 && ch < 91) 94 | ch += 128; 95 | else if (ch > 96 && ch < 123) 96 | ch -= 32; 97 | else if (ch > 192 && ch < 219) 98 | ch -= 128; 99 | else if (ch == '~') 100 | ch = 255; 101 | *buf = ch; 102 | buf++; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | /* NODISKEMU - SD/MMC to IEEE-488 interface/controller 2 | Copyright (C) 2007-2018 Ingo Korb 3 | 4 | NODISKEMU is a fork of sd2iec by Ingo Korb (et al.), http://sd2iec.de 5 | 6 | Inspired by MMC2IEC by Lars Pontoppidan et al. 7 | 8 | FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h. 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; version 2 of the License only. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | 24 | utils.c: Misc. utility functions that didn't fit elsewhere 25 | 26 | */ 27 | 28 | #ifndef UTILS_H 29 | #define UTILS_H 30 | 31 | /* Side-effect safe min/max */ 32 | #define max(a,b) \ 33 | ({ typeof (a) _a = (a); \ 34 | typeof (b) _b = (b); \ 35 | _a > _b ? _a : _b; }) 36 | 37 | #define min(a,b) \ 38 | ({ typeof (a) _a = (a); \ 39 | typeof (b) _b = (b); \ 40 | _a < _b ? _a : _b; }) 41 | 42 | 43 | /* Write a number to a string as ASCII */ 44 | uint8_t *appendnumber(uint8_t *msg, uint8_t value); 45 | 46 | /* Convert between integer and BCD */ 47 | uint8_t bcd2int(uint8_t value); 48 | uint8_t int2bcd(uint8_t value); 49 | 50 | /* Tokenize a string like strtok_r, but with a single delimiter character only */ 51 | uint8_t *ustr1tok(uint8_t *str, const uint8_t delim, uint8_t **saveptr); 52 | 53 | /* ASCII to PETSCII string conversion */ 54 | void asc2pet(uint8_t *buf); 55 | // note: not moving pet2asc out of fatops saves 6 bytes on AVR 56 | 57 | #endif 58 | --------------------------------------------------------------------------------