Lab2
 All Functions Groups
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_get_conf (unsigned long timer, unsigned char *st)
 Reads the input timer configuration via read-back command.
int timer_display_conf (unsigned char conf)
 Shows timer configuration.
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.
int timer_test_config (unsigned long timer)
 Tests display of timer config.

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.

Does not change the LSB (BCD/binary) of the timer's control word.

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_get_conf ( unsigned long  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
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
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
int timer_test_config ( unsigned long  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