aboutsummaryrefslogtreecommitdiff
path: root/include/07.pit
diff options
context:
space:
mode:
Diffstat (limited to 'include/07.pit')
-rw-r--r--include/07.pit/deo13
-rw-r--r--include/07.pit/deo21
-rw-r--r--include/07.pit/deo63
-rw-r--r--include/07.pit/deo74
-rw-r--r--include/07.pit/deo82
-rw-r--r--include/07.pit/timer.c17
-rw-r--r--include/07.pit/timer1.c4
-rw-r--r--include/07.pit/timer2.c (renamed from include/07.pit/deo3)0
-rw-r--r--include/07.pit/timer3.c (renamed from include/07.pit/deo4)3
-rw-r--r--include/07.pit/timer4.c (renamed from include/07.pit/deo5)0
-rw-r--r--include/07.pit/timer5.c4
-rw-r--r--include/07.pit/timer6.c (renamed from include/07.pit/deo9)1
-rw-r--r--include/07.pit/timer7.c (renamed from include/07.pit/deo10)1
13 files changed, 12 insertions, 31 deletions
diff --git a/include/07.pit/deo1 b/include/07.pit/deo1
deleted file mode 100644
index 13fd550..0000000
--- a/include/07.pit/deo1
+++ /dev/null
@@ -1,3 +0,0 @@
-#include<types.h>
-#include<asm.h>
-#include<stdio.h>
diff --git a/include/07.pit/deo2 b/include/07.pit/deo2
deleted file mode 100644
index dfa7284..0000000
--- a/include/07.pit/deo2
+++ /dev/null
@@ -1 +0,0 @@
-void add_idt_entry(size_t num,uint32_t offset);
diff --git a/include/07.pit/deo6 b/include/07.pit/deo6
deleted file mode 100644
index 12cee6a..0000000
--- a/include/07.pit/deo6
+++ /dev/null
@@ -1,3 +0,0 @@
-void init_timer(uint32_t frequency)
-{
- // Firstly, register our timer callback.
diff --git a/include/07.pit/deo7 b/include/07.pit/deo7
deleted file mode 100644
index c780ebc..0000000
--- a/include/07.pit/deo7
+++ /dev/null
@@ -1,4 +0,0 @@
- // The value we send to the PIT is the value to divide it's input clock
- // (1193180 Hz) by, to get our required frequency. Important to note is
- // that the divisor must be small enough to fit into 16-bits.
- uint32_t divisor = 1193180 / frequency;
diff --git a/include/07.pit/deo8 b/include/07.pit/deo8
deleted file mode 100644
index 8c64aaf..0000000
--- a/include/07.pit/deo8
+++ /dev/null
@@ -1,2 +0,0 @@
- // Send the command byte.
- ioport_out(0x43, 0x36);
diff --git a/include/07.pit/timer.c b/include/07.pit/timer.c
index 390e512..3a8f159 100644
--- a/include/07.pit/timer.c
+++ b/include/07.pit/timer.c
@@ -1,20 +1,18 @@
+#include<source/timer.h>
#include<types.h>
#include<asm.h>
-#include<stdio.h>
-
-void add_idt_entry(size_t num,uint32_t offset);
+#include<source/stdio.h>
uint32_t tick=0;
const uint32_t TICKS_PER_SECOND=50;
extern uint32_t time;
uint32_t time=0;
-void timer_handler()
+void timer_handler(void)
{
tick++;
if(tick==TICKS_PER_SECOND)
{
- //printf("%d seconds passed\n",time);
tick=0;
time++;
}
@@ -25,21 +23,12 @@ void timer_handler()
void init_timer(uint32_t frequency)
{
- // Firstly, register our timer callback.
-
- // The value we send to the PIT is the value to divide it's input clock
- // (1193180 Hz) by, to get our required frequency. Important to note is
- // that the divisor must be small enough to fit into 16-bits.
uint32_t divisor = 1193180 / frequency;
-
- // Send the command byte.
ioport_out(0x43, 0x36);
- // Divisor has to be sent byte-wise, so split here into upper/lower bytes.
uint8_t l = (uint8_t)(divisor & 0xFF);
uint8_t h = (uint8_t)( (divisor>>8) & 0xFF );
- // Send the frequency divisor.
ioport_out(0x40, l);
ioport_out(0x40, h);
}
diff --git a/include/07.pit/timer1.c b/include/07.pit/timer1.c
new file mode 100644
index 0000000..02e3f5b
--- /dev/null
+++ b/include/07.pit/timer1.c
@@ -0,0 +1,4 @@
+#include<source/timer.h>
+#include<types.h>
+#include<asm.h>
+#include<source/stdio.h>
diff --git a/include/07.pit/deo3 b/include/07.pit/timer2.c
index 025eb31..025eb31 100644
--- a/include/07.pit/deo3
+++ b/include/07.pit/timer2.c
diff --git a/include/07.pit/deo4 b/include/07.pit/timer3.c
index 8eba051..6527a48 100644
--- a/include/07.pit/deo4
+++ b/include/07.pit/timer3.c
@@ -1,9 +1,8 @@
-void timer_handler()
+void timer_handler(void)
{
tick++;
if(tick==TICKS_PER_SECOND)
{
- //printf("%d seconds passed\n",time);
tick=0;
time++;
}
diff --git a/include/07.pit/deo5 b/include/07.pit/timer4.c
index eaf7bcf..eaf7bcf 100644
--- a/include/07.pit/deo5
+++ b/include/07.pit/timer4.c
diff --git a/include/07.pit/timer5.c b/include/07.pit/timer5.c
new file mode 100644
index 0000000..c1718a5
--- /dev/null
+++ b/include/07.pit/timer5.c
@@ -0,0 +1,4 @@
+void init_timer(uint32_t frequency)
+{
+ uint32_t divisor = 1193180 / frequency;
+ ioport_out(0x43, 0x36);
diff --git a/include/07.pit/deo9 b/include/07.pit/timer6.c
index 1deca04..c93e648 100644
--- a/include/07.pit/deo9
+++ b/include/07.pit/timer6.c
@@ -1,3 +1,2 @@
- // Divisor has to be sent byte-wise, so split here into upper/lower bytes.
uint8_t l = (uint8_t)(divisor & 0xFF);
uint8_t h = (uint8_t)( (divisor>>8) & 0xFF );
diff --git a/include/07.pit/deo10 b/include/07.pit/timer7.c
index 208a223..b7da9b6 100644
--- a/include/07.pit/deo10
+++ b/include/07.pit/timer7.c
@@ -1,4 +1,3 @@
- // Send the frequency divisor.
ioport_out(0x40, l);
ioport_out(0x40, h);
}