Permalink
Browse files

Move public headers to include directories; related cleanups.

Move libmaple/*.h to (new) libmaple/include/libmaple/. The new
accepted way to include a libmaple header foo.h is with:

    #include <libmaple/foo.h>

This is more polite in terms of the include namespace. It also allows
us to e.g. implement the Arduino SPI library at all (which has header
SPI.h; providing it was previously impossible on case-insensitive
filesystems due to libmaple's spi.h).

Similarly for Wirish.

The old include style (#include "header.h") is now deprecated.

libmaple/*.h:

- Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_.
- Add license headers where they're missing
- Add conditional extern "C" { ... } blocks where they're missing
  (they aren't always necessary, but we might was well do it against
  the future, while we're at it.).
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
- Move includes after extern "C".
- Remove extra trailing newlines

Note that this doesn't include the headers under libmaple/usb/ or
libmaple/usb/usb_lib. These will get fixed later.

libmaple/*.c:

- Change includes from #include "foo.h" to #include <libmaple/foo.h>.

Makefile:

- Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS.  This allows
  for users (including Wirish) to migrate their code, but should go
  away ASAP, since it slows down compilation.

Wirish:

- Move wirish/**/*.h to (new) wirish/include/wirish/.  This ignores
  the USB headers, which, as usual, are getting handled after
  everything else.

- Similarly generify wirish/boards/ structure. For each supported
  board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to
  wirish/boards/foo/include/board/board.h and
  wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef
  hacks around the .cpp files.

- wirish/rules.mk: put wirish/boards/foo/include in the include path
  (and add wirish/boards/foo/board.cpp to the list of sources to be
  compiled). This allows saying:

      #include <board/board.h>

  instead of the hack currently in place. We can allow the user to
  override this setting later to make adding custom board definitions
  easier.

- Disable -Werror in libmaple/rules.mk, as the current USB warnings
  don't let the olimex_stm32_h103 board compile. We can re-enable
  -Werror once we've moved the board-specific bits out of libmaple
  proper.

libraries, examples:

- Update includes accordingly.
- Miscellaneous cosmetic fixups.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
  • Loading branch information...
