Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 283 → Rev 310

/MikroBlink/Blitzdings/Blitzdings.pnproj
0,0 → 1,0
<Project name="Blitzdings"><File path="lprg.c"></File><File path="makefile"></File><File path="timer.c"></File><File path="timer.h"></File><File path="main.h"></File><File path="main.c"></File><File path="lprg.h"></File></Project>
/MikroBlink/Blitzdings/Blitzdings.pnps
0,0 → 1,0
<pd><ViewState><e p="Blitzdings" x="true"></e></ViewState></pd>
/MikroBlink/Blitzdings/Hexfiles/Blitzdings_MEGA8.hex
0,0 → 1,84
:100000004EC068C0CBC066C065C064C063C062C07B
:1000100061C08EC15FC05EC05DC05CC05BC05AC0C5
:1000200059C058C057C0E5C0E6C0E7C0E8C0E9C045
:10003000EAC0EBC0ECC0EDC0DAC0F5C0F6C0F7C056
:10004000F8C0F9C0FAC0FBC0FCC0FDC0EAC05CC18A
:1000500058C15CC15BC15AC159C158C14FC156C1D9
:1000600055C154C153C152C151C150C144C14EC107
:100070004DC14CC13DC139C149C148C147C146C14B
:1000800031C144C143C12BC141C140C13FC13EC187
:100090003DC13CC13BC13AC139C138C11DC1112468
:1000A0001FBECFE5D4E0DEBFCDBF11E0A0E6B0E0DB
:1000B000E2E2F4E002C005900D92A435B107D9F751
:1000C00011E0A4E5B1E001C01D92A438B107E1F749
:1000D0001AD0A6C195CFE0915401F0915501EE0FD1
:1000E000FF1FE75BFE4F80819181AFD0809154016B
:1000F00090915501019665E070E07ED19093550195
:100100008093540108950F931F93CF93DF9385E05D
:1001100087BB8EE384BB80EF81BB939A80E88BBF63
:1001200084E085BFC29885B385BB82B382BBC0988B
:100130003ED1D1DF80E197E240D18C0188EE93E09F
:100140003CD1EC0178948091820190918301892BBC
:10015000B1F4C8013BD18823D9F4CE0137D188232B
:1001600091F388B391E0892788BB88EE93E025D18D
:10017000EC018091820190918301892B51F31092BF
:1001800083011092820178D0C80120D1882329F3FD
:10019000A2DF80E197E211D18C01DFCF1F920F9295
:1001A0000FB60F9211242F933F934F935F936F934A
:1001B0007F938F939F93AF93BF93EF93FF938BDFC7
:1001C000FF91EF91BF91AF919F918F917F916F912F
:1001D0005F914F913F912F910F900FBE0F901F9005
:1001E0001895FC010A9720F4ED5EFF4F0994979A49
:1001F0000895C29A0895A99A0895AA9A0895AB9A63
:100200000895AC9A0895AD9A0895949A0895959A90
:100210000895969A0895FC010A9720F4E35EFF4F33
:10022000099497980895C2980895A9980895AA984E
:100230000895AB980895AC980895AD980895949852
:1002400008959598089596980895CF93DF93009711
:1002500081F0E6E5F1E0DC01EF01649610821286A0
:100260008D919D9189939993319681E0E036F807BD
:10027000A9F7DF91CF910895EF92FF920F931F930B
:10028000CF93DF93C6E5D1E084E1E82EF12CEC0EAC
:10029000FD1E00E010E003C08150888337C08881D4
:1002A0008823D1F7F701A081B1818A85FD01E80F8C
:1002B000F11DE0818F5F8A87A80FB11D8C91882383
:1002C00009F41A868E2F90E0FC01FA97E832F105C6
:1002D000E8F4E95DFF4F0994C8019DDF17C081E391
:1002E000888314C083E6888311C083E188830EC0AD
:1002F0008DE188830BC089E0888308C0C80171DF65
:1003000005C084E0888302C081E088830F5F1F4FAF
:10031000219682E090E0E80EF91E0A30110509F0FE
:10032000BECFDF91CF911F910F91FF90EF90089575
:100330001F920F920FB60F9211245F936F937F93CA
:100340008F939F93AF93BF93809181018F5F809331
:100350008101809180018150809380018F3FD9F489
:1003600083E08093800180917E0190917F010196CE
:1003700090937F0180937E0180917E0190917F0117
:100380006AE070E039D0892B31F481E090E09093FD
:10039000830180938201BF91AF919F918F917F9153
:1003A0006F915F910F900FBE0F901F90189582E094
:1003B00083BF89B7816089BF089520917E01309104
:1003C0007F0121503040820F931F089520917E01BC
:1003D00030917F01821B930B892F9927807890E0C1
:1003E0000895CF93DF93E9DFEC01CE01EFDF88239F
:1003F000E1F3DF91CF910895AA1BBB1B51E107C028
:10040000AA1FBB1FA617B70710F0A61BB70B881FA4
:10041000991F5A95A9F780959095BC01CD01089533
:02042000FFCF0C
:1004220041006100413A6149413A6149413A6153AF
:1004320056002E004E4E61494153534E4E4E004ED1
:1004420061494153534E4E4E4E004E413A6149412D
:100452003A6149413A614D530061494153534E4E0D
:100462004E4E4E004E4E4E61494153534E4E006425
:10047200007200740072007F008A0072009900729C
:1004820000A4006200620062006200620062006218
:100492000062006200620060006000600060006054
:1004A2000060006000600060006000614D414D002E
:1004B200EB00EB00EB00EB00EB00EB00EB00EB00E2
:1004C200EB00EB00612E412E00613A413A00613BA4
:1004D200413B006149414900614E414E00614D4935
:1004E200414D490061564156006156494156490005
:1004F2006153415300040109010E0113011801EB7C
:10050200001D01240129013001D700AF00C300F012
:0405120000350100AF
:00000001FF
/MikroBlink/Blitzdings/lprg.c
0,0 → 1,160
/*
* lprg.c
* little LED lighting program interpreter
* (c) 2009 pangu
*/
#include "main.h"
#include "lprg.h"
 
