Naze32 clone with Frysky receiver
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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/MODSERIAL
  84. CPPARGS += -Ilib/mbed
  85. CPPARGS += -Ilib/mbed/TARGET_LPC1768
  86. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP
  87. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X
  88. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768
  89. CPPARGS += -Ilib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  90. CPPARGS += -Os
  91. CPPARGS += -std=$(CPPSTANDARD)
  92. CPPARGS += -Wall -Wextra -pedantic -Werror
  93. CPPARGS += -Wno-main
  94. CPPARGS += -mcpu=$(MCU)
  95. CPPARGS += -mthumb
  96. CPPARGS += -fno-common -fmessage-length=0
  97. CPPARGS += -fno-exceptions -ffunction-sections -fdata-sections
  98. CPPARGS += -fomit-frame-pointer -fno-rtti
  99. CPPARGS += $(PRE_DEFS)
  100. LINKER = -mcpu=$(MCU)
  101. LINKER += -mthumb
  102. LINKER += -Wl,--gc-sections
  103. LINKER += --specs=nano.specs
  104. LINKER += -u _printf_float -u _scanf_float
  105. LINKER += -Wl,--wrap,main
  106. #LINKER += -Wl,--cref
  107. LINKER += -Tlib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
  108. LINKER += -Llib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
  109. LINKER += -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
  110. LINKER += -lmbed
  111. CPPSRC += lib/MODSERIAL/FLUSH.cpp
  112. CPPSRC += lib/MODSERIAL/GETC.cpp
  113. CPPSRC += lib/MODSERIAL/INIT.cpp
  114. CPPSRC += lib/MODSERIAL/ISR_RX.cpp
  115. CPPSRC += lib/MODSERIAL/ISR_TX.cpp
  116. CPPSRC += lib/MODSERIAL/MODSERIAL_IRQ_INFO.cpp
  117. CPPSRC += lib/MODSERIAL/MODSERIAL.cpp
  118. CPPSRC += lib/MODSERIAL/PUTC.cpp
  119. CPPSRC += lib/MODSERIAL/RESIZE.cpp
  120. OBJ = lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/board.o
  121. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/cmsis_nvic.o
  122. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o
  123. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o
  124. OBJ += lib/mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o
  125. endif
  126. ifeq ($(DEBUG),1)
  127. CARGS += -DDEBUG
  128. endif
  129. ifeq ($(AVR),1)
  130. PROGRAMMER = arduino
  131. ISPPORT = /dev/tty.usbserial-A100OZQ1
  132. ISPBAUD = 57600
  133. else
  134. endif
  135. # -----------------------------------------------------------------------------
  136. OBJ += $(addprefix $(BUILDDIR)/, $(SRC:.c=.o))
  137. OBJ += $(addprefix $(BUILDDIR)/, $(CPPSRC:.cpp=.o))
  138. .PHONY: all
  139. all: $(BUILDDIR)/$(TARGET).hex $(BUILDDIR)/$(TARGET).bin
  140. .PHONY: debugArduino
  141. debugArduino:
  142. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328 DEBUG=1 all
  143. .PHONY: debugProgramArduino
  144. debugProgramArduino:
  145. $(MAKE) BUILDDIR=build/avr/debug TARGET=debug MCU=atmega328p DEBUG=1 program
  146. .PHONY: debugMbed
  147. debugMbed:
  148. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 all
  149. .PHONY: debugProgramMbed
  150. debugProgramMbed:
  151. $(MAKE) BUILDDIR=build/arm/debug TARGET=debug AVR=0 DEBUG=1 copy
  152. .PHONY: program
  153. program: $(BUILDDIR)/$(TARGET).hex
  154. $(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -b $(ISPBAUD) -P $(ISPPORT) -e -D -U $(BUILDDIR)/$(TARGET).hex
  155. .PHONY: copy
  156. copy: $(BUILDDIR)/$(TARGET).bin
  157. cp $(BUILDDIR)/$(TARGET).bin /Volumes/MBED/$(TARGET).bin
  158. sync
  159. .PHONY: clean
  160. clean:
  161. $(RM) $(BUILDDIRBASE)
  162. -include $(OBJ:.o=.d)
  163. $(BUILDDIR)/%.o: %.c
  164. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  165. $(GCC) $(CARGS) -c $< -o $@
  166. @$(GCC) $(CARGS) -MM $*.c > $(BUILDDIR)/$*.d
  167. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  168. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  169. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  170. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  171. @rm -f $(BUILDDIR)/$*.d.tmp
  172. $(BUILDDIR)/%.o: %.cpp
  173. @$(MKDIR) $(BUILDDIR)/$(dir $<)
  174. $(GPP) $(CPPARGS) -c $< -o $@
  175. @$(GPP) $(CPPARGS) -MM $*.cpp > $(BUILDDIR)/$*.d
  176. @mv -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
  177. @sed -e 's|.*:|$(BUILDDIR)/$*.o:|' < $(BUILDDIR)/$*.d.tmp > $(BUILDDIR)/$*.d
  178. @sed -e 's/.*://' < $(BUILDDIR)/$*.d.tmp | sed -e 's/\\$$//' | \
  179. fmt -1 | sed -e 's/^ *//' | sed -e 's/$$/:/' >> $(BUILDDIR)/$*.d
  180. @rm -f $(BUILDDIR)/$*.d.tmp
  181. $(BUILDDIR)/$(TARGET).elf: $(OBJ)
  182. $(GCC) $(CARGS) $(OBJ) $(LINKER) --output $@
  183. $(SIZE) $@
  184. $(BUILDDIR)/$(TARGET).hex: $(BUILDDIR)/$(TARGET).elf
  185. $(OBJCOPY) -O ihex $< $@
  186. $(OBJDUMP) -h -S $< > $(@:.hex=.lss)
  187. $(BUILDDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET).elf
  188. $(OBJCOPY) -O binary $< $@