summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 17:21:31 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 19:23:33 +0100
commit025a38a1f743fd9e89cbd477abe3f79a8d098097 (patch)
treea1f20c1b6a7f6c418bee641da923ab3d0d7208fe
parent9e5875f2908c1ce506e7c5712ccabc379f911360 (diff)
Moved os and hal related files into subdirectories.
-rw-r--r--.gitignore3
-rw-r--r--SConstruct6
-rw-r--r--fault.cpp10
-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.cpp3
-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.cpp4
-rw-r--r--os/thread.h (renamed from thread.h)0
-rw-r--r--os/time.cpp3
-rw-r--r--os/time.h (renamed from time.h)9
-rw-r--r--time.cpp9
21 files changed, 31 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index 46fa166..f22d170 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.o
+*.a
*.elf
-.sconsign.dblite \ No newline at end of file
+.sconsign.dblite
diff --git a/SConstruct b/SConstruct
index 08229f4..72ac32d 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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/i2c.cpp b/hal/i2c.cpp
index cee72ec..cee72ec 100644
--- a/i2c.cpp
+++ b/hal/i2c.cpp
diff --git a/i2c.h b/hal/i2c.h
index 3d58056..3d58056 100644
--- a/i2c.h
+++ b/hal/i2c.h
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
diff --git a/rcc.cpp b/hal/rcc.cpp
index e3ae38d..e3ae38d 100644
--- a/rcc.cpp
+++ b/hal/rcc.cpp
diff --git a/rcc.h b/hal/rcc.h
index 8c5fb86..8c5fb86 100644
--- a/rcc.h
+++ b/hal/rcc.h
diff --git a/stm32.h b/hal/stm32.h
index 8144e80..8144e80 100644
--- a/stm32.h
+++ b/hal/stm32.h
diff --git a/usart.h b/hal/usart.h
index 8fde39a..8fde39a 100644
--- a/usart.h
+++ b/hal/usart.h
diff --git a/main.cpp b/main.cpp
index b576869..635467b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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/mutex.h b/os/mutex.h
index d12331d..d12331d 100644
--- a/mutex.h
+++ b/os/mutex.h
diff --git a/pool.cpp b/os/pool.cpp
index f059b05..f059b05 100644
--- a/pool.cpp
+++ b/os/pool.cpp
diff --git a/pool.h b/os/pool.h
index 1cb0a71..1cb0a71 100644
--- a/pool.h
+++ b/os/pool.h
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/thread.h b/os/thread.h
index 2213d6f..2213d6f 100644
--- a/thread.h
+++ b/os/thread.h
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;
diff --git a/time.h b/os/time.h
index f43d8a6..f4706e0 100644
--- a/time.h
+++ b/os/time.h
@@ -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++;
-}