aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--examples/blinky.cpp2
-rw-r--r--examples/debug-dtrrts.cpp9
-rw-r--r--examples/freertos-blinky.cpp2
-rw-r--r--examples/fsmc-stress-test.cpp6
-rw-r--r--examples/mini-exti-test.cpp2
-rw-r--r--examples/qa-slave-shield.cpp2
-rw-r--r--examples/spi_master.cpp2
-rw-r--r--examples/test-bkp.cpp6
-rw-r--r--examples/test-dac.cpp4
-rw-r--r--examples/test-fsmc.cpp4
-rw-r--r--examples/test-print.cpp2
-rw-r--r--examples/test-ring-buffer-insertion.cpp4
-rw-r--r--examples/test-serial-flush.cpp2
-rw-r--r--examples/test-serialusb.cpp6
-rw-r--r--examples/test-servo.cpp2
-rw-r--r--examples/test-session.cpp2
-rw-r--r--examples/test-spi-roundtrip.cpp2
-rw-r--r--examples/test-systick.cpp4
-rw-r--r--examples/test-timers.cpp4
-rw-r--r--examples/test-usart-dma.cpp8
-rw-r--r--examples/vga-leaf.cpp2
-rw-r--r--examples/vga-scope.cpp4
-rw-r--r--libmaple/adc.c6
-rw-r--r--libmaple/bkp.c8
-rw-r--r--libmaple/dac.c6
-rw-r--r--libmaple/delay.h30
-rw-r--r--libmaple/dma.c6
-rw-r--r--libmaple/exti.c8
-rw-r--r--libmaple/flash.c6
-rw-r--r--libmaple/fsmc.c4
-rw-r--r--libmaple/gpio.c4
-rw-r--r--libmaple/i2c.c15
-rw-r--r--libmaple/include/libmaple/adc.h (renamed from libmaple/adc.h)12
-rw-r--r--libmaple/include/libmaple/bitband.h (renamed from libmaple/bitband.h)16
-rw-r--r--libmaple/include/libmaple/bkp.h (renamed from libmaple/bkp.h)8
-rw-r--r--libmaple/include/libmaple/dac.h (renamed from libmaple/dac.h)8
-rw-r--r--libmaple/include/libmaple/delay.h65
-rw-r--r--libmaple/include/libmaple/dma.h (renamed from libmaple/dma.h)12
-rw-r--r--libmaple/include/libmaple/exti.h (renamed from libmaple/exti.h)10
-rw-r--r--libmaple/include/libmaple/flash.h (renamed from libmaple/flash.h)10
-rw-r--r--libmaple/include/libmaple/fsmc.h (renamed from libmaple/fsmc.h)12
-rw-r--r--libmaple/include/libmaple/gpio.h (renamed from libmaple/gpio.h)11
-rw-r--r--libmaple/include/libmaple/i2c.h (renamed from libmaple/i2c.h)20
-rw-r--r--libmaple/include/libmaple/iwdg.h (renamed from libmaple/iwdg.h)10
-rw-r--r--libmaple/include/libmaple/libmaple.h (renamed from libmaple/libmaple.h)19
-rw-r--r--libmaple/include/libmaple/libmaple_types.h (renamed from libmaple/libmaple_types.h)11
-rw-r--r--libmaple/include/libmaple/nvic.h (renamed from libmaple/nvic.h)10
-rw-r--r--libmaple/include/libmaple/pwr.h (renamed from libmaple/pwr.h)7
-rw-r--r--libmaple/include/libmaple/rcc.h (renamed from libmaple/rcc.h)8
-rw-r--r--libmaple/include/libmaple/ring_buffer.h (renamed from libmaple/ring_buffer.h)9
-rw-r--r--libmaple/include/libmaple/scb.h (renamed from libmaple/scb.h)14
-rw-r--r--libmaple/include/libmaple/spi.h (renamed from libmaple/spi.h)16
-rw-r--r--libmaple/include/libmaple/stm32.h (renamed from libmaple/stm32.h)14
-rw-r--r--libmaple/include/libmaple/systick.h (renamed from libmaple/systick.h)13
-rw-r--r--libmaple/include/libmaple/timer.h (renamed from libmaple/timer.h)18
-rw-r--r--libmaple/include/libmaple/usart.h (renamed from libmaple/usart.h)18
-rw-r--r--libmaple/include/libmaple/usb.h (renamed from libmaple/usb.h)10
-rw-r--r--libmaple/include/libmaple/util.h (renamed from libmaple/util.h)8
-rw-r--r--libmaple/iwdg.c2
-rw-r--r--libmaple/nvic.c6
-rw-r--r--libmaple/pwr.c4
-rw-r--r--libmaple/rcc.c8
-rw-r--r--libmaple/rules.mk7
-rw-r--r--libmaple/spi.c4
-rw-r--r--libmaple/syscalls.c2
-rw-r--r--libmaple/systick.c2
-rw-r--r--libmaple/timer.c2
-rw-r--r--libmaple/usart.c2
-rw-r--r--libmaple/usb/usb_cdcacm.h4
-rw-r--r--libmaple/util.c12
-rw-r--r--libraries/FreeRTOS/MapleFreeRTOS.h2
-rw-r--r--libraries/LiquidCrystal/LiquidCrystal.cpp2
-rw-r--r--libraries/LiquidCrystal/LiquidCrystal.h4
-rw-r--r--libraries/Servo/Servo.cpp8
-rw-r--r--libraries/Servo/Servo.h10
-rw-r--r--libraries/Wire/Wire.cpp1
-rw-r--r--libraries/Wire/Wire.h4
-rw-r--r--main.cpp.example2
-rw-r--r--wirish/HardwareTimer.cpp6
-rw-r--r--wirish/Print.cpp5
-rw-r--r--wirish/boards.cpp18
-rw-r--r--wirish/boards/maple/board.cpp (renamed from wirish/boards/maple.cpp)16
-rw-r--r--wirish/boards/maple/include/board/board.h (renamed from wirish/boards/maple.h)4
-rw-r--r--wirish/boards/maple_RET6/board.cpp (renamed from wirish/boards/maple_RET6.cpp)13
-rw-r--r--wirish/boards/maple_RET6/include/board/board.h (renamed from wirish/boards/maple_RET6.h)7
-rw-r--r--wirish/boards/maple_mini/board.cpp (renamed from wirish/boards/maple_mini.cpp)15
-rw-r--r--wirish/boards/maple_mini/include/board/board.h (renamed from wirish/boards/maple_mini.h)7
-rw-r--r--wirish/boards/maple_native/board.cpp (renamed from wirish/boards/maple_native.cpp)18
-rw-r--r--wirish/boards/maple_native/include/board/board.h (renamed from wirish/boards/maple_native.h)7
-rw-r--r--wirish/boards/olimex_stm32_h103/board.cpp (renamed from wirish/boards/olimex_stm32_h103.cpp)15
-rw-r--r--wirish/boards/olimex_stm32_h103/include/board/board.h (renamed from wirish/boards/olimex_stm32_h103.h)4
-rw-r--r--wirish/comm/HardwareSPI.cpp12
-rw-r--r--wirish/comm/HardwareSerial.cpp11
-rw-r--r--wirish/ext_interrupts.cpp8
-rw-r--r--wirish/include/wirish/HardwareSPI.h (renamed from wirish/comm/HardwareSPI.h)11
-rw-r--r--wirish/include/wirish/HardwareSerial.h (renamed from wirish/comm/HardwareSerial.h)10
-rw-r--r--wirish/include/wirish/HardwareTimer.h (renamed from wirish/HardwareTimer.h)6
-rw-r--r--wirish/include/wirish/Print.h (renamed from wirish/Print.h)6
-rw-r--r--wirish/include/wirish/WProgram.h (renamed from wirish/WProgram.h)7
-rw-r--r--wirish/include/wirish/bit_constants.h (renamed from wirish/bit_constants.h)4
-rw-r--r--wirish/include/wirish/bits.h (renamed from wirish/bits.h)7
-rw-r--r--wirish/include/wirish/boards.h (renamed from wirish/boards.h)43
-rw-r--r--wirish/include/wirish/ext_interrupts.h (renamed from wirish/ext_interrupts.h)10
-rw-r--r--wirish/include/wirish/io.h (renamed from wirish/io.h)9
-rw-r--r--wirish/include/wirish/pwm.h (renamed from wirish/pwm.h)6
-rw-r--r--wirish/include/wirish/usb_serial.h (renamed from wirish/usb_serial.h)6
-rw-r--r--wirish/include/wirish/wirish.h (renamed from wirish/wirish.h)34
-rw-r--r--wirish/include/wirish/wirish_debug.h (renamed from wirish/wirish_debug.h)6
-rw-r--r--wirish/include/wirish/wirish_math.h (renamed from wirish/wirish_math.h)4
-rw-r--r--wirish/include/wirish/wirish_time.h (renamed from wirish/wirish_time.h)10
-rw-r--r--wirish/include/wirish/wirish_types.h (renamed from wirish/wirish_types.h)12
-rw-r--r--wirish/pwm.cpp8
-rw-r--r--wirish/rules.mk13
-rw-r--r--wirish/usb_serial.cpp7
-rw-r--r--wirish/wirish_analog.cpp6
-rw-r--r--wirish/wirish_digital.cpp10
-rw-r--r--wirish/wirish_math.cpp2
-rw-r--r--wirish/wirish_shift.cpp2
-rw-r--r--wirish/wirish_time.cpp6
120 files changed, 542 insertions, 507 deletions
diff --git a/Makefile b/Makefile
index 45b34da..c6a1e07 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/examples/blinky.cpp b/examples/blinky.cpp
index dd72514..fad71f8 100644
--- a/examples/blinky.cpp
+++ b/examples/blinky.cpp
@@ -1,6 +1,6 @@
// Blinks the built-in LED
-#include "wirish.h"
+#include <wirish/wirish.h>
void setup() {
pinMode(BOARD_LED_PIN, OUTPUT);
diff --git a/examples/debug-dtrrts.cpp b/examples/debug-dtrrts.cpp
index 3829208..0286212 100644
--- a/examples/debug-dtrrts.cpp
+++ b/examples/debug-dtrrts.cpp
@@ -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,7 +10,6 @@ void setup() {
/* Send a message out USART2 */
Serial2.begin(9600);
Serial2.println("Debugging DTR/RTS...");
-
}
void loop() {
@@ -18,9 +17,9 @@ void loop() {
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.
diff --git a/examples/freertos-blinky.cpp b/examples/freertos-blinky.cpp
index 6f82d71..2e7c7f7 100644
--- a/examples/freertos-blinky.cpp
+++ b/examples/freertos-blinky.cpp
@@ -1,4 +1,4 @@
-#include "wirish.h"
+#include <wirish/wirish.h>
#include "libraries/FreeRTOS/MapleFreeRTOS.h"
static void vLEDFlashTask(void *pvParameters) {
diff --git a/examples/fsmc-stress-test.cpp b/examples/fsmc-stress-test.cpp
index 509a02f..20d3fa7 100644
--- a/examples/fsmc-stress-test.cpp
+++ b/examples/fsmc-stress-test.cpp
@@ -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 -------------------------------------------------------------
diff --git a/examples/mini-exti-test.cpp b/examples/mini-exti-test.cpp
index 84b323e..54a4dd0 100644
--- a/examples/mini-exti-test.cpp
+++ b/examples/mini-exti-test.cpp
@@ -10,7 +10,7 @@
#include <stdio.h>
#include <string.h>
-#include "wirish.h"
+#include <wirish/wirish.h>
// test routines
void run_exti_test(void);
diff --git a/examples/qa-slave-shield.cpp b/examples/qa-slave-shield.cpp
index 2da1c04..ec25e49 100644
--- a/examples/qa-slave-shield.cpp
+++ b/examples/qa-slave-shield.cpp
@@ -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
diff --git a/examples/spi_master.cpp b/examples/spi_master.cpp
index 100fc53..ea6c990 100644
--- a/examples/spi_master.cpp
+++ b/examples/spi_master.cpp
@@ -33,7 +33,7 @@
* Pin 10 is used as slave select.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
#define NSS 10
diff --git a/examples/test-bkp.cpp b/examples/test-bkp.cpp
index f5957b7..719cac7 100644
--- a/examples/test-bkp.cpp
+++ b/examples/test-bkp.cpp
@@ -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);
diff --git a/examples/test-dac.cpp b/examples/test-dac.cpp
index 40ae5d5..af188cc 100644
--- a/examples/test-dac.cpp
+++ b/examples/test-dac.cpp
@@ -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;
diff --git a/examples/test-fsmc.cpp b/examples/test-fsmc.cpp
index 22f6975..1621317 100644
--- a/examples/test-fsmc.cpp
+++ b/examples/test-fsmc.cpp
@@ -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."
diff --git a/examples/test-print.cpp b/examples/test-print.cpp
index 5477512..bdc1894 100644
--- a/examples/test-print.cpp
+++ b/examples/test-print.cpp
@@ -8,7 +8,7 @@
* This file is released into the public domain.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
#undef min
#undef max
diff --git a/examples/test-ring-buffer-insertion.cpp b/examples/test-ring-buffer-insertion.cpp
index e86372a..2188b03 100644
--- a/examples/test-ring-buffer-insertion.cpp
+++ b/examples/test-ring-buffer-insertion.cpp
@@ -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;
diff --git a/examples/test-serial-flush.cpp b/examples/test-serial-flush.cpp
index adc9c3e..409d1f9 100644
--- a/examples/test-serial-flush.cpp
+++ b/examples/test-serial-flush.cpp
@@ -2,7 +2,7 @@
* Tests the "flush" Serial function.
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
void setup() {
Serial1.begin(9600);
diff --git a/examples/test-serialusb.cpp b/examples/test-serialusb.cpp
index 15ab913..098e445 100644
--- a/examples/test-serialusb.cpp
+++ b/examples/test-serialusb.cpp
@@ -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('|');
}
diff --git a/examples/test-servo.cpp b/examples/test-servo.cpp
index b6b8cd5..6f6e3ba 100644
--- a/examples/test-servo.cpp
+++ b/examples/test-servo.cpp
@@ -29,7 +29,7 @@
#include <stdio.h>
-#include "wirish.h"
+#include <wirish/wirish.h>
#include "libraries/Servo/Servo.h"
diff --git a/examples/test-session.cpp b/examples/test-session.cpp
index 6c7cfff..4316cda 100644
--- a/examples/test-session.cpp
+++ b/examples/test-session.cpp
@@ -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)
diff --git a/examples/test-spi-roundtrip.cpp b/examples/test-spi-roundtrip.cpp
index 71ae658..ddc9875 100644
--- a/examples/test-spi-roundtrip.cpp
+++ b/examples/test-spi-roundtrip.cpp
@@ -17,7 +17,7 @@
* Author: Marti Bolivar <mbolivar@leaflabs.com>
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
HardwareSPI alice(2);
diff --git a/examples/test-systick.cpp b/examples/test-systick.cpp
index 78c7307..356f302 100644
--- a/examples/test-systick.cpp
+++ b/examples/test-systick.cpp
@@ -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);
diff --git a/examples/test-timers.cpp b/examples/test-timers.cpp
index 247cc57..2a8223c 100644
--- a/examples/test-timers.cpp
+++ b/examples/test-timers.cpp
@@ -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);
diff --git a/examples/test-usart-dma.cpp b/examples/test-usart-dma.cpp
index 5ff5b86..8fbcccb 100644
--- a/examples/test-usart-dma.cpp
+++ b/examples/test-usart-dma.cpp
@@ -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
diff --git a/examples/vga-leaf.cpp b/examples/vga-leaf.cpp
index f31dc87..5159956 100644
--- a/examples/vga-leaf.cpp
+++ b/examples/vga-leaf.cpp
@@ -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
diff --git a/examples/vga-scope.cpp b/examples/vga-scope.cpp
index b5fa8a5..8730cf0 100644
--- a/examples/vga-scope.cpp
+++ b/examples/vga-scope.cpp
@@ -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
diff --git a/libmaple/adc.c b/libmaple/adc.c
index 2bd2ad1..40369e9 100644
--- a/libmaple/adc.c
+++ b/libmaple/adc.c
@@ -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,
diff --git a/libmaple/bkp.c b/libmaple/bkp.c
index 7d1ad7f..62783e7 100644
--- a/libmaple/bkp.c
+++ b/libmaple/bkp.c
@@ -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);
diff --git a/libmaple/dac.c b/libmaple/dac.c
index 15e944f..efcba15 100644
--- a/libmaple/dac.c
+++ b/libmaple/dac.c
@@ -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
diff --git a/libmaple/delay.h b/libmaple/delay.h
deleted file mode 100644
index 6f8b8ba..0000000
--- a/libmaple/delay.h
+++ /dev/null
@@ -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
-
diff --git a/libmaple/dma.c b/libmaple/dma.c
index 60f4d47..f20613b 100644
--- a/libmaple/dma.c
+++ b/libmaple/dma.c
@@ -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
diff --git a/libmaple/exti.c b/libmaple/exti.c
index 1fcc35b..00e0df2 100644
--- a/libmaple/exti.c
+++ b/libmaple/exti.c
@@ -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);
diff --git a/libmaple/flash.c b/libmaple/flash.c
index a22fbd3..d0e23d0 100644
--- a/libmaple/flash.c
+++ b/libmaple/flash.c
@@ -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.
diff --git a/libmaple/fsmc.c b/libmaple/fsmc.c
index 06ca7df..bf4611d 100644
--- a/libmaple/fsmc.c
+++ b/libmaple/fsmc.c
@@ -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
diff --git a/libmaple/gpio.c b/libmaple/gpio.c
index e643873..e607595 100644
--- a/libmaple/gpio.c
+++ b/libmaple/gpio.c
@@ -29,8 +29,8 @@
* @brief GPIO initialization routine
*/
-#include "gpio.h"
-#include "rcc.h"
+#include <libmaple/gpio.h>
+#include <libmaple/rcc.h>
/*
* GPIO devices
diff --git a/libmaple/i2c.c b/libmaple/i2c.c
index e3f3199..ae44532 100644
--- a/libmaple/i2c.c
+++ b/libmaple/i2c.c
@@ -31,13 +31,14 @@
* Currently, only master mode is supported.
*/
-#include "libmaple.h"
-#include "rcc.h"
-#include "gpio.h"
-#include "nvic.h"
-#include "i2c.h"
-#include "string.h"
-#include "systick.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/rcc.h>
+#include <libmaple/gpio.h>
+#include <libmaple/nvic.h>
+#include <libmaple/i2c.h>
+#include <libmaple/systick.h>
+
+#include <string.h>
static i2c_dev i2c_dev1 = {
.regs = I2C1_BASE,
diff --git a/libmaple/adc.h b/libmaple/include/libmaple/adc.h
index d0b85fa..d531d00 100644
--- a/libmaple/adc.h
+++ b/libmaple/include/libmaple/adc.h
@@ -30,17 +30,17 @@
* @brief Analog-to-Digital Conversion (ADC) header.
*/
-#ifndef _ADC_H_
-#define _ADC_H_
-
-#include "libmaple.h"
-#include "bitband.h"
-#include "rcc.h"
+#ifndef _LIBMAPLE_ADC_H_
+#define _LIBMAPLE_ADC_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple.h>
+#include <libmaple/bitband.h>
+#include <libmaple/rcc.h>
+
/** ADC register map type. */
typedef struct adc_reg_map {
__io uint32 SR; ///< Status register
diff --git a/libmaple/bitband.h b/libmaple/include/libmaple/bitband.h
index 73941b0..607e4eb 100644
--- a/libmaple/bitband.h
+++ b/libmaple/include/libmaple/bitband.h
@@ -30,10 +30,14 @@
* @brief Bit-banding utility functions
*/
-#include "libmaple_types.h"
+#ifndef _LIBMAPLE_BITBAND_H_
+#define _LIBMAPLE_BITBAND_H_
-#ifndef _BITBAND_H_
-#define _BITBAND_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libmaple/libmaple_types.h>
#define BB_SRAM_REF 0x20000000
#define BB_SRAM_BASE 0x22000000
@@ -117,4 +121,8 @@ static inline volatile uint32* __bb_addr(volatile void *address,
bit * 4);
}
-#endif /* _BITBAND_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libmaple/bkp.h b/libmaple/include/libmaple/bkp.h
index a81267d..92359b6 100644
--- a/libmaple/bkp.h
+++ b/libmaple/include/libmaple/bkp.h
@@ -29,15 +29,15 @@
* @brief Backup register support.
*/
-#ifndef _BKP_H_
-#define _BKP_H_
-
-#include "libmaple.h"
+#ifndef _LIBMAPLE_BKP_H_
+#define _LIBMAPLE_BKP_H_
#ifdef __cplusplus
extern "C" {
#endif
+#include <libmaple/libmaple.h>
+
#if defined(STM32_MEDIUM_DENSITY)
#define BKP_NR_DATA_REGS 10
#elif defined(STM32_HIGH_DENSITY)
diff --git a/libmaple/dac.h b/libmaple/include/libmaple/dac.h
index aa04981..738bede 100644
--- a/libmaple/dac.h
+++ b/libmaple/include/libmaple/dac.h
@@ -31,15 +31,15 @@
/* See notes/dac.txt for more info */
-#ifndef _DAC_H_
-#define _DAC_H_
-
-#include "rcc.h"
+#ifndef _LIBMAPLE_DAC_H_
+#define _LIBMAPLE_DAC_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/rcc.h>
+
/*
* Register maps
*/
diff --git a/libmaple/include/libmaple/delay.h b/libmaple/include/libmaple/delay.h
new file mode 100644
index 0000000..f79655d
--- /dev/null
+++ b/libmaple/include/libmaple/delay.h
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * The MIT License
+ *
+ * Copyright (c) 2010 Perry Hung.
+ * Copyright (c) 2011 LeafLabs, LLC.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *****************************************************************************/
+
+/**
+ * @file delay.h
+ * @brief Delay implementation
+ */
+
+#ifndef _LIBMAPLE_DELAY_H_
+#define _LIBMAPLE_DELAY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libmaple/libmaple_types.h>
+#include <libmaple/stm32.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");
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libmaple/dma.h b/libmaple/include/libmaple/dma.h
index 6e8087f..da2bd4f 100644
--- a/libmaple/dma.h
+++ b/libmaple/include/libmaple/dma.h
@@ -37,17 +37,17 @@
* See /notes/dma.txt for more information.
*/
-#ifndef _DMA_H_
-#define _DMA_H_
-
-#include "libmaple_types.h"
-#include "rcc.h"
-#include "nvic.h"
+#ifndef _LIBMAPLE_DMA_H_
+#define _LIBMAPLE_DMA_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+
/*
* Register maps
*/
diff --git a/libmaple/exti.h b/libmaple/include/libmaple/exti.h
index f225844..0a763d7 100644
--- a/libmaple/exti.h
+++ b/libmaple/include/libmaple/exti.h
@@ -31,16 +31,16 @@
/* See notes/exti.txt for more info */
-#include "libmaple.h"
-#include "gpio.h"
-
-#ifndef _EXTI_H_
-#define _EXTI_H_
+#ifndef _LIBMAPLE_EXTI_H_
+#define _LIBMAPLE_EXTI_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple.h>
+#include <libmaple/gpio.h>
+
/** EXTI register map type */
typedef struct exti_reg_map {
__io uint32 IMR; /**< Interrupt mask register */
diff --git a/libmaple/flash.h b/libmaple/include/libmaple/flash.h
index 0b4e49b..e28ea28 100644
--- a/libmaple/flash.h
+++ b/libmaple/include/libmaple/flash.h
@@ -30,15 +30,15 @@
* routines
*/
-#include "libmaple_types.h"
-
-#ifndef _FLASH_H_
-#define _FLASH_H_
+#ifndef _LIBMAPLE_FLASH_H_
+#define _LIBMAPLE_FLASH_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+
/** Flash register map type */
typedef struct flash_reg_map {
__io uint32 ACR; /**< Access control register */
@@ -138,5 +138,3 @@ void flash_set_latency(uint32 wait_states);
#endif
#endif
-
-
diff --git a/libmaple/fsmc.h b/libmaple/include/libmaple/fsmc.h
index ef82b08..95b0d3a 100644
--- a/libmaple/fsmc.h
+++ b/libmaple/include/libmaple/fsmc.h
@@ -33,19 +33,15 @@
* See ../notes/fsmc.txt for more info
*/
-#include "libmaple_types.h"
-
-/**
- * @file fsmc.h
- */
-
-#ifndef _FSMC_H_
-#define _FSMC_H_
+#ifndef _LIBMAPLE_FSMC_H_
+#define _LIBMAPLE_FSMC_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+
#ifdef STM32_HIGH_DENSITY
/*
diff --git a/libmaple/gpio.h b/libmaple/include/libmaple/gpio.h
index a7859a7..685e1b1 100644
--- a/libmaple/gpio.h
+++ b/libmaple/include/libmaple/gpio.h
@@ -31,16 +31,16 @@
* (AFIO) prototypes, defines, and inlined access functions.
*/
-#ifndef _GPIO_H_
-#define _GPIO_H_
-
-#include "libmaple.h"
-#include "rcc.h"
+#ifndef _LIBMAPLE_GPIO_H_
+#define _LIBMAPLE_GPIO_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple.h>
+#include <libmaple/rcc.h>
+
/*
* GPIO register maps and devices
*/
@@ -524,4 +524,3 @@ static inline void afio_cfg_debug_ports(afio_debug_cfg config) {
#endif
#endif
-
diff --git a/libmaple/i2c.h b/libmaple/include/libmaple/i2c.h
index 4c60ad7..35c4628 100644
--- a/libmaple/i2c.h
+++ b/libmaple/include/libmaple/i2c.h
@@ -29,13 +29,17 @@
* @brief Inter-Integrated Circuit (I2C) peripheral support
*/
-#include "libmaple_types.h"
-#include "rcc.h"
-#include "nvic.h"
-#include "gpio.h"
+#ifndef _LIBMAPLE_I2C_H_
+#define _LIBMAPLE_I2C_H_
-#ifndef _I2C_H_
-#define _I2C_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libmaple/libmaple_types.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+#include <libmaple/gpio.h>
/** I2C register map type */
typedef struct i2c_reg_map {
@@ -169,10 +173,6 @@ extern i2c_dev* const I2C2;
* Convenience routines
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void i2c_init(i2c_dev *dev);
/* I2C enable options */
diff --git a/libmaple/iwdg.h b/libmaple/include/libmaple/iwdg.h
index 59e8e18..baddf4f 100644
--- a/libmaple/iwdg.h
+++ b/libmaple/include/libmaple/iwdg.h
@@ -38,16 +38,16 @@
* Once started, the independent watchdog cannot be turned off.
*/
-#ifndef _IWDG_H_
-#define _IWDG_H_
-
-#include "libmaple_types.h"
-#include "util.h"
+#ifndef _LIBMAPLE_IWDG_H_
+#define _LIBMAPLE_IWDG_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/util.h>
+
/*
* Register map
*/
diff --git a/libmaple/libmaple.h b/libmaple/include/libmaple/libmaple.h
index c509f5d..60b23ed 100644
--- a/libmaple/libmaple.h
+++ b/libmaple/include/libmaple/libmaple.h
@@ -29,13 +29,17 @@
* @brief General include file for libmaple
*/
-#ifndef _LIBMAPLE_H_
-#define _LIBMAPLE_H_
+#ifndef _LIBMAPLE_LIBMAPLE_H_
+#define _LIBMAPLE_LIBMAPLE_H_
-#include "libmaple_types.h"
-#include "stm32.h"
-#include "util.h"
-#include "delay.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libmaple/libmaple_types.h>
+#include <libmaple/stm32.h>
+#include <libmaple/util.h>
+#include <libmaple/delay.h>
/*
* Where to put usercode, based on space reserved for bootloader.
@@ -46,5 +50,8 @@
#define USER_ADDR_RAM 0x20000C00
#define STACK_TOP 0x20000800
+#ifdef __cplusplus
+}
#endif
+#endif
diff --git a/libmaple/libmaple_types.h b/libmaple/include/libmaple/libmaple_types.h
index 08adaff..ae01691 100644
--- a/libmaple/libmaple_types.h
+++ b/libmaple/include/libmaple/libmaple_types.h
@@ -30,8 +30,12 @@
* @brief libmaple types
*/
-#ifndef _LIBMAPLE_TYPES_H_
-#define _LIBMAPLE_TYPES_H_
+#ifndef _LIBMAPLE_LIBMAPLE_TYPES_H_
+#define _LIBMAPLE_LIBMAPLE_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
typedef unsigned char uint8;
typedef unsigned short uint16;
@@ -53,5 +57,8 @@ typedef void (*voidFuncPtr)(void);
#define NULL 0
#endif
+#ifdef __cplusplus
+}
#endif
+#endif
diff --git a/libmaple/nvic.h b/libmaple/include/libmaple/nvic.h
index feb7335..d631eeb 100644
--- a/libmaple/nvic.h
+++ b/libmaple/include/libmaple/nvic.h
@@ -43,16 +43,16 @@
* @endcode
*/
-#ifndef _NVIC_H_
-#define _NVIC_H_
-
-#include "libmaple_types.h"
-#include "util.h"
+#ifndef _LIBMAPLE_NVIC_H_
+#define _LIBMAPLE_NVIC_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/util.h>
+
/** NVIC register map type. */
typedef struct nvic_reg_map {
__io uint32 ISER[8]; /**< Interrupt Set Enable Registers */
diff --git a/libmaple/pwr.h b/libmaple/include/libmaple/pwr.h
index 88b49c0..6836e7f 100644
--- a/libmaple/pwr.h
+++ b/libmaple/include/libmaple/pwr.h
@@ -29,12 +29,15 @@
* @brief Power control (PWR) defines.
*/
-#include "libmaple.h"
+#ifndef _LIBMAPLE_PWR_H_
+#define _LIBMAPLE_PWR_H_
#ifdef __cplusplus
extern "C" {
#endif
+#include <libmaple/libmaple.h>
+
/** Power interface register map. */
typedef struct pwr_reg_map {
__io uint32 CR; /**< Control register */
@@ -83,3 +86,5 @@ void pwr_init(void);
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/libmaple/rcc.h b/libmaple/include/libmaple/rcc.h
index c50686c..ef44b68 100644
--- a/libmaple/rcc.h
+++ b/libmaple/include/libmaple/rcc.h
@@ -29,15 +29,15 @@
* @brief reset and clock control definitions and prototypes
*/
-#include "libmaple_types.h"
-
-#ifndef _RCC_H_
-#define _RCC_H_
+#ifndef _LIBMAPLE_RCC_H_
+#define _LIBMAPLE_RCC_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+
/** RCC register map type */
typedef struct rcc_reg_map {
__io uint32 CR; /**< Clock control register */
diff --git a/libmaple/ring_buffer.h b/libmaple/include/libmaple/ring_buffer.h
index c443bc3..7169e7e 100644
--- a/libmaple/ring_buffer.h
+++ b/libmaple/include/libmaple/ring_buffer.h
@@ -32,15 +32,15 @@
* these functions is guaranteed re-entrant.
*/
-#ifndef _RING_BUFFER_H_
-#define _RING_BUFFER_H_
-
-#include "libmaple_types.h"
+#ifndef _LIBMAPLE_RING_BUFFER_H_
+#define _LIBMAPLE_RING_BUFFER_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+
/**
* Ring buffer type.
*
@@ -186,4 +186,3 @@ static inline void rb_reset(ring_buffer *rb) {
#endif
#endif
-
diff --git a/libmaple/scb.h b/libmaple/include/libmaple/scb.h
index feacaa5..9c4ee15 100644
--- a/libmaple/scb.h
+++ b/libmaple/include/libmaple/scb.h
@@ -29,10 +29,14 @@
* @brief System control block header
*/
-#include "libmaple_types.h"
+#ifndef _LIBMAPLE_SCB_H_
+#define _LIBMAPLE_SCB_H_
-#ifndef _SCB_H_
-#define _SCB_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libmaple/libmaple_types.h>
/*
* Register map and base pointer
@@ -198,4 +202,8 @@ typedef struct scb_reg_map {
#define SCB_DFSR_BKPT BIT(1)
#define SCB_DFSR_HALTED BIT(0)
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/libmaple/spi.h b/libmaple/include/libmaple/spi.h
index f4fa4b7..6f509c2 100644
--- a/libmaple/spi.h
+++ b/libmaple/include/libmaple/spi.h
@@ -33,19 +33,19 @@
* I2S support is currently limited to register maps and bit definitions.
*/
-#ifndef _SPI_H_
-#define _SPI_H_
-
-#include "libmaple_types.h"
-#include "rcc.h"
-#include "nvic.h"
-#include "gpio.h"
-#include "util.h"
+#ifndef _LIBMAPLE_SPI_H_
+#define _LIBMAPLE_SPI_H_
#ifdef __cplusplus
extern "C" {
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+#include <libmaple/gpio.h>
+#include <libmaple/util.h>
+
/*
* Register maps
*/
diff --git a/libmaple/stm32.h b/libmaple/include/libmaple/stm32.h
index 3b54dbc..53a5d7a 100644
--- a/libmaple/stm32.h
+++ b/libmaple/include/libmaple/stm32.h
@@ -29,8 +29,12 @@
* @brief STM32 chip-specific definitions
*/
-#ifndef _STM32_H_
-#define _STM32_H_
+#ifndef _LIBMAPLE_STM32_H_
+#define _LIBMAPLE_STM32_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* User-specific configuration.
@@ -188,4 +192,8 @@
#endif
-#endif /* _STM32_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libmaple/systick.h b/libmaple/include/libmaple/systick.h
index 6ec3364..1731c85 100644
--- a/libmaple/systick.h
+++ b/libmaple/include/libmaple/systick.h
@@ -27,19 +27,19 @@
/**
* @file systick.h
*
- * @brief Various system timer definitions
+ * @brief System timer definitions
*/
-#ifndef _SYSTICK_H_
-#define _SYSTICK_H_
-
-#include "libmaple_types.h"
-#include "util.h"
+#ifndef _LIBMAPLE_SYSTICK_H_
+#define _LIBMAPLE_SYSTICK_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/util.h>
+
/** SysTick register map type */
typedef struct systick_reg_map {
__io uint32 CSR; /**< Control and status register */
@@ -114,4 +114,3 @@ static inline uint32 systick_check_underflow(void) {
#endif
#endif
-
diff --git a/libmaple/timer.h b/libmaple/include/libmaple/timer.h
index 53e2547..9e4e20c 100644
--- a/libmaple/timer.h
+++ b/libmaple/include/libmaple/timer.h
@@ -27,23 +27,21 @@
/**
* @file timer.h
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief New-style timer interface.
- *
- * Replaces old timers.h implementation.
+ * @brief Timer interface.
*/
-#ifndef _TIMERS_H_
-#define _TIMERS_H_
-
-#include "libmaple.h"
-#include "rcc.h"
-#include "nvic.h"
-#include "bitband.h"
+#ifndef _LIBMAPLE_TIMERS_H_
+#define _LIBMAPLE_TIMERS_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+#include <libmaple/bitband.h>
+
/*
* Register maps and devices
*/
diff --git a/libmaple/usart.h b/libmaple/include/libmaple/usart.h
index ed00e16..f9bdb8b 100644
--- a/libmaple/usart.h
+++ b/libmaple/include/libmaple/usart.h
@@ -31,19 +31,19 @@
* @brief USART definitions and prototypes
*/
-#ifndef _USART_H_
-#define _USART_H_
-
-#include "libmaple_types.h"
-#include "util.h"
-#include "rcc.h"
-#include "nvic.h"
-#include "ring_buffer.h"
+#ifndef _LIBMAPLE_USART_H_
+#define _LIBMAPLE_USART_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/util.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+#include <libmaple/ring_buffer.h>
+
/*
* Register maps and devices
*/
@@ -333,4 +333,4 @@ static inline void usart_reset_rx(usart_dev *dev) {
} // extern "C"
#endif
-#endif // _USART_H_
+#endif
diff --git a/libmaple/usb.h b/libmaple/include/libmaple/usb.h
index 94579ea..82bace9 100644
--- a/libmaple/usb.h
+++ b/libmaple/include/libmaple/usb.h
@@ -28,16 +28,16 @@
* NOTE: This API is _unstable_ and will change drastically over time.
*/
-#ifndef _USB_H_
-#define _USB_H_
-
-#include "libmaple_types.h"
-#include "rcc.h"
+#ifndef _LIBMAPLE_USB_H_
+#define _LIBMAPLE_USB_H_
#ifdef __cplusplus
extern "C" {
#endif
+#include <libmaple/libmaple_types.h>
+#include <libmaple/rcc.h>
+
#ifndef USB_ISR_MSK
/* Handle CTRM, WKUPM, SUSPM, ERRM, SOFM, ESOFM, RESETM */
#define USB_ISR_MSK 0xBF00
diff --git a/libmaple/util.h b/libmaple/include/libmaple/util.h
index 7b41769..d0b7b0b 100644
--- a/libmaple/util.h
+++ b/libmaple/include/libmaple/util.h
@@ -29,15 +29,15 @@
* @brief Miscellaneous utility macros and procedures.
*/
-#include "libmaple_types.h"
-
-#ifndef _UTIL_H_
-#define _UTIL_H_
+#ifndef _LIBMAPLE_UTIL_H_
+#define _LIBMAPLE_UTIL_H_
#ifdef __cplusplus
extern "C"{
#endif
+#include <libmaple/libmaple_types.h>
+
/*
* Bit manipulation
*/
diff --git a/libmaple/iwdg.c b/libmaple/iwdg.c
index 63c1b2b..6dd77fc 100644
--- a/libmaple/iwdg.c
+++ b/libmaple/iwdg.c
@@ -29,7 +29,7 @@
* @brief Independent watchdog (IWDG) support
*/
-#include "iwdg.h"
+#include <libmaple/iwdg.h>
/**
* @brief Initialise and start the watchdog
diff --git a/libmaple/nvic.c b/libmaple/nvic.c
index 345c850..b80751f 100644
--- a/libmaple/nvic.c
+++ b/libmaple/nvic.c
@@ -29,9 +29,9 @@
* @brief Nested vector interrupt controller support.
*/
-#include "nvic.h"
-#include "scb.h"
-#include "stm32.h"
+#include <libmaple/nvic.h>
+#include <libmaple/scb.h>
+#include <libmaple/stm32.h>
/**
* @brief Set interrupt priority for an interrupt line
diff --git a/libmaple/pwr.c b/libmaple/pwr.c
index ead8b64..f934269 100644
--- a/libmaple/pwr.c
+++ b/libmaple/pwr.c
@@ -29,8 +29,8 @@
* @brief Power control (PWR) support.
*/
-#include "pwr.h"
-#include "rcc.h"
+#include <libmaple/pwr.h>
+#include <libmaple/rcc.h>
/**
* Enables the power interface clock, and resets the power device.
diff --git a/libmaple/rcc.c b/libmaple/rcc.c
index 65abfb6..ed3f11e 100644
--- a/libmaple/rcc.c
+++ b/libmaple/rcc.c
@@ -30,10 +30,10 @@
* stm32, clock enable/disable and peripheral reset commands.
*/
-#include "libmaple.h"
-#include "flash.h"
-#include "rcc.h"
-#include "bitband.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/flash.h>
+#include <libmaple/rcc.h>
+#include <libmaple/bitband.h>
#define APB1 RCC_APB1
#define APB2 RCC_APB2
diff --git a/libmaple/rules.mk b/libmaple/rules.mk
index 1ee611d..a6b330a 100644
--- a/libmaple/rules.mk
+++ b/libmaple/rules.mk
@@ -6,10 +6,13 @@ BUILDDIRS += $(BUILD_PATH)/$(d)
BUILDDIRS += $(BUILD_PATH)/$(d)/usb
BUILDDIRS += $(BUILD_PATH)/$(d)/usb/usb_lib
-LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH) -I$(LIBMAPLE_PATH)/usb -I$(LIBMAPLE_PATH)/usb/usb_lib
+LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH)/include
+# FIXME: move public USB headers to include/libmaple/usb/ or something.
+LIBMAPLE_INCLUDES += -I$(LIBMAPLE_PATH)/usb \
+ -I$(LIBMAPLE_PATH)/usb/usb_lib
# Local flags
-CFLAGS_$(d) = -I$(d) $(LIBMAPLE_INCLUDES) -Wall -Werror
+CFLAGS_$(d) = -I$(d) $(LIBMAPLE_INCLUDES) -Wall # -Werror
# Local rules and targets
cSRCS_$(d) := adc.c \
diff --git a/libmaple/spi.c b/libmaple/spi.c
index 1c68529..d0aaaf0 100644
--- a/libmaple/spi.c
+++ b/libmaple/spi.c
@@ -31,8 +31,8 @@
* Currently, there is no Integrated Interchip Sound (I2S) support.
*/
-#include "spi.h"
-#include "bitband.h"
+#include <libmaple/spi.h>
+#include <libmaple/bitband.h>
static void spi_reconfigure(spi_dev *dev, uint32 cr1_config);
diff --git a/libmaple/syscalls.c b/libmaple/syscalls.c
index 8a57945..86fd8e6 100644
--- a/libmaple/syscalls.c
+++ b/libmaple/syscalls.c
@@ -30,7 +30,7 @@
* memory allocation.
*/
-#include "libmaple.h"
+#include <libmaple/libmaple.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/libmaple/systick.c b/libmaple/systick.c
index 9bb5d50..c6e3cbd 100644
--- a/libmaple/systick.c
+++ b/libmaple/systick.c
@@ -29,7 +29,7 @@
* @brief System timer interrupt handler and initialization routines
*/
-#include "systick.h"
+#include <libmaple/systick.h>
volatile uint32 systick_uptime_millis;
static void (*systick_user_callback)(void);
diff --git a/libmaple/timer.c b/libmaple/timer.c
index 83e9ace..90995e2 100644
--- a/libmaple/timer.c
+++ b/libmaple/timer.c
@@ -30,7 +30,7 @@
* @brief New-style timer interface
*/
-#include "timer.h"
+#include <libmaple/timer.h>
/* Just like the corresponding DIER bits:
* [0] = Update handler;
diff --git a/libmaple/usart.c b/libmaple/usart.c
index 0bdc37a..ba63b79 100644
--- a/libmaple/usart.c
+++ b/libmaple/usart.c
@@ -31,7 +31,7 @@
* @brief USART control routines
*/
-#include "usart.h"
+#include <libmaple/usart.h>
/*
* Devices
diff --git a/libmaple/usb/usb_cdcacm.h b/libmaple/usb/usb_cdcacm.h
index 8ca1c68..ec672a3 100644
--- a/libmaple/usb/usb_cdcacm.h
+++ b/libmaple/usb/usb_cdcacm.h
@@ -32,8 +32,8 @@
#ifndef _USB_CDCACM_H_
#define _USB_CDCACM_H_
-#include "libmaple_types.h"
-#include "gpio.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/gpio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/libmaple/util.c b/libmaple/util.c
index b15d658..07e9572 100644
--- a/libmaple/util.c
+++ b/libmaple/util.c
@@ -30,12 +30,12 @@
* and messages dumped over a UART for failed asserts.
*/
-#include "libmaple.h"
-#include "usart.h"
-#include "gpio.h"
-#include "nvic.h"
-#include "adc.h"
-#include "timer.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/usart.h>
+#include <libmaple/gpio.h>
+#include <libmaple/nvic.h>
+#include <libmaple/adc.h>
+#include <libmaple/timer.h>
/* Failed ASSERT()s send out a message using this USART config. */
#ifndef ERROR_USART
diff --git a/libraries/FreeRTOS/MapleFreeRTOS.h b/libraries/FreeRTOS/MapleFreeRTOS.h
index 839e3e2..dc06979 100644
--- a/libraries/FreeRTOS/MapleFreeRTOS.h
+++ b/libraries/FreeRTOS/MapleFreeRTOS.h
@@ -27,7 +27,7 @@
#ifndef __MAPLE_FREERTOS_H__
#define __MAPLE_FREERTOS_H__
-#include "wirish.h"
+#include <wirish/wirish.h>
extern "C" {
#define GCC_ARMCM3
diff --git a/libraries/LiquidCrystal/LiquidCrystal.cpp b/libraries/LiquidCrystal/LiquidCrystal.cpp
index 85e19ef..5cfb1ca 100644
--- a/libraries/LiquidCrystal/LiquidCrystal.cpp
+++ b/libraries/LiquidCrystal/LiquidCrystal.cpp
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
-#include "WProgram.h"
+#include <wirish/WProgram.h>
// When the display powers up, it is configured as follows:
//
diff --git a/libraries/LiquidCrystal/LiquidCrystal.h b/libraries/LiquidCrystal/LiquidCrystal.h
index 0baf543..06a159d 100644
--- a/libraries/LiquidCrystal/LiquidCrystal.h
+++ b/libraries/LiquidCrystal/LiquidCrystal.h
@@ -2,8 +2,8 @@
#define LiquidCrystal_h
//#include <inttypes.h>
-#include "wirish.h"
-#include "Print.h"
+#include <wirish/wirish.h>
+#include <wirish/Print.h>
// commands
#define LCD_CLEARDISPLAY 0x01
diff --git a/libraries/Servo/Servo.cpp b/libraries/Servo/Servo.cpp
index 8fbd366..ecb85e6 100644
--- a/libraries/Servo/Servo.cpp
+++ b/libraries/Servo/Servo.cpp
@@ -26,10 +26,10 @@
#include "Servo.h"
-#include "boards.h"
-#include "io.h"
-#include "pwm.h"
-#include "wirish_math.h"
+#include <wirish/boards.h>
+#include <wirish/io.h>
+#include <wirish/pwm.h>
+#include <wirish/wirish_math.h>
// 20 millisecond period config. For a 1-based prescaler,
//
diff --git a/libraries/Servo/Servo.h b/libraries/Servo/Servo.h
index 7753b4b..94e1e00 100644
--- a/libraries/Servo/Servo.h
+++ b/libraries/Servo/Servo.h
@@ -27,14 +27,10 @@
#ifndef _SERVO_H_
#define _SERVO_H_
-#include "libmaple_types.h"
-#include "timer.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/timer.h>
-#include "wirish_types.h"
-
-#ifdef MAPLE_IDE
-#include "wirish.h" /* hack for IDE compile */
-#endif
+#include <wirish/wirish_types.h>
/*
* Note on Arduino compatibility:
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp
index 753f831..8416525 100644
--- a/libraries/Wire/Wire.cpp
+++ b/libraries/Wire/Wire.cpp
@@ -30,7 +30,6 @@
*/
#include "Wire.h"
-#include "wirish.h"
/* low level conventions:
* - SDA/SCL idle high (expected high)
diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h
index d2f3608..0640c3b 100644
--- a/libraries/Wire/Wire.h
+++ b/libraries/Wire/Wire.h
@@ -29,11 +29,11 @@
* interface to I2C (two-wire) communication.
*/
-#include "wirish.h"
-
#ifndef _WIRE_H_
#define _WIRE_H_
+#include <wirish/wirish.h>
+
typedef struct {
uint8 scl;
uint8 sda;
diff --git a/main.cpp.example b/main.cpp.example
index 23d5540..4e44489 100644
--- a/main.cpp.example
+++ b/main.cpp.example
@@ -1,7 +1,7 @@
// Sample main.cpp file. Blinks the built-in LED, sends a message out
// USART2, and turns on PWM on pin 2.
-#include "wirish.h"
+#include <wirish/wirish.h>
#define PWM_PIN 2
diff --git a/wirish/HardwareTimer.cpp b/wirish/HardwareTimer.cpp
index bd61a89..52257bf 100644
--- a/wirish/HardwareTimer.cpp
+++ b/wirish/HardwareTimer.cpp
@@ -24,9 +24,9 @@
* SOFTWARE.
*****************************************************************************/
-#include "HardwareTimer.h"
-#include "boards.h" // for CYCLES_PER_MICROSECOND
-#include "wirish_math.h"
+#include <wirish/HardwareTimer.h>
+#include <wirish/boards.h> // for CYCLES_PER_MICROSECOND
+#include <wirish/wirish_math.h>
// TODO [0.1.0] Remove deprecated pieces
diff --git a/wirish/Print.cpp b/wirish/Print.cpp
index 58c7cc7..1a2bddb 100644
--- a/wirish/Print.cpp
+++ b/wirish/Print.cpp
@@ -21,8 +21,9 @@
* Modified 12 April 2011 by Marti Bolivar <mbolivar@leaflabs.com>
*/
-#include "Print.h"
+#include <wirish/Print.h>
+#include <wirish/wirish_math.h>
#include <limits.h>
#ifndef LLONG_MAX
@@ -40,8 +41,6 @@
#define LLONG_MAX 9223372036854775807LL
#endif
-#include "wirish_math.h"
-
/*
* Public methods
*/
diff --git a/wirish/boards.cpp b/wirish/boards.cpp
index 569ca6d..dbdcf1c 100644
--- a/wirish/boards.cpp
+++ b/wirish/boards.cpp
@@ -32,15 +32,15 @@
* at 72MHz. APB1 is clocked at 36MHz.
*/
-#include "boards.h"
-
-#include "flash.h"
-#include "rcc.h"
-#include "nvic.h"
-#include "systick.h"
-#include "gpio.h"
-#include "adc.h"
-#include "timer.h"
+#include <wirish/boards.h>
+
+#include <libmaple/flash.h>
+#include <libmaple/rcc.h>
+#include <libmaple/nvic.h>
+#include <libmaple/systick.h>
+#include <libmaple/gpio.h>
+#include <libmaple/adc.h>
+#include <libmaple/timer.h>
#include "usb_cdcacm.h"
static void setupFlash(void);
diff --git a/wirish/boards/maple.cpp b/wirish/boards/maple/board.cpp
index 43d4386..256bb90 100644
--- a/wirish/boards/maple.cpp
+++ b/wirish/boards/maple/board.cpp
@@ -25,18 +25,16 @@
*****************************************************************************/
/**
- * @file maple.cpp
+ * @file wirish/boards/maple/board.cpp
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief Maple PIN_MAP and boardInit().
+ * @brief Maple board file.
*/
-#ifdef BOARD_maple
+#include <board/board.h>
-#include "maple.h"
-
-#include "gpio.h"
-#include "timer.h"
-#include "wirish_types.h"
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
+#include <wirish/wirish_types.h>
void boardInit(void) {
}
@@ -112,5 +110,3 @@ extern const uint8 boardUsedPins[] __FLASH__ = {
BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN,
BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
};
-
-#endif
diff --git a/wirish/boards/maple.h b/wirish/boards/maple/include/board/board.h
index a986884..49f5b9a 100644
--- a/wirish/boards/maple.h
+++ b/wirish/boards/maple/include/board/board.h
@@ -25,9 +25,9 @@
*****************************************************************************/
/**
- * @file maple.h
+ * @file wirish/boards/maple/include/board/board.h
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief Private include file for Maple in boards.h
+ * @brief Maple board header.
*/
#ifndef _BOARD_MAPLE_H_
diff --git a/wirish/boards/maple_RET6.cpp b/wirish/boards/maple_RET6/board.cpp
index cbd7e25..2ef7de7 100644
--- a/wirish/boards/maple_RET6.cpp
+++ b/wirish/boards/maple_RET6/board.cpp
@@ -25,18 +25,17 @@
*****************************************************************************/
/**
- * @file maple_RET6.cpp
+ * @file wirish/boards/maple_RET6/board.cpp
* @author Marti Bolivar <mbolivar@leaflabs.com>
* @brief Maple RET6 Edition board file
*/
-#ifdef BOARD_maple_RET6
+#include <board/board.h>
-#include "maple_RET6.h"
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
-#include "gpio.h"
-#include "timer.h"
-#include "wirish_types.h"
+#include <wirish/wirish_types.h>
void boardInit(void) {
}
@@ -114,5 +113,3 @@ extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN,
BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
};
-
-#endif
diff --git a/wirish/boards/maple_RET6.h b/wirish/boards/maple_RET6/include/board/board.h
index 9e7ce9d..1a0365a 100644
--- a/wirish/boards/maple_RET6.h
+++ b/wirish/boards/maple_RET6/include/board/board.h
@@ -25,11 +25,12 @@
*****************************************************************************/
/**
- * @file maple_RET6.h
+ * @file wirish/boards/maple_RET6/include/board/board.h
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief Private include file for Maple RET6 Edition in boards.h
+ * @brief Maple RET6 Edition board header.
*
- * See maple.h for more information on these definitions.
+ * See wirish/boards/maple/include/board/board.h for more information
+ * on these definitions.
*/
#ifndef _BOARDS_MAPLE_RET6_H_
diff --git a/wirish/boards/maple_mini.cpp b/wirish/boards/maple_mini/board.cpp
index f111a14..599cb66 100644
--- a/wirish/boards/maple_mini.cpp
+++ b/wirish/boards/maple_mini/board.cpp
@@ -25,19 +25,18 @@
*****************************************************************************/
/**
- * @file maple_mini.cpp
+ * @file wirish/boards/maple_mini/board.cpp
* @author Marti Bolivar <mbolivar@leaflabs.com>
* @brief Maple Mini board file.
*/
-#ifdef BOARD_maple_mini
+#include <board/board.h>
-#include "maple_mini.h"
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
-#include "gpio.h"
-#include "timer.h"
-#include "wirish_debug.h"
-#include "wirish_types.h"
+#include <wirish/wirish_debug.h>
+#include <wirish/wirish_types.h>
/* Since we want the Serial Wire/JTAG pins as GPIOs, disable both SW
* and JTAG debug support */
@@ -102,5 +101,3 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
BOARD_LED_PIN, BOARD_BUTTON_PIN, USB_DP, USB_DM
};
-
-#endif
diff --git a/wirish/boards/maple_mini.h b/wirish/boards/maple_mini/include/board/board.h
index 40f507b..bfba46d 100644
--- a/wirish/boards/maple_mini.h
+++ b/wirish/boards/maple_mini/include/board/board.h
@@ -25,11 +25,12 @@
*****************************************************************************/
/**
- * @file maple_mini.h
+ * @file wirish/boards/maple_mini/include/board/board.h
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief Private include file for Maple Mini in boards.h
+ * @brief Maple Mini board header.
*
- * See maple.h for more information on these definitions.
+ * See wirish/boards/maple/include/board/board.h for more information
+ * on these definitions.
*/
#ifndef _BOARD_MAPLE_MINI_H_
diff --git a/wirish/boards/maple_native.cpp b/wirish/boards/maple_native/board.cpp
index 821be77..515cf5b 100644
--- a/wirish/boards/maple_native.cpp
+++ b/wirish/boards/maple_native/board.cpp
@@ -25,21 +25,19 @@
*****************************************************************************/
/**
- * @file maple_native.cpp
+ * @file wirish/boards/maple_native/board.cpp
* @author Marti Bolivar <mbolivar@leaflabs.com>
* @brief Maple Native board file.
*/
-#ifdef BOARD_maple_native
+#include <board/board.h>
-#include "maple_native.h"
+#include <libmaple/fsmc.h>
+#include <libmaple/gpio.h>
+#include <libmaple/rcc.h>
+#include <libmaple/timer.h>
-#include "fsmc.h"
-#include "gpio.h"
-#include "rcc.h"
-#include "timer.h"
-
-#include "wirish_types.h"
+#include <wirish/wirish_types.h>
static void initSRAMChip(void);
@@ -197,5 +195,3 @@ static void initSRAMChip(void) {
fsmc_nor_psram_set_addset(regs, 0);
fsmc_nor_psram_set_datast(regs, 3);
}
-
-#endif
diff --git a/wirish/boards/maple_native.h b/wirish/boards/maple_native/include/board/board.h
index 7c09014..397afaf 100644
--- a/wirish/boards/maple_native.h
+++ b/wirish/boards/maple_native/include/board/board.h
@@ -25,11 +25,12 @@
*****************************************************************************/
/**
- * @file maple_native.h
+ * @file wirish/boards/maple_native/include/board/board.h.
* @author Marti Bolivar <mbolivar@leaflabs.com>
- * @brief Private include file for Maple Native in boards.h
+ * @brief Maple Native board header file.
*
- * See maple.h for more information on these definitions.
+ * See wirish/boards/maple/include/board/board.h for more information
+ * on these definitions.
*/
#ifndef _BOARD_MAPLE_NATIVE_H_
diff --git a/wirish/boards/olimex_stm32_h103.cpp b/wirish/boards/olimex_stm32_h103/board.cpp
index a9f0936..d9b8033 100644
--- a/wirish/boards/olimex_stm32_h103.cpp
+++ b/wirish/boards/olimex_stm32_h103/board.cpp
@@ -26,18 +26,17 @@
*****************************************************************************/
/**
- * @file olimex_stm32_h103.cpp
+ * @file wirish/boards/olimex_stm32_h103/board.cpp
* @author David Kiliani <mail@davidkiliani.de>
- * @brief Olimex STM32_H103 PIN_MAP and boardInit().
+ * @brief Olimex STM32_H103 board file.
*/
-#ifdef BOARD_olimex_stm32_h103
+#include <board/board.h>
-#include "olimex_stm32_h103.h"
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
-#include "gpio.h"
-#include "timer.h"
-#include "wirish_types.h"
+#include <wirish/wirish_types.h>
void boardInit(void) {
}
@@ -118,5 +117,3 @@ extern const uint8 boardUsedPins[] __FLASH__ = {
BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN,
BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
};
-
-#endif
diff --git a/wirish/boards/olimex_stm32_h103.h b/wirish/boards/olimex_stm32_h103/include/board/board.h
index d2b5fcc..b312e26 100644
--- a/wirish/boards/olimex_stm32_h103.h
+++ b/wirish/boards/olimex_stm32_h103/include/board/board.h
@@ -26,9 +26,9 @@
*****************************************************************************/
/**
- * @file olimex_stm32_h103.h
+ * @file wirish/boards/olimex_stm32_h103/include/board/board.h
* @author David Kiliani <mail@davidkiliani.de>
- * @brief Private include file for Olimex STM32_H103 in boards.h
+ * @brief Olimex STM32_H103 board header.
*/
#ifndef _BOARD_OLIMEX_STM32_H103_H_
diff --git a/wirish/comm/HardwareSPI.cpp b/wirish/comm/HardwareSPI.cpp
index 21ae180..e1f186e 100644
--- a/wirish/comm/HardwareSPI.cpp
+++ b/wirish/comm/HardwareSPI.cpp
@@ -29,14 +29,14 @@
* @brief Wirish SPI implementation.
*/
-#include "HardwareSPI.h"
+#include <wirish/HardwareSPI.h>
-#include "timer.h"
-#include "util.h"
-#include "rcc.h"
+#include <libmaple/timer.h>
+#include <libmaple/util.h>
+#include <libmaple/rcc.h>
-#include "wirish.h"
-#include "boards.h"
+#include <wirish/wirish.h>
+#include <wirish/boards.h>
struct spi_pins {
uint8 nss;
diff --git a/wirish/comm/HardwareSerial.cpp b/wirish/comm/HardwareSerial.cpp
index 6ef9222..a9eb763 100644
--- a/wirish/comm/HardwareSerial.cpp
+++ b/wirish/comm/HardwareSerial.cpp
@@ -29,12 +29,13 @@
* @brief Wirish serial port implementation.
*/
-#include "libmaple.h"
-#include "gpio.h"
-#include "timer.h"
+#include <wirish/HardwareSerial.h>
-#include "HardwareSerial.h"
-#include "boards.h"
+#include <libmaple/libmaple.h>
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
+
+#include <wirish/boards.h>
#define TX1 BOARD_USART1_TX_PIN
#define RX1 BOARD_USART1_RX_PIN
diff --git a/wirish/ext_interrupts.cpp b/wirish/ext_interrupts.cpp
index b7f96f9..8f8c768 100644
--- a/wirish/ext_interrupts.cpp
+++ b/wirish/ext_interrupts.cpp
@@ -30,12 +30,12 @@
* @brief Wiring-like interface for external interrupts
*/
-#include "ext_interrupts.h"
+#include <wirish/ext_interrupts.h>
-#include "gpio.h"
-#include "exti.h"
+#include <libmaple/gpio.h>
+#include <libmaple/exti.h>
-#include "boards.h"
+#include <wirish/boards.h>
static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode);
diff --git a/wirish/comm/HardwareSPI.h b/wirish/include/wirish/HardwareSPI.h
index d138910..ad95191 100644
--- a/wirish/comm/HardwareSPI.h
+++ b/wirish/include/wirish/HardwareSPI.h
@@ -33,13 +33,13 @@
/* TODO [0.1.0] Remove deprecated methods. */
-#include "libmaple_types.h"
-#include "spi.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/spi.h>
-#include "boards.h"
+#include <wirish/boards.h>
-#ifndef _HARDWARESPI_H_
-#define _HARDWARESPI_H_
+#ifndef _WIRISH_HARDWARESPI_H_
+#define _WIRISH_HARDWARESPI_H_
/**
* @brief Defines the possible SPI communication speeds.
@@ -220,4 +220,3 @@ private:
};
#endif
-
diff --git a/wirish/comm/HardwareSerial.h b/wirish/include/wirish/HardwareSerial.h
index f69b67a..c25fd6e 100644
--- a/wirish/comm/HardwareSerial.h
+++ b/wirish/include/wirish/HardwareSerial.h
@@ -29,13 +29,13 @@
* @brief Wirish serial port interface.
*/
-#ifndef _HARDWARESERIAL_H_
-#define _HARDWARESERIAL_H_
+#ifndef _WIRISH_HARDWARESERIAL_H_
+#define _WIRISH_HARDWARESERIAL_H_
-#include "libmaple_types.h"
-#include "usart.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/usart.h>
-#include "Print.h"
+#include <wirish/Print.h>
/*
* IMPORTANT:
diff --git a/wirish/HardwareTimer.h b/wirish/include/wirish/HardwareTimer.h
index 1c34b9d..bdcca5d 100644
--- a/wirish/HardwareTimer.h
+++ b/wirish/include/wirish/HardwareTimer.h
@@ -28,12 +28,12 @@
* @brief Wirish timer class.
*/
-#ifndef _HARDWARETIMER_H_
-#define _HARDWARETIMER_H_
+#ifndef _WIRISH_HARDWARETIMER_H_
+#define _WIRISH_HARDWARETIMER_H_
// TODO [0.1.0] Remove deprecated pieces, pick a better API
-#include "timer.h"
+#include <libmaple/timer.h>
/** Timer mode. */
typedef timer_mode TimerMode;
diff --git a/wirish/Print.h b/wirish/include/wirish/Print.h
index c0c63cb..5fd0b7a 100644
--- a/wirish/Print.h
+++ b/wirish/include/wirish/Print.h
@@ -20,10 +20,10 @@
* Modified 12 April 2011 by Marti Bolivar <mbolivar@leaflabs.com>
*/
-#ifndef _PRINT_H_
-#define _PRINT_H_
+#ifndef _WIRISH_PRINT_H_
+#define _WIRISH_PRINT_H_
-#include "libmaple_types.h"
+#include <libmaple/libmaple_types.h>
enum {
BYTE = 0,
diff --git a/wirish/WProgram.h b/wirish/include/wirish/WProgram.h
index 2949a0a..b24ec2a 100644
--- a/wirish/WProgram.h
+++ b/wirish/include/wirish/WProgram.h
@@ -24,7 +24,12 @@
* SOFTWARE.
*****************************************************************************/
-#include "wirish.h"
+#ifndef _WIRISH_WPROGRAM_H_
+#define _WIRISH_WPROGRAM_H_
+
+#include <wirish/wirish.h>
void setup();
void loop();
+
+#endif
diff --git a/wirish/bit_constants.h b/wirish/include/wirish/bit_constants.h
index 8accc6b..4638f76 100644
--- a/wirish/bit_constants.h
+++ b/wirish/include/wirish/bit_constants.h
@@ -29,8 +29,8 @@
* compatibility.
*/
-#ifndef _BIT_CONSTANTS_H_
-#define _BIT_CONSTANTS_H_
+#ifndef _WIRISH_BIT_CONSTANTS_H_
+#define _WIRISH_BIT_CONSTANTS_H_
#define BIT0 (1 << 0)
#define BIT1 (1 << 1)
diff --git a/wirish/bits.h b/wirish/include/wirish/bits.h
index 3e755b7..0a63c58 100644
--- a/wirish/bits.h
+++ b/wirish/include/wirish/bits.h
@@ -27,4 +27,9 @@
/* Note: Use of this header file is deprecated. Use bit_constants.h
instead. */
-#include "bit_constants.h"
+#ifndef _WIRISH_BITS_H_
+#define _WIRISH_BITS_H_
+
+#include <wirish/bit_constants.h>
+
+#endif
diff --git a/wirish/boards.h b/wirish/include/wirish/boards.h
index 9ca4a66..e708f79 100644
--- a/wirish/boards.h
+++ b/wirish/include/wirish/boards.h
@@ -36,12 +36,12 @@
* file in the top-level Makefile build.
*/
-#ifndef _BOARDS_H_
-#define _BOARDS_H_
+#ifndef _WIRISH_BOARDS_H_
+#define _WIRISH_BOARDS_H_
-#include "libmaple_types.h"
-
-#include "wirish_types.h"
+#include <libmaple/libmaple_types.h>
+#include <wirish/wirish_types.h>
+#include <board/board.h>
/* Set of all possible pin names; not all boards have all these (note
* that we use the Dx convention since all of the Maple's pins are
@@ -115,40 +115,7 @@ extern void boardInit(void);
*/
bool boardUsesPin(uint8 pin);
-/* Include the appropriate private header from boards/: */
-
-/* FIXME HACK put boards/ before these paths once IDE uses make. */
-
-#ifdef BOARD_maple
-#include "maple.h"
-#elif defined(BOARD_maple_native)
-#include "maple_native.h"
-#elif defined(BOARD_maple_mini)
-#include "maple_mini.h"
-#elif defined(BOARD_maple_RET6)
-/*
- * **NOT** MAPLE REV6. This the **Maple RET6 EDITION**, which is a
- * Maple with an STM32F103RET6 (...RET6) instead of an STM32F103RBT6
- * (...RBT6) on it. Maple Rev6 (as of March 2011) DOES NOT EXIST.
- */
-#include "maple_RET6.h"
-#elif defined(BOARD_olimex_stm32_h103)
-#include "olimex_stm32_h103.h"
-#else
-/*
- * TODO turn this into a warning so people can:
- *
- * #include "my_board_config.h"
- * #include "wirish.h"
- *
- * This will enable third-party board support without requiring that
- * anybody hack around in libmaple itself.
- */
-#error "Board type has not been selected correctly."
-#endif
-
/* Set derived definitions */
-
#define CLOCK_SPEED_MHZ CYCLES_PER_MICROSECOND
#define CLOCK_SPEED_HZ (CLOCK_SPEED_MHZ * 1000000UL)
diff --git a/wirish/ext_interrupts.h b/wirish/include/wirish/ext_interrupts.h
index b5c6f98..617e43d 100644
--- a/wirish/ext_interrupts.h
+++ b/wirish/include/wirish/ext_interrupts.h
@@ -24,17 +24,17 @@
* SOFTWARE.
*****************************************************************************/
-#include "libmaple_types.h"
-#include "nvic.h"
-
/**
* @file ext_interrupts.h
*
* @brief Wiring-like external interrupt prototypes and types.
*/
-#ifndef _EXT_INTERRUPTS_H_
-#define _EXT_INTERRUPTS_H_
+#ifndef _WIRISH_EXT_INTERRUPTS_H_
+#define _WIRISH_EXT_INTERRUPTS_H_
+
+#include <libmaple/libmaple_types.h>
+#include <libmaple/nvic.h>
/**
* The kind of transition on an external pin which should trigger an
diff --git a/wirish/io.h b/wirish/include/wirish/io.h
index 0cb9c04..de56a49 100644
--- a/wirish/io.h
+++ b/wirish/include/wirish/io.h
@@ -30,12 +30,11 @@
* @brief Arduino-compatible digital pin I/O interface.
*/
-#ifndef _IO_H_
-#define _IO_H_
+#ifndef _WIRISH_IO_H_
+#define _WIRISH_IO_H_
-#include "libmaple_types.h"
-
-#include "boards.h"
+#include <libmaple/libmaple_types.h>
+#include <wirish/boards.h>
/**
* Specifies a GPIO pin behavior.
diff --git a/wirish/pwm.h b/wirish/include/wirish/pwm.h
index a7705ab..e7130fb 100644
--- a/wirish/pwm.h
+++ b/wirish/include/wirish/pwm.h
@@ -30,10 +30,10 @@
* @brief Arduino-compatible PWM interface.
*/
-#ifndef _PWM_H_
-#define _PWM_H_
+#ifndef _WIRISH_PWM_H_
+#define _WIRISH_PWM_H_
-#include "libmaple_types.h"
+#include <libmaple/libmaple_types.h>
/**
* As a convenience, analogWrite is an alias of pwmWrite to ease
diff --git a/wirish/usb_serial.h b/wirish/include/wirish/usb_serial.h
index d43b288..81e9e97 100644
--- a/wirish/usb_serial.h
+++ b/wirish/include/wirish/usb_serial.h
@@ -28,10 +28,10 @@
* @brief Wirish virtual serial port
*/
-#ifndef _USB_SERIAL_H_
-#define _USB_SERIAL_H_
+#ifndef _WIRISH_USB_SERIAL_H_
+#define _WIRISH_USB_SERIAL_H_
-#include "Print.h"
+#include <wirish/Print.h>
/**
* @brief Virtual serial terminal.
diff --git a/wirish/wirish.h b/wirish/include/wirish/wirish.h
index d024f3b..4097ce1 100644
--- a/wirish/wirish.h
+++ b/wirish/include/wirish/wirish.h
@@ -31,26 +31,26 @@
* substantial pieces of libmaple proper.
*/
-#ifndef _WIRISH_H_
-#define _WIRISH_H_
+#ifndef _WIRISH_WIRISH_H_
+#define _WIRISH_WIRISH_H_
-#include "boards.h"
-#include "io.h"
-#include "bit_constants.h"
-#include "pwm.h"
-#include "ext_interrupts.h"
-#include "wirish_debug.h"
-#include "wirish_math.h"
-#include "wirish_time.h"
-#include "HardwareSPI.h"
-#include "HardwareSerial.h"
-#include "HardwareTimer.h"
-#include "usb_serial.h"
+#include <wirish/boards.h>
+#include <wirish/io.h>
+#include <wirish/bit_constants.h>
+#include <wirish/pwm.h>
+#include <wirish/ext_interrupts.h>
+#include <wirish/wirish_debug.h>
+#include <wirish/wirish_math.h>
+#include <wirish/wirish_time.h>
+#include <wirish/HardwareSPI.h>
+#include <wirish/HardwareSerial.h>
+#include <wirish/HardwareTimer.h>
+#include <wirish/usb_serial.h>
+#include <wirish/wirish_types.h>
-#include "libmaple.h"
-#include "wirish_types.h"
+#include <libmaple/libmaple.h>
-/* Arduino wiring macros and bit defines */
+/* Wiring macros and bit defines */
#define true 0x1
#define false 0x0
diff --git a/wirish/wirish_debug.h b/wirish/include/wirish/wirish_debug.h
index 3f92b02..c8bc077 100644
--- a/wirish/wirish_debug.h
+++ b/wirish/include/wirish/wirish_debug.h
@@ -29,10 +29,10 @@
* @brief High level debug port configuration
*/
-#ifndef _WIRISH_DEBUG_H_
-#define _WIRISH_DEBUG_H_
+#ifndef _WIRISH_WIRISH_DEBUG_H_
+#define _WIRISH_WIRISH_DEBUG_H_
-#include "gpio.h"
+#include <libmaple/gpio.h>
/**
* @brief Disable the JTAG and Serial Wire (SW) debug ports.
diff --git a/wirish/wirish_math.h b/wirish/include/wirish/wirish_math.h
index a85b30a..3820cab 100644
--- a/wirish/wirish_math.h
+++ b/wirish/include/wirish/wirish_math.h
@@ -29,8 +29,8 @@
* @brief Includes <math.h>; provides Arduino-compatible math routines.
*/
-#ifndef _WIRING_MATH_H_
-#define _WIRING_MATH_H_
+#ifndef _WIRISH_WIRISH_MATH_H_
+#define _WIRISH_WIRISH_MATH_H_
#include <math.h>
diff --git a/wirish/wirish_time.h b/wirish/include/wirish/wirish_time.h
index 719a775..a81075c 100644
--- a/wirish/wirish_time.h
+++ b/wirish/include/wirish/wirish_time.h
@@ -29,13 +29,13 @@
* @brief Timing and delay functions.
*/
-#ifndef _TIME_H_
-#define _TIME_H_
+#ifndef _WIRISH_WIRISH_TIME_H_
+#define _WIRISH_WIRISH_TIME_H_
-#include "libmaple_types.h"
-#include "systick.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/systick.h>
-#include "boards.h"
+#include <wirish/boards.h>
#define US_PER_MS 1000
diff --git a/wirish/wirish_types.h b/wirish/include/wirish/wirish_types.h
index 43a6525..d70b26f 100644
--- a/wirish/wirish_types.h
+++ b/wirish/include/wirish/wirish_types.h
@@ -30,13 +30,13 @@
* @brief Wirish library type definitions.
*/
-#include "libmaple_types.h"
-#include "gpio.h"
-#include "timer.h"
-#include "adc.h"
+#ifndef _WIRISH_WIRISH_TYPES_H_
+#define _WIRISH_WIRISH_TYPES_H_
-#ifndef _WIRISH_TYPES_H_
-#define _WIRISH_TYPES_H_
+#include <libmaple/libmaple_types.h>
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
+#include <libmaple/adc.h>
/**
* Invalid stm32_pin_info adc_channel value.
diff --git a/wirish/pwm.cpp b/wirish/pwm.cpp
index 7e8a535..a55f245 100644
--- a/wirish/pwm.cpp
+++ b/wirish/pwm.cpp
@@ -28,12 +28,12 @@
* @brief Arduino-style PWM implementation.
*/
-#include "pwm.h"
+#include <wirish/pwm.h>
-#include "libmaple_types.h"
-#include "timer.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/timer.h>
-#include "boards.h"
+#include <wirish/boards.h>
void pwmWrite(uint8 pin, uint16 duty_cycle) {
timer_dev *dev = PIN_MAP[pin].timer_device;
diff --git a/wirish/rules.mk b/wirish/rules.mk
index 1bf6245..923c17b 100644
--- a/wirish/rules.mk
+++ b/wirish/rules.mk
@@ -4,9 +4,12 @@ dirstack_$(sp) := $(d)
d := $(dir)
BUILDDIRS += $(BUILD_PATH)/$(d)
BUILDDIRS += $(BUILD_PATH)/$(d)/comm
-BUILDDIRS += $(BUILD_PATH)/$(d)/boards
-WIRISH_INCLUDES := -I$(d) -I$(d)/comm -I$(d)/boards
+# Board config -- TODO allow user override
+WIRISH_BOARD_PATH := boards/$(BOARD)
+BUILDDIRS += $(BUILD_PATH)/$(d)/$(WIRISH_BOARD_PATH)
+
+WIRISH_INCLUDES := -I$(d)/include -I$(d)/$(WIRISH_BOARD_PATH)/include
# Local flags
CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
@@ -18,11 +21,6 @@ cSRCS_$(d) := start_c.c
cppSRCS_$(d) := wirish_math.cpp \
Print.cpp \
boards.cpp \
- boards/maple.cpp \
- boards/maple_mini.cpp \
- boards/maple_native.cpp \
- boards/maple_RET6.cpp \
- boards/olimex_stm32_h103.cpp \
comm/HardwareSerial.cpp \
comm/HardwareSPI.cpp \
HardwareTimer.cpp \
@@ -34,6 +32,7 @@ cppSRCS_$(d) := wirish_math.cpp \
pwm.cpp \
ext_interrupts.cpp \
wirish_digital.cpp
+cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp
sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp
index b66b992..1fd6e65 100644
--- a/wirish/usb_serial.cpp
+++ b/wirish/usb_serial.cpp
@@ -28,11 +28,14 @@
* @brief USB virtual serial terminal
*/
+#include <wirish/usb_serial.h>
+
#include <string.h>
-#include "wirish.h"
#include "usb_cdcacm.h"
-#include "usb.h"
+#include <libmaple/usb.h>
+
+#include <wirish/wirish.h>
#define USB_TIMEOUT 50
diff --git a/wirish/wirish_analog.cpp b/wirish/wirish_analog.cpp
index e5b9ffc..7a12156 100644
--- a/wirish/wirish_analog.cpp
+++ b/wirish/wirish_analog.cpp
@@ -28,11 +28,11 @@
* @brief Arduino-compatible ADC implementation.
*/
-#include "io.h"
+#include <wirish/io.h>
-#include "adc.h"
+#include <libmaple/adc.h>
-#include "boards.h"
+#include <wirish/boards.h>
/* Assumes that the ADC has been initialized and that the pin is set
* to INPUT_ANALOG */
diff --git a/wirish/wirish_digital.cpp b/wirish/wirish_digital.cpp
index 6a0577c..6be1a29 100644
--- a/wirish/wirish_digital.cpp
+++ b/wirish/wirish_digital.cpp
@@ -28,13 +28,13 @@
* Arduino-compatible digital I/O implementation.
*/
-#include "io.h"
+#include <wirish/io.h>
-#include "gpio.h"
-#include "timer.h"
+#include <libmaple/gpio.h>
+#include <libmaple/timer.h>
-#include "wirish_time.h"
-#include "boards.h"
+#include <wirish/wirish_time.h>
+#include <wirish/boards.h>
void pinMode(uint8 pin, WiringPinMode mode) {
gpio_pin_mode outputMode;
diff --git a/wirish/wirish_math.cpp b/wirish/wirish_math.cpp
index 5aa6510..1443b3c 100644
--- a/wirish/wirish_math.cpp
+++ b/wirish/wirish_math.cpp
@@ -22,7 +22,7 @@
*/
#include <stdlib.h>
-#include "math.h"
+#include <wirish/wirish_math.h>
void randomSeed(unsigned int seed) {
if (seed != 0) {
diff --git a/wirish/wirish_shift.cpp b/wirish/wirish_shift.cpp
index f67364d..0f24f59 100644
--- a/wirish/wirish_shift.cpp
+++ b/wirish/wirish_shift.cpp
@@ -22,7 +22,7 @@
* $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
*/
-#include "wirish.h"
+#include <wirish/wirish.h>
void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) {
int i;
diff --git a/wirish/wirish_time.cpp b/wirish/wirish_time.cpp
index c9f10a8..9ce934b 100644
--- a/wirish/wirish_time.cpp
+++ b/wirish/wirish_time.cpp
@@ -28,10 +28,10 @@
* @brief Delay implementation.
*/
-#include "wirish_time.h"
+#include <wirish/wirish_time.h>
-#include "libmaple_types.h"
-#include "delay.h"
+#include <libmaple/libmaple_types.h>
+#include <libmaple/delay.h>
void delay(unsigned long ms) {
uint32 i;