From 0f31feb6bbdc55046d1b81e83831426c552cfb0d Mon Sep 17 00:00:00 2001 From: tixiv Date: Sun, 8 May 2011 20:58:56 +0000 Subject: [PATCH] gigaborg support :-) --- animations/programm.c | 4 +- borg_hw/Makefile | 8 +++ borg_hw/borg_hw_gigaborg.c | 131 +++++++++++++++++++++++++++++++++++++ borg_hw/borg_hw_rotor.c | 103 +++++++++++++++++++++++++++++ borg_hw/config.in | 11 +++- borg_hw/config_gigaborg.in | 88 +++++++++++++++++++++++++ borg_hw/config_rotor.in | 91 ++++++++++++++++++++++++++ config.in | 3 +- ioport.h | 40 +++++++++++ 9 files changed, 475 insertions(+), 4 deletions(-) create mode 100644 borg_hw/borg_hw_gigaborg.c create mode 100644 borg_hw/borg_hw_rotor.c create mode 100644 borg_hw/config_gigaborg.in create mode 100644 borg_hw/config_rotor.in create mode 100644 ioport.h diff --git a/animations/programm.c b/animations/programm.c index 008e6cf..b13541c 100644 --- a/animations/programm.c +++ b/animations/programm.c @@ -115,8 +115,8 @@ void schachbrett(unsigned char times){ clear_screen(0); for (unsigned char i = times; i--;) { for (unsigned char row = 0; row < NUM_ROWS; ++row) { - for (unsigned char col = 0; col < LINEBYTES; ++col) { - pixmap[2][row][col] = ((i ^ row) & 0x01) ? 0x55 : 0xAA; + for (unsigned char col = 0; col < NUM_COLS; ++col) { + setpixel( (pixel){col, row}, ((i ^ row ^ col) & 0x01) ? 0:3 ); } } wait(200); diff --git a/borg_hw/Makefile b/borg_hw/Makefile index 9a2b06c..a3b95c9 100644 --- a/borg_hw/Makefile +++ b/borg_hw/Makefile @@ -38,6 +38,14 @@ ifeq ($(BORG_HW),HW_PINGPONG) SRC = borg_hw_pingpong.c endif +ifeq ($(BORG_HW),HW_ROTOR) + SRC = borg_hw_rotor.c +endif + +ifeq ($(BORG_HW),HW_GIGABORG) + SRC = borg_hw_gigaborg.c +endif + ifeq ($(SRC),'') $(error no valid hardware driver selected ) endif diff --git a/borg_hw/borg_hw_gigaborg.c b/borg_hw/borg_hw_gigaborg.c new file mode 100644 index 0000000..f31b34a --- /dev/null +++ b/borg_hw/borg_hw_gigaborg.c @@ -0,0 +1,131 @@ + +#include "../config.h" +#include "../makros.h" + +#include +#include +#include +#include "borg_hw.h" + +/* +// Diese #defines werden nun durch menuconfig gesetzt + + // 16 Spalten insgesamt direkt gesteuert, dafür 2 Ports +#define COLPORT1 PORTC +#define COLDDR1 DDRC + +#define COLPORT2 PORTA +#define COLDDR2 DDRA + +// Der andere Port übernimmt die Steuerung der Schieberegister +#define ROWPORT PORTD +#define ROWDDR DDRD +// Clock und reset gehen gemeinsam an beide Schieberegister +// der reset pin ist negiert +#define PIN_MCLR PD4 +#define PIN_CLK PD6 +//das dier sind die individuellen Dateneingänge für die Schieberegister +#define PIN_DATA PD7 +*/ + +#define COLDDR1 DDR(COLPORT1) +#define COLDDR2 DDR(COLPORT2) +#define ROWDDR DDR(ROWPORT) + +#ifdef __AVR_ATmega644P__ +/* more ifdef magic :-( */ +#define OCR0 OCR0A +#define SIG_OUTPUT_COMPARE0 SIG_OUTPUT_COMPARE0A +#endif + + +//Der Puffer, in dem das aktuelle Bild gespeichert wird +unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; + + +//Dieser Interrupt wird je nach Ebene mit 50kHz 31,25kHz oder 12,5kHz ausgeführt +SIGNAL(SIG_OUTPUT_COMPARE0) +{ + //Watchdog zurücksetzen + wdt_reset(); + + + COLPORT1 = (pixmap[0][0][0] & 0x0f) | (pixmap[0][1][0] << 4); + COLPORT2 = (pixmap[0][2][0] & 0x0f) | (pixmap[0][3][0] << 4); +} + + +void timer0_off(){ + cli(); + + COLPORT1 = 0; + COLPORT2 = 0; + ROWPORT = 0; + +#ifdef __AVR_ATmega644P__ + TCCR0A = 0x00; + TCCR0B = 0x00; +#else + + TCCR0 = 0x00; +#endif + sei(); +} + + +// Den Timer, der denn Interrupt auslöst, initialisieren +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 = 0x04; // clk/256 + TCNT0 = 0; // reset timer + OCR0 = 20; // Compare with this value + TIMSK0 = 0x02; // Compare match Interrupt on +#else + TCCR0 = 0x0C; // CTC Mode, clk/256 + TCNT0 = 0; // reset timer + OCR0 = 20; // Compare with this value + TIMSK = 0x02; // Compare match Interrupt on +#endif +} + +void borg_hw_init(){ + //Spalten Ports auf Ausgang + COLDDR1 = 0xFF; + COLDDR2 = 0xFF; + + //Pins am Zeilenport auf Ausgang + ROWDDR = (1< +#include +#include +#include "borg_hw.h" + + + +//Der Puffer, in dem das aktuelle Bild gespeichert wird +unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES]; + +//Eine Zeile anzeigen +inline void rowshow(unsigned char row){ + //die Daten für die aktuelle Zeile auf die Spaltentreiber ausgeben + + COLPORT1 = pixmap[0][row][0]; + COLPORT2 = pixmap[0][row][1]; + + OUTPUT_ON(LATCH_R); + OUTPUT_OFF(LATCH_R); + + COLPORT1 = pixmap[1][row][0]; + COLPORT2 = pixmap[1][row][1]; + + OUTPUT_ON(LATCH_G); + OUTPUT_OFF(LATCH_G); + + COLPORT1 = pixmap[2][row][0]; + COLPORT2 = pixmap[2][row][1]; + + OUTPUT_ON(LATCH_B); + OUTPUT_OFF(LATCH_B); +} + + +uint32_t mod = 1280000ul; +uint32_t akku; + +unsigned char row = 0; + +ISR(SIG_OUTPUT_COMPARE0) +{ + //Watchdog zurücksetzen + wdt_reset(); + + akku += mod; + + OCR1A = akku / 256; + + rowshow(row); + + if(++row == NUM_ROWS){ + row = NUM_ROWS - 1; + } + +} + +ISR(INT0_vect){ + if(akku > (64ul * 256ul * 64ul)){ + akku -= OCR1A - TCNT1; + + mod = akku / 64; + akku = 0; + row = 0; + OCR1A = 0; + TCNT1 = 0xffff; + } +} + + +void timer0_off(){ + cli(); + + TCCR1B = 0x00; + + sei(); +} + + +// Den Timer, der denn Interrupt auslöst, initialisieren +void timer1_on(){ + TCCR1B = 1; //clk/1 + TIMSK |= (1<