//*****************************************************************************
//
// bl_led_demo.c    : Functions to run LEDs indicating the bootloader status
// Author      : QJ Wang. qjwang@ti.com
// Date        : 5-9-2013
//
// Copyright (c) 2008-2011 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
//*****************************************************************************


#include "reg_het.h"
#include "sys_common.h"

/** @fn void Running_LED_demo(void)
*   
*   This function is used for LED demo based on the SCI
*   command different LED's are turned on and a running 
*	LED demo is included
*/
void run_LED_demo(uint32 ledNum)
{
   	int temp,delay;

   	/** - Delay Parameter */
	delay				= 0x40000;

    /** - NHET is configured as Master 
     *  - NHET is turned On */    
   	hetREG->GCR = 0x01000001;
	
	/** - PULL functinality is enabled */
	hetREG->HETPULDIS = 0x00000000;

	/** - This if statment is a placeholder for ArgoBoard/USBStick check */
	if(1)
	{
		/** - Configure NHET pins as output */
   		hetREG->CCDIR = 0 | (1 << 0)
   				         | (1 << 1)
   				         | (1 << 2)
   				         | (1 << 3)
   				         | (1 << 4)
   				         | (1 << 5);

		/** - Turn all LEDs off */
		hetREG->CCDWR   	= 0x00000000;

		/** - Simple Dealy */
		for(temp=0;temp<delay;temp++);

		/** - Set only NHET[0] */
		hetREG->CCDWR   	= (0x1 << ledNum);
		/** - Simple Dealy */
		for(temp=0;temp<delay;temp++);

	}

}
