Lab 2
Functions
timer

Functions

int timer_set_frequency (unsigned char timer, unsigned long freq)
 Changes the operating frequency of a timer. More...
 
int timer_subscribe_int (void)
 Subscribes and enables Timer 0 interrupts. More...
 
int timer_unsubscribe_int ()
 Unsubscribes Timer 0 interrupts. More...
 
void timer_int_handler ()
 Timer 0 interrupt handler. More...
 
int timer_get_conf (unsigned char timer, unsigned char *st)
 Reads the input timer configuration via read-back command. More...
 
int timer_display_conf (unsigned char conf)
 Shows timer configuration. More...
 
int timer_test_time_base (unsigned long freq)
 Tests change of Timer O interrupt frequency. More...
 
int timer_test_int (unsigned long time)
 Tests Timer 0 interrupt handling. More...
 
int timer_test_config (unsigned char timer)
 Tests display of timer config. More...
 

Detailed Description

Functions for using the i8254 timers

Function Documentation

◆ timer_display_conf()

int timer_display_conf ( unsigned char  conf)

Shows timer configuration.

Displays in a human friendly way, the configuration of a timer as read via the read-back command, by providing the values (and meanings) of the different components of a timer configuration

Parameters
confconfiguration to display in human friendly way
Returns
Return 0 upon success and non-zero otherwise

◆ timer_get_conf()

int timer_get_conf ( unsigned char  timer,
unsigned char *  st 
)

Reads the input timer configuration via read-back command.

Parameters
timerTimer whose config to read (Ranges from 0 to 2)
stAddress of memory position to be filled with the timer config
Returns
Return 0 upon success and non-zero otherwise

◆ timer_int_handler()

void timer_int_handler ( )

Timer 0 interrupt handler.

Increments counter

◆ timer_set_frequency()

int timer_set_frequency ( unsigned char  timer,
unsigned long  freq 
)

Changes the operating frequency of a timer.

Must not change the 3 LSBs (mode and BCD/binary) of the timer's control word.

Parameters
timerTimer to configure. (Ranges from 0 to 2)
freqTimer operating frequency
Returns
Return 0 upon success and non-zero otherwise

◆ timer_subscribe_int()

int timer_subscribe_int ( void  )

Subscribes and enables Timer 0 interrupts.

Returns
Returns bit order in interrupt mask; negative value on failure

◆ timer_test_config()

int timer_test_config ( unsigned char  timer)

Tests display of timer config.

Just calls timer_get_conf() followed by timer_display_conf()

Parameters
timerTimer whose config to read (Ranges from 0 to 2)
Returns
Return 0 upon success and non-zero otherwise

◆ timer_test_int()

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

◆ timer_test_time_base()

int timer_test_time_base ( unsigned long  freq)

Tests change of Timer O interrupt frequency.

Programs Timer 0 to generate interrupts with input frequency

Parameters
freqFrequency of interrupts to generate
Returns
Return 0 upon success and non-zero otherwise

◆ timer_unsubscribe_int()

int timer_unsubscribe_int ( )

Unsubscribes Timer 0 interrupts.

Returns
Return 0 upon success and non-zero otherwise