
/*
 *
 *     Module Name: gpio_def.h
 *	       Version: 1.00
 *   Original Date: 08/16/02	
 *	        Author: Charles Gordon
 *	      Language: Ansi C
 * Compile Options:
 * Compile defines:
 *	     Libraries:
 *    Link Options:
 *
 *    Entry Points:
 *
 *  Copyright (c) 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 useful constant definitions for setting up the
 *  GPIO ports.
 *
 *
 *
 * Edit Date/Ver   Edit Description
 * ==============  =======================================================
 *
 *
 */

#ifndef GPIO_DEF_H

#define GPIO_DEF_H
#include <Npttypes.h>
/*
 * This constant can be written to a GPIO port to set all pins to be
 * inputs.  In most cases, ports that are not used should be set
 * as inputs.
 */
#define GPIO_SET_ALL_PINS_TO_INPUTS                      0
#define GPIO_PORT_IS_NOT_USED                            GPIO_SET_ALL_PINS_TO_INPUTS



/*
 * Constants to set up pins as I/O signals.  Use shift operations
 * to adjust the constant for the correct pin.  For example, use the
 * following constant to set up pin 3 as an output and set it high.
 *      (GPIO_OUTPUT_PIN_HIGH << 3)
 */
#define GPIO_INPUT_PIN          0x00000000
#define GPIO_OUTPUT_PIN_LOW     0x00010000
#define GPIO_OUTPUT_PIN_HIGH    0x00010001

/*
 * These constants are used to configure individual pins on GPIO
 * ports to support the serial ports.  Do not shift these constants.
 * They can be used on ports A and B on the NETA-15, 20, 40, and 50,
 * and on ports A and C on the NETA-20UM.
 */
#define GPIO_TXD                0x80800000
#define GPIO_DREQ               0x40000000
#define GPIO_DTR                0x40400000
#define GPIO_RTS                0x20200000
#define GPIO_SPI_S_CLK_IN       0x10000000
#define GPIO_RXC_IN             0x10000000
#define GPIO_SPI_M_CLK_OUT      0x10100000
#define GPIO_RXC_OUT            0x10100000
#define GPIO_OUT1               0x10100000
#define GPIO_RXD                0x08000000
#define GPIO_DSR                0x04000000
#define GPIO_DACK               0x04040000
#define GPIO_CTS                0x02000000
#define GPIO_DCD                0x01000000
#define GPIO_DONE_IN            0x01000000
#define GPIO_DONE_OUT           0x01010000

/*
 * The DACK and DONE_OUT signals use different bits on the 20UM.
 */
#define GPIO_20UM_DACK          0x08080000
#define GPIO_20UM_DONE_OUT      0x02020000


/*
 * Defines for other things on port A on the 20UM.
 */
#define GPIO_AMUX                   0x04040000
#define GPIO_USB_POWER              0x04040000
#define GPIO_20UM_SPI_S_ENABLE_A    0x01000000
#define GPIO_20UM_SPI_M_ENABLE_A    0x01010000
#define GPIO_20UM_OUT1B             0x01010000


/*
 * This constant configures a GPIO port to provide full support
 * for serial operations.
 */
#define GPIO_FULL_FUNCTION_SERIAL_PORT   (GPIO_TXD | GPIO_DTR | GPIO_RTS | GPIO_RXD | GPIO_DSR | GPIO_CTS | GPIO_DCD)


/*
 * These constants can be used to setup GPIO port C on NET-15, 20, 40, and 50 chips.
 */
#define GPIO_SPI_S_ENABLE_A     0x80000000
#define GPIO_TXCA_IN            0x80000000
#define GPIO_SPI_M_ENABLE_A     0x80800000
#define GPIO_SPI_TXCA_OUT       0x80800000
#define GPIO_OUT2A              0x80800000
#define GPIO_20UM_IRQOUT        0x80800000
#define GPIO_RIA                0x40000000
#define GPIO_IRQ_OUT            0x40400000
#define GPIO_SPI_S_ENABLE_B     0x20000000
#define GPIO_TXCB_IN            0x20000000
#define GPIO_SPI_M_ENABLE_B     0x20200000
#define GPIO_TXCB_OUT           0x20200000
#define GPIO_OUT2B              0x20200000
#define GPIO_RIB                0x10000000
#define GPIO_RESET_OUT          0x10100000
#define GPIO_CI3_FALLING_EDGE   0x08000000
#define GPIO_CI3_RISING_EDGE    0x08080000
#define GPIO_CI2_FALLING_EDGE   0x04000000
#define GPIO_CI2_RISING_EDGE    0x04040000
#define GPIO_CI1_FALLING_EDGE   0x02000000
#define GPIO_CI1_RISING_EDGE    0x02020000
#define GPIO_CI0_FALLING_EDGE   0x01000000
#define GPIO_CI0_RISING_EDGE    0x01010000

