From 8841f4f204a92f99f24b21cf7f5d707eb6b85489 Mon Sep 17 00:00:00 2001 From: markusC64 Date: Sun, 8 Jan 2023 12:44:44 +0100 Subject: [PATCH] LCD version - ported to my version --- .github/workflows/ci.yml | 25 +- .github/workflows/release.yml | 22 +- README.md | 39 ++ README_LCD | 187 +++++++++ configs/config-evo2 | 73 ++++ configs/config-larsp | 7 +- configs/config-lcd | 70 ++++ configs/config-lcdcf | 70 ++++ configs/config-mbed | 4 + configs/config-sw1 | 1 - scripts/Makefile.main | 13 +- src/avr/arch-config.h | 92 +++++ src/buffers.c | 9 + src/d64ops.c | 16 +- src/display_lcd.c | 183 +++++++++ src/display_lcd.h | 67 ++++ src/doscmd.c | 69 +++- src/errormsg.c | 15 + src/fastloader.h | 4 + src/fatops.c | 18 + src/fileops.c | 18 +- src/fl-anotherworld.c | 3 +- src/fl-n0s-iffl.c | 1 + src/lcd.c | 715 ++++++++++++++++++++++++++++++++++ src/lcd.h | 371 ++++++++++++++++++ src/lpc17xx/llfl-common.c | 1 + src/lpc17xx/llfl-dreamload.c | 1 + src/lpc17xx/llfl-hypraload.c | 3 +- src/lpc17xx/llfl-krill.c | 3 +- src/lpc17xx/llfl-ultraboot.c | 3 +- src/main.c | 45 +++ 31 files changed, 2115 insertions(+), 33 deletions(-) create mode 100644 README.md create mode 100644 README_LCD create mode 100644 configs/config-evo2 create mode 100644 configs/config-lcd create mode 100644 configs/config-lcdcf create mode 100644 src/display_lcd.c create mode 100644 src/display_lcd.h create mode 100644 src/lcd.c create mode 100644 src/lcd.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 328898a9..8f7a4058 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,7 @@ name: CI on: push: branches: - - devel - - master + - devel_lcd - testing* jobs: @@ -15,21 +14,31 @@ jobs: - name: Build dist run: | sudo apt-get update - sudo apt-get -y install avr-libc + sudo apt-get -y install avr-libc gcc-arm-none-eabi REV=$(git rev-parse --short HEAD | tr a-z A-Z) VER=94 PLUS=+ - make CONFIG=configs/config-uIEC PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-uIEC3 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-larsp PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-sw1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-sw2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV + make CONFIG=configs/config-uIEC PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-uIEC3 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-larsp PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-sw1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-sw2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-arm2iec1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-petSD PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-evo2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-lcd PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-lcdcf PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD mkdir bin cp obj-m1281-uIEC/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1281-uIEC.bin cp obj-m1281-uIEC3/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1281-uIEC3.bin cp obj-m1284p-larsp/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-larsp.bin cp obj-m1284p-sw1/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-sw1.bin cp obj-m1284p-sw2/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-sw2.bin + cp obj-lpc1768-arm2iec1/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-lpc1768-arm2iec1.bin + cp obj-m1284p-petSD/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-petSD.bin + cp obj-m1284p-evo2/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-evo2.bin + cp obj-m1284p-lcd/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-lcd.bin + cp obj-m1284p-lcdcf/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-lcdcf.bin - name: Upload artifacts uses: actions/upload-artifact@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8365e9e..a20e609b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,22 +14,32 @@ jobs: id: build run: | sudo apt-get update - sudo apt-get -y install avr-libc + sudo apt-get -y install avr-libc gcc-arm-none-eabi REV=$(git rev-parse --short HEAD | tr a-z A-Z) VER=94 PLUS=+ echo "ver=1.0.0atentdead0-${VER}${PLUS}-$REV" >> $GITHUB_OUTPUT - make CONFIG=configs/config-uIEC PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-uIEC3 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-larsp PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-sw1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV - make CONFIG=configs/config-sw2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV + make CONFIG=configs/config-uIEC PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-uIEC3 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-larsp PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-sw1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-sw2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-arm2iec1 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-petSD PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-evo2 PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-lcd PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD + make CONFIG=configs/config-lcdcf PRERELEASE=ATENTDEAD0-${VER}${PLUS}-$REV-LCD mkdir bin cp obj-m1281-uIEC/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1281-uIEC.bin cp obj-m1281-uIEC3/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1281-uIEC3.bin cp obj-m1284p-larsp/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-larsp.bin cp obj-m1284p-sw1/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-sw1.bin cp obj-m1284p-sw2/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-sw2.bin + cp obj-lpc1768-arm2iec1/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-lpc1768-arm2iec1.bin + cp obj-m1284p-petSD/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-petSD.bin + cp obj-m1284p-evo2/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-evo2.bin + cp obj-m1284p-lcd/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-lcd.bin + cp obj-m1284p-lcdcf/sd2iec.bin bin/sd2iec-1.0.0atentdead0-${VER}${PLUS}-$REV-m1284p-lcdcf.bin cd bin zip ../sd2iec-firmware-1.0.0atentdead0-${VER}${PLUS}-$REV.zip sd2iec* cd .. diff --git a/README.md b/README.md new file mode 100644 index 00000000..61280a4d --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ + SD2IEC-LCD +============ + +This is a fork of the official [SD2IEC](https://sd2iec.de/) firmware, with +an additional branch for support of LCDs based upon the version introduced +in the +[Forum64](https://www.forum64.de/index.php?thread/74116-lcd-sd2iec-firmware-1-0-0-f%C3%BCr-larsp-layout/). +It also includes changes done by Javi M to support the C64 Version of +"Another World" and "Wings Of Fury". Original source of this is available +at [github](https://github.com/jamarju/sd2iec-anotherworld/). + +Branches +-------- +These branches are available in this repository: + +- master: contains the original code from [sd2iec.de](https://sd2iec.de/) +- LCD: (this branch) contains the merged code for LCD versions +- c128d-internal: contains additional code for a custom C128D + internal mounted version + +See Also +-------- +- [README](README) of the original SD2IEC +- [README_LCD](README_LCD) for the LCD changes +- [NEWS](NEWS) referring to the original SD2IEC +- [COPYING](COPYING) GPLv2 license + +Note +---- +The maintainer of this repository has done this effort, because he's got +an "evo2"-variant *without* and LCD. So there is no testing possible. + +Pull requests are *very* welcome and will be processed in good faith. + +Special thanks to Ingo Korb and CapFuture1975 and all the others +contributing to SD2IEC. This is be no means my work. I just had the luck, +that trying to pull some pieces together worked out pretty well. + +-- SvOlli diff --git a/README_LCD b/README_LCD new file mode 100644 index 00000000..0aee346a --- /dev/null +++ b/README_LCD @@ -0,0 +1,187 @@ + +Some project history +==================== + +This software is based on the sd2iec-0.10.3 software by Ingo Korb. +First the LCD functionality made by Draco for an older version was added by Seanser. +Then andi6510 added support for DOGM LCD modules based on a ST7036 controller +and did some tidy up work by removing all remaining non-LCD related differences +between Seansers version and the official sd2iec-0.10.3. + +This software was tested on an ATMEGA1284p microcontroller with a ST7036 based +DOGM162 module and another HD44780 based module (exact type unkonwn). + + +New files added on top of sd2iec 0.10.3 +======================================= + +lcd.c - low level LCD driver - initial version from draco, andi6510 added lcd auto detection and st7036 support +lcd.h - low level LCD driver interface +display_lcd.c - high level LCD functions - initial version from draco, andi6510 added contrast setting for st7036 +display_lcd.h - high level LCD functions interface +config-larspLCD - configuration for LarsP hardware with LCD attached +config-evo2 - configuration for hardware sold as "evo2", a slightly modified sw2 +README_LCD - this file + + + +Modified files of sd2iec 0.10.3 +=============================== + +buffer.c - display "READY" when the last buffer has been closed - seems more a hack and should be replaced with a proper solution +d64ops.c - display "LOAD" and "SAVE" when files are accessed in a D64 image +doscmd.c - display various messages on each command - add LCD specific X-commands: XT XA XG XX XC +eeprom.c - add LCD-contrast setting to eeprom storage +errormsg.c - display current error message +fatops.c - display current directory +fileops.c - display "LOAD" and "SAVE" files (CapFuture) +main.c - initialise LCD functions, display welcome screen, debug output of detected LCD type +Makefile - added files display_lcd.c and lcd.c to build process, added prerelease tag LCD + + + +Additional Commands available via IEC +===================================== + +XT* Text Commands +----------------- + +The display can be accessed from the c64! +Use commands "XT1" and "XT2" to send text to display line 1 or 2. +The addressed line will be cleared before text is printed. + +Example 1 - send "Lightyears ahead!" to line1: + +OPEN15,8,15,"XT1Lightyears ahead!" + +The "XTC" command allows to send a control code followed by data, which makes it possible +to program the display from the C64 side, e.g. define own characters. + +Example2 - clear the screen: + +OPEN15,8,15,"XTC"+CHR$(1) will clear the screen. + +Example 3 - define a special character with a "heart" (line 2) and print it 3 times (line 3): +1 OPEN15,8,15 +2 PRINT#15,"XTC"+CHR$(64)+CHR$(27)+CHR$(31)+CHR$(31)+CHR$(14)+CHR$(4)+CHR$(0)+CHR $(0) +3 print#15,"XT1"+CHR$(8)+CHR$(8)+CHR$(8) +4 CLOSE15 + + +Display About Message +---------------------- + +The XA command shows a small about message: + +Example: + +OPEN15,8,15,"XA" + +Display Greetings & Credits +--------------------------- + +The XG command shows the greetings and credits: + +Example: + +OPEN15,8,15,"XG" + + +Undocumented experimental feature +---------------------------------- + +The XX command is not documented. It might cause skynet to +link all computers together to play a game of global +thermonuclear war. + +Maybe your C64 is not connected to skynet, so you'll give it a try. +Good luck! + +Example: + +OPEN15,8,15,"XX" + + +Setup LCD contrast (only for ST7036 based displays) +--------------------------------------------------- + +The XC command changes the display contrast on a ST7036 based display +Valid contrast values go from 0 to 63. + +Example: + +OPEN15,8,15,"XC 40" + +Note: +Once contrast is adjusted properly the setting can be saved with the XW command! + + + +LCD Hardware +============ + +Every HD 44780 or ST7036 compatible displays (2x16 or 2x20 chars) should work +The display is accessed in 4-bit mode. + +Different pinouts have to be used depending on the hardware variant +of the SD2IEC / MMC2IEC device: + +sd2iec V1.4 by Shadowolf (sw1 variant) +MMC2IEC by Lars Pontoppidan (larsp variant) +------------------------------------------- +(original design, also used by PCBs from Peter Sieg) + +Display Atmega +RS PB0 +RW PB1 +E PB2 +DB4 PC4 +DB5 PC5 +DB6 PC6 +DB7 PC7 + + +sd2iec V1.6 by Shadowolf (sw2 variant) +-------------------------------------- +ATTENTION: I have not yet tested this pinout so it might be possible that it is not working. +At least it will be hard to solder the display to PB0,PB1 and PB3 if using a TQFP44 mcu. + +Display Atmega +RS PB0 +RW PB1 +E PB3 + +DB4 PC4 +DB5 PC5 +DB6 PC6 +DB7 PC7 + +For other variants please feel encouraged to change the lcd.h to suit your needs. + + +Credits +======= + +Draco who did most of the LCD functionality +Seanser who started the initial porting from version 0.8 to 0.10.3 +Ingo Korb alias for his great SD2IEC firmware. +Shadowolf for his outstanding hardware designs running the SD2IEC firmware. +Lars Pontoppidan for creating the MMC2IEC in the first place. +Jim Brain & ChaN for basic code like IEC routines and FAT driver. +Commodore for the good times. + +Licence +======= + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License only. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \ No newline at end of file diff --git a/configs/config-evo2 b/configs/config-evo2 new file mode 100644 index 00000000..f5b5de45 --- /dev/null +++ b/configs/config-evo2 @@ -0,0 +1,73 @@ +# This may not look like it, but it's a -*- makefile -*- +# +# sd2iec - SD/MMC to Commodore serial bus interface/controller +# Copyright (C) 2007-2010 Ingo Korb +# +# Inspiration and low-level SD/MMC access based on code from MMC2IEC +# by Lars Pontoppidan et al., see sdcard.c|h and config.h. +# +# FAT filesystem access based on code from ChaN, see tff.c|h. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# config-larsp: sd2iec configuration for SD2IEC evo2 from 16xEight +# +# +# This file is included in the main sd2iec Makefile and also parsed +# into autoconf.h. +CONFIG_ARCH=avr +CONFIG_MCU=atmega1284p +CONFIG_LINKER_RELAX=y +CONFIG_MCU_FREQ=8000000 +CONFIG_BOOTLOADER=y +CONFIG_BOOT_DEVID=0x5053524c +CONFIG_COMMAND_CHANNEL_DUMP=y +# In case someone added a crystal to his board +CONFIG_LOADER_TURBODISK=y +CONFIG_LOADER_FC3=y +CONFIG_LOADER_DREAMLOAD=y +CONFIG_LOADER_ULOAD3=y +CONFIG_LOADER_GIJOE=y +CONFIG_LOADER_EPYXCART=y +CONFIG_LOADER_GEOS=y +CONFIG_LOADER_WHEELS=y +CONFIG_LOADER_NIPPON=y +CONFIG_LOADER_AR6=y +CONFIG_LOADER_ELOAD1=y +CONFIG_HARDWARE_VARIANT=10 +CONFIG_HARDWARE_NAME=mmc2iec +CONFIG_SD_AUTO_RETRIES=10 +CONFIG_SD_DATACRC=y +CONFIG_ERROR_BUFFER_SIZE=46 +CONFIG_COMMAND_BUFFER_SIZE=120 +CONFIG_BUFFER_COUNT=6 +CONFIG_EEPROM_SIZE=512 +CONFIG_EEPROM_OFFSET=512 +CONFIG_MAX_PARTITIONS=4 +CONFIG_RTC_DSRTC=y +CONFIG_REMOTE_DISPLAY=n +CONFIG_DISPLAY_BUFFER_SIZE=40 +CONFIG_LCD_DISPLAY=y +CONFIG_UART_DEBUG=n +CONFIG_HAVE_IEC=y +CONFIG_M2I=y +CONFIG_P00CACHE=y +CONFIG_P00CACHE_SIZE=12000 +CONFIG_HAVE_EEPROMFS=y +CONFIG_LOADER_MMZAK=y +CONFIG_LOADER_N0SDOS=y +CONFIG_LOADER_SAMSJOURNEY=y +CONFIG_LOADER_ANOTHERWORLD=y +CONFIG_LOADER_WINGSOFFURY=y +CONFIG_LOADER_N0S_IFFL=Y diff --git a/configs/config-larsp b/configs/config-larsp index 427f8d5f..3f0f4e8e 100644 --- a/configs/config-larsp +++ b/configs/config-larsp @@ -54,9 +54,10 @@ CONFIG_ERROR_BUFFER_SIZE=100 CONFIG_COMMAND_BUFFER_SIZE=120 CONFIG_BUFFER_COUNT=6 CONFIG_MAX_PARTITIONS=4 -CONFIG_RTC_PCF8583=y -CONFIG_RTC_DSRTC=y -CONFIG_REMOTE_DISPLAY=y +CONFIG_RTC_PCF8583=n +CONFIG_RTC_DSRTC=n +CONFIG_LCD_DISPLAY=y +CONFIG_REMOTE_DISPLAY=n CONFIG_DISPLAY_BUFFER_SIZE=40 CONFIG_HAVE_IEC=y CONFIG_M2I=y diff --git a/configs/config-lcd b/configs/config-lcd new file mode 100644 index 00000000..74be4fea --- /dev/null +++ b/configs/config-lcd @@ -0,0 +1,70 @@ +# This may not look like it, but it's a -*- makefile -*- +# +# sd2iec - SD/MMC to Commodore serial bus interface/controller +# Copyright (C) 2007-2014 Ingo Korb +# +# Inspired by MMC2IEC by Lars Pontoppidan et al. +# +# FAT filesystem access based on code from ChaN, see tff.c|h. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# config-larsp: sd2iec configuration for Lars Pontoppidan's MMC2IEC +# +# +# This file is included in the main sd2iec Makefile and also parsed +# into autoconf.h. + +CONFIG_ARCH=avr +CONFIG_MCU=atmega1284p +CONFIG_LINKER_RELAX=y +CONFIG_MCU_FREQ=8000000 +CONFIG_BOOTLOADER=y +CONFIG_BOOT_DEVID=0x5053524c +CONFIG_COMMAND_CHANNEL_DUMP=y +# In case someone added a crystal to his board +CONFIG_LOADER_TURBODISK=y +CONFIG_LOADER_FC3=y +CONFIG_LOADER_DREAMLOAD=y +CONFIG_LOADER_ULOAD3=y +CONFIG_LOADER_GIJOE=y +CONFIG_LOADER_EPYXCART=y +CONFIG_LOADER_GEOS=y +CONFIG_LOADER_WHEELS=y +CONFIG_LOADER_NIPPON=y +CONFIG_LOADER_AR6=y +CONFIG_LOADER_ELOAD1=y +CONFIG_HARDWARE_VARIANT=3 +CONFIG_HARDWARE_NAME=mmc2iec +CONFIG_SD_AUTO_RETRIES=10 +CONFIG_SD_DATACRC=y +CONFIG_ERROR_BUFFER_SIZE=100 +CONFIG_COMMAND_BUFFER_SIZE=120 +CONFIG_BUFFER_COUNT=6 +CONFIG_MAX_PARTITIONS=4 +CONFIG_RTC_PCF8583=n +CONFIG_REMOTE_DISPLAY=n +CONFIG_DISPLAY_BUFFER_SIZE=40 +CONFIG_HAVE_IEC=y +CONFIG_M2I=y +CONFIG_P00CACHE=y +CONFIG_P00CACHE_SIZE=12000 +CONFIG_HAVE_EEPROMFS=y +CONFIG_LOADER_MMZAK=y +CONFIG_LOADER_N0SDOS=y +CONFIG_LCD_DISPLAY=y +CONFIG_LOADER_SAMSJOURNEY=y +CONFIG_LOADER_ANOTHERWORLD=y +CONFIG_LOADER_WINGSOFFURY=y +CONFIG_LOADER_N0S_IFFL=Y diff --git a/configs/config-lcdcf b/configs/config-lcdcf new file mode 100644 index 00000000..74be4fea --- /dev/null +++ b/configs/config-lcdcf @@ -0,0 +1,70 @@ +# This may not look like it, but it's a -*- makefile -*- +# +# sd2iec - SD/MMC to Commodore serial bus interface/controller +# Copyright (C) 2007-2014 Ingo Korb +# +# Inspired by MMC2IEC by Lars Pontoppidan et al. +# +# FAT filesystem access based on code from ChaN, see tff.c|h. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# config-larsp: sd2iec configuration for Lars Pontoppidan's MMC2IEC +# +# +# This file is included in the main sd2iec Makefile and also parsed +# into autoconf.h. + +CONFIG_ARCH=avr +CONFIG_MCU=atmega1284p +CONFIG_LINKER_RELAX=y +CONFIG_MCU_FREQ=8000000 +CONFIG_BOOTLOADER=y +CONFIG_BOOT_DEVID=0x5053524c +CONFIG_COMMAND_CHANNEL_DUMP=y +# In case someone added a crystal to his board +CONFIG_LOADER_TURBODISK=y +CONFIG_LOADER_FC3=y +CONFIG_LOADER_DREAMLOAD=y +CONFIG_LOADER_ULOAD3=y +CONFIG_LOADER_GIJOE=y +CONFIG_LOADER_EPYXCART=y +CONFIG_LOADER_GEOS=y +CONFIG_LOADER_WHEELS=y +CONFIG_LOADER_NIPPON=y +CONFIG_LOADER_AR6=y +CONFIG_LOADER_ELOAD1=y +CONFIG_HARDWARE_VARIANT=3 +CONFIG_HARDWARE_NAME=mmc2iec +CONFIG_SD_AUTO_RETRIES=10 +CONFIG_SD_DATACRC=y +CONFIG_ERROR_BUFFER_SIZE=100 +CONFIG_COMMAND_BUFFER_SIZE=120 +CONFIG_BUFFER_COUNT=6 +CONFIG_MAX_PARTITIONS=4 +CONFIG_RTC_PCF8583=n +CONFIG_REMOTE_DISPLAY=n +CONFIG_DISPLAY_BUFFER_SIZE=40 +CONFIG_HAVE_IEC=y +CONFIG_M2I=y +CONFIG_P00CACHE=y +CONFIG_P00CACHE_SIZE=12000 +CONFIG_HAVE_EEPROMFS=y +CONFIG_LOADER_MMZAK=y +CONFIG_LOADER_N0SDOS=y +CONFIG_LCD_DISPLAY=y +CONFIG_LOADER_SAMSJOURNEY=y +CONFIG_LOADER_ANOTHERWORLD=y +CONFIG_LOADER_WINGSOFFURY=y +CONFIG_LOADER_N0S_IFFL=Y diff --git a/configs/config-mbed b/configs/config-mbed index 8a861559..6134bbee 100644 --- a/configs/config-mbed +++ b/configs/config-mbed @@ -67,3 +67,7 @@ CONFIG_REMOTE_DISPLAY=y CONFIG_DISPLAY_BUFFER_SIZE=80 CONFIG_HAVE_IEC=y CONFIG_M2I=y +CONFIG_LOADER_BOOZE=n +CONFIG_LOADER_SPINDLE=n +CONFIG_LOADER_BITFIRE=n +CONFIG_LOADER_SPARKLE=n diff --git a/configs/config-sw1 b/configs/config-sw1 index 827973f1..aa631852 100644 --- a/configs/config-sw1 +++ b/configs/config-sw1 @@ -64,7 +64,6 @@ CONFIG_HAVE_EEPROMFS=y CONFIG_LOADER_MMZAK=y CONFIG_LOADER_N0SDOS=y CONFIG_LOADER_SAMSJOURNEY=y - CONFIG_LOADER_ULTRABOOT=y CONFIG_LOADER_HYPRALOAD=y CONFIG_LOADER_KRILL=y diff --git a/scripts/Makefile.main b/scripts/Makefile.main index d33e87cc..0c3bd816 100644 --- a/scripts/Makefile.main +++ b/scripts/Makefile.main @@ -7,7 +7,7 @@ PATCHLEVEL = 0 FIX = # Forces bootloader version to 0, comment out or leave empty for release -PRERELEASE = atentdead0 +PRERELEASE = -LCD0 #---------------------------------------------------------------------------- # WinAVR Makefile Template written by Eric B. Weddington, Joerg Wunsch, et al. @@ -95,6 +95,11 @@ ifeq ($(CONFIG_UART_DEBUG),y) SRC += $(CONFIG_ARCH)/uart.c endif +ifeq ($(CONFIG_LCD_DISPLAY),y) + SRC += display_lcd.c lcd.c +# NEED_I2C := y +endif + ifeq ($(CONFIG_REMOTE_DISPLAY),y) SRC += display.c NEED_I2C := y @@ -186,12 +191,14 @@ PROGRAMVERSION := $(MAJOR).$(MINOR) BOOT_VERSION := $(BOOT_VERSION)00 endif +LCDVERSION := $(PROGRAMVERSION) ifdef PRERELEASE PROGRAMVERSION := $(PROGRAMVERSION)$(PRERELEASE) +LCDVERSION := $(LCDVERSION) endif LONGVERSION := -$(CONFIGSUFFIX) -CDEFS += -DVERSION=\"$(PROGRAMVERSION)\" -DLONGVERSION=\"$(LONGVERSION)\" +CDEFS += -DVERSION=\"$(PROGRAMVERSION)\" -DLONGVERSION=\"$(LONGVERSION)\" -DLCDVERSION=\"$(LCDVERSION)\" # Define programs and commands. @@ -320,8 +327,6 @@ $(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(Q)$(OBJCOPY) -O binary -R .eeprom $< $@ $(E) " CRCGEN $@" $(Q)$(CRCGEN) $@ $(BINARY_LENGTH) $(CONFIG_BOOT_DEVID) $(BOOT_VERSION) - $(E) " COPY sd2iec-$(CONFIGSUFFIX)-$(PROGRAMVERSION).bin" - $(Q)$(COPY) $@ $(OBJDIR)/sd2iec-$(CONFIGSUFFIX)-$(PROGRAMVERSION).bin else $(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(E) " BIN $@" diff --git a/src/avr/arch-config.h b/src/avr/arch-config.h index d674a757..e699405d 100644 --- a/src/avr/arch-config.h +++ b/src/avr/arch-config.h @@ -1124,6 +1124,98 @@ static inline void buttons_init(void) { PORTB |= BUTTON_NEXT | BUTTON_PREV; } +#elif CONFIG_HARDWARE_VARIANT == 10 +/* ---------- Hardware configuration: evo2 ---------- */ +# define HAVE_SD +# define SD_CHANGE_HANDLER ISR(INT0_vect) +# define SD_SUPPLY_VOLTAGE (1L<<21) + +# define SPI_DIVISOR_SLOW 32 +# define SPI_DIVISOR_FAST 4 + +static inline void sdcard_interface_init(void) { + DDRD &= ~_BV(PD2); + PORTD |= _BV(PD2); + DDRD &= ~_BV(PD6); + PORTD |= _BV(PD6); + EICRA |= _BV(ISC00); + EIMSK |= _BV(INT0); +} + +static inline uint8_t sdcard_detect(void) { + return !(PIND & _BV(PD2)); +} + +static inline uint8_t sdcard_wp(void) { + return PIND & _BV(PD6); +} + +static inline uint8_t device_hw_address(void) { + return 8 + !(PINA & _BV(PA2)) + 2*!(PINA & _BV(PA3)); +} + +static inline void device_hw_address_init(void) { + DDRA &= ~(_BV(PA2)|_BV(PA3)); + PORTA |= _BV(PA2)|_BV(PA3); +} + +static inline void leds_init(void) { + DDRA |= _BV(PA0); + DDRA |= _BV(PA1); +} + +static inline __attribute__((always_inline)) void set_busy_led(uint8_t state) { + if (state) + PORTA &= ~_BV(PA0); + else + PORTA |= _BV(PA0); +} + +static inline __attribute__((always_inline)) void set_dirty_led(uint8_t state) { + if (state) + PORTA &= ~_BV(PA1); + else + PORTA |= _BV(PA1); +} + +static inline void toggle_dirty_led(void) { + PINA |= _BV(PA1); +} + +# define IEC_INPUT PINC +# define IEC_DDR DDRC +# define IEC_PORT PORTC +# define IEC_PIN_ATN PC0 +# define IEC_PIN_DATA PC1 +# define IEC_PIN_CLOCK PC2 +# define IEC_PIN_SRQ PC3 +# define IEC_ATN_INT_VECT PCINT2_vect +# define IEC_PCMSK PCMSK2 + +static inline void iec_interrupts_init(void) { + PCICR |= _BV(PCIE2); + PCIFR |= _BV(PCIF2); +} + +# define BUTTON_NEXT _BV(PA4) +# define BUTTON_PREV _BV(PA5) + +static inline rawbutton_t buttons_read(void) { + return PINA & (BUTTON_NEXT | BUTTON_PREV); +} + +static inline void buttons_init(void) { + DDRA &= (uint8_t)~(BUTTON_NEXT | BUTTON_PREV); + PORTA |= BUTTON_NEXT | BUTTON_PREV; +} + +# define SOFTI2C_PORT PORTA +# define SOFTI2C_PIN PINA +# define SOFTI2C_DDR DDRA +# define SOFTI2C_BIT_SCL PA6 +# define SOFTI2C_BIT_SDA PA7 +# define SOFTI2C_BIT_INTRQ PA5 +# define SOFTI2C_DELAY 6 #else # error "CONFIG_HARDWARE_VARIANT is unset or set to an unknown value." diff --git a/src/buffers.c b/src/buffers.c index fc23aed4..a527e009 100644 --- a/src/buffers.c +++ b/src/buffers.c @@ -31,6 +31,11 @@ #include "led.h" #include "buffers.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#include "iec.h" +#endif + dh_t matchdh; uint8_t ops_scratch[33]; @@ -218,6 +223,10 @@ void free_buffer(buffer_t *buffer) { active_buffers--; update_leds(); + +#ifdef CONFIG_LCD_DISPLAY + if (active_buffers == 0 && !(led_state & LED_ERROR)) DS_READY(device_address); +#endif } /** diff --git a/src/d64ops.c b/src/d64ops.c index 0d1d3e49..7fa90eae 100644 --- a/src/d64ops.c +++ b/src/d64ops.c @@ -43,6 +43,10 @@ /* Max 7 additional tracks with 17 256 byte sectors each + 802 error bytes */ #define D41_SIZE_MAX (D41_SIZE_MIN + 7*17*256 + 802) +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#endif + #define D41_BAM_TRACK 18 #define D41_BAM_SECTOR 0 #define D41_BAM_BYTES_PER_TRACK 4 @@ -1521,6 +1525,10 @@ static uint16_t d64_freeblocks(uint8_t part) { static void d64_open_read(path_t *path, cbmdirent_t *dent, buffer_t *buf) { /* Read the directory entry of the file */ +#ifdef CONFIG_LCD_DISPLAY + DS_LOAD((char *) dent->name); +#endif + if (read_entry(path->part, &dent->pvt.dxx.dh, ops_scratch)) return; @@ -1553,6 +1561,10 @@ static void d64_open_write(path_t *path, cbmdirent_t *dent, uint8_t type, buffer while (!current_error && buf->data[0]) buf->refill(buf); +#ifdef CONFIG_LCD_DISPLAY + DS_SAVE((char *) dent->name); +#endif + if (current_error) return; @@ -2306,8 +2318,8 @@ static void d64_format(path_t *path, uint8_t *name, uint8_t *id) { if (d64_getid(path, idbuf)) return; - if ((partition[part].imagetype & D64_TYPE_MASK) == D64_TYPE_D71) - if (d64_format_track(part, buf, 53)) + if ((partition[part].imagetype & D64_TYPE_MASK) == D64_TYPE_D71) + if (d64_format_track(part, buf, 53)) return; /* clear the entire directory track */ diff --git a/src/display_lcd.c b/src/display_lcd.c new file mode 100644 index 00000000..b40bff50 --- /dev/null +++ b/src/display_lcd.c @@ -0,0 +1,183 @@ +/* + SD2IEC LCD - SD/MMC to Commodore IEC bus controller with LCD support. + Created 2008,2009 by Sascha Bader + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + display_lcd.h: lcd display routines and data +*/ + +#include "display_lcd.h" +#include + +#include "uart.h" +#include + +uint8_t buffer_msg[3]; +uint8_t fs_mode; +uint8_t lcdcontrast; // andi6510: global LCD contrast setting + + +static const char mychars[64] PROGMEM = { + 0x00, 0x01, 0x07, 0x0F, 0x0F, 0x1E, 0x1C, 0x1C, + 0x1F, 0x1F, 0x1F, 0x11, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1E, 0x1C, 0x00, + 0x1C, 0x1E, 0x0F, 0x0F, 0x07, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x11, 0x1F, 0x1F, 0x1F, 0x00, + 0x1C, 0x1E, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x07, 0x02, 0x00, 0x00, + 0x00, 0x1B, 0x1F, 0x1F, 0x0E, 0x04, 0x00, 0x00 + }; + +#ifdef EEE +static const char eee1[16] PROGMEM = { + 0x20, 0x06, 0x07, 0x06, 0x20, 0x20, 0x08, 0x01, 0x02, 0x06, 0x07, 0x06, 0x20, 0x07, 0x20, 0x20 +}; + +static const char eee2[16] PROGMEM = { + 0x20, 0x06, 0x20, 0x07, 0x06, 0x20, 0x03, 0x04, 0x05, 0x20, 0x06, 0x07, 0x06, 0x20, 0x06, 0x20 +}; +#endif + +void lcd_clrline(int line) +{ + if (lcd_controller_type() != 0) + { + lcd_gotoxy(0,line); + + for (int i=0; i < MAXLINELENGHT; i++) + { + lcd_putc(0x20); + } + lcd_gotoxy(0,line); + } +} + + +void lcd_cmdseq(char * cmdseq) +{ + if (lcd_controller_type() != 0) + { + lcd_command(cmdseq[0]); + lcd_puts(cmdseq+1); + } +} + +void lcd_setCustomChars() +{ + char * progmem_s; + + if (lcd_controller_type() != 0) + { + lcd_command(0x40); // write to CGRAM + progmem_s = (char *) mychars; + for (int i=0;i<64;i++) + { + _delay_us(64); + lcd_data( pgm_read_byte(progmem_s++) ); + } + } +} + +void lcd_eee() +{ +#ifdef EEE + char * progmem_s; + if (lcd_controller_type() != 0) + { + lcd_setCustomChars(); + lcd_clrscr(); + lcd_gotoxy(0,0); + progmem_s = (char *) eee1; + for (int j=0;j<16;j++) + { + lcd_putc( pgm_read_byte(progmem_s++) ); + } + lcd_gotoxy(0,1); + progmem_s = (char *) eee2; + for (int j=0;j<16;j++) + { + lcd_putc( pgm_read_byte(progmem_s++) ); + } + } +#endif +} + +void lcd_logo() +{ + if (lcd_controller_type() != 0) + { + lcd_setCustomChars(); + lcd_clrscr(); + lcd_putc(0); // andi6510 - initally the character 8 was set but on my DOG-M display this was not the correct one... + lcd_putc(1); + lcd_putc(2); + lcd_gotoxy(0,1); + lcd_putc(3); + lcd_putc(4); + lcd_putc(5); + lcd_gotoxy(4,0); + lcd_puts_p(PSTR("Commodore")); + lcd_gotoxy(4,1); + lcd_puts_p(PSTR("never dies!")); + } +} + +void lcd_ready(uint8_t dev_addr) +{ + char *msg = (char *) buffer_msg; + + if (lcd_controller_type() != 0) + { + //memset(buffer_da,0,sizeof(buffer_da)); + lcd_clrline(1); + lcd_puts_p(PSTR("READY:")); + *msg++ = '0' + dev_addr/10; + *msg++ = '0' + dev_addr%10; + *msg++ = '\0'; + lcd_puts((char*)buffer_msg); + } +} + +void lcd_path(char * fs_path) +{ + char *msg = (char *) buffer_msg; + + if (lcd_controller_type() != 0) + { + //memset(buffer_da,0,sizeof(buffer_da)); + lcd_clrline(0); + if (fs_mode == 0) *msg++ = 'D'; + else + *msg++ = 'I'; + // *msg++ = '0' + fs_mode%10; + *msg++ = '\0'; + lcd_puts((char*)buffer_msg); + lcd_puts_p(PSTR(":")); + lcd_puts((char*)fs_path); + } +} + +void lcd_contrast(uint8_t contrast) +{ + // andi6510: in case we have a st7036 LCD set contrast value by software + if (lcd_controller_type() == 7) + { + lcdcontrast = contrast; + lcd_command(0x29); // activate instruction table 1 + lcd_command(0x50 | ((0x30 & contrast) >> 4)); // icon off, booster off, contrast XX.... + lcd_command(0x70 | (0x0F & contrast) ); // contrast ...XXXX + lcd_command(0x28); // activate instruction table 0 + } +} \ No newline at end of file diff --git a/src/display_lcd.h b/src/display_lcd.h new file mode 100644 index 00000000..e1f32d04 --- /dev/null +++ b/src/display_lcd.h @@ -0,0 +1,67 @@ +/* + SD2IEC LCD - SD/MMC to Commodore IEC bus controller with LCD support. + Created 2008,2009 by Sascha Bader + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + display_lcd.c: lcd display routines and data +*/ + +#ifndef DISPLAY_LCD +#define DISPLAY_LCD + +#include "lcd.h" + +#define MAXLINELENGHT 20 + +#define DS_CLR lcd_clrscr(); +#define DS_CLRLINE(A) lcd_clrline(A); +#define DS_READY(A) lcd_ready(A); +#define DS_INIT lcd_init(LCD_DISP_ON); + +#define DS_CTRL(A) lcd_cmdseq(A); + +#define DS_LOGO lcd_logo(); + +#define DS_PUTS(A) lcd_puts(A); +#define DS_PUTSP(A) lcd_puts_p(PSTR(A)); +#define DS_PUTSPP(A) lcd_puts_p(A); + +#define DS_SHOW(A,B) lcd_clrline(A); lcd_puts(B); +#define DS_SHOWP(A,B) lcd_clrline(A); lcd_puts_p(PSTR(B)); + +#define EEE +#define DS_EEE lcd_eee(); +#define DS_CONTRAST(A) lcd_contrast(A); + +#define DS_TITLE lcd_clrline(0); lcd_puts_p(PSTR("SD2IEC " LCDVERSION)); +#define DS_DIR lcd_clrline(1); lcd_puts_p(PSTR("L:$")); +#define DS_LOAD(A) lcd_clrline(1); lcd_puts_p(PSTR("L:")); lcd_puts(A); +#define DS_SAVE(A) lcd_clrline(1); lcd_puts_p(PSTR("S:")); lcd_puts(A); +#define DS_DEL(A) lcd_clrline(1); lcd_puts_p(PSTR("R:")); lcd_puts(A); +#define DS_CD(A) lcd_path(A); +#define DS_SHOWP1(A) lcd_gotoxy(0,1); lcd_puts_p(PSTR(A)); + +void lcd_clrline(int line); +void lcd_cmdseq(char * seq); +void lcd_logo(void); +void lcd_eee(void); +void lcd_setCustomChars(void); +void lcd_ready(uint8_t device); +void lcd_path(char * path); +void lcd_contrast(uint8_t contrast); +extern uint8_t fs_mode; +extern uint8_t lcdcontrast; + +#endif diff --git a/src/doscmd.c b/src/doscmd.c index 733fdb49..ac76af79 100644 --- a/src/doscmd.c +++ b/src/doscmd.c @@ -54,6 +54,10 @@ #include "wrapops.h" #include "doscmd.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#endif + #define CURSOR_RIGHT 0x1d static FIL romfile; @@ -94,6 +98,7 @@ struct fastloader_rxtx_s { fastloader_tx_t txfunc; }; +#ifdef CONFIG_HAVE_IEC static const PROGMEM struct fastloader_rxtx_s fl_rxtx_table[] = { #ifdef CONFIG_LOADER_GEOS [RXTX_GEOS_1MHZ] = { geos_get_byte_1mhz, geos_send_byte_1mhz }, @@ -123,6 +128,7 @@ static const PROGMEM struct fastloader_rxtx_s fl_rxtx_table[] = { [RXTX_BITFIRE_ICLK] = { bitfire_get_byte_data_clk_inv, NULL }, #endif }; +#endif struct fastloader_crc_s { uint16_t crc; @@ -456,7 +462,6 @@ static const PROGMEM struct fastloader_handler_s fl_handler_table[] = { #ifdef CONFIG_LOADER_SPARKLE { 0x0205, FL_NONE, load_sparkle, 0 }, #endif - { 0, FL_NONE, NULL, 0 }, // end marker }; @@ -789,6 +794,10 @@ void do_chdir(uint8_t *parsestr) { if (parse_path(parsestr, &path, &name, 1)) return; +#ifdef CONFIG_LCD_DISPLAY + if (fs_mode == 0) DS_CD((char *)name); +#endif + /* clear '*' file */ previous_file_dirent.name[0] = 0; @@ -867,6 +876,9 @@ static void parse_rmdir(void) { path.dir = partition[part].current_dir; +#ifdef CONFIG_LCD_DISPLAY + ///DS_DEL((char *)&dent); +#endif res = file_delete(&path, &dent); if (res != 255) set_error_ts(ERROR_SCRATCHED,res,0); @@ -2375,6 +2387,61 @@ static void parse_xcommand(void) { clean_cmdbuffer(); switch (command_buffer[1]) { + +#ifdef CONFIG_LCD_DISPLAY + case 'T': + /* Text */ + str = command_buffer+3; + if (command_buffer[2]=='1') + { + DS_SHOW(0,(char *)str); + } + if (command_buffer[2]=='2') + { + DS_SHOW(1,(char *)str); + } + if (command_buffer[2]=='C') + { + DS_CTRL((char *)str); + } + break; + + case 'A': + /* About */ + DS_TITLE; + DS_SHOWP(1,"2009 by S. Bader"); + break; + + case 'G': + /* Greetings / Credits */ + DS_SHOWP(0,"Credits 2 Unseen"); + DS_SHOWP(1," and Shadowolf!"); + break; + + case 'X': + /* eee */ + DS_EEE; + break; + + case 'C': + /* andi6510: LCD contrast */ + str = command_buffer + 2; + num = parse_number(&str); + if (num < 64) + { + char buf[3]; + buf[0]='0'+num/10; + buf[1]='0'+num%10; + buf[2]=0; + DS_SHOWP(1,"Contrast: "); + DS_PUTS(buf); + DS_CONTRAST(num); + } else { + set_error(ERROR_SYNTAX_UNABLE); + } + break; +#endif + case 'E': /* Change file extension mode */ str = command_buffer+2; diff --git a/src/errormsg.c b/src/errormsg.c index fa380c9e..e44209e2 100644 --- a/src/errormsg.c +++ b/src/errormsg.c @@ -38,6 +38,10 @@ #include "ustring.h" #include "utils.h" #include "errormsg.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#include "iec.h" +#endif uint8_t current_error; uint8_t error_buffer[CONFIG_ERROR_BUFFER_SIZE]; @@ -262,9 +266,20 @@ void set_error_ts(uint8_t errornum, uint8_t track, uint8_t sector) { // FIXME: Compare to E648 // NOTE: 1571 doesn't write the BAM and closes some buffers if an error occured led_state |= LED_ERROR; + +#ifdef CONFIG_LCD_DISPLAY + DS_CLRLINE(1); + DS_PUTSP("E:"); + DS_PUTS((char *) error_buffer); +#endif + } else { led_state &= (uint8_t)~LED_ERROR; set_error_led(0); + +#ifdef CONFIG_LCD_DISPLAY + DS_READY(device_address); +#endif } buffers[ERRORBUFFER_IDX].lastused = msg - error_buffer; diff --git a/src/fastloader.h b/src/fastloader.h index 681b0f74..17dc35f6 100644 --- a/src/fastloader.h +++ b/src/fastloader.h @@ -117,6 +117,8 @@ extern uint8_t (*fast_get_byte)(void); uint8_t check_keys(void); bool bus_sleep(uint8_t); +#ifdef CONFIG_HAVE_IEC + /* per-loader functions, located in separate fl-*.c files */ bool load_turbodisk(uint8_t); bool load_fc3(uint8_t freezed); @@ -177,4 +179,6 @@ static inline void parallel_clear_rxflag(void) {} # endif #endif // not assembler +#endif // CONFIG_HAVE_IEC + #endif diff --git a/src/fatops.c b/src/fatops.c index b8b3cfe0..83bede66 100644 --- a/src/fatops.c +++ b/src/fatops.c @@ -50,6 +50,10 @@ #include "wrapops.h" #include "fatops.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#endif + #define P00_HEADER_SIZE 26 #define P00_CBMNAME_OFFSET 8 #define P00_RECORDLEN_OFFSET 25 @@ -1157,6 +1161,10 @@ uint8_t fat_chdir(path_t *path, cbmdirent_t *dent) { partition[path->part].fop = &d64ops; } +#ifdef CONFIG_LCD_DISPLAY + DS_CD((char *)dent->pvt.fat.realname); +#endif + return 0; } } @@ -1552,6 +1560,16 @@ uint8_t image_unmount(uint8_t part) { if (partition[part].fop == &d64ops) d64_unmount(part); +#ifdef CONFIG_LCD_DISPLAY + path_t path; + path.part = part; + path.dir.fat = partition[part].current_dir.fat; + fat_getdirlabel(&path, ops_scratch); + fs_mode = 0; + DS_CD((char*)ops_scratch); + ///DS_TITLE; +#endif + if (display_found) { /* Send current path to display */ path_t path; diff --git a/src/fileops.c b/src/fileops.c index f1cc65c3..95d6fd95 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -45,6 +45,9 @@ #include "utils.h" #include "wrapops.h" #include "fileops.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#endif /* ------------------------------------------------------------------------- */ /* global variables */ @@ -835,6 +838,9 @@ void file_open(uint8_t secondary) { /* Direct access? */ if (command_buffer[0] == '#') { +#ifdef CONFIG_LCD_DISPLAY + DS_LOAD((const char *) command_buffer); +#endif open_buffer(secondary); return; } @@ -910,6 +916,9 @@ void file_open(uint8_t secondary) { /* Load directory? */ if (command_buffer[0] == '$') { +#ifdef CONFIG_LCD_DISPLAY + DS_LOAD((const char *) command_buffer); +#endif load_directory(secondary); return; } @@ -988,8 +997,15 @@ void file_open(uint8_t secondary) { if (filetype == TYPE_DEL) filetype = TYPE_SEQ; } - +#ifdef CONFIG_LCD_DISPLAY + if (mode == OPEN_READ) { + DS_LOAD((const char *) command_buffer); + } +#endif if (mode == OPEN_WRITE) { +#ifdef CONFIG_LCD_DISPLAY + DS_SAVE((const char * ) command_buffer); +#endif if (res == 0) { /* Match found */ if (command_buffer[0] == '@') { diff --git a/src/fl-anotherworld.c b/src/fl-anotherworld.c index d807a023..d373521b 100644 --- a/src/fl-anotherworld.c +++ b/src/fl-anotherworld.c @@ -316,5 +316,6 @@ bool load_anotherworld(UNUSED_PARAMETER) { delay_ms(200); set_dirty_led(0); set_busy_led(0); - return true; + + return true; } diff --git a/src/fl-n0s-iffl.c b/src/fl-n0s-iffl.c index 85325914..58e32a23 100644 --- a/src/fl-n0s-iffl.c +++ b/src/fl-n0s-iffl.c @@ -101,6 +101,7 @@ bool scan_n0s_iffl(UNUSED_PARAMETER) { sector_count++; } free_buffer(buf); + return true; } diff --git a/src/lcd.c b/src/lcd.c new file mode 100644 index 00000000..3709f97b --- /dev/null +++ b/src/lcd.c @@ -0,0 +1,715 @@ +/**************************************************************************** +Title : HD44780U LCD library + Author: Peter Fleury http://jump.to/fleury + File: $Id: lcd.c,v 1.14.2.1 2006/01/29 12:16:41 peter Exp $ + Software: AVR-GCC 3.3 + Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega + + DESCRIPTION + Basic routines for interfacing a HD44780U-based text lcd display + + Originally based on Volker Oth's lcd library, + changed lcd_init(), added additional constants for lcd_command(), + added 4-bit I/O mode, improved and optimized code. + + Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in + 4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported. + + Memory mapped mode compatible with Kanda STK200, but supports also + generation of R/W signal through A8 address line. + + USAGE + See the C include lcd.h file for a description of each function + + HISTORY + Jan 2013: andi6510 added LCD auto detection functionality and support + for ST7036 controllers. + +*****************************************************************************/ +#include +#include +#include +#include +#include "uart.h" +#include "lcd.h" + +static uint8_t lcd_autodetect = 0; + +/* +** constants/macros +*/ +#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */ +#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */ + #define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) ) +#else + #define PIN(x) (*(&x - 2)) /* address of input register of port x */ +#endif + + +#if LCD_IO_MODE +#define lcd_e_delay() __asm__ __volatile__( "rjmp 1f\n 1: rjmp 1f\n 1:" ); // delay 500ns (4 cycles) +#define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN); +#define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN); +#define lcd_e_toggle() toggle_e() +#define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN) +#define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN) +#define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN) +#define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN) +#endif + +#if LCD_IO_MODE +#if LCD_LINES==1 +#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE +#else +#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES +#endif +#else +#if LCD_LINES==1 +#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE +#else +#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES +#endif +#endif + +#if LCD_CONTROLLER_KS0073 +#if LCD_LINES==4 + +#define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x24 /* |0|010|0100 4-bit mode extension-bit RE = 1 */ +#define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x20 /* |0|000|1001 4 lines mode */ +#define KS0073_4LINES_MODE 0x09 /* |0|001|0000 4-bit mode, extension-bit RE = 0 */ + +#endif +#endif + +/* +** function prototypes +*/ +#if LCD_IO_MODE +static void toggle_e(void); +#endif + +/* +** local functions +*/ + + + +/************************************************************************* + delay loop for small accurate delays: 16-bit counter, 4 cycles/loop +*************************************************************************/ +static inline void _delayFourCycles(unsigned int __count) +{ + if ( __count == 0 ) + __asm__ __volatile__( "rjmp 1f\n 1:" ); // 2 cycles + else + __asm__ __volatile__ ( + "1: sbiw %0,1" "\n\t" + "brne 1b" // 4 cycles/loop + : "=w" (__count) + : "0" (__count) + ); +} + + +/************************************************************************* +delay for a minimum of microseconds +the number of loops is calculated at compile-time from MCU clock frequency +*************************************************************************/ +#define delay(us) _delay_us(us) + + +#if LCD_IO_MODE +/* toggle Enable Pin to initiate write */ +static void toggle_e(void) +{ + lcd_e_high(); + lcd_e_delay(); + lcd_e_low(); +} +#endif + + +/************************************************************************* +Low-level function to write byte to LCD controller +Input: data byte to write to LCD + rs 1: write data + 0: write instruction +Returns: none +*************************************************************************/ +#if LCD_IO_MODE +static void lcd_write(uint8_t data,uint8_t rs) +{ + unsigned char dataBits ; + + + if (rs) { /* write data (RS=1, RW=0) */ + lcd_rs_high(); + } else { /* write instruction (RS=0, RW=0) */ + lcd_rs_low(); + } + lcd_rw_low(); + + if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) + && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) ) + { + /* configure data pins as output */ + DDR(LCD_DATA0_PORT) |= 0x0F; + + /* output high nibble first */ + dataBits = LCD_DATA0_PORT & 0xF0; + LCD_DATA0_PORT = dataBits |((data>>4)&0x0F); + lcd_e_toggle(); + + /* output low nibble */ + LCD_DATA0_PORT = dataBits | (data&0x0F); + lcd_e_toggle(); + + /* all data pins high (inactive) */ + LCD_DATA0_PORT = dataBits | 0x0F; + } + else + { + /* configure data pins as output */ + DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN); + DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN); + DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN); + DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN); + + /* output high nibble first */ + LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); + LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); + LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); + LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); + if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); + if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); + if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); + if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); + lcd_e_toggle(); + + /* output low nibble */ + LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN); + LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN); + LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN); + LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); + if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); + if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); + if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); + if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); + lcd_e_toggle(); + + /* all data pins high (inactive) */ + LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); + LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); + LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN); + LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN); + } +} +#else +#define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d; +/* rs==0 -> write instruction to LCD_IO_FUNCTION */ +/* rs==1 -> write data to LCD_IO_DATA */ +#endif + + +/************************************************************************* +Low-level function to read byte from LCD controller +Input: rs 1: read data + 0: read busy flag / address counter +Returns: byte read from LCD controller +*************************************************************************/ +#if LCD_IO_MODE +static uint8_t lcd_read(uint8_t rs) +{ + uint8_t data; + + + if (rs) + lcd_rs_high(); /* RS=1: read data */ + else + lcd_rs_low(); /* RS=0: read busy flag */ + lcd_rw_high(); /* RW=1 read mode */ + + if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT ) + && ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) ) + { + DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */ + + lcd_e_high(); + lcd_e_delay(); + data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */ + lcd_e_low(); + + lcd_e_delay(); /* Enable 500ns low */ + + lcd_e_high(); + lcd_e_delay(); + data |= PIN(LCD_DATA0_PORT)&0x0F; /* read low nibble */ + lcd_e_low(); + } + else + { + /* configure data pins as input */ + DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN); + DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN); + DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN); + DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN); + + /* read high nibble first */ + lcd_e_high(); + lcd_e_delay(); + data = 0; + if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10; + if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20; + if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40; + if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80; + lcd_e_low(); + + lcd_e_delay(); /* Enable 500ns low */ + + /* read low nibble */ + lcd_e_high(); + lcd_e_delay(); + if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01; + if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02; + if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04; + if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08; + lcd_e_low(); + } + return data; +} +#else +#define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ) +/* rs==0 -> read instruction from LCD_IO_FUNCTION */ +/* rs==1 -> read data from LCD_IO_DATA */ +#endif + + +/************************************************************************* +loops while lcd is busy, returns address counter +*************************************************************************/ +static uint8_t lcd_waitbusy(void) + +{ + register uint8_t c; + + if (lcd_autodetect) + { + /* wait until busy flag is cleared */ + while ( (c=lcd_read(0)) & (1<= LCD_START_LINE2) && (pos < LCD_START_LINE3) ) + addressCounter = LCD_START_LINE3; + else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) ) + addressCounter = LCD_START_LINE4; + else + addressCounter = LCD_START_LINE1; +#else + if ( pos < LCD_START_LINE3 ) + addressCounter = LCD_START_LINE2; + else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) ) + addressCounter = LCD_START_LINE3; + else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) ) + addressCounter = LCD_START_LINE4; + else + addressCounter = LCD_START_LINE1; +#endif +#endif + lcd_command((1<>4; + LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // _BV(LCD_FUNCTION_8BIT)>>4; + lcd_e_toggle(); + delay(4992); /* delay, busy flag can't be checked here */ + + /* repeat last command */ + lcd_e_toggle(); + delay(64); /* delay, busy flag can't be checked here */ + + /* repeat last command a third time */ + lcd_e_toggle(); + delay(64); /* delay, busy flag can't be checked here */ + + /* now configure for 4bit mode */ + LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4 + lcd_e_toggle(); + delay(64); /* some displays need this additional delay */ + + /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */ +#else + /* + * Initialize LCD to 8 bit memory mapped mode + */ + + /* enable external SRAM (memory mapped lcd) and one wait state */ + MCUCR = _BV(SRE) | _BV(SRW); + + /* reset LCD */ + delay(16000); /* wait 16ms after power-on */ + lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ + delay(4992); /* wait 5ms */ + lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ + delay(64); /* wait 64us */ + lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */ + delay(64); /* wait 64us */ +#endif + +// andi6510: have to comment this out since KS0073 support would interfere with LCD auto detection if enabled +//#if KS0073_4LINES_MODE +// /* Display with KS0073 controller requires special commands for enabling 4 line mode */ +// lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON); +// lcd_command(KS0073_4LINES_MODE); +// lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF); +//#else +// lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */ +//#endif + + // andi6510: autodetect if LCD is connected + lcd_autodetect = 0; + lcd_write(LCD_FUNCTION_DEFAULT,0); /* function set: display lines */ + c = lcd_read(0) & (1< 0x23 = 35 + lcd_command(0x69); // follower on, amp ratio 1 + lcd_command(LCD_FUNCTION_DEFAULT); // activate instruction table 0 + break; + + case 0: + // sorry, but seems no LCD is attached! + break; + } + + lcd_command(LCD_DISP_OFF); /* display off */ + lcd_clrscr(); /* display clear */ + lcd_command(LCD_MODE_DEFAULT); /* set entry mode */ + lcd_command(dispAttr); /* display/cursor control */ + +}/* lcd_init */ + +uint8_t lcd_controller_type(void) +{ + return lcd_autodetect; +} diff --git a/src/lcd.h b/src/lcd.h new file mode 100644 index 00000000..3a8a1b4d --- /dev/null +++ b/src/lcd.h @@ -0,0 +1,371 @@ +#ifndef LCD_H +#define LCD_H + +/* + Note that this file was changed for: + + SD2IEC LCD - SD/MMC to Commodore IEC bus controller with LCD support. + Created 2008,2009 by Sascha Bader + + Some defines to select different hardware variants were added. + +*/ + +/************************************************************************* + Title : C include file for the HD44780U LCD library (lcd.c) + Author: Peter Fleury http://jump.to/fleury + File: $Id: lcd.h,v 1.13.2.2 2006/01/30 19:51:33 peter Exp $ + Software: AVR-GCC 3.3 + Hardware: any AVR device, memory mapped mode only for AT90S4414/8515/Mega +***************************************************************************/ + +/** + @defgroup pfleury_lcd LCD library + @code #include @endcode + + @brief Basic routines for interfacing a HD44780U-based text LCD display + + Originally based on Volker Oth's LCD library, + changed lcd_init(), added additional constants for lcd_command(), + added 4-bit I/O mode, improved and optimized code. + + Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in + 4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported. + + Memory mapped mode compatible with Kanda STK200, but supports also + generation of R/W signal through A8 address line. + + @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury + + @see The chapter Interfacing a HD44780 Based LCD to an AVR + on my home page. + +*/ + + +/*@{*/ + + +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 303 +#error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !" +#endif + +#include +#include + +/** + * @name Definitions for MCU Clock Frequency + * Adapt the MCU clock frequency in Hz to your target. + */ +#define XTAL 8000000 /**< clock frequency in Hz, used to calculate delay timer */ + + +/** + * @name Definition for LCD controller type + * Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller. + */ +#define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */ + +/** + * @name Definitions for Display Size + * Change these definitions to adapt setting to your display + */ +#define LCD_LINES 2 /**< number of visible lines of the display */ +#define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */ +#define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */ +#define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */ +#define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */ +#define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */ +#define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */ +#define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */ + + +#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */ +#if LCD_IO_MODE +/** + * @name Definitions for 4-bit IO mode + * Change LCD_PORT if you want to use a different port for the LCD pins. + * + * The four LCD data lines and the three control lines RS, RW, E can be on the + * same port or on different ports. + * Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on + * different ports. + * + * Normally the four data lines should be mapped to bit 0..3 on one port, but it + * is possible to connect these data lines in different order or even on different + * ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions. + * + */ + +/*------------------------- Begin of changes by SBa ----------------------- */ + +#include "config.h" + +/* Lars Pontoppidan variant (larsp) */ +#if CONFIG_HARDWARE_VARIANT==3 + +#define LCD_PORT PORTC /**< port for the LCD lines */ +#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ +#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ +#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ +#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ +#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ +#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ +#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ +#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ +#define LCD_RS_PORT PORTB /**< port for RS line */ +#define LCD_RS_PIN 0 /**< pin for RS line */ +#define LCD_RW_PORT PORTB /**< port for RW line */ +#define LCD_RW_PIN 1 /**< pin for RW line */ +#define LCD_E_PORT PORTB /**< port for Enable line */ +#define LCD_E_PIN 2 /**< pin for Enable line */ + +#endif + +/* Shadowolf 1 (sw1) */ +#if CONFIG_HARDWARE_VARIANT==2 + +#define LCD_PORT PORTA /**< port for the LCD lines */ +#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ +#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ +#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ +#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ +#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ +#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ +#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ +#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ +#define LCD_RS_PORT PORTB /**< port for RS line */ +#define LCD_RS_PIN 0 /**< pin for RS line */ +#define LCD_RW_PORT PORTB /**< port for RW line */ +#define LCD_RW_PIN 1 /**< pin for RW line */ +#define LCD_E_PORT PORTB /**< port for Enable line */ +#define LCD_E_PIN 2 /**< pin for Enable line */ + +#endif + +/* Shadowolf 2 variant (sw2) */ +/* added by SBa */ +#if CONFIG_HARDWARE_VARIANT==5 + +#define LCD_PORT PORTB /**< port for the LCD lines */ +#define LCD_DATA0_PORT PORTC /**< port for 4bit data bit 0 */ +#define LCD_DATA1_PORT PORTC /**< port for 4bit data bit 1 */ +#define LCD_DATA2_PORT PORTC /**< port for 4bit data bit 2 */ +#define LCD_DATA3_PORT PORTC /**< port for 4bit data bit 3 */ +#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ +#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ +#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ +#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ +#define LCD_RS_PORT PORTB /**< port for RS line */ +#define LCD_RS_PIN 0 /**< pin for RS line */ +#define LCD_RW_PORT PORTB /**< port for RW line */ +#define LCD_RW_PIN 1 /**< pin for RW line */ +#define LCD_E_PORT PORTB /**< port for Enable line */ +#define LCD_E_PIN 3 /**< pin for Enable line */ + + +#endif + +/*------------------------- End of changes by SBa ----------------------- */ + +/* evo2 variant */ +/* added by 16x8 */ + +#if CONFIG_HARDWARE_VARIANT==10 + +#define LCD_PORT PORTC /**< port for the LCD lines */ +#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ +#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ +#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ +#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ +#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ +#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ +#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ +#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ +#define LCD_RS_PORT PORTB /**< port for RS line */ +#define LCD_RS_PIN 0 /**< pin for RS line */ +#define LCD_RW_PORT PORTB /**< port for RW line */ +#define LCD_RW_PIN 1 /**< pin for RW line */ +#define LCD_E_PORT PORTB /**< port for Enable line */ +#define LCD_E_PIN 2 /**< pin for Enable line */ + +#endif + + + +#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \ + defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \ + defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__) +/* + * memory mapped mode is only supported when the device has an external data memory interface + */ +#define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */ +#define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */ +#define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */ +#else +#error "external data memory interface not available for this device, use 4-bit IO port mode" + +#endif + + +/** + * @name Definitions for LCD command instructions + * The constants define the various LCD controller instructions which can be passed to the + * function lcd_command(), see HD44780 data sheet for a complete description. + */ + +/* instruction register bit positions, see HD44780U data sheet */ +#define LCD_CLR 0 /* DB0: clear display */ +#define LCD_HOME 1 /* DB1: return to home position */ +#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */ +#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */ +#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */ +#define LCD_ON 3 /* DB3: turn lcd/cursor on */ +#define LCD_ON_DISPLAY 2 /* DB2: turn display on */ +#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */ +#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */ +#define LCD_MOVE 4 /* DB4: move cursor/display */ +#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */ +#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */ +#define LCD_FUNCTION 5 /* DB5: function set */ +#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */ +#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */ +#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */ +#define LCD_FUNCTION_IS1 1 /* DB1: instuction set select bit 1 */ +#define LCD_FUNCTION_IS0 0 /* DB0: instuction set select bit 0 */ +#define LCD_CGRAM 6 /* DB6: set CG RAM address */ +#define LCD_DDRAM 7 /* DB7: set DD RAM address */ +#define LCD_BUSY 7 /* DB7: LCD is busy */ + +/* set entry mode: display shift on/off, dec/inc cursor move direction */ +#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */ +#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */ +#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */ +#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */ + +/* display on/off, cursor on/off, blinking char at cursor position */ +#define LCD_DISP_OFF 0x08 /* display off */ +#define LCD_DISP_ON 0x0C /* display on, cursor off */ +#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */ +#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */ +#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */ + +/* move cursor/shift display */ +#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */ +#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */ +#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */ +#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */ + +/* function set: set interface data length and number of display lines */ +#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */ +#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */ +#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */ +#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */ + + +#define LCD_MODE_DEFAULT ((1< #include "config.h" #include "bitband.h" #include "fastloader.h" diff --git a/src/lpc17xx/llfl-dreamload.c b/src/lpc17xx/llfl-dreamload.c index 5867c6ca..04bfc31c 100644 --- a/src/lpc17xx/llfl-dreamload.c +++ b/src/lpc17xx/llfl-dreamload.c @@ -23,6 +23,7 @@ */ +#include #include "config.h" #include "bitband.h" #include "fastloader.h" // for fl_track etc. diff --git a/src/lpc17xx/llfl-hypraload.c b/src/lpc17xx/llfl-hypraload.c index 864ef1b8..796a19cf 100644 --- a/src/lpc17xx/llfl-hypraload.c +++ b/src/lpc17xx/llfl-hypraload.c @@ -26,8 +26,7 @@ */ #include "config.h" -#include -#include +#include "bitband.h" #include "iec-bus.h" #include "llfl-common.h" #include "system.h" diff --git a/src/lpc17xx/llfl-krill.c b/src/lpc17xx/llfl-krill.c index d029193e..fa18e670 100644 --- a/src/lpc17xx/llfl-krill.c +++ b/src/lpc17xx/llfl-krill.c @@ -26,8 +26,7 @@ */ #include "config.h" -#include -#include +#include "bitband.h" #include "llfl-common.h" #include "system.h" #include "fastloader-ll.h" diff --git a/src/lpc17xx/llfl-ultraboot.c b/src/lpc17xx/llfl-ultraboot.c index 573722d1..00c03044 100644 --- a/src/lpc17xx/llfl-ultraboot.c +++ b/src/lpc17xx/llfl-ultraboot.c @@ -26,8 +26,7 @@ */ #include "config.h" -#include -#include +#include "bitband.h" #include "iec-bus.h" #include "llfl-common.h" #include "system.h" diff --git a/src/main.c b/src/main.c index ea412ecc..cc0827e2 100644 --- a/src/main.c +++ b/src/main.c @@ -47,6 +47,10 @@ #include "ustring.h" #include "utils.h" +#ifdef CONFIG_LCD_DISPLAY +#include "display_lcd.h" +#endif + #if defined(__AVR__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 1)) int main(void) __attribute__((OS_main)); @@ -85,6 +89,11 @@ int main(void) { disk_init(); // accesses card read_configuration(); +#ifdef CONFIG_LCD_DISPLAY + /* initialize display, cursor off */ + DS_INIT; +#endif + filesystem_init(0); change_init(); @@ -92,6 +101,27 @@ int main(void) { uart_puthex(device_address); uart_putcrlf(); +#ifdef CONFIG_LCD_DISPLAY + uart_putcrlf(); + uart_puts_P(PSTR("\n\nLCD: ")); + switch(lcd_controller_type()) + { + case 4: + uart_puts_P(PSTR("HD44780 ")); + break; + case 7: + uart_puts_P(PSTR("ST7036 ")); + break; + default: + uart_puts_P(PSTR("none ")); + break; + } + uart_putcrlf(); + + /* clear display and home cursor */ + DS_CLR; +#endif + #ifdef CONFIG_REMOTE_DISPLAY /* at this point all buffers should be free, */ /* so just use the data area of the first to build the string */ @@ -119,6 +149,21 @@ int main(void) { } #endif +#ifdef CONFIG_LCD_DISPLAY + + DS_READY(device_address); + fs_mode = 0; + + /* clear display and home cursor */ + DS_CLR; + DS_LOGO; + + _delay_ms(1000); + + /* put string to display (line 1) with linefeed */ + DS_TITLE; +#endif + bus_mainloop(); while (1);