Enable PIT ISR to count milliseconds
This commit is contained in:
1 parent
e357f2ba44
commit
e480bd0ed0
4 files changed
+18
-5
No files matched your search
+6
-2
@@ -5,12 +5,13 @@ module hulk.pit;
|
||||
|
||||
import hulk.cpu;
|
||||
import hulk.klog;
|
||||
import hulk.console;
|
||||
|
||||
struct Pit
|
||||
{
|
||||
/** PIT input frequency in 1/1000 Hz. */
|
||||
private enum ulong PIT_FREQUENCY_1000HZ = 1_193_181_667u;
|
||||
private enum ulong TARGET_INTERRUPT_HZ = 100u;
|
||||
private enum ulong TARGET_INTERRUPT_HZ = 1000u;
|
||||
private enum ulong TARGET_INTERRUPT_1000HZ = TARGET_INTERRUPT_HZ * 1000u;
|
||||
private enum ulong PIT_DIVIDER = (PIT_FREQUENCY_1000HZ + TARGET_INTERRUPT_1000HZ / 2u) / TARGET_INTERRUPT_1000HZ;
|
||||
|
||||
@@ -28,8 +29,11 @@ struct Pit
|
||||
private enum ubyte MC_RATE_GENERATOR = 0x04u;
|
||||
private enum ubyte MC_BINARY = 0x00u;
|
||||
|
||||
private static __gshared ulong milliseconds;
|
||||
|
||||
public static void initialize()
|
||||
{
|
||||
Klog.writefln("\a3Initializing PIT");
|
||||
out8(PORT_MC, MC_CH_0 | MC_LO_HI | MC_RATE_GENERATOR | MC_BINARY);
|
||||
out8(PORT_CH_0, PIT_DIVIDER & 0xFFu);
|
||||
out8(PORT_CH_0, PIT_DIVIDER >> 8u);
|
||||
@@ -37,6 +41,6 @@ struct Pit
|
||||
|
||||
public static void isr()
|
||||
{
|
||||
Klog.writefln("PIT ISR");
|
||||
milliseconds++;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user