static lprg lpg;
 
void LED_ON(int i) {
switch (i) {
case 0:
LED_1_ON;
break;
case 1:
LED_2_ON;
break;
case 2:
LED_3_ON;
break;
case 3:
LED_4_ON;
break;
case 4:
LED_5_ON;
break;
case 5:
LED_6_ON;
break;
case 6:
LED_7_ON;
break;
case 7:
LED_8_ON;
break;
case 8:
LED_9_ON;
break;
case 9:
LED_10_ON;
break;
}
}
 
void LED_OFF(int i) {
switch (i) {
case 0:
LED_1_OFF;
break;
case 1:
LED_2_OFF;
break;
case 2:
LED_3_OFF;
break;
case 3:
LED_4_OFF;
break;
case 4:
LED_5_OFF;
break;
case 5:
LED_6_OFF;
break;
case 6:
LED_7_OFF;
break;
case 7:
LED_8_OFF;
break;
case 8:
LED_9_OFF;
break;
case 9:
LED_10_OFF;
break;
}
}
 
 
void lprg_init(char *code[]) {
int i;
 
if(!code) return; // do nothing with no input
 
for(i=0; i<LEDCOUNT; i++) {
lpg.wait[i] = 0;
lpg.cur[i] = 0;
lpg.code[i] = code[i];
}
}
 
 
void lprg_step(void) { // to be called every 10ms. perform next step in lighting prog
 
int i;
char a;
for(i=0;i<LEDCOUNT;i++) {
 
// need to wait?
if(lpg.wait[i]) {
lpg.wait[i]--;
continue;
}
// get current command
a = *(lpg.code[i]+lpg.cur[i]);
lpg.cur[i]++;
if(!lpg.code[i][lpg.cur[i]]) // wrap to start if commands for LED finished
lpg.cur[i] = 0;
// look at current char
switch(a) {
case 'A': // if its LED on, turn LED on
LED_ON(i);
break;
case 'a': // if its LED off, turn LED off
LED_OFF(i);
break;
// Wait flags:
// . 10 ms (. or any other char)
// : 20 ms
// ; 50 ms
// I 100 ms
// N 200 ms
// M 300 ms
// V 500 ms
// S 1s
case ':':
lpg.wait[i] = 1;
break;
case ';':
lpg.wait[i] = 4;
break;
case 'I':
lpg.wait[i] = 9;
break;
case 'N':
lpg.wait[i] = 19;
break;
case 'M':
lpg.wait[i] = 29;
break;
case 'V':
lpg.wait[i] = 49;
break;
case 'S':
lpg.wait[i] = 99;
break;
}
}
}
 
 
/MikroBlink/Blitzdings/lprg.h
0,0 → 1,19
/*
* lprg.h
* little LED lighting program interpreter
* (c) 2009 pangu
*/
 
