Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. # Build configuration:
  2. # Target device. May be one of:
  3. # t13 => ATTiny13 with reduced feature set.
  4. # t25 => ATTiny25 with reduced feature set.
  5. # t45 => ATTiny45 with full feature set for one PWM.
  6. # t85 => ATTiny85 with full feature set for one PWM.
  7. # m88p => ATMega88P with full feature set for three PWM (RGB).
  8. # m328p => ATMega328P with full feature set for three PWM (RGB).
  9. DEV := t85
  10. # Limit the maximum PWM duty cycle to this percentage:
  11. PWM_LIM := 100
  12. # Invert the PWM output signal?
  13. PWM_INVERT := 0
  14. # Invert the ADC input signal?
  15. ADC_INVERT := 0
  16. # Interpret the ADC setpoints as HSL instead of RGB, if 3 ADCs are available?
  17. ADC_HSL := 1
  18. ##############################################################################
  19. ##############################################################################
  20. ##############################################################################
  21. $(info DEV=$(DEV) PWM_LIM=$(PWM_LIM) PWM_INVERT=$(PWM_INVERT) ADC_INVERT=$(ADC_INVERT) ADC_HSL=$(ADC_HSL))
  22. # Project name
  23. NAME := simplepwm
  24. # Project source files
  25. SRCS := \
  26. adc.c \
  27. battery.c \
  28. color.c \
  29. crc.c \
  30. curve.c \
  31. debug.c \
  32. eeprom.c \
  33. filter.c \
  34. main.c \
  35. movingavg.c \
  36. outputsp.c \
  37. potentiometer.c \
  38. pcint.c \
  39. pwm.c \
  40. remote.c \
  41. ring.c \
  42. standby.c \
  43. uart.c \
  44. watchdog.c
  45. GEN_SRCS :=
  46. # Bootloader source files
  47. BOOT_SRCS :=
  48. BOOT_GEN_SRCS :=
  49. BOOT_OFFSET :=
  50. # Project fuse bits
  51. ifeq ($(DEV),t13)
  52. # ATTiny 13
  53. # 9.6 MHz, SUT 4 ms, BOD 2.7 V, WDT on, SPIEN
  54. F_CPU := 9600000UL
  55. LFUSE := 0x56
  56. HFUSE := 0xFB
  57. EFUSE :=
  58. endif
  59. ifeq ($(DEV),t25)
  60. # ATTiny 25
  61. # 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
  62. F_CPU := 8000000UL
  63. LFUSE := 0xD2
  64. HFUSE := 0xDD
  65. EFUSE := 0xFF
  66. endif
  67. ifeq ($(DEV),t45)
  68. # ATTiny 45
  69. # 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
  70. F_CPU := 8000000UL
  71. LFUSE := 0xD2
  72. HFUSE := 0xDD
  73. EFUSE := 0xFF
  74. endif
  75. ifeq ($(DEV),t85)
  76. # ATTiny 85
  77. # 8 MHz, SUT 4 ms, BOD 2.7 V, WDT off, SPIEN
  78. F_CPU := 8000000UL
  79. LFUSE := 0xD2
  80. HFUSE := 0xDD
  81. EFUSE := 0xFF
  82. endif
  83. ifeq ($(DEV),m88p)
  84. # ATMega 88P
  85. # 8 MHz, SUT 4.1 ms, BOD 2.7 V, WDT off, SPIEN
  86. F_CPU := 8000000UL
  87. LFUSE := 0xD2
  88. HFUSE := 0xDD
  89. EFUSE := 0xF9
  90. endif
  91. ifeq ($(DEV),m328p)
  92. # ATMega 328P
  93. # 8 MHz, SUT 4.1 ms, BOD 2.7 V, WDT off, SPIEN
  94. F_CPU := 8000000UL
  95. LFUSE := 0xD2
  96. HFUSE := 0xD9
  97. EFUSE := 0xFD
  98. endif
  99. # Architecture configuration
  100. GCC_ARCH := $(subst m,atmega,$(subst t,attiny,$(DEV)))
  101. AVRDUDE_ARCH := $(DEV)
  102. FUNC_STACK_LIMIT :=
  103. # Programmer selection.
  104. # Values can be: avrisp2, mysmartusb
  105. PROGRAMMER := avrisp2
  106. AVRDUDE_SPEED := 10
  107. AVRDUDE_SLOW_SPEED := 200
  108. # Instrumentation
  109. INSTRUMENT_FUNC :=
  110. BOOT_INSTRUMENT_FUNC :=
  111. # Additional compiler flags
  112. CFLAGS := -DPWM_LIM="$(PWM_LIM)" \
  113. -DPWM_INVERT="(!!($(PWM_INVERT)))" \
  114. -DADC_INVERT="(!!($(ADC_INVERT)))" \
  115. -DADC_HSL="$(ADC_HSL)"
  116. LDFLAGS :=
  117. # Additional "clean" and "distclean" target files
  118. CLEAN_FILES := pwm0_isr.c pwm1_isr.c pwm2_isr.c
  119. DISTCLEAN_FILES :=
  120. streq = $(and $(filter 1,$(words $2)),$(filter $1,$(firstword $2)))
  121. deveq = $(call streq,$1,$(DEV))
  122. ifeq ($(strip $(call deveq,t13)\
  123. $(call deveq,t25)\
  124. $(call deveq,t45)\
  125. $(call deveq,t85)\
  126. $(call deveq,m88p)\
  127. $(call deveq,m328p)),)
  128. $(error "DEV=$(DEV) is not supported.")
  129. endif
  130. include avrmakelib.mk
  131. pwm.c: pwm0_isr.c pwm1_isr.c pwm2_isr.c
  132. pwm0_isr.c: pwm_isr_template.c
  133. $(QUIET_SED) -e 's/%INDEX%/0/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@
  134. pwm1_isr.c: pwm_isr_template.c
  135. $(QUIET_SED) -e 's/%INDEX%/1/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@
  136. pwm2_isr.c: pwm_isr_template.c
  137. $(QUIET_SED) -e 's/%INDEX%/2/g' -e 's/%HEADER%/THIS IS A GENERATED FILE/g' $< > $@