initial commit

master
Eggert Jung 3 years ago
commit 49e31df61f

@ -0,0 +1,59 @@
TARGET = main
SRCS := $(shell find -name '*.c')
FILES = $(SRCS:%.c=%) #main uart avrIOhelper/io-helper #uart#hier alle c-Datein reinschreiben, trennung durch " " und ohne .c-Endung
MCU = atmega32
PROGC = m32
CC = avr-gcc
TOOL = stk500 -P /dev/ttyUSB0
#TOOL = atmelice_isp
#TOOL = avrispmkii
#TOOL = usbasp-clone
BUILDDIR = Builds
DEFINES = -I . -IInternet/MQTT -I Internet/MQTT/MQTTPacket/src -I Ethernet/W5500 -I Ethernet -DF_CPU=16000000UL -D_WIZCHIP_=W5100
CFLAGS =-mmcu=$(MCU) -O2 -Wall -Wpedantic $(DEFINES) -std=c99 -ffunction-sections -fdata-sections
LDFLAGS =-mmcu=$(MCU) -Wl,--gc-sections
LDFILES = $(foreach FILE,$(FILES),$(BUILDDIR)/$(FILE).o)
all: clean $(BUILDDIR)/$(TARGET).elf
$(BUILDDIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $(BUILDDIR)/$*.o
$(BUILDDIR)/$(TARGET).elf: $(LDFILES)
mkdir -p $(dir $@)
$(CC) $(LDFLAGS) $(LDFILES) -o $(BUILDDIR)/$(TARGET).elf
$(BUILDDIR)/$(TARGET).hex : $(BUILDDIR)/$(TARGET).elf
avr-objcopy -j .data -j .text -O ihex $< $@
fuse:
avrdude -p $(PROGC) -c $(TOOL) -U lfuse:w:0xE8:m -U hfuse:w:0xD1:m
load: $(BUILDDIR)/$(TARGET).hex
avrdude -p $(PROGC) -c $(TOOL) -U flash:w:$(BUILDDIR)/$(TARGET).hex -v -B 4MHz
program: clean load
reset:
avrdude -p $(PROGC) -c $(TOOL)
size: $(BUILDDIR)/$(TARGET).elf
avr-size -C --mcu=$(MCU) $(BUILDDIR)/$(TARGET).elf
.PHONY=clean
clean:
rm -rf $(BUILDDIR)
#Fuse m1284p external Osz. Long startuptime
# avrdude -c usbasp-clone -p m1284p -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m
#Fuse m1284p internal Osz. Long startuptime
# avrdude -c usbasp-clone -p m1284p -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

@ -0,0 +1,18 @@
-D
__AVR_ATmega32__
-D
F_CPU=16000000UL
-D
_WIZCHIP_=W5100
-I
/usr/lib/avr/include
-I
Internet
-I
Internet/MQTT
-I
Internet/MQTT/MQTTPacket/src
-I
Ethernet
-I
Ethernet/W5500

@ -0,0 +1,62 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <util/delay.h>
uint8_t font[] = {
0xEE,
0x82,
0xDC,
0xD6,
0xB2,
0x76,
0x7E,
0xC2,
0xFE,
0xF6,
};
uint8_t display[4];
void timer0_init()
{
TCCR0 = (1<<WGM01); //TIMER0 SET-UP: CTC MODE
TCCR0 = (1<<CS01)|(1<<CS00); // PS 1:64
OCR0 = 249; // 1ms reach for clear (16mz:64=>250kHz:250-=>1kHz)
TIMSK |= 1<<OCIE0; //IRQ on TIMER0 output compareA
}
int main(void){
DDRB |= _BV(3) | _BV(2) | _BV(1) | _BV(0);
DDRD = 0xFC;
DDRA = 0x03 << 4;
DDRC = 0xFE;
display[3] = font[1];
display[2] = font[3];
display[1] = font[3];
display[0] = font[7];
timer0_init();
sei();
while(1){
}
}
ISR(TIMER0_COMP_vect)
{
if(PORTB & 0x01){
PORTB = 1<<1 | 1<<3;
PORTD = display[3] & 0xFC;
PORTA = (display[3] & 0x03) << 4;
PORTC = display[1];
}
else{
PORTB = 1<<0 | 1<<2;
PORTD = display[2] & 0xFC;
PORTA = (display[2] & 0x03) << 4;
PORTC = display[0];
}
}

Binary file not shown.
Loading…
Cancel
Save