Lab3
Functions

timer

Functions

int timer_set_square (unsigned long timer, unsigned long freq)
 Configures a timer to generate a square wave.
int timer_subscribe_int (void)
 Subscribes and enables Timer 0 interrupts.
int timer_unsubscribe_int ()
 Unsubscribes Timer 0 interrupts.
void timer_int_handler ()
 Timer 0 interrupt handler.
int timer_test_square (unsigned long freq)
 Tests programming timer in square wave mode.
int timer_test_int (unsigned long time)
 Tests Timer 0 interrupt handling.

Detailed Description

Functions for using the i8254 timers


Function Documentation

int timer_set_square ( unsigned long  timer,
unsigned long  freq 
)

Configures a timer to generate a square wave.

Parameters:
timerTimer to configure. (Ranges from 0 to 2)
freqFrequency of the square wave to generate
Returns:
Return 0 upon success and non-zero otherwise
int timer_subscribe_int ( void  )

Subscribes and enables Timer 0 interrupts.

Returns:
Returns bit order in interrupt mask; negative value on failure
int timer_unsubscribe_int ( )

Unsubscribes Timer 0 interrupts.

Returns:
Return 0 upon success and non-zero otherwise
void timer_int_handler ( )

Timer 0 interrupt handler.

Increments counter

int timer_test_square ( unsigned long  freq)

Tests programming timer in square wave mode.

Programs Timer 0 to generate square mode with input frequency

Parameters:
freqFrequency of square wave to generate
Returns:
Return 0 upon success and non-zero otherwise
int timer_test_int ( unsigned long  time)

Tests Timer 0 interrupt handling.

Subscribes Timer 0 interrupts and prints a message once per second for the specified time interval

Parameters:
timeLength of time interval while interrupts are subscribed
Returns:
Return 0 upon success and non-zero otherwise