/*
 * These constants can be use to acknowlege interrupts on port C
 * GPIO pins.  Note that in most cases you want to acknowledge any
 * pending interrupts when you enable interrupt functionality on
 * a pin.  For example, to program CI3 to generate an interrupt on
 * a falling edge you would normally write 
 * (GPIO_CI3_FALLING_EDGE | GPIO_CI3_ACK).
 */
#define GPIO_CI3_ACK            0x00000008
#define GPIO_CI2_ACK            0x00000004
#define GPIO_CI1_ACK            0x00000002
#define GPIO_CI0_ACK            0x00000001


/*
 * Constants for 20UM which has slightly different bit assignments.
 */
#define GPIO_20UM_TXDB                  0x80808000
#define GPIO_20UM_DREQ2_IN              0x40004000
#define GPIO_20UM_DTR                   0x40404000
#define GPIO_20UM_REJECT                0x20002000
#define GPIO_20UM_RTS                   0x20202000
#define GPIO_20UM_USB_OVERCURR          0x00001000
#define GPIO_20UM_SPI_S_CLK_B_IN        0x10001000
#define GPIO_20UM_RXCB_IN               0x10001000
#define GPIO_20UM_SPI_M_CLK_B_OUT       0x10101000
#define GPIO_20UM_TXCB_OUT              0x10101000
#define GPIO_20UM_OUT2A                 0x10101000
#define GPIO_20UM_RXDB                  0x08000800
#define GPIO_20UM_DACK2_OUT             0x08080800
#define GPIO_20UM_DSRB                  0x04000400
#define GPIO_20UM_RPSF                  0x04040400
#define GPIO_20UM_CTSB                  0x02000200
#define GPIO_20UM_DONE2_OUT             0x02020200
#define GPIO_20UM_SPI_S_ENABLE_B_IN     0x01000100
#define GPIO_20UM_DCDB                  0x01000100
#define GPIO_20UM_TXCB_IN               0x01000100
#define GPIO_20UM_SPI_M_ENABLE_B_OUT    0x01010100
#define GPIO_20UM_OUT2B                 0x01010100

/*
 * Constant to pull pin C6 down for the NS7520 PLL fix.
 */
#define GPIO_NS7520_PLL_FIX             (GPIO_OUTPUT_PIN_LOW << 6)

/*
 * This structure is used to store the state of switches and buttons at power up. 
 * This information is read by the function customizeReadPowerOnButtons() shortly
 * after the GPIO ports and RAM have been set up.  This version of the structure
 * was designed to support NET+OS development boards.  It may need to be customized
 * for your specific application.
 *
 * The fields are defined as follows:
 *
 *      gen_id          the GEN_ID field read from the System Status Register
 *      porta           the data bits from GPIO port A
 *      portb           the data bits from GPIO port B (doesn't exist on NET20UM)
 *      portc           the data bits from GPIO port C
 *      portd           the data bits from GPIO port D
 *      porte           the data bits from GPIO port E (doesn't exist at all, but...)
 *      portf           the data bits from GPIO port F
 *      portg           the data bits from GPIO port G
 *      porth           the data bits from GPIO port H
 */
typedef struct
{
    WORD32 gen_id;
    WORD32 porta;
    WORD32 portb;
    WORD32 portc;
    WORD32 portd;
    WORD32 porte;
    WORD32 portf;
    WORD32 portg;
    WORD32 porth;
} customizeButtonsType;

/*
 * Fields in the above structure are set the the value below.
 */
#define GPIO_PORT_DOESNT_EXIST  0xffffff00




#endif



