## Makefile for lcd_temp # # (c) Daniel Vindevag, 2013 # USB vendor and produkt id, manufacturer and product string USB_VID = 0x0403 USB_PID = 0x9132 USB_MAN_STR = Daniel Vindevag USB_PROD_STR = LCD and Temperature USB interface. USB_PID = 0x9136 USB_PROD_STR = Pulse counter. # MCU name MCU = at90usb162 MCU = atmega32u2 #MCU = atmega8u2 F_CPU = 16000000 ## Config # # Temp DS18S20 temperature sensors, max 3 # LCD Character LCD, HD44780 # RTC Timer routines # TIME_H Date formatting for LCD, requires RTC and LCD # BUTTONS Button inputs # KEYBOARD Send button input as USB Keyboard/HID, requires BUTTONS # RELAYS Relay outputs # Counter Pulse counter, handled by interrupts # #TEMP = yes #LCD = yes LCD = hw2 RTC = yes TIME_H = yes #BUTTONS = yes #KEYBOARD = yes #RELAYS = yes COUNTER = yes # Check hardware Bootloader Button at startup, set no if no 10KOhm pullup on HWB pin CHECK_HWB = yes # Use PWM controller for LCD backlight #PWM = yes # Device name for running USB device LCD_TEMP_DEVICE = "/dev/pulsecounter" # Path to source files, i.e. one directory up, use . if makefile is in base directory BASE_DIR = .. AVRDUDE_PROGRAMMER = avrispmkII LCD_OPTS = SRC_LCD = ifeq ($(LCD), yes) LCD_OPTS = -D LCD_D_PORT=PORTD # Data port LCD_OPTS += -D LCD_DATA0_PIN=3 # pin setup 4bit LCD_OPTS += -D LCD_DATA1_PIN=4 LCD_OPTS += -D LCD_DATA2_PIN=5 LCD_OPTS += -D LCD_DATA3_PIN=6 LCD_OPTS += -D LCD_C_PORT=PORTD # Control port LCD_OPTS += -D LCD_RS_PIN=0 LCD_OPTS += -D LCD_RW_PIN=1 LCD_OPTS += -D LCD_E_PIN=2 # LCD_OPTS += -D LCD_LINES=2 # Display size LCD_OPTS += -D LCD_DISP_LENGTH=16 LCD_OPTS += -D LCD_BL_PORT="PORTC" # Pin för turning on B/L Own HW ver 1 LCD_OPTS += -D LCD_BL_MASK="(1 << PC2)" LCD_OPTS += -D LCD=yes SRC_LCD = $(BASE_DIR)/lib/lcd.c endif ifeq ($(LCD), hw2) LCD_OPTS = -D LCD_D_PORT=PORTC # Data port LCD_OPTS += -D LCD_DATA0_PIN=4 # pin setup 4bit LCD_OPTS += -D LCD_DATA1_PIN=5 LCD_OPTS += -D LCD_DATA2_PIN=6 LCD_OPTS += -D LCD_DATA3_PIN=7 LCD_OPTS += -D LCD_C_PORT=PORTB # Control port LCD_OPTS += -D LCD_RS_PIN=4 LCD_OPTS += -D LCD_RW_PIN=5 LCD_OPTS += -D LCD_E_PIN=6 # LCD_OPTS += -D LCD_LINES=4 # Display size LCD_OPTS += -D LCD_DISP_LENGTH=20 LCD_OPTS += -D LCD_BL_PORT="PORTB" # Pin för turning on B/L PWM LCD_OPTS += -D LCD_BL_MASK="(1 << PB7)" LCD_OPTS += -D PWM_REG="OCR0A" LCD_OPTS += -D LCD=yes SRC_LCD = $(BASE_DIR)/lib/lcd.c PWM=yes endif 1WIRE_OPTS = SRC_1WIRE = ifeq ($(TEMP), yes) 1WIRE_OPTS = -D OW_PIN=PB2 1WIRE_OPTS += -D OW_PORT=PORTB 1WIRE_OPTS += -D TEMP=yes SRC_1WIRE = $(BASE_DIR)/lib/crc8.c $(BASE_DIR)/lib/onewire.c $(BASE_DIR)/lib/ds18x20.c endif # Hardware button and Reset BOOT_DEFS = -D HWB_PORT="PORTD" BOOT_DEFS += -D HWB_MASK="(1 << PD7)" BOOT_DEFS += -DAVR_RESET_LINE_PORT="PORTC" BOOT_DEFS += -DAVR_RESET_LINE_MASK="(1 << PC1)" # Time and timezone BOOT_DEFS += -D TIMESTAMP=$(shell date +"%s") BOOT_DEFS += -D TZ=$(shell date +%z | awk '{print int($$1/100)}') ifeq ($(CHECK_HWB), yes) BOOT_DEFS += -D CHECK_HWB=1 endif ifeq ($(PWM), yes) BOOT_DEFS += -D PWM=1 endif ifeq ($(RTC), yes) BOOT_DEFS += -D RTC=1 ifeq ($(TIME_H), yes) BOOT_DEFS += -D TIME_H=1 endif endif ifeq ($(BUTTONS), yes) BOOT_DEFS += -D BUTTONS=1 ifeq ($(KEYBOARD), yes) BOOT_DEFS += -D KEYBOARD=1 endif endif ifeq ($(RELAYS), yes) BOOT_DEFS += -D RELAYS=1 endif ifeq ($(COUNTER), yes) BOOT_DEFS += -D COUNTER=1 endif ARCH = AVR8 BOARD = NONE F_USB = $(F_CPU) OPTIMIZATION = s TARGET = lcd_temp SRC = $(BASE_DIR)/$(TARGET).c $(BASE_DIR)/Descriptors.c \ $(SRC_LCD) $(SRC_1WIRE) \ $(LUFA_SRC_USBCLASS) $(LUFA_SRC_USB) #LUFA_PATH = $(BASE_DIR)/../LUFA-130303/LUFA LUFA_PATH = $(BASE_DIR)/LUFA CC_FLAGS = -D USE_LUFA_CONFIG_HEADER -I $(BASE_DIR) CC_FLAGS += -D USB_VID=$(USB_VID) -D USB_PID=$(USB_PID) CC_FLAGS += -D USB_MAN_LEN=$(USB_MAN_LEN) -D USB_MAN_STR="L\"$(USB_MAN_STR)\"" CC_FLAGS += -D USB_PROD_LEN=$(USB_PROD_LEN) -D USB_PROD_STR="L\"$(USB_PROD_STR)\"" CC_FLAGS += $(LCD_OPTS) $(1WIRE_OPTS) $(BOOT_DEFS) LD_FLAGS = relpath = dokument/dokument/Development/avr/lcd_temp/ # Default target all: elektra: rsync -rlaz --delete /home/josefk/$(relpath) /pub/home/josefk/$(relpath) html: $(BASE_DIR)/mk_html backup: tar --gzip -cvf $(BASE_DIR)/backup/lcd_temp_`date +%Y%m%d_%H%M`.tar.gz $(BASE_DIR)/*.c $(BASE_DIR)/*.h \ $(BASE_DIR)/lib/*.c $(BASE_DIR)/lib/*.h makefile *.hex *.eep $(BASE_DIR)/mk_html archive: tar --dereference --gzip -cvf $(BASE_DIR)/backup/lcd_temp.tar.gz $(BASE_DIR)/*.c $(BASE_DIR)/*.h \ $(BASE_DIR)/lib/*.c $(BASE_DIR)/lib/*.h $(BASE_DIR)/gcc/makefile $(BASE_DIR)/LUFA start: dfu-programmer $(MCU) start update: echo "ATf" > ${LCD_TEMP_DEVICE} reboot: echo "ATw" > ${LCD_TEMP_DEVICE} flash: echo "ATf" > ${LCD_TEMP_DEVICE} make sleep 3 dfu-programmer $(MCU) erase dfu-programmer $(MCU) flash lcd_temp.hex dfu-programmer $(MCU) start settime: echo `date +"ATRTCSET %s"` > ${LCD_TEMP_DEVICE} gettime: ../time_diff ${LCD_TEMP_DEVICE} cleareeprom: echo ATEECLEAR > ${LCD_TEMP_DEVICE} # Include LUFA build script makefiles include $(LUFA_PATH)/Build/lufa_core.mk include $(LUFA_PATH)/Build/lufa_sources.mk include $(LUFA_PATH)/Build/lufa_build.mk include $(LUFA_PATH)/Build/lufa_cppcheck.mk include $(LUFA_PATH)/Build/lufa_doxygen.mk include $(LUFA_PATH)/Build/lufa_dfu.mk include $(LUFA_PATH)/Build/lufa_hid.mk include $(LUFA_PATH)/Build/lufa_avrdude.mk include $(LUFA_PATH)/Build/lufa_atprogram.mk