#define LEDCOUNT 10
 
typedef struct _lprg {
char wait[LEDCOUNT];
char cur[LEDCOUNT];
char *code[LEDCOUNT];
} lprg;
 
 
extern void lprg_init(char *code[]);
extern void lprg_step();
 
 
/MikroBlink/Blitzdings/main.c
0,0 → 1,178
/*
* Blitzdings main.c
* (c) pangu
*/
#include "main.h"
#include "timer.h"
#include "lprg.h"
 
/* Strings zum definieren von Dauer-Ein Dauer-Aus */
const char l_on[]="A";
const char l_off[]="a";
 
// Wait flags:
// . 10 ms
// : 20 ms
// ; 50 ms
// I 100 ms
// N 200 ms
// M 300 ms
// V 500 ms
// S 1s
// LED:
// A-an a-aus
 
// Rot+Grün blitzen dreimal kurz, zeitlich leicht versetzt, alle 1,5s
// 2 weisse und 2 blaue LEDs sind an und gehen alle 3s reihum kurz aus
char *led_posflash[] = {
"A:aIA:aIA:aSV", // LED #1 rot
".", // LED #2
"NNaIASSNNN", // LED #3 blau
".", // LED #4
"NaIASSNNNN", // LED #5 weiss
"NA:aIA:aIA:aMS", // LED #6 grün
".", // LED #7
"aIASSNNNNN", // LED #8 weiss
".", // LED #9
"NNNaIASSNN" // LED #10 blau
};
 
 
char *led_aus[] = {
l_off, // LED #1 rot
l_off, // LED #2 blau
l_off, // LED #3 blau
l_off, // LED #4
l_off, // LED #5 weiss
l_off, // LED #6 grün
l_off, // LED #7
l_off, // LED #8 weiss
l_off, // LED #9
l_off // LED #10
};
 
char *led_an[] = {
l_on, // LED #1 rot
l_on, // LED #2 blau
l_on, // LED #3 blau
l_on, // LED #4
l_on, // LED #5 weiss
l_on, // LED #6 grün
l_on, // LED #7
l_on, // LED #8 weiss
l_on, // LED #9
l_on // LED #10
};
 
// alle LEDs toggeln synchron, 300ms Leucht/Aus-Dauer
char *led_flash1[] = {
"aMAM", // LED #1 rot
"aMAM", // LED #2 blau
"aMAM", // LED #3 blau
"aMAM", // LED #4
"aMAM", // LED #5 weiss
"aMAM", // LED #6 grün
"aMAM", // LED #7
"aMAM", // LED #8 weiss
"aMAM", // LED #9
"aMAM" // LED #10
};
 
// alle LEDs toggeln mit verschiednen Zykluszeiten
char *led_flash2[] = {
"a.A.", // LED #1 rot
"a:A:", // LED #2 blau
"a;A;", // LED #3 blau
"aIAI", // LED #4
"aNAN", // LED #5 weiss
"aMAM", // LED #6 grün
"aMIAMI", // LED #7
"aVAV", // LED #8 weiss
"aVIAVI", // LED #9
"aSAS" // LED #10
};
 
 
// Hier die zu verwendenden LichtProgramme einfach eintragen.
void *modes[]= { led_an, led_posflash, led_aus, led_flash1, led_flash2 };
 
void nextMode() {
 
static int current = 0;
lprg_init(modes[current]);
current = ++current % (sizeof(modes)/sizeof(void *));
 
}
 
ISR(INT1_vect)
{
 
nextMode();
 
}
 
 
 
