diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-10-18 15:11:25 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-10-18 15:12:21 -0400 |
commit | 8f97a6061ad5e7a9fe42b98f5ec1e2fa8aa7051c (patch) | |
tree | 3106b624c61c660b31302a4a19aa14ea04d7d10a /wirish | |
parent | 66b204637594927f72e47d87d9c279682d1bd174 (diff) | |
download | librambutan-8f97a6061ad5e7a9fe42b98f5ec1e2fa8aa7051c.tar.gz librambutan-8f97a6061ad5e7a9fe42b98f5ec1e2fa8aa7051c.zip |
wirish: Clean up includes; other fixups.
Clean up various core files' includes to fit this pattern:
- Header files include what they use.
- CPP files include their header first
- Include order is libmaple proper headers, then wirish
headers (modulo CPP rule above).
wirish.h: Move HIGH and LOW to io.h, and the boolean and byte typedefs
into wirish_types.h. These don't belong in wirish.h.
Add include guards to wirish_debug.h. Oops.
wirish_digital.cpp: Use standard bool instead of "boolean".
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish')
-rw-r--r-- | wirish/boards.h | 4 | ||||
-rw-r--r-- | wirish/ext_interrupts.cpp | 6 | ||||
-rw-r--r-- | wirish/io.h | 9 | ||||
-rw-r--r-- | wirish/pwm.cpp | 3 | ||||
-rw-r--r-- | wirish/pwm.h | 2 | ||||
-rw-r--r-- | wirish/wirish.h | 16 | ||||
-rw-r--r-- | wirish/wirish_analog.cpp | 6 | ||||
-rw-r--r-- | wirish/wirish_debug.h | 7 | ||||
-rw-r--r-- | wirish/wirish_digital.cpp | 9 | ||||
-rw-r--r-- | wirish/wirish_time.cpp | 4 | ||||
-rw-r--r-- | wirish/wirish_time.h | 6 | ||||
-rw-r--r-- | wirish/wirish_types.h | 3 |
12 files changed, 46 insertions, 29 deletions
diff --git a/wirish/boards.h b/wirish/boards.h index e9f7c28..9ca4a66 100644 --- a/wirish/boards.h +++ b/wirish/boards.h @@ -39,9 +39,7 @@ #ifndef _BOARDS_H_ #define _BOARDS_H_ -#include "libmaple.h" -#include "gpio.h" -#include "timer.h" +#include "libmaple_types.h" #include "wirish_types.h" diff --git a/wirish/ext_interrupts.cpp b/wirish/ext_interrupts.cpp index f014f13..b7f96f9 100644 --- a/wirish/ext_interrupts.cpp +++ b/wirish/ext_interrupts.cpp @@ -30,10 +30,12 @@ * @brief Wiring-like interface for external interrupts */ -#include "boards.h" +#include "ext_interrupts.h" + #include "gpio.h" #include "exti.h" -#include "ext_interrupts.h" + +#include "boards.h" static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode); diff --git a/wirish/io.h b/wirish/io.h index 50e748f..0cb9c04 100644 --- a/wirish/io.h +++ b/wirish/io.h @@ -33,10 +33,9 @@ #ifndef _IO_H_ #define _IO_H_ -#include "gpio.h" -#include "adc.h" +#include "libmaple_types.h" -#include "wirish_time.h" +#include "boards.h" /** * Specifies a GPIO pin behavior. @@ -112,6 +111,9 @@ typedef enum WiringPinMode { */ void pinMode(uint8 pin, WiringPinMode mode); +#define HIGH 0x1 +#define LOW 0x0 + /** * Writes a (digital) value to a pin. The pin must have its * mode set to OUTPUT or OUTPUT_OPEN_DRAIN. @@ -219,4 +221,3 @@ uint8 waitForButtonPress(uint32 timeout_millis=0); void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value); #endif - diff --git a/wirish/pwm.cpp b/wirish/pwm.cpp index 1806348..7e8a535 100644 --- a/wirish/pwm.cpp +++ b/wirish/pwm.cpp @@ -28,11 +28,12 @@ * @brief Arduino-style PWM implementation. */ +#include "pwm.h" + #include "libmaple_types.h" #include "timer.h" #include "boards.h" -#include "pwm.h" void pwmWrite(uint8 pin, uint16 duty_cycle) { timer_dev *dev = PIN_MAP[pin].timer_device; diff --git a/wirish/pwm.h b/wirish/pwm.h index 6c53626..a7705ab 100644 --- a/wirish/pwm.h +++ b/wirish/pwm.h @@ -33,6 +33,8 @@ #ifndef _PWM_H_ #define _PWM_H_ +#include "libmaple_types.h" + /** * As a convenience, analogWrite is an alias of pwmWrite to ease * porting Arduino code. However, period and duty will have to be diff --git a/wirish/wirish.h b/wirish/wirish.h index 6be8423..d024f3b 100644 --- a/wirish/wirish.h +++ b/wirish/wirish.h @@ -27,18 +27,16 @@ /** * @brief Main include file for the Wirish core. * - * Includes various Arduino wiring macros and bit defines + * Includes most of Wirish, and (transitively or otherwise) + * substantial pieces of libmaple proper. */ #ifndef _WIRISH_H_ #define _WIRISH_H_ -#include "libmaple.h" - -#include "wirish_types.h" #include "boards.h" #include "io.h" -#include "bits.h" +#include "bit_constants.h" #include "pwm.h" #include "ext_interrupts.h" #include "wirish_debug.h" @@ -49,9 +47,10 @@ #include "HardwareTimer.h" #include "usb_serial.h" +#include "libmaple.h" +#include "wirish_types.h" + /* Arduino wiring macros and bit defines */ -#define HIGH 0x1 -#define LOW 0x0 #define true 0x1 #define false 0x0 @@ -68,8 +67,5 @@ bitClear(value, bit)) #define bit(b) (1UL << (b)) -typedef uint8 boolean; -typedef uint8 byte; - #endif diff --git a/wirish/wirish_analog.cpp b/wirish/wirish_analog.cpp index 63b5eb2..e5b9ffc 100644 --- a/wirish/wirish_analog.cpp +++ b/wirish/wirish_analog.cpp @@ -28,10 +28,12 @@ * @brief Arduino-compatible ADC implementation. */ -#include "libmaple.h" -#include "wirish.h" #include "io.h" +#include "adc.h" + +#include "boards.h" + /* Assumes that the ADC has been initialized and that the pin is set * to INPUT_ANALOG */ uint16 analogRead(uint8 pin) { diff --git a/wirish/wirish_debug.h b/wirish/wirish_debug.h index d4c0bab..3f92b02 100644 --- a/wirish/wirish_debug.h +++ b/wirish/wirish_debug.h @@ -29,6 +29,11 @@ * @brief High level debug port configuration */ +#ifndef _WIRISH_DEBUG_H_ +#define _WIRISH_DEBUG_H_ + +#include "gpio.h" + /** * @brief Disable the JTAG and Serial Wire (SW) debug ports. * @@ -52,3 +57,5 @@ static inline void disableDebugPorts(void) { static inline void enableDebugPorts(void) { afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ); } + +#endif diff --git a/wirish/wirish_digital.cpp b/wirish/wirish_digital.cpp index a8b3ad8..6a0577c 100644 --- a/wirish/wirish_digital.cpp +++ b/wirish/wirish_digital.cpp @@ -28,12 +28,17 @@ * Arduino-compatible digital I/O implementation. */ -#include "wirish.h" #include "io.h" +#include "gpio.h" +#include "timer.h" + +#include "wirish_time.h" +#include "boards.h" + void pinMode(uint8 pin, WiringPinMode mode) { gpio_pin_mode outputMode; - boolean pwm = false; + bool pwm = false; if (pin >= BOARD_NR_GPIO_PINS) { return; diff --git a/wirish/wirish_time.cpp b/wirish/wirish_time.cpp index 270da28..c9f10a8 100644 --- a/wirish/wirish_time.cpp +++ b/wirish/wirish_time.cpp @@ -28,9 +28,9 @@ * @brief Delay implementation. */ -#include "libmaple.h" -#include "systick.h" #include "wirish_time.h" + +#include "libmaple_types.h" #include "delay.h" void delay(unsigned long ms) { diff --git a/wirish/wirish_time.h b/wirish/wirish_time.h index c37da87..ab225e8 100644 --- a/wirish/wirish_time.h +++ b/wirish/wirish_time.h @@ -32,9 +32,9 @@ #ifndef _TIME_H_ #define _TIME_H_ -#include "libmaple.h" -#include "nvic.h" +#include "libmaple_types.h" #include "systick.h" + #include "boards.h" #define US_PER_MS 1000 @@ -64,7 +64,7 @@ static inline uint32 micros(void) { } while (ms != millis()); /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it - actually takes to complete a SysTick reload */ + * actually takes to complete a SysTick reload */ res = (ms * US_PER_MS) + (SYSTICK_RELOAD_VAL + 1 - cycle_cnt) / CYCLES_PER_MICROSECOND; diff --git a/wirish/wirish_types.h b/wirish/wirish_types.h index 39efae0..43a6525 100644 --- a/wirish/wirish_types.h +++ b/wirish/wirish_types.h @@ -62,4 +62,7 @@ typedef struct stm32_pin_info { * variable in Flash instead of RAM. */ #define __FLASH__ __attr_flash +typedef uint8 boolean; +typedef uint8 byte; + #endif |