diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-11-19 17:21:31 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-11-19 19:23:33 +0100 |
commit | 025a38a1f743fd9e89cbd477abe3f79a8d098097 (patch) | |
tree | a1f20c1b6a7f6c418bee641da923ab3d0d7208fe | |
parent | 9e5875f2908c1ce506e7c5712ccabc379f911360 (diff) |
Moved os and hal related files into subdirectories.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | SConstruct | 6 | ||||
-rw-r--r-- | fault.cpp | 10 | ||||
-rw-r--r-- | hal/fault.cpp (renamed from thread.cpp) | 18 | ||||
-rw-r--r-- | hal/i2c.cpp (renamed from i2c.cpp) | 0 | ||||
-rw-r--r-- | hal/i2c.h (renamed from i2c.h) | 0 | ||||
-rw-r--r-- | hal/interrupt.cpp (renamed from interrupt.cpp) | 0 | ||||
-rw-r--r-- | hal/interrupt.h (renamed from interrupt.h) | 0 | ||||
-rw-r--r-- | hal/rcc.cpp (renamed from rcc.cpp) | 0 | ||||
-rw-r--r-- | hal/rcc.h (renamed from rcc.h) | 0 | ||||
-rw-r--r-- | hal/stm32.h (renamed from stm32.h) | 0 | ||||
-rw-r--r-- | hal/usart.h (renamed from usart.h) | 0 | ||||
-rw-r--r-- | main.cpp | 3 | ||||
-rw-r--r-- | os/mutex.h (renamed from mutex.h) | 0 | ||||
-rw-r--r-- | os/pool.cpp (renamed from pool.cpp) | 0 | ||||
-rw-r--r-- | os/pool.h (renamed from pool.h) | 0 | ||||
-rw-r--r-- | os/thread.cpp | 4 | ||||
-rw-r--r-- | os/thread.h (renamed from thread.h) | 0 | ||||
-rw-r--r-- | os/time.cpp | 3 | ||||
-rw-r--r-- | os/time.h (renamed from time.h) | 9 | ||||
-rw-r--r-- | time.cpp | 9 |
21 files changed, 31 insertions, 34 deletions
@@ -1,3 +1,4 @@ *.o +*.a *.elf -.sconsign.dblite
\ No newline at end of file +.sconsign.dblite @@ -18,13 +18,15 @@ env = Environment( AR = 'arm-none-eabi-ar',
RANLIB = 'arm-none-eabi-ranlib',
- #CPPPATH = [],
+ CPPPATH = ['os', 'hal'],
#LIBPATH = [],
LIBS = ['m'],
)
-firmware = env.Program('suzumebachi.elf', Glob('*.cpp'))
+sources = Glob('os/*.cpp') + Glob('hal/*.cpp') + Glob('*.cpp')
+
+firmware = env.Program('suzumebachi.elf', sources)
env.Depends(firmware, 'suzumebachi.ld')
env.Command('prog', ['suzumebachi.elf'], 'openocd -f openocd.cfg -c flash_chip')
diff --git a/fault.cpp b/fault.cpp deleted file mode 100644 index 42ebd30..0000000 --- a/fault.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "interrupt.h" - -template<> void interrupt<Interrupt::NMI>() { while(1); } -template<> void interrupt<Interrupt::HardFault>() { while(1); } -template<> void interrupt<Interrupt::MemManage>() { while(1); } -template<> void interrupt<Interrupt::BusFault>() { while(1); } -template<> void interrupt<Interrupt::UsageFault>() { while(1); } -//template<> void interrupt<Interrupt::SVCall>() { while(1); } -template<> void interrupt<Interrupt::PendSV>() { while(1); } -//template<> void interrupt<Interrupt::SysTick>() { while(1); } diff --git a/thread.cpp b/hal/fault.cpp index a08bd61..a176ae6 100644 --- a/thread.cpp +++ b/hal/fault.cpp @@ -1,8 +1,6 @@ -#include "thread.h" #include "interrupt.h" - -Thread Thread::main_thread __attribute__ ((init_priority (1000))); -Thread* Thread::active_thread = &Thread::main_thread; +#include "thread.h" +#include "time.h" inline void __attribute__((naked)) switch_context() { asm volatile ("cpsid i"); @@ -29,3 +27,15 @@ template<> void interrupt<Interrupt::SVCall>() { switch_context(); } + +template<> +void interrupt<Interrupt::SysTick>() { + Time::tick(); +} + +template<> void interrupt<Interrupt::NMI>() { while(1); } +template<> void interrupt<Interrupt::HardFault>() { while(1); } +template<> void interrupt<Interrupt::MemManage>() { while(1); } +template<> void interrupt<Interrupt::BusFault>() { while(1); } +template<> void interrupt<Interrupt::UsageFault>() { while(1); } +template<> void interrupt<Interrupt::PendSV>() { while(1); } diff --git a/interrupt.cpp b/hal/interrupt.cpp index e9e7b24..e9e7b24 100644 --- a/interrupt.cpp +++ b/hal/interrupt.cpp diff --git a/interrupt.h b/hal/interrupt.h index f817103..f817103 100644 --- a/interrupt.h +++ b/hal/interrupt.h @@ -127,7 +127,8 @@ Thread gps_thread(gps_stack, sizeof(gps_stack), gps_thread_main); int main() { // Initialize system timer. - Time::init(); + STK.LOAD = 72000000 / 8 / 1000; // 1000 Hz. + STK.CTRL = 0x03; RCC.enable(RCC.AFIO); RCC.enable(RCC.IOPA); diff --git a/os/thread.cpp b/os/thread.cpp new file mode 100644 index 0000000..426fffd --- /dev/null +++ b/os/thread.cpp @@ -0,0 +1,4 @@ +#include "thread.h" + +Thread Thread::main_thread __attribute__ ((init_priority (1000))); +Thread* Thread::active_thread = &Thread::main_thread; diff --git a/os/time.cpp b/os/time.cpp new file mode 100644 index 0000000..6c96027 --- /dev/null +++ b/os/time.cpp @@ -0,0 +1,3 @@ +#include "time.h" + +volatile uint32_t Time::systime; @@ -1,20 +1,15 @@ #ifndef TIME_H #define TIME_H -#include "stm32.h" -#include "interrupt.h" #include "thread.h" class Time { - friend void interrupt<Interrupt::SysTick>(); - private: static volatile uint32_t systime; public: - static void init() { - STK.LOAD = 72000000 / 8 / 1000; // 1000 Hz. - STK.CTRL = 0x03; + inline static void tick() { + systime++; } inline static void sleep(uint32_t ms) { diff --git a/time.cpp b/time.cpp deleted file mode 100644 index a5d1f0b..0000000 --- a/time.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "time.h" -#include "interrupt.h" - -volatile uint32_t Time::systime; - -template<> -void interrupt<Interrupt::SysTick>() { - Time::systime++; -} |