int main() {
 
int tim10s, tim1s;
// Ports einstellen
// Pin B |7|6|5|4|3|2|1|0
// Binär:|0|0|0|0|0|1|0|1 (b) => #05 (h)
// Pin B0 und B2 als Ausgänge festlegen
DDRB = 0x05;
 
// Pin C |7|6|5|4|3|2|1|0
// Binär:|0|0|1|1|1|1|1|0 (b) => #3E (h)
// Pin C1 bis C5 als Ausgänge festlegen
DDRC = 0x3E;
// Pin D |7|6|5|4|3|2|1|0
// Binär:|1|1|1|1|0|0|0|0 (b) => #F0 (h)
DDRD = 0xF0;
//Pullup für PD3 aktivieren
PORTD |= (1 << PD3);
//interrupt konfigurueren
GIMSK = 1<<INT1;
MCUCR = 1<<ISC10;
 
ALLES_OFF;
STATUS_ON;
 
Timer_Init();
nextMode();
tim10s = SetDelay(10000);
tim1s = SetDelay(1000);
sei(); //interrupts einschalten
 
while (1) {
 
if(flag10ms) { // every 10ms
flag10ms = 0;
lprg_step(); // next step in light prog
}
 
if(CheckDelay(tim10s)) { // alle 10 sec programm wechseln
nextMode();
tim10s = SetDelay(10000);
}
if(CheckDelay(tim1s)) { // alle 1 sec STatus-LED toggeln
STATUS_TOGGLE;
tim1s = SetDelay(1000);
}
}
 
}
 
 
 
 
 
/MikroBlink/Blitzdings/main.h
0,0 → 1,50
 
#include <avr/io.h>
#include <util/delay.h>
#include <stdint.h>
#include <avr/interrupt.h>
 
#include "timer.h"
 
#define LED_1 PB2 // LED port 1
#define LED_2 PC1 // LED port 2
#define LED_3 PC2 // LED port 3
#define LED_4 PC3 // LED port 4
#define LED_5 PC4 // LED port 5
#define LED_6 PC5 // LED port 6
#define LED_7 PD4 // LED port 7
#define LED_8 PD5 // LED port 8
#define LED_9 PD6 // LED port 9
#define LED_10 PD7 // LED port 10
#define LED_STATUS PB0 // LED blau - on board
 
#define STATUS_OFF PORTB |= (1<<LED_STATUS) //Den Portpin auf high setzen
#define STATUS_ON PORTB &= ~(1<<LED_STATUS) //Den Portpin auf low setzen
#define STATUS_TOGGLE PORTB ^= (1<<LED_STATUS) //Den Portpin toggeln
 
#define LED_1_ON PORTB |= (1<<LED_1) //Den Portpin auf high setzen
#define LED_1_OFF PORTB &= ~(1<<LED_1) //Den Portpin auf low setzen
 
#define LED_2_ON PORTC |= (1<<LED_2) //Den Portpin auf high setzen
#define LED_2_OFF PORTC &= ~(1<<LED_2) //Den Portpin auf low setzen
#define LED_3_ON PORTC |= (1<<LED_3) //Den Portpin auf high setzen
#define LED_3_OFF PORTC &= ~(1<<LED_3) //Den Portpin auf low setzen
#define LED_4_ON PORTC |= (1<<LED_4) //Den Portpin auf high setzen
#define LED_4_OFF PORTC &= ~(1<<LED_4) //Den Portpin auf low setzen
#define LED_5_ON PORTC |= (1<<LED_5) //Den Portpin auf high setzen
#define LED_5_OFF PORTC &= ~(1<<LED_5) //Den Portpin auf low setzen
#define LED_6_ON PORTC |= (1<<LED_6)
#define LED_6_OFF PORTC &= ~(1<<LED_6)
 
#define LED_7_ON PORTD |= (1<<LED_7)
#define LED_7_OFF PORTD &= ~(1<<LED_7)
#define LED_8_ON PORTD |= (1<<LED_8)
#define LED_8_OFF PORTD &= ~(1<<LED_8)
#define LED_9_ON PORTD |= (1<<LED_9)
#define LED_9_OFF PORTD &= ~(1<<LED_9)
#define LED_10_ON PORTD |= (1<<LED_10)
#define LED_10_OFF PORTD &= ~(1<<LED_10)
 
