From 4bdb0d419dd3479098732eae0ce1615205bd97e9 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Sun, 4 Dec 2011 06:31:48 +0000 Subject: [PATCH] added experimental driver for the ancient borg (not testet, yet!) --- borg_hw/Makefile | 4 ++ borg_hw/borg_hw_ancient.c | 119 ++++++++++++++++++++++++++++++++++++++ borg_hw/config.in | 27 ++++----- borg_hw/config_ancient.in | 18 ++++++ profiles/borg-ancient | 108 ++++++++++++++++++++++++++++++++++ 5 files changed, 259 insertions(+), 17 deletions(-) create mode 100644 borg_hw/borg_hw_ancient.c create mode 100644 borg_hw/config_ancient.in create mode 100644 profiles/borg-ancient diff --git a/borg_hw/Makefile b/borg_hw/Makefile index a3b95c9..748424f 100644 --- a/borg_hw/Makefile +++ b/borg_hw/Makefile @@ -46,6 +46,10 @@ ifeq ($(BORG_HW),HW_GIGABORG) SRC = borg_hw_gigaborg.c endif +ifeq ($(BORG_HW),HW_ANCIENTBORG) + SRC = borg_hw_ancient.c +endif + ifeq ($(SRC),'') $(error no valid hardware driver selected ) endif diff --git a/borg_hw/borg_hw_ancient.c b/borg_hw/borg_hw_ancient.c new file mode 100644 index 0000000..523da2c --- /dev/null +++ b/borg_hw/borg_hw_ancient.c @@ -0,0 +1,119 @@ +#include +#include + +#undef WATCHDOG_ENABLED +#ifdef WATCHDOG_ENABLED +# include +#endif + +#include "../config.h" +#include "../makros.h" +#include "borg_hw.h" + +// define row port +#ifndef ROWPORT +# define ROWPORT PORTA +#endif +#define ROWDDR DDR(ROWPORT) + +// define column port +#ifndef COLPORT +# define COLPORT PORTC +#endif +#define COLDDR DDR(COLPORT) + + +// buffer which holds the currently shown frame +unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; + + +SIGNAL(SIG_OUTPUT_COMPARE0) +{ + static unsigned char plane = 0; + static unsigned char row = 0; + +#ifdef WATCHDOG_ENABLED + // reset watchdog + wdt_reset(); +#endif + + ROWPORT = 0; + row++; + if ((COLPORT <<= 1) == 0) { + row = 0; + COLPORT = 1; + + if (++plane == NUMPLANE) + { + plane = 0; + } + } + + for (unsigned char x = 0; x < 10; x++) { + asm volatile ("nop"); + } + + ROWPORT = pixmap[plane][row][0]; +} + +void timer0_off(){ + cli(); + + COLPORT = 0; + ROWPORT = 0; + +#ifdef __AVR_ATmega644P__ + TCCR0A = 0x00; + TCCR0B = 0x00; + TIMSK0 = 0; +#else + TCCR0 = 0x00; + TIMSK = 0; +#endif + + sei(); +} + +static void timer0_on(){ +/* TCCR0: FOC0 WGM00 COM01 COM00 WGM01 CS02 CS01 CS00 + CS02 CS01 CS00 + 0 0 0 stop + 0 0 1 clk + 0 1 0 clk/8 + 0 1 1 clk/64 + 1 0 0 clk/256 + 1 0 1 clk/1024 + +*/ + +#ifdef __AVR_ATmega644P__ + TCCR0A = 0x02; // CTC Mode + TCCR0B = 0x03; // clk/64 + TCNT0 = 0x00; // reset timer + OCR0 = 0x0A; // compare with this value + TIMSK0 = 0x02; // compare match Interrupt on +#else + TCCR0 = 0x0B; // CTC Mode, clk/64 + TCNT0 = 0x00; // reset timer + OCR0 = 0x0A; // compare with this value + TIMSK = 0x02; // compare match Interrupt on +#endif +} + +void borg_hw_init(){ + // switch all pins of both the row and the column port to output mode + ROWDDR = 0xFF; + COLDDR = 0xFF; + + // switch off all rows and columns for now + COLPORT = 0; + ROWPORT = 0; + + timer0_on(); + +#ifdef WATCHDOG_ENABLED + // activate watchdog timer + wdt_reset(); + wdt_enable(0x00); // 17ms watchdog +#endif +} diff --git a/borg_hw/config.in b/borg_hw/config.in index 16b561c..77caf23 100644 --- a/borg_hw/config.in +++ b/borg_hw/config.in @@ -10,14 +10,15 @@ int "Number of brightnes-levels" NUMPLANE 3 choice 'Hardware Driver' \ "Borg-16 HW_BORG_16 \ - Andre-borg HW_BORG_ANDRE \ - Laufschrift-borg HW_BORG_LS \ - Laufschrift-borg-mh HW_BORG_MH \ - Borg-mini HW_BORG_MINI \ + Andre-Borg HW_BORG_ANDRE \ + Laufschrift-Borg HW_BORG_LS \ + Laufschrift-Borg-MH HW_BORG_MH \ + Borg-Mini HW_BORG_MINI \ Panel-One HW_PANEL_ONE \ 4xPD1165 HW_PD1165 \ - PingPong HW_PINGPONG \ - Gigaborg HW_GIGABORG" \ + Ping-Pong HW_PINGPONG \ + Giga-Borg HW_GIGABORG \ + Ancient-Borg HW_ANCIENTBORG" \ 'Borg-16' BORG_HW @@ -61,17 +62,9 @@ if [ "$BORG_HW" == "HW_GIGABORG" ] ; then source borg_hw/config_gigaborg.in fi - - - -# case $x in -# y) flag="*" ;; -# m) flag="M" ;; -# *) flag=" " ;; -# esac - - - +if [ "$BORG_HW" == "HW_ANCIENTBORG" ] ; then + source borg_hw/config_ancient.in +fi endmenu diff --git a/borg_hw/config_ancient.in b/borg_hw/config_ancient.in new file mode 100644 index 0000000..41fb59b --- /dev/null +++ b/borg_hw/config_ancient.in @@ -0,0 +1,18 @@ +mainmenu_option next_comment +comment "Ancient Borg Port Setup" + +choice 'Column Port' \ + "PORTA PORTA \ + PORTB PORTB \ + PORTC PORTC \ + PORTD PORTD" \ + 'PORTC' COLPORT + +choice 'Row Port' \ + "PORTA PORTA \ + PORTB PORTB \ + PORTC PORTC \ + PORTD PORTD" \ + 'PORTA' ROWPORT + +endmenu diff --git a/profiles/borg-ancient b/profiles/borg-ancient new file mode 100644 index 0000000..5a5fdee --- /dev/null +++ b/profiles/borg-ancient @@ -0,0 +1,108 @@ +# +# Automatically generated by make menuconfig: don't edit +# + +# +# General Setup +# +MCU=atmega32 +FREQ=16000000 + +# +# Borg Hardware +# +NUM_ROWS=8 +NUM_COLS=8 +NUMPLANE=3 +BORG_HW=HW_ANCIENTBORG + +# +# Ancient Borg Port Setup +# +COLPORT=PORTC +ROWPORT=PORTA + +# +# Features +# +RANDOM_SUPPORT=y +# LAP_TIME_EXTENSION is not set +SCROLLTEXT_SUPPORT=y +SCROLLTEXT_FONT=FONT_ARIAL8 +SCROLLTEXT_BUFFER_SIZE=128 +SCROLL_X_SPEED=20 +SCROLL_Y_SPEED=20 +SCROLLTEXT_TEXT="