Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Build configuration:
  2. # Target device. May be one of:
  3. # t13 => ATTiny13
  4. # t25 => ATTiny25
  5. # t45 => ATTiny45
  6. # t85 => ATTiny85
  7. # m328p => ATMega328P
  8. DEV := t85
  9. # Load pulse configuration (all values in milliseconds):
  10. # Minimum length of high-phase:
  11. CONF_HIGH_MIN_MS := 4
  12. # Maximum length of high-phase:
  13. CONF_HIGH_MAX_MS := 6
  14. # Minimum length of low-phase:
  15. CONF_LOW_MIN_MS := 40000
  16. # Maximum length of low-phase:
  17. CONF_LOW_MAX_MS := 55000
  18. ##############################################################################
  19. ##############################################################################
  20. ##############################################################################
  21. $(info DEV=$(DEV) \
  22. CONF_HIGH_MIN_MS=$(CONF_HIGH_MIN_MS) \
  23. CONF_HIGH_MAX_MS=$(CONF_HIGH_MAX_MS) \
  24. CONF_LOW_MIN_MS=$(CONF_LOW_MIN_MS) \
  25. CONF_LOW_MAX_MS=$(CONF_LOW_MAX_MS))
  26. # Project name
  27. NAME := pbwake
  28. # Project source files
  29. SRCS := \
  30. bitops.c \
  31. load.c \
  32. main.c \
  33. shr3.c \
  34. watchdog.c
  35. GEN_SRCS :=
  36. # Bootloader source files
  37. BOOT_SRCS :=
  38. BOOT_GEN_SRCS :=
  39. BOOT_OFFSET :=
  40. ifeq ($(DEV),t13)
  41. # ATTiny 13
  42. # 128 kHz, SUT 64 ms, BOD 2.7 V, WDT on, SPIEN
  43. F_CPU := 128000UL
  44. LFUSE := 0x5B
  45. HFUSE := 0xFB
  46. EFUSE :=
  47. endif
  48. ifeq ($(DEV),t25)
  49. # ATTiny 25
  50. # 128 kHz, SUT 64 ms, BOD 2.7 V, WDT on, SPIEN
  51. F_CPU := 128000UL
  52. LFUSE := 0xE4
  53. HFUSE := 0xCD
  54. EFUSE := 0xFF
  55. endif
  56. ifeq ($(DEV),t45)
  57. # ATTiny 45
  58. # 128 kHz, SUT 64 ms, BOD 2.7 V, WDT on, SPIEN
  59. F_CPU := 128000UL
  60. LFUSE := 0xE4
  61. HFUSE := 0xCD
  62. EFUSE := 0xFF
  63. endif
  64. ifeq ($(DEV),t85)
  65. # ATTiny 85
  66. # 128 kHz, SUT 64 ms, BOD 2.7 V, WDT on, SPIEN
  67. F_CPU := 128000UL
  68. LFUSE := 0xE4
  69. HFUSE := 0xCD
  70. EFUSE := 0xFF
  71. endif
  72. ifeq ($(DEV),m328p)
  73. # ATMega 328P
  74. # 128 kHz, SUT 65 ms, BOD 2.7 V, WDT on, SPIEN
  75. F_CPU := 128000UL
  76. LFUSE := 0xE3
  77. HFUSE := 0xC9
  78. EFUSE := 0xFD
  79. endif
  80. # Architecture configuration
  81. GCC_ARCH := $(subst m,atmega,$(subst t,attiny,$(DEV)))
  82. AVRDUDE_ARCH := $(DEV)
  83. FUNC_STACK_LIMIT :=
  84. # Programmer selection.
  85. # Values can be: avrisp2, mysmartusb
  86. PROGRAMMER := avrisp2
  87. AVRDUDE_SPEED := 50
  88. AVRDUDE_SLOW_SPEED := 200
  89. # Instrumentation
  90. INSTRUMENT_FUNC :=
  91. BOOT_INSTRUMENT_FUNC :=
  92. # Additional compiler flags
  93. CFLAGS := -DCONF_HIGH_MIN_MS="$(CONF_HIGH_MIN_MS)" \
  94. -DCONF_HIGH_MAX_MS="$(CONF_HIGH_MAX_MS)" \
  95. -DCONF_LOW_MIN_MS="$(CONF_LOW_MIN_MS)" \
  96. -DCONF_LOW_MAX_MS="$(CONF_LOW_MAX_MS)"
  97. BOOT_CFLAGS := $(CFLAGS)
  98. LDFLAGS :=
  99. # Additional "clean" and "distclean" target files
  100. CLEAN_FILES :=
  101. DISTCLEAN_FILES :=
  102. streq = $(and $(filter 1,$(words $2)),$(filter $1,$(firstword $2)))
  103. deveq = $(call streq,$1,$(DEV))
  104. ifeq ($(strip $(call deveq,t13)\
  105. $(call deveq,t25)\
  106. $(call deveq,t45)\
  107. $(call deveq,t85)\
  108. $(call deveq,m328p)),)
  109. $(error "DEV=$(DEV) is not supported.")
  110. endif
  111. include avrmakelib.mk