/*!
|
/*!
|
lightshow -- lightshow on Experimental Board 1.10
|
lightshow -- lightshow on Experimental Board 1.10
|
Copyright (C) 2009-2010 ZTEX e.K.
|
Copyright (C) 2009-2014 ZTEX GmbH
|
http://www.ztex.de
|
http://www.ztex.de
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License version 3 as
|
it under the terms of the GNU General Public License version 3 as
|
published by the Free Software Foundation.
|
published by the Free Software Foundation.
|
|
|
This program is distributed in the hope that it will be useful, but
|
This program is distributed in the hope that it will be useful, but
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
General Public License for more details.
|
General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, see http://www.gnu.org/licenses/.
|
along with this program; if not, see http://www.gnu.org/licenses/.
|
!*/
|
!*/
|
|
|
#include <avr/io.h>
|
#include <avr/io.h>
|
|
|
#define F_CPU 32000000UL
|
#define F_CPU 32000000UL
|
#include <util/delay.h>
|
#include <util/delay.h>
|
|
|
typedef uint8_t byte;
|
typedef uint8_t byte;
|
|
|
int main(void)
|
int main(void)
|
{
|
{
|
// enable 32.768 kHz, 32 MHz, 2 Mhz clocks
|
// enable 32.768 kHz, 32 MHz, 2 Mhz clocks
|
asm volatile (
|
asm volatile (
|
"ldi r24,0xd8" "\n\t"
|
"ldi r24,0xd8" "\n\t"
|
"ldi r23,7" "\n\t"
|
"ldi r23,7" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"sts 0x50,r23"
|
"sts 0x50,r23"
|
::: "r24", "r23"
|
::: "r24", "r23"
|
);
|
);
|
|
|
// wait until clocks are ready
|
// wait until clocks are ready
|
while ( (OSC.STATUS & 7) != 7 ) { }
|
while ( (OSC.STATUS & 7) != 7 ) { }
|
|
|
// enable run time configuration of 32 MHz and 2 MHz clocks; select 32 MHz clock as system clock
|
// enable run time configuration of 32 MHz and 2 MHz clocks; select 32 MHz clock as system clock
|
asm volatile (
|
asm volatile (
|
"ldi r24,0xd8" "\n\t"
|
"ldi r24,0xd8" "\n\t"
|
"ldi r23,1" "\n\t"
|
"ldi r23,1" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"sts 0x60,r23" "\n\t"
|
"sts 0x60,r23" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"sts 0x68,r23" "\n\t"
|
"sts 0x68,r23" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"sts 0x40,r23"
|
"sts 0x40,r23"
|
::: "r24", "r23"
|
::: "r24", "r23"
|
);
|
);
|
|
|
// disable JTAG at portb
|
// disable JTAG at portb
|
asm volatile (
|
asm volatile (
|
"ldi r24,0xd8" "\n\t"
|
"ldi r24,0xd8" "\n\t"
|
"ldi r23,1" "\n\t"
|
"ldi r23,1" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"out 0x34,r24" "\n\t"
|
"sts 0x96,r23" "\n\t"
|
"sts 0x96,r23" "\n\t"
|
::: "r24", "r23"
|
::: "r24", "r23"
|
);
|
);
|
|
|
// clock output to PD7
|
// clock output to PD7
|
PORTCFG.CLKEVOUT = 2;
|
PORTCFG.CLKEVOUT = 2;
|
PORTD.DIR = 128;
|
PORTD.DIR = 128;
|
|
|
PORTJ.DIR = 0; // input: 4 LED's
|
PORTJ.DIR = 0; // input: 4 LED's
|
PORTH.DIR = 0; // input: 8 LED's
|
PORTH.DIR = 0; // input: 8 LED's
|
PORTD.DIR |= 15; // output: 4 LED's
|
PORTD.DIR |= 15; // output: 4 LED's
|
PORTF.DIR = 255; // output: 8 LED's
|
PORTF.DIR = 255; // output: 8 LED's
|
|
|
while (1) {
|
while (1) {
|
PORTD.OUT = PORTJ.IN;
|
PORTD.OUT = PORTJ.IN;
|
PORTF.OUT = PORTH.IN;
|
PORTF.OUT = PORTH.IN;
|
}
|
}
|
}
|
}
|
|
|
|
|