summaryrefslogtreecommitdiffstats
path: root/firmware/Makefile
blob: 29caf4c7e92eed962b341b8c3034f278838917a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Build configuration:

# Target device. May be one of:
#	t13	=> ATTiny13 with reduced feature set.
#	t25	=> ATTiny25 with reduced feature set.
#	t45	=> ATTiny45 with full feature set for one PWM.
#	t85	=> ATTiny85 with full feature set for one PWM.
#	m328p	=> ATMega328P with full feature set for three PWM (RGB).
DEV			:= t85

# Limit the maximum PWM duty cycle to this percentage:
PWM_LIM			:= 100
# Invert the PWM output signal?
PWM_INVERT		:= 0

# Invert the ADC input signal?
ADC_INVERT		:= 0

# Interpret the ADC setpoints as HSL instead of RGB, if 3 ADCs are available?
ADC_HSL			:= 1



##############################################################################
##############################################################################
##############################################################################

$(info DEV=$(DEV) PWM_LIM=$(PWM_LIM) PWM_INVERT=$(PWM_INVERT) ADC_INVERT=$(ADC_INVERT) ADC_HSL=$(ADC_HSL))

# Project name
NAME			:= simplepwm

# Project source files
SRCS			:= \
			adc.c \
			battery.c \
			color.c \
			crc.c \
			curve.c \
			debug.c \
			eeprom.c \
			filter.c \
			main.c \
			movingavg.c \
			outputsp.c \
			potentiometer.c \
			pcint.c \
			pwm.c \
			remote.c \
			ring.c \
			standby.c \
			uart.c \
			watchdog.c

GEN_SRCS		:=

# Bootloader source files
BOOT_SRCS		:=
BOOT_GEN_SRCS		:=
BOOT_OFFSET		:=

# Project fuse bits
ifeq ($(DEV),t13)
# ATTiny 13
# 9.6 MHz, SUT 4 ms, BOD 2.7 V, WDT on, SPIEN
F_CPU			:= 9600000UL
LFUSE			:= 0x56
HFUSE			:= 0xFB
EFUSE			:=
endif
ifeq ($(DEV),t25)
# ATTiny 25
# 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
F_CPU			:= 8000000UL
LFUSE			:= 0xD2
HFUSE			:= 0xDD
EFUSE			:= 0xFF
endif
ifeq ($(DEV),t45)
# ATTiny 45
# 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
F_CPU			:= 8000000UL
LFUSE			:= 0xD2
HFUSE			:= 0xDD
EFUSE			:= 0xFF
endif
ifeq ($(DEV),t85)
# ATTiny 85
# 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
F_CPU			:= 8000000UL
LFUSE			:= 0xD2
HFUSE			:= 0xDD
EFUSE			:= 0xFF
endif
ifeq ($(DEV),m328p)
# ATMega 328P
# 8 MHz, SUT 4.1 ms, BOD 2.7 V, WDT off, SPIEN
F_CPU			:= 8000000UL
LFUSE			:= 0xD2
HFUSE			:= 0xD9
EFUSE			:= 0xFD
endif

# Architecture configuration
GCC_ARCH		:= $(subst m,atmega,$(subst t,attiny,$(DEV)))
AVRDUDE_ARCH		:= $(DEV)
FUNC_STACK_LIMIT	:=

# Programmer selection.
# Values can be:  avrisp2, mysmartusb
PROGRAMMER		:= avrisp2
AVRDUDE_SPEED		:= 10
AVRDUDE_SLOW_SPEED	:= 200

# Instrumentation
INSTRUMENT_FUNC		:=
BOOT_INSTRUMENT_FUNC	:=

# Additional compiler flags
CFLAGS			:= -DPWM_LIM="$(PWM_LIM)" \
			   -DPWM_INVERT="(!!($(PWM_INVERT)))" \
			   -DADC_INVERT="(!!($(ADC_INVERT)))" \
			   -DADC_HSL="$(ADC_HSL)"
LDFLAGS			:=

# Additional "clean" and "distclean" target files
CLEAN_FILES		:= pwm0_isr.c pwm1_isr.c pwm2_isr.c
DISTCLEAN_FILES		:=


streq = $(and $(filter 1,$(words $2)),$(filter $1,$(firstword $2)))
deveq = $(call streq,$1,$(DEV))

ifeq ($(strip $(call deveq,t13)\
	      $(call deveq,t25)\
	      $(call deveq,t45)\
	      $(call deveq,t85)\
	      $(call deveq,m328p)),)
$(error "DEV=$(DEV) is not supported.")
endif

include avrmakelib.mk

pwm.c: pwm0_isr.c pwm1_isr.c pwm2_isr.c

pwm0_isr.c: pwm_isr_template.c
	$(QUIET_SED) -e 's/%INDEX%/0/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@

pwm1_isr.c: pwm_isr_template.c
	$(QUIET_SED) -e 's/%INDEX%/1/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@

pwm2_isr.c: pwm_isr_template.c
	$(QUIET_SED) -e 's/%INDEX%/2/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@
bues.ch cgit interface