KernOS
TIMER Namespace Reference

Timer namespace. More...

Enumerations

enum  PORT : uint8_t { CHANNEL_O = 0x40, CHANNEL_1 = 0x41, CHANNEL_2 = 0x42, COMMAND = 0x43 }
 
enum  CHANNEL : uint8_t { TIMER0 = 0x00, TIMER1 = 0x40, TIMER2 = 0x80 }
 
enum  ACCESSMODE : uint8_t { LATCH = 0x00, LO_ONLY = 0x10, HI_ONLY = 0x20, HI_LO = 0x30 }
 
enum  OPMODE : uint8_t {
  COUNTDOWN = 0x0, ONESHOT = 0x2, RATE_GENERATOR = 0x4, SQUAREWAVE_GENERATOR = 0x6,
  SOFTWARE_STROBE = 0x8, HARDWARE_STROBE = 0xA, RATE_GENERATOR2 = 0xC, SQUAREWAVE_GENERATOR2 = 0xE
}
 
enum  DECIMALMODE : uint8_t { BINARY = 0x0, BCD = 0x1 }
 

Functions

void PIT_825x ()
 

Variables

uint64_t timer_ticks
 
const uint32_t BASE_FREQ = 1'193'182
 14.31818 MHz / 12 (due to hardware historical reason) More...
 
const uint16_t TICKS_PER_SECOND = 1'000
 

Detailed Description

Timer namespace.

Programmable Interval Timer (PIT) 8253/8254 chip.

See also
https://wiki.osdev.org/Programmable_Interval_Timer, www.osdever.net/bkerndev/Docs/pit.htm
Mode/Command byte
| 07 | 06 | 05 | 04 | 03 | 02 | 01 |     00     |
| Channel |  Access |   Operating  | BCD/Binary |

Enumeration Type Documentation

◆ ACCESSMODE

enum TIMER::ACCESSMODE : uint8_t
Enumerator
LATCH 

00(00)'0000 Latch count value

LO_ONLY 

00(01)'0000 Low byte only

HI_ONLY 

00(10)'0000 Low byte only

HI_LO 

00(11)'0000 Low byte only

Definition at line 47 of file pit.cpp.

◆ CHANNEL

enum TIMER::CHANNEL : uint8_t
Enumerator
TIMER0 

(00)00'0000 Channel 0

TIMER1 

(01)00'0000 Channel 1

TIMER2 

(10)00'0000 Channel 2

Definition at line 40 of file pit.cpp.

◆ DECIMALMODE

enum TIMER::DECIMALMODE : uint8_t
Enumerator
BINARY 

0000'000(0) 16 bit binary

BCD 

0000'000(1) 4 digit binary coded decimal

Definition at line 67 of file pit.cpp.

◆ OPMODE

enum TIMER::OPMODE : uint8_t
Enumerator
COUNTDOWN 

0000'(000)0

ONESHOT 

0000'(001)0

RATE_GENERATOR 

0000'(010)0

SQUAREWAVE_GENERATOR 

0000'(011)0

SOFTWARE_STROBE 

0000'(100)0

HARDWARE_STROBE 

0000'(101)0

RATE_GENERATOR2 

0000'(110)0

SQUAREWAVE_GENERATOR2 

0000'(111)0

Definition at line 55 of file pit.cpp.

◆ PORT

enum TIMER::PORT : uint8_t
Enumerator
CHANNEL_O 

I/O port for channel 0 data port.

CHANNEL_1 

I/O port for channel 1 data port.

CHANNEL_2 

I/O port for channel 2 data port.

COMMAND 

Mode/command register.

Definition at line 32 of file pit.cpp.

Function Documentation

◆ PIT_825x()

void TIMER::PIT_825x ( )

Definition at line 76 of file pit.cpp.

Variable Documentation

◆ BASE_FREQ

const uint32_t TIMER::BASE_FREQ = 1'193'182

14.31818 MHz / 12 (due to hardware historical reason)

Definition at line 73 of file pit.cpp.

◆ TICKS_PER_SECOND

const uint16_t TIMER::TICKS_PER_SECOND = 1'000

Definition at line 74 of file pit.cpp.

◆ timer_ticks

uint64_t TIMER::timer_ticks

Definition at line 30 of file pit.cpp.