34f473c0a4905c3f203358fabe8143ef61c2843b
1 /******************************************************************************
2 * Copyright (c) 2010 Texas Instruments Incorporated - http://www.ti.com
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *****************************************************************************/
33 /******************************************************************************
34 *
35 * File Name: gpio.h
36 *
37 * Description: This file is the header file for GPIO module
38 *
39 * History:
40 * JUL/22/2009, Amit Solanki, Created the file
41 *
42 ******************************************************************************/
43 #ifndef GPIO_H_
44 #define GPIO_H_
45 /****************
46 * Include Files
47 ****************/
48 #include "types.h"
50 /*********************************
51 * Defines and Macros and globals
52 *********************************/
54 #define GPIO_0 0
55 #define GPIO_1 1
56 #define GPIO_2 2
57 #define GPIO_3 3
58 #define GPIO_4 4
59 #define GPIO_5 5
60 #define GPIO_6 6
61 #define GPIO_7 7
62 #define GPIO_8 8
63 #define GPIO_9 9
64 #define GPIO_10 10
65 #define GPIO_11 11
66 #define GPIO_12 12
67 #define GPIO_13 13
68 #define GPIO_14 14
69 #define GPIO_15 15
71 #define GPIO_DATAMASK 0x000000FF
73 #define GPIO_MAX_NUMBER 15
75 #define SUCCESS 0
76 #define GPIO_LOW 0
77 #define GPIO_HIGH 1
78 #define INVALID_GPIO_NUMBER 2
79 #define INVALID_GPIO_DIRECTION 3
80 #define INVALID_GPIO_STATE 4
82 // GPIO pins and the Nand flash controller signal mapping
84 // GPIO[7:0] are used as bi-directional data-bus
85 // between DSP and FPGA
87 // Command pins
88 #define DSP_FPGA_CMD0 GPIO_8
89 #define DSP_FPGA_CMD1 GPIO_9
91 // DSP to FPGA strobe for synchronization
92 #define DSP_FPGA_STROBE GPIO_10
94 // FPGA to DSP ready signal
95 #define FPGA_DSP_READY GPIO_11
97 // LED signals
98 #define DSP_FPGA_LED_0 GPIO_12
99 #define DSP_FPGA_LED_1 GPIO_13
101 // NAND or non-UART FPGA interrupt
102 #define FPGA_DSP_NFC_INTR GPIO_14
104 // Nand mode selection GPIO
105 #define NAND_MODE_GPIO GPIO_14
107 // UART interrupt
108 #define FPGA_DSP_UART_INTR GPIO_15
110 /*********************
111 * Typedefs and Enums
112 *********************/
113 typedef enum _GpioDirection
114 {
115 GPIO_OUT = 0,
116 GPIO_IN
117 }GpioDirection;
119 /************************
120 * Function declarations
121 ************************/
122 void hwGpioSetDirection( Uint32 uiNumber, GpioDirection direction );
123 void hwGpioSetDataBusDirection( GpioDirection direction );
124 void hwGpioSetOutput( Uint32 uiNumber);
125 void hwGpioClearOutput( Uint32 uiNumber);
126 Uint32 hwGpioReadInput( Uint32 uiNumber );
127 void hwGpioWriteDataBus ( Uint8 uchValue );
128 Uint8 hwGpioReadDataBus( void );
129 void hwGpioEnableGlobalInterrupt( void );
130 void hwGpioSetDataBus(Uint8 uchValue);
131 void hwGpioClearDataBus(Uint8 uchValue);
132 void hwGpioDisableGlobalInterrupt( void );
133 void hwGpioSetRisingEdgeInterrupt( Uint32 uiNumber );
134 void hwGpioClearRisingEdgeInterrupt( Uint32 uiNumber );
135 void hwGpioSetFallingEdgeInterrupt( Uint32 uiNumber );
136 void hwGpioClearFallingEdgeInterrupt( Uint32 uiNumber );
138 #endif // GPIO_H_