1 parent 053ddb9 commit 954f9e5065b39fe4c683f4d216b54326d876f51b Marti Bolivar committed Nov 15, 2011
Showing with 542 additions and 507 deletions.
  1. +7 −0 Makefile
  2. +1 −1 examples/blinky.cpp
  3. +4 −5 examples/debug-dtrrts.cpp
  4. +1 −1 examples/freertos-blinky.cpp
  5. +3 −3 examples/fsmc-stress-test.cpp
  6. +1 −1 examples/mini-exti-test.cpp
  7. +1 −1 examples/qa-slave-shield.cpp
  8. +1 −1 examples/spi_master.cpp
  9. +3 −3 examples/test-bkp.cpp
  10. +2 −2 examples/test-dac.cpp
  11. +2 −2 examples/test-fsmc.cpp
  12. +1 −1 examples/test-print.cpp
  13. +2 −2 examples/test-ring-buffer-insertion.cpp
  14. +1 −1 examples/test-serial-flush.cpp
  15. +3 −3 examples/test-serialusb.cpp
  16. +1 −1 examples/test-servo.cpp
  17. +1 −1 examples/test-session.cpp
  18. +1 −1 examples/test-spi-roundtrip.cpp
  19. +2 −2 examples/test-systick.cpp
  20. +2 −2 examples/test-timers.cpp
  21. +4 −4 examples/test-usart-dma.cpp
  22. +1 −1 examples/vga-leaf.cpp
  23. +2 −2 examples/vga-scope.cpp
  24. +3 −3 libmaple/adc.c
  25. +4 −4 libmaple/bkp.c
  26. +3 −3 libmaple/dac.c
  27. +0 −30 libmaple/delay.h
  28. +3 −3 libmaple/dma.c
  29. +4 −4 libmaple/exti.c
  30. +3 −3 libmaple/flash.c
  31. +2 −2 libmaple/fsmc.c
  32. +2 −2 libmaple/gpio.c
  33. +8 −7 libmaple/i2c.c
  34. +6 −6 libmaple/{ → include/libmaple}/adc.h
  35. +12 −4 libmaple/{ → include/libmaple}/bitband.h
  36. +4 −4 libmaple/{ → include/libmaple}/bkp.h
  37. +4 −4 libmaple/{ → include/libmaple}/dac.h
  38. +65 −0 libmaple/include/libmaple/delay.h
  39. +6 −6 libmaple/{ → include/libmaple}/dma.h
  40. +5 −5 libmaple/{ → include/libmaple}/exti.h
  41. +4 −6 libmaple/{ → include/libmaple}/flash.h
  42. +4 −8 libmaple/{ → include/libmaple}/fsmc.h
  43. +5 −6 libmaple/{ → include/libmaple}/gpio.h
  44. +10 −10 libmaple/{ → include/libmaple}/i2c.h
  45. +5 −5 libmaple/{ → include/libmaple}/iwdg.h
  46. +13 −6 libmaple/{ → include/libmaple}/libmaple.h
  47. +9 −2 libmaple/{ → include/libmaple}/libmaple_types.h
  48. +5 −5 libmaple/{ → include/libmaple}/nvic.h
  49. +6 −1 libmaple/{ → include/libmaple}/pwr.h
  50. +4 −4 libmaple/{ → include/libmaple}/rcc.h
  51. +4 −5 libmaple/{ → include/libmaple}/ring_buffer.h
  52. +11 −3 libmaple/{ → include/libmaple}/scb.h
  53. +8 −8 libmaple/{ → include/libmaple}/spi.h
  54. +11 −3 libmaple/{ → include/libmaple}/stm32.h
  55. +6 −7 libmaple/{ → include/libmaple}/systick.h
  56. +8 −10 libmaple/{ → include/libmaple}/timer.h
  57. +9 −9 libmaple/{ → include/libmaple}/usart.h
  58. +5 −5 libmaple/{ → include/libmaple}/usb.h
  59. +4 −4 libmaple/{ → include/libmaple}/util.h
  60. +1 −1 libmaple/iwdg.c
  61. +3 −3 libmaple/nvic.c
  62. +2 −2 libmaple/pwr.c
  63. +4 −4 libmaple/rcc.c
  64. +5 −2 libmaple/rules.mk
  65. +2 −2 libmaple/spi.c
  66. +1 −1 libmaple/syscalls.c
  67. +1 −1 libmaple/systick.c
  68. +1 −1 libmaple/timer.c
  69. +1 −1 libmaple/usart.c
  70. +2 −2 libmaple/usb/usb_cdcacm.h
  71. +6 −6 libmaple/util.c
  72. +1 −1 libraries/FreeRTOS/MapleFreeRTOS.h
  73. +1 −1 libraries/LiquidCrystal/LiquidCrystal.cpp
  74. +2 −2 libraries/LiquidCrystal/LiquidCrystal.h
  75. +4 −4 libraries/Servo/Servo.cpp
  76. +3 −7 libraries/Servo/Servo.h
  77. +0 −1 libraries/Wire/Wire.cpp
  78. +2 −2 libraries/Wire/Wire.h
  79. +1 −1 main.cpp.example
  80. +3 −3 wirish/HardwareTimer.cpp
  81. +2 −3 wirish/Print.cpp
  82. +9 −9 wirish/boards.cpp
  83. +6 −10 wirish/boards/{maple.cpp → maple/board.cpp}
  84. +2 −2 wirish/boards/{maple.h → maple/include/board/board.h}
  85. +5 −8 wirish/boards/{maple_RET6.cpp → maple_RET6/board.cpp}
  86. +4 −3 wirish/boards/{maple_RET6.h → maple_RET6/include/board/board.h}
  87. +6 −9 wirish/boards/{maple_mini.cpp → maple_mini/board.cpp}
  88. +4 −3 wirish/boards/{maple_mini.h → maple_mini/include/board/board.h}
  89. +7 −11 wirish/boards/{maple_native.cpp → maple_native/board.cpp}
  90. +4 −3 wirish/boards/{maple_native.h → maple_native/include/board/board.h}
  91. +6 −9 wirish/boards/{olimex_stm32_h103.cpp → olimex_stm32_h103/board.cpp}
  92. +2 −2 wirish/boards/{olimex_stm32_h103.h → olimex_stm32_h103/include/board/board.h}
  93. +6 −6 wirish/comm/HardwareSPI.cpp
  94. +6 −5 wirish/comm/HardwareSerial.cpp
  95. +4 −4 wirish/ext_interrupts.cpp
  96. +5 −6 wirish/{comm → include/wirish}/HardwareSPI.h
  97. +5 −5 wirish/{comm → include/wirish}/HardwareSerial.h
  98. +3 −3 wirish/{ → include/wirish}/HardwareTimer.h
  99. +3 −3 wirish/{ → include/wirish}/Print.h
  100. +6 −1 wirish/{ → include/wirish}/WProgram.h
  101. +2 −2 wirish/{ → include/wirish}/bit_constants.h
  102. +6 −1 wirish/{ → include/wirish}/bits.h
  103. +5 −38 wirish/{ → include/wirish}/boards.h
  104. +5 −5 wirish/{ → include/wirish}/ext_interrupts.h
  105. +4 −5 wirish/{ → include/wirish}/io.h
  106. +3 −3 wirish/{ → include/wirish}/pwm.h
  107. +3 −3 wirish/{ → include/wirish}/usb_serial.h
  108. +17 −17 wirish/{ → include/wirish}/wirish.h
  109. +3 −3 wirish/{ → include/wirish}/wirish_debug.h
  110. +2 −2 wirish/{ → include/wirish}/wirish_math.h
  111. +5 −5 wirish/{ → include/wirish}/wirish_time.h
  112. +6 −6 wirish/{ → include/wirish}/wirish_types.h
  113. +4 −4 wirish/pwm.cpp
  114. +6 −7 wirish/rules.mk
  115. +5 −2 wirish/usb_serial.cpp
  116. +3 −3 wirish/wirish_analog.cpp
  117. +5 −5 wirish/wirish_digital.cpp
  118. +1 −1 wirish/wirish_math.cpp
  119. +1 −1 wirish/wirish_shift.cpp
  120. +3 −3 wirish/wirish_time.cpp
View
@@ -46,6 +46,13 @@ GLOBAL_FLAGS := -D$(VECT_BASE_ADDR) \
-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.
+GLOBAL_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)
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.
@@ -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 -------------------------------------------------------------
@@ -10,7 +10,7 @@
#include <stdio.h>
#include <string.h>
-#include "wirish.h"
+#include <wirish/wirish.h>
// test routines
void run_exti_test(void);
@@ -1,6 +1,6 @@
// Slave mode for Quality Assurance test
-#include "wirish.h"
+#include <wirish/wirish.h>
#define INTER_TOGGLE_DELAY_NORMAL 5
#define INTER_TOGGLE_DELAY_SLOW 80
@@ -33,7 +33,7 @@
* Pin 10 is used as slave select.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
#define NSS 10
@@ -1,8 +1,8 @@
#include <stdio.h> // for snprintf()
-#include "wirish.h"
-#include "bkp.h"
-#include "iwdg.h"
+#include <wirish/wirish.h>
+#include <libmaple/bkp.h>
+#include <libmaple/iwdg.h>
void print_bkp_contents();
void write_to_bkp(uint16 val);
@@ -6,8 +6,8 @@
* This file is released into the public domain.
*/
-#include "wirish.h"
-#include "dac.h"
+#include <wirish/wirish.h>
+#include <libmaple/dac.h>
uint16 count = 0;
@@ -1,7 +1,7 @@
#include <stddef.h> // for ptrdiff_t
-#include "wirish.h"
-#include "fsmc.h"
+#include <wirish/wirish.h>
+#include <libmaple/fsmc.h>
#ifndef BOARD_maple_native
#error "Sorry, this example only works on Maple Native."
@@ -8,7 +8,7 @@
* This file is released into the public domain.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
#undef min
#undef max
@@ -12,9 +12,9 @@
* This file is released into the public domain.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
-#include "ring_buffer.h"
+#include <libmaple/ring_buffer.h>
#define BUF_SIZE 64
ring_buffer ring_buf;
@@ -2,7 +2,7 @@
* Tests the "flush" Serial function.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
void setup() {
Serial1.begin(9600);
@@ -1,7 +1,7 @@
// Tests SerialUSB functionality.
-#include "wirish.h"
-#include "usb.h"
+#include <wirish/wirish.h>
+#include "usb_cdcacm.h"
#define QUICKPRINT 0
#define BIGSTUFF 1
@@ -37,7 +37,7 @@ void loop() {
switch (state) {
case QUICKPRINT:
for (int i = 0; i < 30; i++) {
- usbSendBytes(&c1, 1);
+ usb_cdcacm_putc((char)c1, 1);
SerialUSB.print('.');
SerialUSB.print('|');
}
@@ -29,7 +29,7 @@
#include <stdio.h>
-#include "wirish.h"
+#include <wirish/wirish.h>
#include "libraries/Servo/Servo.h"
@@ -4,7 +4,7 @@
// Useful for testing Maple features and troubleshooting.
// Communicates over SerialUSB.
-#include "wirish.h"
+#include <wirish/wirish.h>
// ASCII escape character
#define ESC ((uint8)27)
@@ -17,7 +17,7 @@
* Author: Marti Bolivar <mbolivar@leaflabs.com>
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
HardwareSPI alice(2);
@@ -1,7 +1,7 @@
// Tests the SysTick enable/disable functions
-#include "wirish.h"
-#include "systick.h"
+#include <wirish/wirish.h>
+#include <libmaple/systick.h>
void setup() {
pinMode(BOARD_LED_PIN, OUTPUT);
@@ -1,7 +1,7 @@
// Program to test the timer.h implementation's essential functionality.
-#include "wirish.h"
-#include "timer.h"
+#include <wirish/wirish.h>
+#include <libmaple/timer.h>
void handler1(void);
void handler2(void);
@@ -19,11 +19,11 @@
* This code is released into the public domain.
*/
-#include "dma.h"
-#include "usart.h"
-#include "gpio.h"
+#include <libmaple/dma.h>
+#include <libmaple/usart.h>
+#include <libmaple/gpio.h>
-#include "wirish.h"
+#include <wirish/wirish.h>
#define BAUD 9600
@@ -32,7 +32,7 @@
// FIXME: generalize for Native and Mini
-#include "wirish.h"
+#include <wirish/wirish.h>
// Pinouts -- you also must change the GPIO macros below if you change
// these
@@ -35,8 +35,8 @@
Marti Bolivar <mbolivar@leaflabs.com>
*/
-#include "wirish.h"
-#include "systick.h"
+#include <wirish/wirish.h>
+#include <libmaple/systick.h>
// FIXME: generalize for Native and Mini
View
@@ -37,9 +37,9 @@
* See STM32 manual RM0008 for how to calculate this.
*/
-#include "libmaple.h"
-#include "rcc.h"
-#include "adc.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/rcc.h>
+#include <libmaple/adc.h>
static adc_dev adc1 = {
.regs = ADC1_BASE,
View
@@ -29,10 +29,10 @@
* @brief Backup register support.
*/
-#include "bkp.h"
-#include "pwr.h"
-#include "rcc.h"
-#include "bitband.h"
+#include <libmaple/bkp.h>
+#include <libmaple/pwr.h>
+#include <libmaple/rcc.h>
+#include <libmaple/bitband.h>
static inline __io uint32* data_register(uint8 reg);
View
@@ -29,9 +29,9 @@
* @brief Digital to analog converter support.
*/
-#include "libmaple.h"
-#include "gpio.h"
-#include "dac.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/gpio.h>
+#include <libmaple/dac.h>
#ifdef STM32_HIGH_DENSITY
View
@@ -1,30 +0,0 @@
-/**
- * @file delay.h
- * @brief Delay implementation
- */
-
-#include "libmaple_types.h"
-#include "stm32.h"
-
-#ifndef _DELAY_H_
-#define _DELAY_H_
-
-/**
- * @brief Delay the given number of microseconds.
- *
- * @param us Number of microseconds to delay.
- */
-static inline void delay_us(uint32 us) {
- us *= STM32_DELAY_US_MULT;
-
- /* fudge for function call overhead */
- us--;
- asm volatile(" mov r0, %[us] \n\t"
- "1: subs r0, #1 \n\t"
- " bhi 1b \n\t"
- :
- : [us] "r" (us)
- : "r0");
-}
-#endif
-
View
@@ -31,9 +31,9 @@
* @brief Direct Memory Access peripheral support
*/
-#include "dma.h"
-#include "bitband.h"
-#include "util.h"
+#include <libmaple/dma.h>
+#include <libmaple/bitband.h>
+#include <libmaple/util.h>
/*
* Devices
View
@@ -29,10 +29,10 @@
* @brief External interrupt control routines
*/
-#include "exti.h"
-#include "libmaple.h"
-#include "nvic.h"
-#include "bitband.h"
+#include <libmaple/exti.h>
+#include <libmaple/libmaple.h>
+#include <libmaple/nvic.h>
+#include <libmaple/bitband.h>
static inline void dispatch_single_exti(uint32 exti_num);
static inline void dispatch_extis(uint32 start, uint32 stop);
View
@@ -29,9 +29,9 @@
* @brief Flash management functions
*/
-#include "libmaple.h"
-#include "flash.h"
-#include "bitband.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/flash.h>
+#include <libmaple/bitband.h>
/**
* @brief Turn on the hardware prefetcher.
View
@@ -29,8 +29,8 @@
* @brief Flexible static memory controller support.
*/
-#include "fsmc.h"
-#include "gpio.h"
+#include <libmaple/fsmc.h>
+#include <libmaple/gpio.h>
#ifdef STM32_HIGH_DENSITY
View
@@ -29,8 +29,8 @@
* @brief GPIO initialization routine
*/
-#include "gpio.h"
-#include "rcc.h"
+#include <libmaple/gpio.h>
+#include <libmaple/rcc.h>
/*
* GPIO devices
Oops, something went wrong.

0 comments on commit 954f9e5

Please sign in to comment.