/*
 *  Copyright (c) 1996-2007 Digi International Inc., All Rights Reserved
 *
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *
 *  Restricted Rights Legend
 *
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 * Description.
 * =======================================================================
 *  This file contains the routines that reset and restart the processor,
 *  and the LED initialization routine.  These routines need to be customized
 *  to support your hardware.
 *
 *
 * Edit Date/Ver   Edit Description
 * ==============  =======================================================
 *
 * 05/17/06 JZW		Vantive 18586 - The connectem has a red LED, but customizeLeds.c does 
 *                  not have accomodations for this. Instead it follows the architecture of
 *                  its predecessor the NS7520 (yellow and green only). Added red LED
 *
 */

#include <stdlib.h>
#include <Npttypes.h>
#include <reg_def.h>
#include <narmled.h>
#include <nareset.h>
#include <init.h>
#include <bootldr.h>
#include <gpio_def.h>
#include <gpio.h>




/*
 * Bit definitions for LEDs on the NET+OS development board.  Unless your
 * board happens to have the LEDs on the same pins, you will have to change
 * these for your board.
 */
#define YELLOW_LED_GPIO_BIT        BIT_2
#define GREEN_LED_GPIO_BIT         BIT_4
#define RED_LED_GPIO_BIT           BIT_6


/*
 * The NET+OS LED driver uses values in the table NALedTable
 * to determine how to turn LEDs on and off.  See the BSP
 * Reference guide for information on how to modify this
 * table for your custom hardware.  
 *
 * This table sets up the LEDs on the development board.  Pin
 * C1 is connected to the green LED, and pin C2 is connected
 * to the yellow LED.  Setting a pin HIGH turns the LED OFF,
 * and setting it LOW turns the LED ON.
 *
 * The LED driver has to be able to work even when RAM is not
 * setup.  It is the only way to get status information out
 * during initialization.  Therefore, this table should be
 * declared as a constant so that it is stored in ROM.  If you
 * need to support multiple boards that have the LEDs connected
 * to different pins, then use #ifdef statements to create
 * different tables for different boards.
 */

 /*
  * In addition, the YELLOW LED can be used to show ethernet activity
  * (as opposed to link status). But this is optional. If the YELLOW LED
  * is NOT used for ethernet activity, it can be used under software control
  * by an appliction. The manifest constant BSP_WANT_ETHERNET_ACTIVITY_LED
  * which is defined in bsp.h in your platforms directory, controls whether
  * or not this LED is used for ethernet activity. If your application wants to use
  * this LED for its own activity, then define BSP_WANT_ETHERNET_ACTIVITY_LED 
  * to FALSE. If your application does not want to use the YELLOW LED, then
  * leave BSP_WANT_ETHERNET_ACTIVITY_LED defined as TRUE
  * 
  * To access this YELLOW LED use NALedOn(LED_ETHERNET) and 
  * NALedOff(LED_ETHERNET)
  */

const NALedTableType NALedTable[] = 
{
    {                       /* setup for the yellow LED*/
        (WORD32*)NARM_PORTC_ADDR,
        0,
        ~RED_LED_GPIO_BIT,
        RED_LED_GPIO_BIT,
        0xffffffff,
        TRUE
    },
    {                       /* setup for the green LED*/
        (WORD32*)NARM_PORTC_ADDR,
        0,
        ~GREEN_LED_GPIO_BIT,
        GREEN_LED_GPIO_BIT,
        0xffffffff,
        TRUE
    }, 
    {                       /* setup for the red LED*/
        (WORD32*)NARM_PORTC_ADDR,
        0,
        ~YELLOW_LED_GPIO_BIT,
        YELLOW_LED_GPIO_BIT,
        0xffffffff,
        TRUE
    }

};


/*
 * This constant should be set to the number of LEDs supported by
 * the H/W.  The LED driver uses it 
 * to determine the size of the table.
 */
const int NA_LED_COUNT = sizeof NALedTable/sizeof(NALedTableType);









