2018-09-01 23:07:13 +02:00
|
|
|
# Doorlock AVR - The AVR part of doorlockd
|
2015-09-16 22:58:00 +02:00
|
|
|
#
|
2018-09-01 23:07:13 +02:00
|
|
|
# Copyright (c) Binary Kitchen e.V., 2018
|
2015-09-16 22:58:00 +02:00
|
|
|
#
|
2018-09-01 23:07:13 +02:00
|
|
|
# Authors:
|
|
|
|
# Ralf Ramsauer <ralf@binary-kitchen.de>
|
2015-09-16 22:58:00 +02:00
|
|
|
#
|
2018-09-01 23:07:13 +02:00
|
|
|
# This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
# the COPYING file in the top-level directory.
|
2015-09-16 22:58:00 +02:00
|
|
|
|
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
TARGET = doorlock
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
MCU ?= attiny2313a
|
|
|
|
F_OSC ?= 4000000
|
|
|
|
UART_BAUD ?= 9600
|
|
|
|
AVRDUDE_MCU ?= t2313
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-26 23:40:37 +02:00
|
|
|
PROGRAMMER=linuxspi
|
|
|
|
PORT=/dev/spidev0.0:/dev/gpiochip0:25
|
|
|
|
SPEED=125000
|
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
OBJS = main.o uart.o
|
2015-09-16 22:58:00 +02:00
|
|
|
|
|
|
|
CC = avr-gcc
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
AVRDUDE = avrdude
|
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
CFLAGS := -g -O2 -mmcu=$(MCU)
|
|
|
|
CFLAGS += -Wall -Wextra -Wstrict-prototypes
|
|
|
|
CFLAGS += -DF_OSC=$(F_OSC) -DF_CPU=F_OSC -DUART_BAUD=$(UART_BAUD)UL -DMCU=$(MCU)
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
all: $(TARGET).hex
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
$(TARGET).elf: $(OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $(TARGET).elf $^
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
$(TARGET).hex: $(TARGET).elf
|
|
|
|
$(OBJCOPY) -O ihex -R .eeprom $^ $@
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
program: $(TARGET).hex
|
2018-09-26 23:40:37 +02:00
|
|
|
$(AVRDUDE) -p $(AVRDUDE_MCU) -c $(PROGRAMMER) -P $(PORT) -U flash:w:$^
|
|
|
|
|
|
|
|
fuse:
|
|
|
|
$(AVRDUDE) -p $(AVRDUDE_MCU) -c $(PROGRAMMER) -P $(PORT) -b $(SPEED) -U lfuse:w:0xfd:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
|
2015-09-16 22:58:00 +02:00
|
|
|
|
2018-09-01 23:07:13 +02:00
|
|
|
clean:
|
|
|
|
rm -f $(OBJS)
|
|
|
|
rm -f $(TARGET).elf $(TARGET).hex
|