#define ALLES_OFF LED_1_OFF;PORTC &= ~(1<<LED_2 & 1<<LED_3 & 1<<LED_4 & 1<<LED_5);PORTD &= ~(1<<LED_6 & 1<<LED_7 & 1<<LED_8 & 1<<LED_9 & 1<<LED_10);
#define ALLES_ON LED_1_ON;PORTC |= (1<<LED_2 & 1<<LED_3 & 1<<LED_4 & 1<<LED_5);PORTD |= (1<<LED_6 & 1<<LED_7 & 1<<LED_8 & 1<<LED_9 & 1<<LED_10);
 
/MikroBlink/Blitzdings/makefile
0,0 → 1,420
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
# Additional material for this makefile was submitted by:
# Tim Henigan
# Peter Fleury
# Reiner Patommel
# Sander Pool
# Frederik Rouleau
# Markus Pfaff
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
# 4.07 or greater).
#
# make program = Download the hex file to the device, using avrdude. Please
# customize the avrdude settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#
 
# MCU name
 
MCU = atmega8
F_CPU = 8000000UL
 
#Fuse settings for ATmega8
ifeq ($(MCU), atmega8)
FUSE_BITS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
HEX_FILE_NAME = MEGA8
endif
 
 
 
 
 
 
 
 
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
 
# Target file name (without extension).
TARGET = Hexfiles/Blitzdings_$(HEX_FILE_NAME)
 
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = 2
 
# If there is more than one source file, append them above, or modify and
# uncomment the following:
SRC = main.c lprg.c timer.c
 
 
 
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC =
 
 
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS =
 
 
# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
CFLAGS = -g -O$(OPT) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wstrict-prototypes \
-Wa,-adhlns=$(<:.c=.lst) \
$(patsubst %,-I%,$(EXTRAINCDIRS))
 
 
# Set a "language standard" compiler flag.
# Unremark just one line below to set the language standard to use.
# gnu99 = C99 + GNU extensions. See GCC manual for more information.
#CFLAGS += -std=c89
#CFLAGS += -std=gnu89
#CFLAGS += -std=c99
CFLAGS += -std=gnu99
 
CFLAGS += -DF_CPU=$(F_CPU)
 
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
 
 
 
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
 
 
 
# Additional libraries
 
# Minimalistic printf version
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
 
# Floating point printf version (requires -lm below)
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
 
# -lm = math library
LDFLAGS += -lm
 
 
 
 
# Programming support using avrdude. Settings and variables.
 
# Programming hardware: alf avr910 avrisp bascom bsd
# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
#
# Type: avrdude -c ?
# to get a full listing.
#
 
#AVRDUDE_PROGRAMMER = AVR910
#AVRDUDE_PROGRAMMER = stk300
#AVRDUDE_PROGRAMMER = USBasp
#AVRDUDE_PROGRAMMER = dt006
#AVRDUDE_PROGRAMMER = bascom
AVRDUDE_PROGRAMMER = siprog
#AVRDUDE_PROGRAMMER = avrisp2
#AVRDUDE_PROGRAMMER = AVRISPMKII
 
 
 
#AVRDUDE_PORT = usb # programmer connected to USB port
AVRDUDE_PORT = com2 # programmer connected to serial device
#AVRDUDE_PORT = lpt1 # programmer connected to parallel port
 
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_BITS)
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
 
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -b 115200 -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
 
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
 
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V
 
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
 
 
 
 
# ---------------------------------------------------------------------------
 
# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
 
 
# Define programs and commands.
SHELL = sh
 
CC = avr-gcc
 
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
 
 
# Programming support using avrdude.
AVRDUDE = avrdude
 
 
REMOVE = rm -f
COPY = cp
 
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
 
 
 
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
 
 
 
 
# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
 
# Define all listing files.
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
 
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 
# Default target.
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
$(TARGET).lss $(TARGET).sym sizeafter finished end
 
 
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@echo
@echo $(MSG_BEGIN)
 
finished:
@echo $(MSG_ERRORS_NONE)
 
end:
@echo $(MSG_END)
@echo
 
 
# Display size of file.
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
 
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
 
 
 
