Permalink
Browse files

removed scheduler and just left tasks

  • Loading branch information...
1 parent 296db86 commit 039232c60d7be106542e66e4f3fc016c2741aa18 @mholling committed Apr 8, 2010
Showing with 38 additions and 43 deletions.
  1. +2 −2 Makefile
  2. +3 −1 app.cpp
  3. +1 −2 app.h
  4. +1 −1 pid.h
  5. +0 −28 scheduler.h
  6. +4 −4 scheduler.cpp → task.cpp
  7. +22 −0 task.h
  8. +5 −5 timer.h
View
@@ -16,8 +16,8 @@
DEVICE = atmega328p
CLOCK = 8000000
PROGRAMMER = -c arduino -P /dev/tty.usbserial-A800csBR -b 57600
-# OBJECTS = main.o app.o scheduler.o serial.o timer.o eeprom.o orientation.o i2c.o magnetometer.o accelerometer.o analog.o spi.o shift_register.o gyros.o pwm.o motors.o trajectory.o attitude.o pid.o diagnostic.o
-OBJECTS = main.o app.o scheduler.o serial.o timer.o eeprom.o orientation.o i2c.o magnetometer.o accelerometer.o analog.o spi.o shift_register.o gyros.o pwm.o motors.o attitude.o diagnostic.o
+# OBJECTS = main.o app.o task.o serial.o timer.o eeprom.o orientation.o i2c.o magnetometer.o accelerometer.o analog.o spi.o shift_register.o gyros.o pwm.o motors.o trajectory.o attitude.o pid.o diagnostic.o
+OBJECTS = main.o app.o task.o serial.o timer.o eeprom.o orientation.o i2c.o magnetometer.o accelerometer.o analog.o spi.o shift_register.o gyros.o pwm.o motors.o attitude.o diagnostic.o
# Tune the lines below only if you know what you are doing:
View
@@ -1,8 +1,10 @@
#include "app.h"
#include <avr/io.h>
+#include <avr/interrupt.h>
void App::run() {
- scheduler.init();
+ sei();
+
serial.init();
timer.init(); // TODO: should be inited last to make sure to premature tasks run...
eeprom.init();
View
3 app.h
@@ -1,7 +1,7 @@
#ifndef __APP_H_
#define __APP_H_
-#include "scheduler.h"
+#include "task.h"
#include "serial.h"
#include "timer.h"
#include "eeprom.h"
@@ -25,7 +25,6 @@ class App {
App() { }
// Hardware:
- Scheduler scheduler;
Serial serial;
Timer timer;
Eeprom eeprom;
View
2 pid.h
@@ -1,7 +1,7 @@
#ifndef __PID_H_
#define __PID_H_
-#include "scheduler.h"
+#include "task.h"
#include "gyros.h"
#include "motors.h"
#include "trajectory.h"
View
@@ -1,28 +0,0 @@
-#ifndef __SCHEDULER_H_
-#define __SCHEDULER_H_
-
-#include "prioritised.h"
-#include <avr/interrupt.h>
-
-class Scheduler {
-public:
- class Task : protected Prioritised<Task> {
- private:
- typedef Prioritised<Task> Base;
-
- bool enqueue();
- void start();
- void dequeue();
-
- public:
- Task(unsigned int level) : Base(level) { }
-
- void operator ()() { enqueue(); }
- virtual void run() = 0;
- bool pending() { return Base::pending(); }
- };
-
- void init() { sei(); }
-};
-
-#endif
@@ -1,22 +1,22 @@
-#include "scheduler.h"
+#include "task.h"
#include "critical_section.h"
#include <avr/io.h>
-bool Scheduler::Task::enqueue() {
+bool Task::enqueue() {
CriticalSection cs;
if (!Base::enqueue()) return false;
if (at_head()) start();
return true;
}
-void Scheduler::Task::start() {
+void Task::start() {
sei();
run();
cli();
dequeue();
}
-void Scheduler::Task::dequeue() {
+void Task::dequeue() {
Base::dequeue();
if (any()) head().start();
}
View
22 task.h
@@ -0,0 +1,22 @@
+#ifndef __SCHEDULER_H_
+#define __SCHEDULER_H_
+
+#include "prioritised.h"
+
+class Task : protected Prioritised<Task> {
+private:
+ typedef Prioritised<Task> Base;
+
+ bool enqueue();
+ void start();
+ void dequeue();
+
+public:
+ Task(unsigned int level) : Base(level) { }
+
+ void operator ()() { enqueue(); }
+ virtual void run() = 0;
+ bool pending() { return Base::pending(); }
+};
+
+#endif
View
10 timer.h
@@ -1,15 +1,15 @@
#ifndef __TIMER_H_
#define __TIMER_H_
-#include "scheduler.h"
+#include "task.h"
class Timer {
private:
unsigned long int count;
- class TimedTasks : public Scheduler::Task {
+ class TimedTasks : public ::Task {
public:
- TimedTasks() : Scheduler::Task(Timer::Task::priority + 1) { }
+ TimedTasks() : ::Task(Timer::Task::priority + 1) { }
void run();
} timed_tasks;
@@ -22,10 +22,10 @@ class Timer {
void interrupt();
- class Task : public Scheduler::Task {
+ class Task : public ::Task {
public:
enum { priority = 100 };
- Task() : Scheduler::Task(priority) { }
+ Task() : ::Task(priority) { }
};
class Interval {

0 comments on commit 039232c

Please sign in to comment.