Permalink
Browse files

Merge branch 'wip-family-support'

Merge the long-lived (too long; future changes like these will need to
proceed more incrementally) development branch of libmaple, containing
experimental STM32F2 and STM32F1 value line support, into master.

This required many changes to the structure of the library. The most
important structural reorganizations occurred in:

- 954f9e5: moves public headers to include directories
- 3efa313: uses "series" instead of "family"
- c0d60e3: adds board files to the build system, to make it easier to
  add new boards
- 096d86c: adds build logic for targeting different STM32 series
  (e.g. STM32F1, STM32F2)

This last commit in particular (096d86c) is the basis for the
repartitioning of libmaple into portable sections, which work on all
supported MCUs, and nonportable sections, which are segregated into
separate directories and contain all series-specific code. Moving
existing STM32F1-only code into libmaple/stm32f1 and wirish/stm32f1,
along with adding equivalents under .../stm32f2 directories, was the
principal project of this branch.

Important API changes occur in several places. Existing code is still
expected to work on STM32F1 targets, but there have been many
deprecations. A detailed changelog explaining the situation needs to
be prepared.

F2 and F1 value line support is not complete; the merge is proceeding
prematurely in this respect. We've been getting more libmaple patches
from the community lately, and I'm worried that the merge conflicts
with the old tree structure will become painful to manage.

Conflicts:
	Makefile

Resolved Makefile conflicts manually; this required propagating
-Xlinker usage into support/make/target-config.mk.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
  • Loading branch information...
