Naze32 clone with Frysky receiver
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

makefile 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. TARGET = rx
  2. AVR = 1
  3. EXTRAINCDIR = include
  4. CSTANDARD = gnu99
  5. CPPSTANDARD = gnu++98
  6. BUILDDIRBASE = build
  7. ifeq ($(AVR),1)
  8. MCU = attiny85
  9. F_CPU = 16000000
  10. BUILDDIR = $(BUILDDIRBASE)/avr
  11. else
  12. MCU = cortex-m3
  13. BUILDDIR = $(BUILDDIRBASE)/arm
  14. endif
  15. RM = rm -rf
  16. MKDIR = mkdir -p
  17. ifeq ($(AVR),1)
  18. GCC = avr-gcc
  19. SIZE = avr-size
  20. OBJCOPY = avr-objcopy
  21. OBJDUMP = avr-objdump
  22. AVRDUDE = avrdude
  23. else
  24. GCC_BIN = ~/bin/mbed/gcc-arm-none-eabi/bin
  25. GCC = $(GCC_BIN)/arm-none-eabi-gcc
  26. GPP = $(GCC_BIN)/arm-none-eabi-g++
  27. SIZE = $(GCC_BIN)/arm-none-eabi-size
  28. OBJCOPY = $(GCC_BIN)/arm-none-eabi-objcopy
  29. OBJDUMP = $(GCC_BIN)/arm-none-eabi-objdump
  30. endif
  31. SRC = src/main.c
  32. SRC += src/cc2500.c
  33. SRC += src/rx.c
  34. SRC += src/spi.c
  35. ifeq ($(AVR),1)
  36. SRC += src/avr/timer.c
  37. SRC += src/avr/cppm.c
  38. ifeq ($(DEBUG),1)
  39. SRC += src/avr/serial.c
  40. endif
  41. else
  42. CPPSRC += src/arm/cppm.cpp
  43. CPPSRC += src/arm/serial.cpp
  44. CPPSRC += src/arm/spi.cpp
  45. CPPSRC += src/arm/timer.cpp
  46. endif
  47. ifeq ($(AVR),1)
  48. CARGS = -I$(EXTRAINCDIR)
  49. CARGS += -Os
  50. CARGS += -std=$(CSTANDARD)
  51. CARGS += -Wall -Wextra -pedantic -Werror
  52. CARGS += -mmcu=$(MCU)
  53. CARGS += -funsigned-bitfields
  54. CARGS += -fpack-struct
  55. CARGS += -fshort-enums
  56. CARGS += -ffunction-sections
  57. CARGS += -Wshadow
  58. CARGS += -Wpointer-arith -Wcast-qual -Wstrict-prototypes
  59. CARGS += -Wno-main -Wno-write-strings -Wno-unused-parameter
  60. CARGS += -DF_CPU=$(F_CPU)
  61. LINKER = -Wl,--relax
  62. LINKER += -Wl,-Map -Wl,$(@:.elf=.map)
  63. else
  64. PRE_DEFS = -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -DARM_MATH_CM3
  65. PRE_DEFS += -DTARGET_LIKE_CORTEX_M3 -DTARGET_CORTEX_M
  66. PRE_DEFS += -DMBED_BUILD_TIMESTAMP=1462534374.34
  67. PRE_DEFS += -DTARGET_LIKE_MBED -DTARGET_LPC176X -DTARGET_NXP
  68. PRE_DEFS += -DTARGET_LPC1768 -D__CORTEX_M3 -DTARGET_M3
  69. PRE_DEFS += -DTARGET_MBED_LPC1768 -D__MBED__=1
  70. CARGS = -I$(EXTRAINCDIR)
  71. CARGS += -Ilib
  72. CARGS += -Os
  73. CARGS += -std=$(CSTANDARD)
  74. CARGS += -Wall -Wextra -pedantic -Werror
  75. CARGS += -Wno-main
  76. CARGS += -mcpu=$(MCU)
  77. CARGS += -mthumb
  78. CARGS += -fno-common -fmessage-length=0
  79. CARGS += -fno-exceptions -ffunction-sections -fdata-sections
  80. CARGS += -fomit-frame-pointer
  81. CARGS += $(PRE_DEFS)
  82. CPPARGS = -I$(EXTRAINCDIR)
  83. CPPARGS += -Ilib/mbed
  84. CPPARGS += -Ilib/mbed/TARGET_LPC1768
  85. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP
  86. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X
  87. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768
  88. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  89. CPPARGS += -Os
  90. CPPARGS += -std=$(CPPSTANDARD)
  91. CPPARGS += -Wall -Wextra -pedantic -Werror
  92. CPPARGS += -Wno-main
  93. CPPARGS += -mcpu=$(MCU)
  94. CPPARGS += -mthumb
  95. CPPARGS += -fno-common -fmessage-length=0
  96. CPPARGS += -fno-exceptions -ffunction-sections -fdata-sections
  97. CPPARGS += -fomit-frame-pointer -fno-rtti
  98. CPPARGS += $(PRE_DEFS)
  99. LINKER = -mcpu=$(MCU)
  100. LINKER += -mthumb
  101. LINKER += -Wl,--gc-sections
  102. LINKER += --specs=nano.specs
  103. LINKER += -u _printf_float -u _scanf_float
  104. LINKER += -Wl,--wrap,main
  105. #LINKER += -Wl,--cref
  106. LINKER += -Tlib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
  107. LINKER += -Llib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  108. LINKER += -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
  109. LINKER += -lmbed
  110. CPPSRC += lib/MODSERIAL/FLUSH.cpp
  111. CPPSRC += lib/MODSERIAL/GETC.cpp
  112. CPPSRC += lib/MODSERIAL/INIT.cpp
  113. CPPSRC += lib/MODSERIAL/ISR_RX.cpp
  114. CPPSRC += lib/MODSERIAL/ISR_TX.cpp
  115. CPPSRC += lib/MODSERIAL/MODSERIAL_IRQ_INFO.cpp
  116. CPPSRC += lib/MODSERIAL/MODSERIAL.cpp
  117. CPPSRC += lib/MODSERIAL/PUTC.cpp
  118. CPPSRC += lib/MODSERIAL/RESIZE.cpp
  119. OBJ = lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o
  120. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o
  121. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o
  122. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o
  123. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o
  124. endif
  125. ifeq ($(DEBUG),1)
  126. CARGS += -DDEBUG
  127. endif
  128. ifeq ($(AVR),1)
  129. PROGRAMMER = arduino
  130. ISPPORT = /dev/tty.usbserial-A100OZQ1
  131. ISPBAUD = 57600
  132. else
  133. endif
  134. # -----------------------------------------------------------------------------
  135. OBJ += $(addprefix $(BUILDDIR)/, $(SRC:.c=.o))
  136. OBJ += $(addprefix $(BUILDDIR)/, $(CPPSRC:.cpp=.o))
  137. .PHONY: all
  138. all: $(BUILDDIR)/$(TARGET).hex $(BUILDDIR)/$(TARGET).bin
  139. .PHONY: debugArduino
  140. debugArduino:
  141. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328 DEBUG=1 all
  142. .PHONY: debugProgramArduino
  143. debugProgramArduino:
  144. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328p DEBUG=1 program
  145. .PHONY: debugMbed
  146. debugMbed:
  147. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 all
  148. .PHONY: debugProgramMbed
  149. debugProgramMbed:
  150. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 copy
  151. .PHONY: program
  152. program: $(BUILDDIR)/$(TARGET).hex
  153. $(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -b $(ISPBAUD) -P $(ISPPORT) -e -D -U $(BUILDDIR)/$(TARGET).hex
  154. .PHONY: copy
  155. copy: $(BUILDDIR)/$(TARGET).bin
  156. cp $(BUILDDIR)/$(TARGET).bin /Volumes/MBED/$(TARGET).bin
  157. .PHONY: clean
  158. clean:
  159. $(RM) $(BUILDDIRBASE)
  160. -include $(OBJ:.o=.d)
  161. $(BUILDDIR)/%.o: %.c
  162. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  163. $(GCC) $(CARGS) -c $< -o $@
  164. @$(GCC) $(CARGS) -MM $*.c > $(BUILDDIR)/$*.d
  165. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  166. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  167. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  168. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  169. @rm -f $(BUILDDIR)/$*.d.tmp
  170. $(BUILDDIR)/%.o: %.cpp
  171. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  172. $(GPP) $(CPPARGS) -c $< -o $@
  173. @$(GPP) $(CPPARGS) -MM $*.cpp > $(BUILDDIR)/$*.d
  174. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  175. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  176. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  177. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  178. @rm -f $(BUILDDIR)/$*.d.tmp
  179. $(BUILDDIR)/$(TARGET).elf: $(OBJ)
  180. $(GCC) $(CARGS) $(OBJ) $(LINKER) --output $@
  181. $(SIZE) $@
  182. $(BUILDDIR)/$(TARGET).hex: $(BUILDDIR)/$(TARGET).elf
  183. $(OBJCOPY) -O ihex $< $@
  184. $(OBJDUMP) -h -S $< > $(@:.hex=.lss)
  185. $(BUILDDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET).elf
  186. $(OBJCOPY) -O binary $< $@