/************************************************************************
*									*
*           Flash the LEDs on the DSLMU Microcontroller Board           *
*									*
************************************************************************/

/*  Author:   John Zaitseff <J.Zaitseff@unsw.edu.au>
    Date:     6th March, 2003
    Version:  1.5

    This program, when run on the DSLMU Microcontroller Board, flashes the
    LEDs on and off.  It does the same thing as the second version of the
    assembly language program.
*/


#include "flash.h"


/*  ---------------------------------------------------------------------
    Function:    main           - Main program entry point
    Parameters:  (none)         - No parameters are passed
    Returns:     (nothing)      - This function never returns

    This function performs the main work of the program, flashing the LEDs
    on and off.
*/

int main (void)
{
    byte *LED_port = (byte *) LED_port_addr;	/* LED port */

    while (TRUE) {				/* Do this forever */

	*LED_port = Value1;			/* Turn the LEDs on */
	delay(WaitVal);				/* and wait for WaitVal */

	*LED_port = Value2;			/* Turn the LEDs off */
	delay(WaitVal);				/* and again wait */
    }

    return 0;					/* We don't return, but */
						/* keep the compiler happy */
}


/*  ---------------------------------------------------------------------
    Function:    delay          - Delay program execution by wasting time
    Parameters:  delayval       - Number of empty loops to repeat
    Returns:     (nothing)      - No value is returned

    This function delays the program by "spinning in an idle loop".  In
    other words, it just repeats a "do nothing" statement "delayval"
    number of times.
*/

void delay (int delayval)
{
    int i;

    for (i = 0; i < delayval; i++)
	;					/* Do nothing */
}

