summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2021-01-22 13:45:09 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2021-01-22 13:45:09 +0100
commit257c13ef064e20bfbe7330004c76a77f8a73b86b (patch)
tree8610cedea8481d8d6dbbc02edadd61e4983e758d
parent1a38973eb8fd0f889f7c272e9ef183687034d550 (diff)
os: Remove old threading code.
-rw-r--r--i2c/i2c.cpp3
-rw-r--r--os/thread.cpp4
-rw-r--r--os/thread.h63
-rw-r--r--os/time.h3
-rw-r--r--spi/spi.h3
-rw-r--r--usart/usart.h1
6 files changed, 2 insertions, 75 deletions
diff --git a/i2c/i2c.cpp b/i2c/i2c.cpp
index 3039e47..75aee94 100644
--- a/i2c/i2c.cpp
+++ b/i2c/i2c.cpp
@@ -1,7 +1,6 @@
#include "i2c.h"
#include <rcc/rcc.h>
-#include <os/thread.h>
#if defined(STM32F1)
I2C_t I2C1(0x40005400, 36000000);
@@ -113,7 +112,6 @@ void I2C_t::write_reg(uint8_t addr_, uint8_t reg_, uint8_t data) {
reg.CR1 |= 0x100;
while(busy) {
- Thread::yield();
}
}
@@ -128,7 +126,6 @@ void I2C_t::read_reg(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t* buf) {
reg.CR1 |= 0x100;
while(busy) {
- Thread::yield();
}
}
#endif
diff --git a/os/thread.cpp b/os/thread.cpp
deleted file mode 100644
index 426fffd..0000000
--- a/os/thread.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "thread.h"
-
-Thread Thread::main_thread __attribute__ ((init_priority (1000)));
-Thread* Thread::active_thread = &Thread::main_thread;
diff --git a/os/thread.h b/os/thread.h
deleted file mode 100644
index 2213d6f..0000000
--- a/os/thread.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef THREAD_H
-#define THREAD_H
-
-#include <stdint.h>
-
-class Thread {
- friend void switch_context();
-
- private:
- struct int_frame_t {
- // Software saved.
- uint32_t r4;
- uint32_t r5;
- uint32_t r6;
- uint32_t r7;
- uint32_t r8;
- uint32_t r9;
- uint32_t r10;
- uint32_t r11;
- uint32_t lr_ex;
-
- // Hardware saved.
- uint32_t r0;
- uint32_t r1;
- uint32_t r2;
- uint32_t r3;
- uint32_t r12;
- uint32_t lr;
- uint32_t pc;
- uint32_t psr;
- };
-
- int_frame_t* sp;
-
- Thread* next;
-
- static Thread* active_thread;
- static Thread main_thread;
-
- Thread() : next(this) {}
-
- public:
- Thread(void* stack, uint32_t stack_size, void (*func)()) {
- sp = (int_frame_t*)((uint8_t*)stack + stack_size - sizeof(int_frame_t));
-
- sp->lr_ex = 0xfffffff9;
-
- // frame->lr = thread exit handler
- sp->pc = (uint32_t)func;
- sp->psr = 0x01000000;
- }
-
- void start() {
- next = active_thread->next;
- active_thread->next = this;
- }
-
- static inline void yield() {
- asm volatile("svc 0");
- }
-};
-
-#endif
diff --git a/os/time.h b/os/time.h
index f4e3ce6..eddba32 100644
--- a/os/time.h
+++ b/os/time.h
@@ -1,7 +1,7 @@
#ifndef TIME_H
#define TIME_H
-#include "thread.h"
+#include <cstdint>
struct STK_t {
volatile uint32_t CTRL;
@@ -28,7 +28,6 @@ class Time {
inline static void sleep(uint32_t ms) {
ms += systime;
while(systime < ms) {
- Thread::yield();
}
}
};
diff --git a/spi/spi.h b/spi/spi.h
index c781a56..010d353 100644
--- a/spi/spi.h
+++ b/spi/spi.h
@@ -1,7 +1,7 @@
#ifndef SPI_H
#define SPI_H
-#include <os/thread.h>
+#include <cstdint>
struct SPI_reg_t {
volatile uint32_t CR1;
@@ -28,7 +28,6 @@ class SPI_t {
reg.DR8 = out;
while(!(reg.SR & 0x01)) {
- Thread::yield();
}
return reg.DR8;
diff --git a/usart/usart.h b/usart/usart.h
index f318d3e..9f3d838 100644
--- a/usart/usart.h
+++ b/usart/usart.h
@@ -3,7 +3,6 @@
#include <rcc/rcc.h>
#include <interrupt/interrupt.h>
-#include <os/thread.h>
#if defined(STM32F1) || defined(STM32F4)
struct USART_reg_t {