2 parents 7451d1d + 12aecf5 commit ccc23369719f8909fe61a8423fdf382582414702 @mbolivar mbolivar committed Jun 26, 2012
Showing with 17,303 additions and 5,417 deletions.
  1. +2 −1 .gitignore
  2. +58 −54 Makefile
  3. +0 −1 README
  4. 0 {support → contrib}/openocd/debug_0.3.cfg
  5. 0 {support → contrib}/openocd/debug_0.4.cfg
  6. 0 {support → contrib}/openocd/flash_0.3.cfg
  7. 0 {support → contrib}/openocd/flash_0.4.cfg
  8. 0 {support/scripts → contrib/openocd}/openocd-wrapper.sh
  9. +1 −1 examples/blinky.cpp
  10. +5 −7 examples/debug-dtrrts.cpp
  11. +1 −1 examples/freertos-blinky.cpp
  12. +3 −3 examples/fsmc-stress-test.cpp
  13. +145 −0 examples/i2c-mcp4725-dac.cpp
  14. +1 −1 examples/mini-exti-test.cpp
  15. +1 −1 examples/qa-slave-shield.cpp
  16. +30 −0 examples/serial-echo.cpp
  17. +1 −1 examples/spi_master.cpp
  18. +3 −3 examples/test-bkp.cpp
  19. +2 −2 examples/test-dac.cpp
  20. +2 −2 examples/test-fsmc.cpp
  21. +1 −1 examples/test-print.cpp
  22. +2 −2 examples/test-ring-buffer-insertion.cpp
  23. +1 −1 examples/test-serial-flush.cpp
  24. +3 −3 examples/test-serialusb.cpp
  25. +1 −1 examples/test-servo.cpp
  26. +1 −1 examples/test-session.cpp
  27. +1 −1 examples/test-spi-roundtrip.cpp
  28. +2 −2 examples/test-systick.cpp
  29. +475 −235 examples/test-timers.cpp
  30. +154 −66 examples/test-usart-dma.cpp
  31. +1 −1 examples/vga-leaf.cpp
  32. +2 −2 examples/vga-scope.cpp
  33. +11 −67 libmaple/adc.c
  34. +11 −17 libmaple/dac.c
  35. +0 −168 libmaple/dac.h
  36. +0 −30 libmaple/delay.h
  37. +33 −330 libmaple/dma.c
  38. +0 −453 libmaple/dma.h
  39. +61 −0 libmaple/dma_private.h
  40. +38 −25 libmaple/exti.c
  41. +34 −0 libmaple/exti_private.h
  42. +8 −14 libmaple/flash.c
  43. +5 −152 libmaple/gpio.c
  44. +216 −272 libmaple/i2c.c
  45. +79 −0 libmaple/i2c_private.h
  46. +79 −114 libmaple/{ → include/libmaple}/adc.h
  47. +15 −7 libmaple/{ → include/libmaple}/bitband.h
  48. +7 −7 libmaple/{ → include/libmaple}/bkp.h
  49. +158 −0 libmaple/include/libmaple/dac.h
  50. +65 −0 libmaple/include/libmaple/delay.h
  51. +444 −0 libmaple/include/libmaple/dma.h
  52. +114 −0 libmaple/include/libmaple/dma_common.h
  53. +76 −12 libmaple/{ → include/libmaple}/exti.h
  54. +106 −0 libmaple/include/libmaple/flash.h
  55. +64 −44 libmaple/{ → include/libmaple}/fsmc.h
  56. +121 −0 libmaple/include/libmaple/gpio.h
  57. +229 −164 libmaple/{ → include/libmaple}/i2c.h
  58. +95 −0 libmaple/include/libmaple/i2c_common.h
  59. +7 −8 libmaple/{ → include/libmaple}/iwdg.h
  60. +14 −7 libmaple/{ → include/libmaple}/libmaple.h
  61. +19 −4 libmaple/{ → include/libmaple}/libmaple_types.h
  62. +155 −0 libmaple/include/libmaple/nvic.h
  63. +43 −13 libmaple/{ → include/libmaple}/pwr.h
  64. +175 −0 libmaple/include/libmaple/rcc.h
  65. +5 −6 libmaple/{ → include/libmaple}/ring_buffer.h
  66. +12 −4 libmaple/{ → include/libmaple}/scb.h
  67. +91 −78 libmaple/{ → include/libmaple}/spi.h
  68. +237 −0 libmaple/include/libmaple/stm32.h
  69. +151 −0 libmaple/include/libmaple/syscfg.h
  70. +7 −9 libmaple/{ → include/libmaple}/systick.h
  71. +372 −274 libmaple/{ → include/libmaple}/timer.h
  72. +209 −50 libmaple/{ → include/libmaple}/usart.h
  73. +6 −6 libmaple/{ → include/libmaple}/usb.h
  74. +5 −5 libmaple/{usb → include/libmaple}/usb_cdcacm.h
  75. +8 −8 libmaple/{ → include/libmaple}/util.h
  76. +2 −2 libmaple/iwdg.c
  77. +19 −15 libmaple/nvic.c
  78. +3 −3 libmaple/pwr.c
  79. +116 −153 libmaple/rcc.c
  80. +67 −0 libmaple/rcc_private.h
  81. +23 −31 libmaple/rules.mk
  82. +4 −80 libmaple/spi.c
  83. +37 −0 libmaple/spi_private.h
  84. +0 −191 libmaple/stm32.h
  85. +45 −0 libmaple/stm32_private.h
  86. +112 −0 libmaple/stm32f1/adc.c
  87. +6 −6 libmaple/{ → stm32f1}/bkp.c
  88. +412 −0 libmaple/stm32f1/dma.c
  89. +32 −0 libmaple/stm32f1/exti.c
  90. +11 −9 libmaple/{ → stm32f1}/fsmc.c
  91. +166 −0 libmaple/stm32f1/gpio.c
  92. +129 −0 libmaple/stm32f1/i2c.c
  93. +254 −0 libmaple/stm32f1/include/series/adc.h
  94. +71 −0 libmaple/stm32f1/include/series/dac.h
  95. +565 −0 libmaple/stm32f1/include/series/dma.h
  96. +46 −0 libmaple/stm32f1/include/series/exti.h
  97. +46 −39 libmaple/{ → stm32f1/include/series}/flash.h
  98. +211 −245 libmaple/{ → stm32f1/include/series}/gpio.h
  99. +85 −0 libmaple/stm32f1/include/series/i2c.h
  100. +57 −125 libmaple/{ → stm32f1/include/series}/nvic.h
  101. +52 −0 libmaple/stm32f1/include/series/pwr.h
  102. +259 −230 libmaple/{ → stm32f1/include/series}/rcc.h
  103. +99 −0 libmaple/stm32f1/include/series/spi.h
  104. +212 −0 libmaple/stm32f1/include/series/stm32.h
  105. +128 −0 libmaple/stm32f1/include/series/timer.h
  106. +76 −0 libmaple/stm32f1/include/series/usart.h
  107. +27 −1 libmaple/stm32f1/{isrs_performance.S → performance/isrs.S}
  108. +27 −1 libmaple/stm32f1/{vector_table_performance.S → performance/vector_table.S}
  109. +164 −0 libmaple/stm32f1/rcc.c
  110. +24 −3 libmaple/stm32f1/rules.mk
  111. +84 −0 libmaple/stm32f1/spi.c
  112. +124 −0 libmaple/stm32f1/timer.c
  113. +170 −0 libmaple/stm32f1/usart.c
  114. +270 −0 libmaple/stm32f1/value/isrs.S
  115. +116 −0 libmaple/stm32f1/value/vector_table.S
  116. +84 −0 libmaple/stm32f2/adc.c
  117. +504 −0 libmaple/stm32f2/dma.c
  118. +33 −0 libmaple/stm32f2/exti.c
  119. +90 −0 libmaple/stm32f2/fsmc.c
  120. +194 −0 libmaple/stm32f2/gpio.c
  121. +331 −0 libmaple/stm32f2/include/series/adc.h
  122. +94 −0 libmaple/stm32f2/include/series/dac.h
  123. +810 −0 libmaple/stm32f2/include/series/dma.h
  124. +46 −0 libmaple/stm32f2/include/series/exti.h
  125. +202 −0 libmaple/stm32f2/include/series/flash.h
  126. +264 −0 libmaple/stm32f2/include/series/gpio.h
  127. +160 −0 libmaple/stm32f2/include/series/nvic.h
  128. +73 −0 libmaple/stm32f2/include/series/pwr.h
  129. +951 −0 libmaple/stm32f2/include/series/rcc.h
  130. +88 −0 libmaple/stm32f2/include/series/spi.h
  131. +77 −0 libmaple/stm32f2/include/series/stm32.h
  132. +176 −0 libmaple/stm32f2/include/series/timer.h
  133. +111 −0 libmaple/stm32f2/include/series/usart.h
  134. +322 −0 libmaple/stm32f2/isrs.S
  135. +175 −0 libmaple/stm32f2/rcc.c
  136. +40 −0 libmaple/stm32f2/rules.mk
  137. +88 −0 libmaple/stm32f2/spi.c
  138. +78 −0 libmaple/stm32f2/syscfg.c
  139. +148 −0 libmaple/stm32f2/timer.c
  140. +204 −0 libmaple/stm32f2/usart.c
  141. +135 −0 libmaple/stm32f2/vector_table.S
  142. +3 −3 libmaple/systick.c
  143. +204 −272 libmaple/timer.c
  144. +235 −0 libmaple/timer_private.h
  145. +6 −138 libmaple/usart.c
  146. +41 −0 libmaple/usart_private.c
  147. +53 −0 libmaple/usart_private.h
  148. +30 −39 libmaple/usb/README
  149. +45 −0 libmaple/usb/rules.mk
  150. +8 −4 libmaple/usb/{ → stm32f1}/usb.c
  151. +13 −13 libmaple/usb/{ → stm32f1}/usb_cdcacm.c
  152. +1 −1 libmaple/usb/{ → stm32f1}/usb_descriptors.h
  153. +1 −0 libmaple/usb/{ → stm32f1}/usb_lib_globals.h
  154. 0 libmaple/usb/{ → stm32f1}/usb_reg_map.c
  155. +2 −2 libmaple/usb/{ → stm32f1}/usb_reg_map.h
  156. +46 −77 libmaple/util.c
  157. +1 −1 libraries/FreeRTOS/MapleFreeRTOS.h
  158. +1 −1 libraries/LiquidCrystal/LiquidCrystal.cpp
  159. +2 −2 libraries/LiquidCrystal/LiquidCrystal.h
  160. +4 −4 libraries/Servo/Servo.cpp
  161. +3 −7 libraries/Servo/Servo.h
  162. +0 −1 libraries/Wire/Wire.cpp
  163. +2 −2 libraries/Wire/Wire.h
  164. +1 −1 main.cpp.example
  165. 0 notes/{dma.txt → dma-stm32f1.txt}
  166. +63 −0 notes/stm32.txt
  167. +12 −6 support/doxygen/Doxyfile
  168. +38 −0 support/doxygen/evil_mangler.awk
  169. +26 −0 support/ld/flash.ld
  170. +31 −0 support/ld/jtag.ld
  171. +0 −24 support/ld/maple/flash.ld
  172. +0 −24 support/ld/maple/jtag.ld
  173. +0 −22 support/ld/maple/ram.ld
  174. +0 −18 support/ld/maple_RET6/flash.ld
  175. +0 −18 support/ld/maple_RET6/jtag.ld
  176. +0 −17 support/ld/maple_RET6/ram.ld
  177. +0 −23 support/ld/maple_mini/flash.ld
  178. +0 −24 support/ld/maple_mini/jtag.ld
  179. +0 −22 support/ld/maple_mini/ram.ld
  180. +0 −22 support/ld/maple_native/flash.ld
  181. +0 −22 support/ld/maple_native/jtag.ld
  182. +0 −20 support/ld/maple_native/ram.ld
  183. +0 −1 support/ld/olimex_stm32_h103
  184. +25 −0 support/ld/ram.ld
  185. +3 −0 support/ld/stm32/mem/maple_native/maple_native_heap.inc
  186. +7 −0 support/ld/stm32/mem/maple_native/mem-flash.inc
  187. +7 −0 support/ld/stm32/mem/maple_native/mem-jtag.inc
  188. +7 −0 support/ld/stm32/mem/maple_native/mem-ram.inc
  189. +5 −0 support/ld/stm32/mem/sram_112k_flash_1024k/mem-jtag.inc
  190. +5 −0 support/ld/stm32/mem/sram_112k_flash_1024k/mem-ram.inc
  191. +5 −0 support/ld/stm32/mem/sram_20k_flash_128k/mem-flash.inc
  192. +5 −0 support/ld/stm32/mem/sram_20k_flash_128k/mem-jtag.inc
  193. +5 −0 support/ld/stm32/mem/sram_20k_flash_128k/mem-ram.inc
  194. +5 −0 support/ld/stm32/mem/sram_64k_flash_512k/mem-flash.inc
  195. +5 −0 support/ld/stm32/mem/sram_64k_flash_512k/mem-jtag.inc
  196. +5 −0 support/ld/stm32/mem/sram_64k_flash_512k/mem-ram.inc
  197. +5 −0 support/ld/stm32/mem/sram_8k_flash_128k/mem-flash.inc
  198. +5 −0 support/ld/stm32/mem/sram_8k_flash_128k/mem-jtag.inc
  199. +5 −0 support/ld/stm32/mem/sram_8k_flash_128k/mem-ram.inc
  200. 0 support/ld/stm32/{f1 → series/stm32f1}/performance/vector_symbols.inc
  201. +78 −0 support/ld/stm32/series/stm32f1/value/vector_symbols.inc
  202. +98 −0 support/ld/stm32/series/stm32f2/vector_symbols.inc
  203. +7 −0 support/make/board-includes/VLDiscovery.mk
  204. +10 −0 support/make/board-includes/maple.mk
  205. +7 −0 support/make/board-includes/maple_RET6.mk
  206. +7 −0 support/make/board-includes/maple_mini.mk
  207. +7 −0 support/make/board-includes/maple_native.mk
  208. +7 −0 support/make/board-includes/olimex_stm32_h103.mk
  209. +5 −0 support/make/board-includes/st_stm3220g_eval.mk
  210. +0 −1 support/make/build-rules.mk
  211. +0 −1 support/make/build-templates.mk
  212. +33 −64 support/make/target-config.mk
  213. +9 −13 wirish/{comm → }/HardwareSPI.cpp
  214. +134 −0 wirish/HardwareSerial.cpp
  215. +37 −28 wirish/HardwareTimer.cpp
  216. +3 −3 wirish/Print.cpp
  217. +108 −70 wirish/boards.cpp
  218. +20 −32 wirish/boards/{maple.cpp → VLDiscovery/board.cpp}
  219. +91 −0 wirish/boards/VLDiscovery/include/board/board.h
  220. +143 −0 wirish/boards/maple/board.cpp
  221. +17 −12 wirish/boards/{maple.h → maple/include/board/board.h}
  222. +5 −8 wirish/boards/{maple_RET6.cpp → maple_RET6/board.cpp}
  223. +5 −7 wirish/boards/{maple_RET6.h → maple_RET6/include/board/board.h}
  224. +6 −9 wirish/boards/{maple_mini.cpp → maple_mini/board.cpp}
  225. +4 −3 wirish/boards/{maple_mini.h → maple_mini/include/board/board.h}
  226. +7 −11 wirish/boards/{maple_native.cpp → maple_native/board.cpp}
  227. +4 −3 wirish/boards/{maple_native.h → maple_native/include/board/board.h}
  228. +6 −9 wirish/boards/{olimex_stm32_h103.cpp → olimex_stm32_h103/board.cpp}
  229. +2 −2 wirish/boards/{olimex_stm32_h103.h → olimex_stm32_h103/include/board/board.h}
  230. +60 −0 wirish/boards/st_stm3220g_eval/board.cpp
  231. +53 −0 wirish/boards/st_stm3220g_eval/include/board/board.h
  232. +71 −0 wirish/boards_private.h
  233. +0 −119 wirish/comm/HardwareSerial.cpp
  234. +9 −9 wirish/ext_interrupts.cpp
  235. +14 −7 wirish/{comm → include/wirish}/HardwareSPI.h
  236. +28 −12 wirish/{comm → include/wirish}/HardwareSerial.h
  237. +15 −9 wirish/{ → include/wirish}/HardwareTimer.h
  238. +3 −3 wirish/{ → include/wirish}/Print.h
  239. +6 −1 wirish/{ → include/wirish}/WProgram.h
  240. +2 −2 wirish/{ → include/wirish}/bit_constants.h
  241. +6 −1 wirish/{ → include/wirish}/bits.h
  242. +60 −42 wirish/{ → include/wirish}/boards.h
  243. +7 −8 wirish/{ → include/wirish}/ext_interrupts.h
  244. +8 −9 wirish/{ → include/wirish}/io.h
  245. +5 −6 wirish/{ → include/wirish}/pwm.h
  246. +7 −4 wirish/{ → include/wirish}/usb_serial.h
  247. +21 −17 wirish/{ → include/wirish}/wirish.h
  248. +6 −10 wirish/{ → include/wirish}/wirish_debug.h
  249. +4 −4 wirish/{ → include/wirish}/wirish_math.h
  250. +6 −6 wirish/{ → include/wirish}/wirish_time.h
  251. +7 −7 wirish/{ → include/wirish}/wirish_types.h
  252. +12 −9 wirish/pwm.cpp
  253. +33 −25 wirish/rules.mk
  254. +89 −0 wirish/stm32f1/boards_setup.cpp
  255. +83 −0 wirish/stm32f1/util_hooks.c
  256. +41 −0 wirish/stm32f1/wirish_debug.cpp
  257. +89 −0 wirish/stm32f1/wirish_digital.cpp
  258. +120 −0 wirish/stm32f2/boards_setup.cpp
  259. +45 −0 wirish/stm32f2/util_hooks.c
  260. +60 −0 wirish/stm32f2/wirish_debug.cpp
  261. +99 −0 wirish/stm32f2/wirish_digital.cpp
  262. +19 −16 {libmaple → wirish}/syscalls.c
  263. +15 −3 wirish/usb_serial.cpp
  264. +9 −8 wirish/wirish_analog.cpp
  265. +9 −61 wirish/wirish_digital.cpp
  266. +1 −1 wirish/wirish_math.cpp
  267. +29 −32 wirish/wirish_shift.cpp
  268. +3 −3 wirish/wirish_time.cpp
