Browse Source

gigaborg support :-)

feature/2015
tixiv 14 years ago
parent
commit
0f31feb6bb
  1. 4
      animations/programm.c
  2. 8
      borg_hw/Makefile
  3. 131
      borg_hw/borg_hw_gigaborg.c
  4. 103
      borg_hw/borg_hw_rotor.c
  5. 11
      borg_hw/config.in
  6. 88
      borg_hw/config_gigaborg.in
  7. 91
      borg_hw/config_rotor.in
  8. 3
      config.in
  9. 40
      ioport.h

4
animations/programm.c

@ -115,8 +115,8 @@ void schachbrett(unsigned char times){
clear_screen(0); clear_screen(0);
for (unsigned char i = times; i--;) { for (unsigned char i = times; i--;) {
for (unsigned char row = 0; row < NUM_ROWS; ++row) { for (unsigned char row = 0; row < NUM_ROWS; ++row) {
for (unsigned char col = 0; col < LINEBYTES; ++col) { for (unsigned char col = 0; col < NUM_COLS; ++col) {
pixmap[2][row][col] = ((i ^ row) & 0x01) ? 0x55 : 0xAA; setpixel( (pixel){col, row}, ((i ^ row ^ col) & 0x01) ? 0:3 );
} }
} }
wait(200); wait(200);

8
borg_hw/Makefile

@ -38,6 +38,14 @@ ifeq ($(BORG_HW),HW_PINGPONG)
SRC = borg_hw_pingpong.c SRC = borg_hw_pingpong.c
endif 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),'') ifeq ($(SRC),'')
$(error no valid hardware driver selected ) $(error no valid hardware driver selected )
endif endif

131
borg_hw/borg_hw_gigaborg.c

@ -0,0 +1,131 @@
#include "../config.h"
#include "../makros.h"
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>
#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<<PIN_MCLR) | (1<<PIN_CLK) | (1<< PIN_DATA);
//Alle Spalten erstmal aus
COLPORT1 = 0;
COLPORT2 = 0;
//Schieberegister für Zeilen zurücksetzen
ROWPORT = 0;
//Alle Zeilen ausgänge an bei gigaborg
ROWPORT |= (1<<PIN_DATA) | (1<<PIN_MCLR);
uint8_t x;
for(x=0;x<16;x++){
ROWPORT|= (1<<PIN_CLK);
ROWPORT&= ~(1<<PIN_CLK);
}
timer0_on();
//Watchdog Timer aktivieren
wdt_reset();
wdt_enable(0x00); // 17ms Watchdog
}

103
borg_hw/borg_hw_rotor.c

@ -0,0 +1,103 @@
#include "../config.h"
#include "../makros.h"
#include "../ioport.h"
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>
#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<<OCIE1A);
}
void borg_hw_init(){
DDR(COLPORT1) = 0xff;
DDR(COLPORT2) = 0xff;
SET_DDR(LATCH_R);
SET_DDR(LATCH_G);
SET_DDR(LATCH_B);
timer1_on();
//Watchdog Timer aktivieren
wdt_reset();
wdt_enable(0x00); // 17ms Watchdog
}

11
borg_hw/config.in

@ -16,7 +16,8 @@ choice 'Hardware Driver' \
Borg-mini HW_BORG_MINI \ Borg-mini HW_BORG_MINI \
Panel-One HW_PANEL_ONE \ Panel-One HW_PANEL_ONE \
4xPD1165 HW_PD1165 \ 4xPD1165 HW_PD1165 \
PingPong HW_PINGPONG" \ PingPong HW_PINGPONG \
Gigaborg HW_GIGABORG" \
'Borg-16' BORG_HW 'Borg-16' BORG_HW
@ -52,6 +53,14 @@ if [ "$BORG_HW" == "HW_PINGPONG" ] ; then
source borg_hw/config_pingpong.in source borg_hw/config_pingpong.in
fi fi
if [ "$BORG_HW" == "HW_ROTOR" ] ; then
source borg_hw/config_rotor.in
fi
if [ "$BORG_HW" == "HW_GIGABORG" ] ; then
source borg_hw/config_gigaborg.in
fi

88
borg_hw/config_gigaborg.in

