From 300fa7122a9b896f507f637415c0fcd8effe2b88 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 30 Mar 2011 08:06:42 -0400 Subject: Hacks to get things to compile in the IDE. --- support/scripts/copy-to-ide | 7 +++- wirish/boards.h | 11 +++-- wirish/io.h | 3 +- wirish/time.cpp | 43 -------------------- wirish/time.h | 99 --------------------------------------------- wirish/wirish.h | 2 +- wirish/wirish_time.cpp | 43 ++++++++++++++++++++ wirish/wirish_time.h | 99 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 158 insertions(+), 149 deletions(-) delete mode 100644 wirish/time.cpp delete mode 100644 wirish/time.h create mode 100644 wirish/wirish_time.cpp create mode 100644 wirish/wirish_time.h diff --git a/support/scripts/copy-to-ide b/support/scripts/copy-to-ide index 5254974..674615e 100755 --- a/support/scripts/copy-to-ide +++ b/support/scripts/copy-to-ide @@ -23,6 +23,8 @@ LMAPLE_SRC="LICENSE ./wirish/*.cpp ./wirish/comm/*.cpp ./wirish/comm/*.h + ./wirish/boards/*.h + ./wirish/boards/*.cpp ./support/ld/common_ram.inc ./support/ld/common_rom.inc ./support/ld/libcs3_stm32_high_density.a @@ -52,6 +54,10 @@ cp -R $LMAPLE_SRC $DEST_CORES echo Copying over libraries cp -R libraries/* $DEST_LIBS +# libmaple version +echo Creating libmaple-version.txt +git show-ref HEAD | cut -c 1-10 > $DEST/libmaple-version.txt + # docs echo Deleting old reference directory contents rm -rf $DEST_REF/* @@ -62,5 +68,4 @@ echo Rebuilding documentation echo Copying over documentation cp -R $LMAPLE_DOCS_BUILD/* $DEST_REF - echo Done. diff --git a/wirish/boards.h b/wirish/boards.h index cec844f..8df7028 100644 --- a/wirish/boards.h +++ b/wirish/boards.h @@ -119,19 +119,22 @@ bool boardUsesPin(uint8 pin); /* Include the appropriate private header from boards/: */ +/* FIXME put boards/ before these paths once you stick make into the + * IDE; current situation is a hack. */ + #ifdef BOARD_maple -#include "boards/maple.h" +#include "maple.h" #elif defined(BOARD_maple_native) -#include "boards/maple_native.h" +#include "maple_native.h" #elif defined(BOARD_maple_mini) -#include "boards/maple_mini.h" +#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 "boards/maple_RET6.h" +#include "maple_RET6.h" #else #error "Board type has not been selected correctly." #endif diff --git a/wirish/io.h b/wirish/io.h index 4e415b5..137377d 100644 --- a/wirish/io.h +++ b/wirish/io.h @@ -33,7 +33,8 @@ #include "gpio.h" #include "adc.h" -#include "time.h" + +#include "wirish_time.h" /** * Specifies a GPIO pin behavior. diff --git a/wirish/time.cpp b/wirish/time.cpp deleted file mode 100644 index b5663b0..0000000 --- a/wirish/time.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * 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. - *****************************************************************************/ - -/** - * @brief Delay implementation. - */ - -#include "libmaple.h" -#include "systick.h" -#include "time.h" -#include "delay.h" - -void delay(unsigned long ms) { - uint32 i; - for (i = 0; i < ms; i++) { - delayMicroseconds(1000); - } -} - -void delayMicroseconds(uint32 us) { - delay_us(us); -} diff --git a/wirish/time.h b/wirish/time.h deleted file mode 100644 index a0c0c82..0000000 --- a/wirish/time.h +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * 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 time.h - * @brief Timing and delay functions. - */ - -#ifndef _TIME_H -#define _TIME_H - -#include "libmaple.h" -#include "nvic.h" -#include "systick.h" -#include "boards.h" - -#define US_PER_MS 1000 - -/** - * Returns time (in milliseconds) since the beginning of program - * execution. On overflow, restarts at 0. - * @see micros() - */ -static inline uint32 millis(void) { - return systick_timer_millis; -} - -/** - * Returns time (in microseconds) since the beginning of program - * execution. On overflow, restarts at 0. - * @see millis() - */ -static inline uint32 micros(void) { - uint32 ms; - uint32 cycle_cnt; - uint32 res; - - nvic_globalirq_disable(); - - cycle_cnt = systick_get_count(); - ms = millis(); - - nvic_globalirq_enable(); - - /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it - actually takes to complete a SysTick reload */ - res = (ms * US_PER_MS) + - (SYSTICK_RELOAD_VAL + 1 - cycle_cnt)/CYCLES_PER_MICROSECOND; - - return res; -} - -/** - * Delay for at least the given number of milliseconds. - * - * Interrupts, etc. may cause the actual number of milliseconds to - * exceed ms. However, this function will return no less than ms - * milliseconds from the time it is called. - * - * @param ms the number of milliseconds to delay. - * @see delayMicroseconds() - */ -void delay(unsigned long ms); - -/** - * Delay for at least the given number of microseconds. - * - * Interrupts, etc. may cause the actual number of microseconds to - * exceed us. However, this function will return no less than us - * microseconds from the time it is called. - * - * @param us the number of microseconds to delay. - * @see delay() - */ -void delayMicroseconds(uint32 us); - -#endif - diff --git a/wirish/wirish.h b/wirish/wirish.h index 880157d..4cc142d 100644 --- a/wirish/wirish.h +++ b/wirish/wirish.h @@ -40,7 +40,7 @@ #include "pwm.h" #include "ext_interrupts.h" #include "wirish_math.h" -#include "time.h" +#include "wirish_time.h" #include "HardwareSPI.h" #include "HardwareSerial.h" #include "usb_serial.h" diff --git a/wirish/wirish_time.cpp b/wirish/wirish_time.cpp new file mode 100644 index 0000000..2771e95 --- /dev/null +++ b/wirish/wirish_time.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2010 Perry Hung. + * + * 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. + *****************************************************************************/ + +/** + * @brief Delay implementation. + */ + +#include "libmaple.h" +#include "systick.h" +#include "wirish_time.h" +#include "delay.h" + +void delay(unsigned long ms) { + uint32 i; + for (i = 0; i < ms; i++) { + delayMicroseconds(1000); + } +} + +void delayMicroseconds(uint32 us) { + delay_us(us); +} diff --git a/wirish/wirish_time.h b/wirish/wirish_time.h new file mode 100644 index 0000000..a0c0c82 --- /dev/null +++ b/wirish/wirish_time.h @@ -0,0 +1,99 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2010 Perry Hung. + * + * 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 time.h + * @brief Timing and delay functions. + */ + +#ifndef _TIME_H +#define _TIME_H + +#include "libmaple.h" +#include "nvic.h" +#include "systick.h" +#include "boards.h" + +#define US_PER_MS 1000 + +/** + * Returns time (in milliseconds) since the beginning of program + * execution. On overflow, restarts at 0. + * @see micros() + */ +static inline uint32 millis(void) { + return systick_timer_millis; +} + +/** + * Returns time (in microseconds) since the beginning of program + * execution. On overflow, restarts at 0. + * @see millis() + */ +static inline uint32 micros(void) { + uint32 ms; + uint32 cycle_cnt; + uint32 res; + + nvic_globalirq_disable(); + + cycle_cnt = systick_get_count(); + ms = millis(); + + nvic_globalirq_enable(); + + /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it + actually takes to complete a SysTick reload */ + res = (ms * US_PER_MS) + + (SYSTICK_RELOAD_VAL + 1 - cycle_cnt)/CYCLES_PER_MICROSECOND; + + return res; +} + +/** + * Delay for at least the given number of milliseconds. + * + * Interrupts, etc. may cause the actual number of milliseconds to + * exceed ms. However, this function will return no less than ms + * milliseconds from the time it is called. + * + * @param ms the number of milliseconds to delay. + * @see delayMicroseconds() + */ +void delay(unsigned long ms); + +/** + * Delay for at least the given number of microseconds. + * + * Interrupts, etc. may cause the actual number of microseconds to + * exceed us. However, this function will return no less than us + * microseconds from the time it is called. + * + * @param us the number of microseconds to delay. + * @see delay() + */ +void delayMicroseconds(uint32 us); + +#endif + -- cgit v1.2.3