diff options
Diffstat (limited to 'wirish')
-rw-r--r-- | wirish/HardwareTimer.cpp | 2 | ||||
-rw-r--r-- | wirish/SystemTick.cpp | 40 | ||||
-rw-r--r-- | wirish/SystemTick.h | 43 | ||||
-rw-r--r-- | wirish/boards.h | 7 | ||||
-rw-r--r-- | wirish/rules.mk | 5 | ||||
-rw-r--r-- | wirish/time.h | 1 | ||||
-rw-r--r-- | wirish/wirish.h | 1 |
7 files changed, 93 insertions, 6 deletions
diff --git a/wirish/HardwareTimer.cpp b/wirish/HardwareTimer.cpp index 5675948..64fa222 100644 --- a/wirish/HardwareTimer.cpp +++ b/wirish/HardwareTimer.cpp @@ -32,7 +32,7 @@ #include "HardwareTimer.h" HardwareTimer::HardwareTimer(uint8 timerNum) { - ASSERT(timerNum < NR_TIMERS); + ASSERT(timerNum <= NR_TIMERS); this->timerNum = timerNum; // Need to remember over flow for bounds checking this->overflow = 0xFFFF; diff --git a/wirish/SystemTick.cpp b/wirish/SystemTick.cpp new file mode 100644 index 0000000..8631a70 --- /dev/null +++ b/wirish/SystemTick.cpp @@ -0,0 +1,40 @@ +/* ***************************************************************************** + * The MIT License + * + * Copyright (c) 2010 Marti F. Bolivar. + * + * 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. + * ****************************************************************************/ + +#include "SystemTick.h" +#include "systick.h" +#include "time.h" + +SysTick::SysTick(void) { +} + +void SysTick::begin(void) { + systick_init(MAPLE_RELOAD_VAL); +} + +void SysTick::end(void) { + systick_disable(); +} + +SysTick SystemTick; diff --git a/wirish/SystemTick.h b/wirish/SystemTick.h new file mode 100644 index 0000000..f0dd876 --- /dev/null +++ b/wirish/SystemTick.h @@ -0,0 +1,43 @@ +/* ***************************************************************************** + * The MIT License + * + * Copyright (c) 2010 Marti F. Bolivar. + * + * 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 wrapper class for starting and stopping SysTick interrupts. + */ + +#ifndef _SYSTEMTICK_H_ +#define _SYSTEMTICK_H_ + +#include "systick.h" + +class SysTick { + public: + SysTick(void); + void begin(void); + void end(void); +}; + +extern SysTick SystemTick; + +#endif diff --git a/wirish/boards.h b/wirish/boards.h index 035868a..11d1774 100644 --- a/wirish/boards.h +++ b/wirish/boards.h @@ -75,8 +75,9 @@ typedef struct ExtiInfo { #ifdef BOARD_maple #define CYCLES_PER_MICROSECOND 72 + #define MAPLE_RELOAD_VAL 72000 - static PinMapping PIN_MAP[NR_GPIO_PINS] = { + static __attribute__ ((unused)) PinMapping PIN_MAP[NR_GPIO_PINS] = { {GPIOA_BASE, 3, ADC3, TIMER2_CH4_CCR}, // D0/PA3 {GPIOA_BASE, 2, ADC2, TIMER2_CH3_CCR}, // D1/PA2 {GPIOA_BASE, 0, ADC0, TIMER2_CH1_CCR}, // D2/PA0 @@ -120,7 +121,8 @@ typedef struct ExtiInfo { {GPIOC_BASE, 9, ADC_INVALID, TIMER_INVALID} // D38/PC9 (BUT) }; - static ExtiInfo PIN_TO_EXTI_CHANNEL[NR_GPIO_PINS] = { + static __attribute__ ((unused)) ExtiInfo PIN_TO_EXTI_CHANNEL[NR_GPIO_PINS] = + { {EXTI3, EXTI_CONFIG_PORTA}, // D0/PA3 {EXTI2, EXTI_CONFIG_PORTA}, // D1/PA2 {EXTI0, EXTI_CONFIG_PORTA}, // D2/PA0 @@ -143,6 +145,7 @@ typedef struct ExtiInfo { #ifdef BOARD_maple_native #define CYCLES_PER_MICROSECOND 72 + #define MAPLE_RELOAD_VAL 72000 // TODO: static PinMapping PIN_MAP[NR_GPIO_PINS] = { diff --git a/wirish/rules.mk b/wirish/rules.mk index b2110bd..18d93b2 100644 --- a/wirish/rules.mk +++ b/wirish/rules.mk @@ -24,8 +24,9 @@ cppSRCS_$(d) := wirish_math.cpp \ comm/HardwareSerial.cpp \ comm/HardwareSPI.cpp \ usb_serial.cpp \ - HardwareTimer.cpp \ - cxxabi-compat.cpp + HardwareTimer.cpp \ + cxxabi-compat.cpp \ + SystemTick.cpp cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) diff --git a/wirish/time.h b/wirish/time.h index 33c04b4..f73d133 100644 --- a/wirish/time.h +++ b/wirish/time.h @@ -38,7 +38,6 @@ extern "C"{ #include "boards.h" #define US_PER_MS 1000 -#define MAPLE_RELOAD_VAL (CYCLES_PER_MICROSECOND * US_PER_MS) extern volatile uint32 systick_timer_millis; diff --git a/wirish/wirish.h b/wirish/wirish.h index 7ede77c..d293901 100644 --- a/wirish/wirish.h +++ b/wirish/wirish.h @@ -45,6 +45,7 @@ #include "HardwareSPI.h" #include "HardwareSerial.h" #include "usb_serial.h" +#include "SystemTick.h" #include "HardwareTimer.h" #endif |