# Display compiler version information.
gccversion :
@$(CC) --version
 
 
 
 
# Convert ELF to COFF for use in debugging / simulating in
# AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
 
 
coff: $(TARGET).elf
@echo
@echo $(MSG_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
 
 
extcoff: $(TARGET).elf
@echo
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
 
 
 
 
# Program the device.
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
 
 
 
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
 
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 
# Create extended listing file from ELF output file.
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
 
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
avr-nm -n $< > $@
 
 
 
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
 
 
# Compile: create object files from C source files.
%.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
 
 
# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
 
 
# Assemble: create object files from assembler source files.
%.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
 
 
 
 
 
 
# Target: clean project.
clean: begin clean_list finished end
 
clean_list :
@echo
@echo $(MSG_CLEANING)
# $(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).cof
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
 
 
# Automatically generate C source code dependencies.
# (Code originally taken from the GNU make user manual and modified
# (See README.txt Credits).)
#
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
# (see the SHELL variable defined above).
# This may not work with other shells or other seds.
#
%.d: %.c
set -e; $(CC) -MM $(ALL_CFLAGS) $< \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
[ -s $@ ] || rm -f $@
 
 
# Remove the '-' if you want to see the dependency files generated.
-include $(SRC:.c=.d)
 
 
 
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
clean clean_list program
 
/MikroBlink/Blitzdings/timer.c
0,0 → 1,60
/*****************************************************************************
*****************************************************************************/
#include "main.h"
 
volatile unsigned int CountMilliseconds = 0;
volatile unsigned char Timer0Overflow;
volatile unsigned int flag10ms;
enum {
STOP = 0,
CK = 1,
CK8 = 2,
CK64 = 3,
CK256 = 4,
CK1024 = 5,
T0_FALLING_EDGE = 6,
T0_RISING_EDGE = 7
};
 
 
SIGNAL(SIG_OVERFLOW0)
{
static unsigned char cnt=0;
Timer0Overflow++;
if(!cnt--)
{
cnt = 3;
CountMilliseconds += 1;
if(!(CountMilliseconds % 10)) {
flag10ms = 1;
}
}
}
 
 
void Timer_Init(void)
{
TCCR0 = CK8;
TIM0_START;
}
 
 
unsigned int SetDelay(unsigned int t)
{
return(CountMilliseconds + t - 1);
}
 
char CheckDelay (unsigned int t)
{
return(((t - CountMilliseconds) & 0x8000) >> 8);
}
 
void Delay_ms(unsigned int w)
{
unsigned int akt;
akt = SetDelay(w);
while (!CheckDelay(akt));
}
/MikroBlink/Blitzdings/timer.h
0,0 → 1,35
#if defined (__AVR_ATmega8__)
#define TIMER_TEILER CK8
//#define TIMER_RELOAD_VALUE 125
#endif
 
#define INT0_ENABLE GIMSK |= 0x40
#define INT0_DISABLE GIMSK &= ~0x40
#define TIM0_START TIMSK |= 0x01
#define TIM0_STOPP TIMSK &= ~0x01
#define ICP_INT_ENABLE TIMSK |= 0x20
#define ICP_INT_DISABLE TIMSK &= ~0x20
#define TIMER1_INT_ENABLE TIMSK |= 0x04
#define TIMER1_INT_DISABLE TIMSK &= ~0x04
#define TIMER2_INT_ENABLE TIMSK |= 0x40
#define TIMER2_INT_DISABLE TIMSK &= ~0x40
#define INT0_POS_FLANKE MCUCR |= 0x01
#define INT0_ANY_FLANKE MCUCR |= 0x01
#define INT0_NEG_FLANKE MCUCR &= ~0x01
#define CLR_INT0_FLAG GIFR &= ~0x40
#define INIT_INT0_FLANKE MCUCR &= ~0x03; MCUCR |= 0x02;
#define TIMER0_PRESCALER TCCR0
#define ICP_POS_FLANKE TCCR1B |= (1<<ICES1)
#define ICP_NEG_FLANKE TCCR1B &= ~(1<<ICES1)
 
 
extern volatile unsigned int CountMilliseconds;
extern volatile unsigned char Timer0Overflow;
extern volatile unsigned int flag10ms;
 
 
void Timer_Init(void);
void Delay_ms(unsigned int);
unsigned int SetDelay (unsigned int t);
char CheckDelay (unsigned int t);