Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
4.6 KiB

  1. PROJECT_NAME = $(PWD:B) ;
  2. PROJECT_DIR = . ;
  3. PROJECT_LIBS = EEPROM SPI RF24 ;
  4. OUT_DIR = ojam ;
  5. F_CPU = 16000000 ;
  6. MCU = atmega328p ;
  7. PORTS = /dev/tty.usbserial-A600eHIs /dev/tty.usbserial-A40081RP /dev/tty.usbserial-A9007LmI ;
  8. UPLOAD_RATE = 57600 ;
  9. AVRDUDE_PROTOCOL = stk500v1 ;
  10. COM = 33 ;
  11. # Host-specific overrides for locations
  12. if $(OS) = MACOSX
  13. {
  14. ARDUINO_VERSION = 22 ;
  15. OLD_DIR = /opt/arduino-0021 ;
  16. AVR_TOOLS_PATH = $(OLD_DIR)/hardware/tools/avr/bin ;
  17. AVRDUDECONFIG_PATH = $(OLD_DIR)/hardware/tools/avr/etc ;
  18. ARDUINO_DIR = /opt/Arduino ;
  19. ARDUINO_AVR = /usr/lib/avr/include ;
  20. }
  21. # Where is everything?
  22. ARDUINO_VERSION ?= 22 ;
  23. AVR_TOOLS_PATH ?= /usr/bin ;
  24. ARDUINO_DIR ?= /opt/arduino-00$(ARDUINO_VERSION) ;
  25. ARDUINO_AVR ?= $(ARDUINO_DIR)/hardware/tools/avr/avr/include/avr ;
  26. AVRDUDECONFIG_PATH ?= $(ARDUINO_DIR)/hardware/tools ;
  27. ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ;
  28. ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
  29. SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
  30. AVR_CC = $(AVR_TOOLS_PATH)/avr-gcc ;
  31. AVR_CXX = $(AVR_TOOLS_PATH)/avr-g++ ;
  32. AVR_LD = $(AVR_TOOLS_PATH)/avr-gcc ;
  33. AVR_OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy ;
  34. AVRDUDE = $(AVR_TOOLS_PATH)/avrdude ;
  35. DEFINES = F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
  36. CTUNING = -ffunction-sections -fdata-sections ;
  37. CXXTUNING = -fno-exceptions -fno-strict-aliasing ;
  38. CFLAGS = -Os -Wall -Wextra -mmcu=$(MCU) $(CTUNING) ;
  39. CXXFLAGS = $(CFLAGS) $(CXXTUNING) ;
  40. LDFLAGS = -Os -lm -Wl,--gc-sections -mmcu=atmega328p ;
  41. # Search everywhere for headers
  42. HDRS = $(PROJECT_DIR) $(ARDUINO_AVR) $(ARDUINO_CORE) [ GLOB $(ARDUINO_LIB) $(SKETCH_LIB) : [^.]* ] ;
  43. # Grab everything from the core directory
  44. CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
  45. # Grab everything from libraries. To avoid this "grab everything" behaviour, you
  46. # can specify specific modules to pick up in PROJECT_MODULES
  47. LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp ] ;
  48. # In addition to explicitly-specified program modules, pick up anything from the current
  49. # dir.
  50. PROJECT_MODULES += [ GLOB $(PROJECT_DIR) : *.c *.cpp *.pde ] ;
  51. # Shortcut for the out files
  52. OUT = $(OUT_DIR)/$(PROJECT_NAME) ;
  53. # AvrDude setup
  54. AVRDUDE_FLAGS = -V -F -D -C $(AVRDUDECONFIG_PATH)/avrdude.conf -p $(MCU) -c $(AVRDUDE_PROTOCOL) -b $(UPLOAD_RATE) ;
  55. rule GitVersion
  56. {
  57. Always $(<) ;
  58. Depends all : $(<) ;
  59. }
  60. actions GitVersion
  61. {
  62. echo "const char program_version[] = \"\\" > $(<)
  63. git log -1 --pretty=format:%h >> $(<)
  64. echo "\";" >> $(<)
  65. }
  66. GitVersion version.h ;
  67. rule AvrCc
  68. {
  69. Depends $(<) : $(>) ;
  70. Depends $(<) : $(<:D) ;
  71. Clean clean : $(<) ;
  72. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  73. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  74. }
  75. actions AvrCc
  76. {
  77. $(AVR_CC) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CFLAGS) $(>)
  78. }
  79. rule AvrC++
  80. {
  81. Depends $(<) : $(>) ;
  82. Depends $(<) : $(<:D) ;
  83. Clean clean : $(<) ;
  84. CCHDRS on $(<) = [ on $(<) FIncludes $(HDRS) ] ;
  85. CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ;
  86. }
  87. actions AvrC++
  88. {
  89. $(AVR_CXX) -c -o $(<) $(CCHDRS) $(CCDEFS) $(CXXFLAGS) $(>)
  90. }
  91. rule Pde
  92. {
  93. Depends $(<) : $(>) ;
  94. Depends $(<) : $(<:D) ;
  95. Clean clean : $(<) ;
  96. }
  97. actions Pde
  98. {
  99. echo "#include <WProgram.h>" > $(<)
  100. echo "#line 1 \"$(>)\"" >> $(<)
  101. cat $(>) >> $(<)
  102. }
  103. rule AvrPde
  104. {
  105. local _CPP = $(OUT_DIR)/$(_I:B).cpp ;
  106. Pde $(_CPP) : $(>) ;
  107. AvrC++ $(<) : $(_CPP) ;
  108. }
  109. rule AvrObject
  110. {
  111. switch $(>:S)
  112. {
  113. case .c : AvrCc $(<) : $(>) ;
  114. case .cpp : AvrC++ $(<) : $(>) ;
  115. case .pde : AvrPde $(<) : $(>) ;
  116. }
  117. }
  118. rule AvrObjects
  119. {
  120. for _I in $(<)
  121. {
  122. AvrObject $(OUT_DIR)/$(_I:B).o : $(_I) ;
  123. }
  124. }
  125. rule AvrMainFromObjects
  126. {
  127. Depends $(<) : $(>) ;
  128. Depends $(<) : $(<:D) ;
  129. MkDir $(<:D) ;
  130. Depends all : $(<) ;
  131. Clean clean : $(<) ;
  132. }
  133. actions AvrMainFromObjects
  134. {
  135. $(AVR_LD) $(LDFLAGS) -o $(<) $(>)
  136. }
  137. rule AvrMain
  138. {
  139. AvrMainFromObjects $(<) : $(OUT_DIR)/$(>:B).o ;
  140. AvrObjects $(>) ;
  141. }
  142. rule AvrHex
  143. {
  144. Depends $(<) : $(>) ;
  145. Depends $(<) : $(<:D) ;
  146. Depends hex : $(<) ;
  147. Clean clean : $(<) ;
  148. }
  149. actions AvrHex
  150. {
  151. $(AVR_OBJCOPY) -O ihex -R .eeprom $(>) $(<)
  152. }
  153. rule AvrUpload
  154. {
  155. Depends $(1) : $(2) ;
  156. Depends $(2) : $(3) ;
  157. NotFile $(1) ;
  158. Always $(1) ;
  159. Always $(2) ;
  160. AvrUploadAction $(2) : $(3) ;
  161. }
  162. actions AvrUploadAction
  163. {
  164. $(AVRDUDE) $(AVRDUDE_FLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
  165. }
  166. AvrMain $(OUT).elf : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
  167. AvrHex $(OUT).hex : $(OUT).elf ;
  168. AvrUpload p6 : /dev/tty.usbserial-A600eHIs : $(OUT).hex ;
  169. AvrUpload p4 : /dev/tty.usbserial-A40081RP : $(OUT).hex ;
  170. AvrUpload p9 : /dev/tty.usbserial-A9007LmI : $(OUT).hex ;