@ -0,0 +1,88 @@
mainmenu_option next_comment
comment "Borg16 port setup"
#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_RST PD4
#define PIN_CLK PD6
#//das dier sind die individuellen Dateneingänge für die Schieberegister
#define PIN_SHFT1 PD7
choice 'Column Port 1 (right)' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTC' COLPORT1
choice 'Column Port 2 (left)' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTA' COLPORT2
choice 'port for row shiftregisters' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTD' ROWPORT
comment "pin numbers on shiftregister port"
choice '/MCLR Pin' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin4' PIN_MCLR
choice 'CLK Pin' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin6' PIN_CLK
choice 'DATA Pin' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin7' PIN_DATA
comment "fixing hardwareproblems in software"
bool "reverse cols" REVERSE_COLS n
bool "invert rows " INVERT_ROWS n
comment "for borg jacket"
bool "interlaced rows" INTERLACED_ROWS n
bool "interlaced cols" INTERLACED_COLS n
endmenu

91
borg_hw/config_rotor.in

@ -0,0 +1,91 @@
mainmenu_option next_comment
comment "Rotor port setup"
#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_RST PD4
#define PIN_CLK PD6
#//das dier sind die individuellen Dateneingänge für die Schieberegister
#define PIN_SHFT1 PD7
choice 'Column Port 1 (upper)' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTC' COLPORT1
choice 'Column Port 2 (lower)' \
"PORTA PORTA \
PORTB PORTB \
PORTC PORTC \
PORTD PORTD" \
'PORTA' COLPORT2
choice 'Latch Red Port' \
"PORTA A \
PORTB B \
PORTC C \
PORTD D" \
'PORTD' LATCH_R_PORT
choice 'Latch Red Bit' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin0' LATCH_R_BIT
choice 'Latch Green Port' \
"PORTA A \
PORTB B \
PORTC C \
PORTD D" \
'PORTD' LATCH_G_PORT
choice 'Latch Green Bit' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin1' LATCH_G_BIT
choice 'Latch Blue Port' \
"PORTA A \
PORTB B \
PORTC C \
PORTD D" \
'PORTD' LATCH_B_PORT
choice 'Latch Blue Bit' \
"Pin0 0 \
Pin1 1 \
Pin2 2 \
Pin3 3 \
Pin4 4 \
Pin5 5 \
Pin6 6 \
Pin7 7" \
'Pin2' LATCH_B_BIT
endmenu

3
config.in

@ -9,7 +9,8 @@ comment "General Setup"
"ATmega8 atmega8 \ "ATmega8 atmega8 \
ATmega32 atmega32 \ ATmega32 atmega32 \
ATmega644 atmega644 \ ATmega644 atmega644 \
ATmega644p atmega644p" \ ATmega644p atmega644p \
ATmega8515 atmega8515" \
'ATmega32' MCU 'ATmega32' MCU
int "MCU frequency" FREQ 16000000 int "MCU frequency" FREQ 16000000

40
ioport.h

@ -0,0 +1,40 @@
// Makros for simplified single pin io access.
#define PORT_(port) PORT ## port
#define DDR_(port) DDR ## port
#define PIN_(port) PIN ## port
#define PORT(port) PORT_(port)
#define DDRR(port) DDR_(port)
#define PINN(port) PIN_(port)
#define SET_DDR(p) DDRR(p##_PORT) |= (1<<p##_BIT)
#define CLEAR_DDR(p) DDRR(p##_PORT) &= ~(1<<p##_BIT)
#define OUTPUT_ON(p) PORT(p##_PORT) |= (1<<p##_BIT)
#define OUTPUT_OFF(p) PORT(p##_PORT) &= ~(1<<p##_BIT)
#define INPUT(p) ((PINN(p##_PORT) & (1<<p##_BIT)) != 0)
/*
Use Like this:
#define LED_PORT C
#define LED_BIT 7
#define SWITCH_PORT B
#define SWITCH_BIT 0
int main(){
SET_DDR(LED); //set to output
OUTPUT_ON(SWITCH); //turn on pullup
if(INPUT(SWITCH)){
OUTPUT_ON(LED);
}else{
OUTPUT_OFF(LED);
}
}
*/
Loading…
Cancel
Save