View
@@ -1,5 +1,6 @@
build/
-doxygen/
+doxygen/xml/
+doxygen/html/
main.cpp
libmaple.layout
tags
View
@@ -19,10 +19,7 @@ SUPPORT_PATH := $(SRCROOT)/support
LDDIR := $(SUPPORT_PATH)/ld
# Support files for this Makefile
MAKEDIR := $(SUPPORT_PATH)/make
-
-# USB ID for DFU upload
-VENDOR_ID := 1EAF
-PRODUCT_ID := 0003
+BOARD_INCLUDE_DIR := $(MAKEDIR)/board-includes
##
## Target-specific configuration. This determines some compiler and
@@ -41,40 +38,42 @@ include $(MAKEDIR)/target-config.mk
## Compilation flags
##
-GLOBAL_FLAGS := -D$(VECT_BASE_ADDR) \
- -DBOARD_$(BOARD) -DMCU_$(MCU) \
- -DERROR_LED_PORT=$(ERROR_LED_PORT) \
- -DERROR_LED_PIN=$(ERROR_LED_PIN) \
- -D$(DENSITY)
+# FIXME: the following allows for deprecated include style, e.g.:
+# #include "libmaple.h"
+# or
+# #include "wirish.h"
+# It slows compilation noticeably; remove after 1 release.
+TARGET_FLAGS += -I$(LIBMAPLE_PATH)/include/libmaple \
+ -I$(WIRISH_PATH)/include/wirish
GLOBAL_CFLAGS := -Os -g3 -gdwarf-2 -mcpu=cortex-m3 -mthumb -march=armv7-m \
-nostdlib -ffunction-sections -fdata-sections \
- -Wl,--gc-sections $(GLOBAL_FLAGS)
-GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall $(GLOBAL_FLAGS)
+ -Wl,--gc-sections $(TARGET_FLAGS)
+GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall $(TARGET_FLAGS)
GLOBAL_ASFLAGS := -mcpu=cortex-m3 -march=armv7-m -mthumb \
- -x assembler-with-cpp $(GLOBAL_FLAGS)
-LDFLAGS = -T$(LDDIR)/$(LDSCRIPT) -L$(LDDIR) \
- -mcpu=cortex-m3 -mthumb -Xlinker -L $(LD_FAMILY_PATH) \
- -Xlinker --gc-sections -Xlinker --print-gc-sections \
- -Xassembler --march=armv7-m -Wall
+ -x assembler-with-cpp $(TARGET_FLAGS)
+LDFLAGS = $(TARGET_LDFLAGS) -mcpu=cortex-m3 -mthumb \
+ -Xlinker --gc-sections -Xlinker --print-gc-sections \
+ -Xassembler --march=armv7-m -Wall
##
## Build rules and useful templates
##
-include $(SUPPORT_PATH)/make/build-rules.mk
-include $(SUPPORT_PATH)/make/build-templates.mk
+include $(MAKEDIR)/build-rules.mk
+include $(MAKEDIR)/build-templates.mk
##
## Set all submodules here
##
LIBMAPLE_MODULES += $(SRCROOT)/libmaple
-LIBMAPLE_MODULES += $(LIBMAPLE_MODULE_FAMILY) # family submodule in libmaple
+LIBMAPLE_MODULES += $(SRCROOT)/libmaple/usb # The USB module is kept separate
+LIBMAPLE_MODULES += $(LIBMAPLE_MODULE_SERIES) # STM32 series submodule in libmaple
LIBMAPLE_MODULES += $(SRCROOT)/wirish
+
# Official libraries:
LIBMAPLE_MODULES += $(SRCROOT)/libraries/Servo
LIBMAPLE_MODULES += $(SRCROOT)/libraries/LiquidCrystal
LIBMAPLE_MODULES += $(SRCROOT)/libraries/Wire
-
# Experimental libraries:
LIBMAPLE_MODULES += $(SRCROOT)/libraries/FreeRTOS
@@ -93,16 +92,18 @@ $(foreach m,$(LIBMAPLE_MODULES),$(eval $(call LIBMAPLE_MODULE_template,$(m))))
# main target
include $(SRCROOT)/build-targets.mk
-.PHONY: install sketch clean help debug cscope tags ctags ram flash jtag doxygen mrproper
+.PHONY: install sketch clean help cscope tags ctags ram flash jtag doxygen mrproper list-boards
# Target upload commands
+# USB ID for DFU upload -- FIXME: do something smarter with this
+BOARD_USB_VENDOR_ID := 1EAF
+BOARD_USB_PRODUCT_ID := 0003
UPLOAD_ram := $(SUPPORT_PATH)/scripts/reset.py && \
sleep 1 && \
- $(DFU) -a0 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
+ $(DFU) -a0 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
UPLOAD_flash := $(SUPPORT_PATH)/scripts/reset.py && \
sleep 1 && \
- $(DFU) -a1 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
-UPLOAD_jtag := $(OPENOCD_WRAPPER) flash
+ $(DFU) -a1 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
# Conditionally upload to whatever the last build was
install: INSTALL_TARGET = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null)
@@ -127,38 +128,37 @@ mrproper: clean
help:
@echo ""
- @echo " libmaple Makefile help"
- @echo " ----------------------"
- @echo " "
- @echo " Programming targets:"
- @echo " sketch: Compile for BOARD to MEMORY_TARGET (default)."
- @echo " install: Compile and upload code over USB, using Maple bootloader"
- @echo " "
- @echo " You *must* set BOARD if not compiling for Maple (e.g."
- @echo " use BOARD=maple_mini for mini, etc.), and MEMORY_TARGET"
- @echo " if not compiling to Flash."
- @echo " "
- @echo " Valid BOARDs:"
- @echo " maple, maple_mini, maple_RET6, maple_native"
- @echo " "
- @echo " Valid MEMORY_TARGETs (default=flash):"
- @echo " ram: Compile sketch code to ram"
- @echo " flash: Compile sketch code to flash"
- @echo " jtag: Compile sketch code for jtag; overwrites bootloader"
- @echo " "
- @echo " Other targets:"
- @echo " debug: Start OpenOCD gdb server on port 3333, telnet on port 4444"
- @echo " clean: Remove all build and object files"
- @echo " help: Show this message"
- @echo " doxygen: Build Doxygen HTML and XML documentation"
- @echo " mrproper: Remove all generated files"
- @echo " "
-
-debug:
- $(OPENOCD_WRAPPER) debug
+ @echo "Basic usage (BOARD defaults to maple):"
+ @echo " $$ cp your-main.cpp main.cpp"
+ @echo " $$ make BOARD=your_board"
+ @echo " $$ make BOARD=your_board install"
+ @echo ""
+ @echo "(Multiple source files? Link with libmaple.a (\`$$ make library')"
+ @echo "or hack build-targets.mk appropriately.)"
+ @echo ""
+ @echo "Important targets:"
+ @echo " sketch: Compile for BOARD to MEMORY_TARGET (default)."
+ @echo " install: Compile and upload over USB using Maple bootloader"
+ @echo ""
+ @echo "You *must* set BOARD if not compiling for Maple (e.g."
+ @echo "use BOARD=maple_mini for mini, etc.), and MEMORY_TARGET"
+ @echo "if not compiling to Flash. Run \`$$ make list-boards' for"
+ @echo "a list of all boards."
+ @echo ""
+ @echo "Valid MEMORY_TARGETs (default=flash):"
+ @echo " ram: Compile to RAM (doesn't touch Flash)"
+ @echo " flash: Compile to Flash (for Maple bootloader)"
+ @echo " jtag: Compile for JTAG/SWD upload (overwrites bootloader)"
+ @echo ""
+ @echo "Other targets:"
+ @echo " clean: Remove all build and object files"
+ @echo " doxygen: Build Doxygen HTML and XML documentation"
+ @echo " help: Show this message"
+ @echo " mrproper: Remove all generated files"
+ @echo ""
cscope:
- rm -rf *.cscope
+ rm -rf cscope.*
find . -name '*.[hcS]' -o -name '*.cpp' | xargs cscope -b
tags:
@@ -180,3 +180,7 @@ jtag:
doxygen:
doxygen $(SUPPORT_PATH)/doxygen/Doxyfile
+
+# This output is kind of ugly, but I don't understand make very well.
+list-boards:
+ @echo " $(addsuffix "\\n",$(basename $(notdir $(wildcard $(BOARD_INCLUDE_DIR)/*.mk))))"
View
@@ -122,7 +122,6 @@ Repository Layout
gdb/ GDB scripts.
ld/ Linker scripts.
make/ Additional scripts used by the top-level Makefile.
- openocd/ OpenOCD scripts for JTAG debugging.
scripts/ Miscellany.
doxygen/ Doxygen configuration.
stm32loader.py Script for uploading via the built-in USART bootloader.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -1,6 +1,6 @@
// Blinks the built-in LED
-#include "wirish.h"
+#include <wirish/wirish.h>
void setup() {
pinMode(BOARD_LED_PIN, OUTPUT);
@@ -1,7 +1,7 @@
// Test sketch for figuring out DTR/RTS behavior on different platforms.
-#include "wirish.h"
-#include "usb.h"
+#include <wirish/wirish.h>
+#include "usb_cdcacm.h"
void setup() {
/* Set up the LED to blink */
@@ -10,17 +10,16 @@ void setup() {
/* Send a message out USART2 */
Serial2.begin(9600);
Serial2.println("Debugging DTR/RTS...");
-
}
void loop() {
toggleLED();
delay(100);
Serial2.print("DTR: ");
- Serial2.print(usbGetDTR(), DEC);
+ Serial2.print(usb_cdcacm_get_dtr(), DEC);
Serial2.print("\tRTS: ");
- Serial2.println(usbGetRTS(), DEC);
+ Serial2.println(usb_cdcacm_get_rts(), DEC);
}
// Force init to be called *first*, i.e. before static object allocation.
@@ -32,9 +31,8 @@ __attribute__((constructor)) void premain() {
int main(void) {
setup();
- while (1) {
+ while (true) {
loop();
}
return 0;
}
-
@@ -1,4 +1,4 @@
-#include "wirish.h"
+#include <wirish/wirish.h>
#include "libraries/FreeRTOS/MapleFreeRTOS.h"
static void vLEDFlashTask(void *pvParameters) {
@@ -12,9 +12,9 @@
#include <stdio.h>
#include <stddef.h>
-#include "wirish.h"
-#include "rcc.h"
-#include "fsmc.h"
+#include <wirish/wirish.h>
+#include <libmaple/rcc.h>
+#include <libmaple/fsmc.h>
// -- SRAM config -------------------------------------------------------------
@@ -0,0 +1,145 @@
+// i2c-mcp4725-dac.cpp
+//
+// Written by Andrew Meyer <ajm@leaflabs.com>
+// Modified by Marti Bolivar <mbolivar@leaflabs.com>
+//
+// Simple program showing how to control an MCP4725 DAC using the
+// libmaple I2C interface. There's an MCP4725 breakout board available
+// on SparkFun:
+//
+// http://www.sparkfun.com/products/8736
+//
+// How to use:
+//
+// 1. Connect the DAC SDA and SCL pins to I2C2, with a pullup
+// resistor (1 KOhm should work) to VCC.
+// 2. Load the sketch and connect to SerialUSB.
+// 3. Press the button.
+//
+// The program then makes sure the DAC is connected properly (during
+// setup()), then has the DAC output a sawtooth wave (with loop()).
+
+#include <wirish/wirish.h>
+#include <libmaple/i2c.h>
+
+#define MCP_ADDR 0x60
+#define MCP_WRITE_DAC 0b01000000
+#define MCP_WRITE_EEPROM 0b01100000
+#define MCP_PD_NORMAL 0b00000000
+#define MCP_PD_1K 0b00000010
+#define MCP_PD_100K 0b00000100
+#define MCP_PD_500K 0b00000110
+
+static uint8 write_msg_data[3];
+static i2c_msg write_msg;
+
+static uint8 read_msg_data[5];
+static i2c_msg read_msg;
+
+/*
+ * DAC control routines
+ */
+
+void mcp_i2c_setup(void) {
+ write_msg.addr = MCP_ADDR;
+ write_msg.flags = 0; // write, 7 bit address
+ write_msg.length = sizeof(write_msg_data);
+ write_msg.xferred = 0;
+ write_msg.data = write_msg_data;
+
+ read_msg.addr = MCP_ADDR;
+ read_msg.flags = I2C_MSG_READ;
+ read_msg.length = sizeof(read_msg_data);
+ read_msg.xferred = 0;
+ read_msg.data = read_msg_data;
+}
+
+void mcp_write_val(uint16 val) {
+ write_msg_data[0] = MCP_WRITE_DAC | MCP_PD_NORMAL;
+ uint16 tmp = val >> 4;
+ write_msg_data[1] = tmp;
+ tmp = (val << 4) & 0x00FF;
+ write_msg_data[2] = tmp;
+
+ i2c_master_xfer(I2C2, &write_msg, 1, 0);
+}
+
+uint16 mcp_read_val() {
+ uint16 tmp = 0;
+
+ i2c_master_xfer(I2C2, &read_msg, 1, 2);
+
+ /* We don't care about the status and EEPROM bytes (0, 3, and 4). */
+ tmp = (read_msg_data[1] << 4);
+ tmp += (read_msg_data[2] >> 4);
+ return tmp;
+}
+
+int mcp_test() {
+ uint16 val;
+ uint16 test_val = 0x0101;
+
+ SerialUSB.println("Testing the MCP4725...");
+ /* Read the value of the register (should be 0x0800 if factory fresh) */
+ val = mcp_read_val();
+ SerialUSB.print("DAC Register = 0x");
+ SerialUSB.println(val, HEX);
+
+ mcp_write_val(test_val);
+ SerialUSB.print("Wrote 0x");
+ SerialUSB.print(test_val, HEX);
+ SerialUSB.println(" to the DAC");
+
+ val = mcp_read_val();
+ SerialUSB.print("DAC Register = 0x");
+ SerialUSB.println(val, HEX);
+
+ if (val != test_val) {
+ SerialUSB.println("ERROR: MCP4725 not responding correctly");
+ return 0;
+ }
+
+ SerialUSB.println("MCP4725 seems to be working");
+ return 1;
+}
+
+/*
+ * setup() and loop()
+ */
+
+void setup() {
+ pinMode(BOARD_BUTTON_PIN, INPUT);
+ i2c_master_enable(I2C2, 0);
+ mcp_i2c_setup();
+
+ waitForButtonPress();
+ ASSERT(mcp_test());
+
+ SerialUSB.println("Starting sawtooth wave");
+}
+
+void loop() {
+ static uint16 dout = 0;
+
+ mcp_write_val(dout);
+
+ dout += 50;
+ if (dout >= 32768) {
+ dout = 0;
+ }
+}
+
+// -- init() and main() -------------------------------------------------------
+
+__attribute__((constructor)) void premain() {
+ init();
+}
+
+int main(void) {
+ setup();
+
+ while (true) {
+ loop();
+ }
+ return 0;
+}
Oops, something went wrong. Retry.

0 comments on commit ccc2336

Please sign in to comment.