From 0bff8199e4a800d5ea1bd422dcf06643d6daf008 Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Mon, 10 Jan 2022 22:15:15 +0100 Subject: include/setup.sh --- include/07.pit/deo1 | 3 +++ include/07.pit/deo10 | 4 ++++ include/07.pit/deo2 | 1 + include/07.pit/deo3 | 4 ++++ include/07.pit/deo4 | 9 +++++++++ include/07.pit/deo5 | 3 +++ include/07.pit/deo6 | 3 +++ include/07.pit/deo7 | 4 ++++ include/07.pit/deo8 | 2 ++ include/07.pit/deo9 | 3 +++ include/07.pit/pit00.c | 3 --- include/07.pit/pit01.c | 5 ----- include/07.pit/pit02.c | 13 ------------- include/07.pit/pit03.c | 20 -------------------- include/07.pit/timer.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 15 files changed, 81 insertions(+), 41 deletions(-) create mode 100644 include/07.pit/deo1 create mode 100644 include/07.pit/deo10 create mode 100644 include/07.pit/deo2 create mode 100644 include/07.pit/deo3 create mode 100644 include/07.pit/deo4 create mode 100644 include/07.pit/deo5 create mode 100644 include/07.pit/deo6 create mode 100644 include/07.pit/deo7 create mode 100644 include/07.pit/deo8 create mode 100644 include/07.pit/deo9 delete mode 100644 include/07.pit/pit00.c delete mode 100644 include/07.pit/pit01.c delete mode 100644 include/07.pit/pit02.c delete mode 100644 include/07.pit/pit03.c create mode 100644 include/07.pit/timer.c (limited to 'include/07.pit') diff --git a/include/07.pit/deo1 b/include/07.pit/deo1 new file mode 100644 index 0000000..13fd550 --- /dev/null +++ b/include/07.pit/deo1 @@ -0,0 +1,3 @@ +#include +#include +#include diff --git a/include/07.pit/deo10 b/include/07.pit/deo10 new file mode 100644 index 0000000..208a223 --- /dev/null +++ b/include/07.pit/deo10 @@ -0,0 +1,4 @@ + // Send the frequency divisor. + ioport_out(0x40, l); + ioport_out(0x40, h); +} diff --git a/include/07.pit/deo2 b/include/07.pit/deo2 new file mode 100644 index 0000000..dfa7284 --- /dev/null +++ b/include/07.pit/deo2 @@ -0,0 +1 @@ +void add_idt_entry(size_t num,uint32_t offset); diff --git a/include/07.pit/deo3 b/include/07.pit/deo3 new file mode 100644 index 0000000..025eb31 --- /dev/null +++ b/include/07.pit/deo3 @@ -0,0 +1,4 @@ +uint32_t tick=0; +const uint32_t TICKS_PER_SECOND=50; +extern uint32_t time; +uint32_t time=0; diff --git a/include/07.pit/deo4 b/include/07.pit/deo4 new file mode 100644 index 0000000..8eba051 --- /dev/null +++ b/include/07.pit/deo4 @@ -0,0 +1,9 @@ +void timer_handler() +{ + 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/deo5 new file mode 100644 index 0000000..eaf7bcf --- /dev/null +++ b/include/07.pit/deo5 @@ -0,0 +1,3 @@ + ioport_out(0x20, 0x20); + ioport_out(0xa0,0x20); +} diff --git a/include/07.pit/deo6 b/include/07.pit/deo6 new file mode 100644 index 0000000..12cee6a --- /dev/null +++ b/include/07.pit/deo6 @@ -0,0 +1,3 @@ +void init_timer(uint32_t frequency) +{ + // Firstly, register our timer callback. diff --git a/include/07.pit/deo7 b/include/07.pit/deo7 new file mode 100644 index 0000000..c780ebc --- /dev/null +++ b/include/07.pit/deo7 @@ -0,0 +1,4 @@ + // 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 new file mode 100644 index 0000000..8c64aaf --- /dev/null +++ b/include/07.pit/deo8 @@ -0,0 +1,2 @@ + // Send the command byte. + ioport_out(0x43, 0x36); diff --git a/include/07.pit/deo9 b/include/07.pit/deo9 new file mode 100644 index 0000000..1deca04 --- /dev/null +++ b/include/07.pit/deo9 @@ -0,0 +1,3 @@ + // 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/pit00.c b/include/07.pit/pit00.c deleted file mode 100644 index 13fd550..0000000 --- a/include/07.pit/pit00.c +++ /dev/null @@ -1,3 +0,0 @@ -#include -#include -#include diff --git a/include/07.pit/pit01.c b/include/07.pit/pit01.c deleted file mode 100644 index c199373..0000000 --- a/include/07.pit/pit01.c +++ /dev/null @@ -1,5 +0,0 @@ -void add_idt_entry(size_t num,uint32_t offset); -uint32_t tick=0; -const uint32_t TICKS_PER_SECOND=50; -extern uint32_t time; -uint32_t time=0; diff --git a/include/07.pit/pit02.c b/include/07.pit/pit02.c deleted file mode 100644 index 523d14b..0000000 --- a/include/07.pit/pit02.c +++ /dev/null @@ -1,13 +0,0 @@ -void timer_handler() -{ - tick++; - if(tick==TICKS_PER_SECOND) - { - //printf("%d seconds passed\n",time); - tick=0; - time++; - } - - ioport_out(0x20, 0x20); - ioport_out(0xa0,0x20); -} diff --git a/include/07.pit/pit03.c b/include/07.pit/pit03.c deleted file mode 100644 index 287adba..0000000 --- a/include/07.pit/pit03.c +++ /dev/null @@ -1,20 +0,0 @@ -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/timer.c b/include/07.pit/timer.c new file mode 100644 index 0000000..390e512 --- /dev/null +++ b/include/07.pit/timer.c @@ -0,0 +1,45 @@ +#include +#include +#include + +void add_idt_entry(size_t num,uint32_t offset); + +uint32_t tick=0; +const uint32_t TICKS_PER_SECOND=50; +extern uint32_t time; +uint32_t time=0; + +void timer_handler() +{ + tick++; + if(tick==TICKS_PER_SECOND) + { + //printf("%d seconds passed\n",time); + tick=0; + time++; + } + + ioport_out(0x20, 0x20); + ioport_out(0xa0,0x20); +} + +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); +} -- cgit v1.2.3