PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
pit.h File Reference
#include <stdint.h>
Include dependency graph for pit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pit_configure_channel (int channel, int mode, int frequency)
 devices/pit.h More...
 

Function Documentation

◆ pit_configure_channel()

void pit_configure_channel ( int  channel,
int  mode,
int  frequency 
)

devices/pit.h

devices/pit.h

In a PC, the PIT's three output channels are hooked up like this:

  • Channel 0 is connected to interrupt line 0, so that it can be used as a periodic timer interrupt, as implemented in Pintos in devices/timer.c.
  • Channel 1 is used for dynamic RAM refresh (in older PCs). No good can come of messing with this.
  • Channel 2 is connected to the PC speaker, so that it can be used to play a tone, as implemented in Pintos in devices/speaker.c.

MODE specifies the form of output:

  • Mode 2 is a periodic pulse: the channel's output is 1 for most of the period, but drops to 0 briefly toward the end of the period. This is useful for hooking up to an interrupt controller to generate a periodic interrupt.
  • Mode 3 is a square wave: for the first half of the period it is 1, for the second half it is 0. This is useful for generating a tone on a speaker.
  • Other modes are less useful.

FREQUENCY is the number of periods per second, in Hz.

Definition at line 46 of file pit.c.

References ASSERT, intr_disable(), intr_set_level(), mode, outb(), PIT_HZ, PIT_PORT_CONTROL, and PIT_PORT_COUNTER.

Referenced by speaker_on(), and timer_init().

Here is the call graph for this function:
Here is the caller graph for this function: