| 1 |
610 |
jeremybenn |
//*****************************************************************************
|
| 2 |
|
|
//
|
| 3 |
|
|
// gpio.h - Defines and Macros for GPIO API.
|
| 4 |
|
|
//
|
| 5 |
|
|
// Copyright (c) 2005-2008 Luminary Micro, Inc. All rights reserved.
|
| 6 |
|
|
//
|
| 7 |
|
|
// Software License Agreement
|
| 8 |
|
|
//
|
| 9 |
|
|
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
| 10 |
|
|
// exclusively on LMI's microcontroller products.
|
| 11 |
|
|
//
|
| 12 |
|
|
// The software is owned by LMI and/or its suppliers, and is protected under
|
| 13 |
|
|
// applicable copyright laws. All rights are reserved. You may not combine
|
| 14 |
|
|
// this software with "viral" open-source software in order to form a larger
|
| 15 |
|
|
// program. Any use in violation of the foregoing restrictions may subject
|
| 16 |
|
|
// the user to criminal sanctions under applicable laws, as well as to civil
|
| 17 |
|
|
// liability for the breach of the terms and conditions of this license.
|
| 18 |
|
|
//
|
| 19 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
| 20 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
| 21 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
| 22 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
| 23 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
| 24 |
|
|
//
|
| 25 |
|
|
// This is part of revision 2523 of the Stellaris Peripheral Driver Library.
|
| 26 |
|
|
//
|
| 27 |
|
|
//*****************************************************************************
|
| 28 |
|
|
|
| 29 |
|
|
#ifndef __GPIO_H__
|
| 30 |
|
|
#define __GPIO_H__
|
| 31 |
|
|
|
| 32 |
|
|
//*****************************************************************************
|
| 33 |
|
|
//
|
| 34 |
|
|
// If building with a C++ compiler, make all of the definitions in this header
|
| 35 |
|
|
// have a C binding.
|
| 36 |
|
|
//
|
| 37 |
|
|
//*****************************************************************************
|
| 38 |
|
|
#ifdef __cplusplus
|
| 39 |
|
|
extern "C"
|
| 40 |
|
|
{
|
| 41 |
|
|
#endif
|
| 42 |
|
|
|
| 43 |
|
|
//*****************************************************************************
|
| 44 |
|
|
//
|
| 45 |
|
|
// The following values define the bit field for the ucPins argument to several
|
| 46 |
|
|
// of the APIs.
|
| 47 |
|
|
//
|
| 48 |
|
|
//*****************************************************************************
|
| 49 |
|
|
#define GPIO_PIN_0 0x00000001 // GPIO pin 0
|
| 50 |
|
|
#define GPIO_PIN_1 0x00000002 // GPIO pin 1
|
| 51 |
|
|
#define GPIO_PIN_2 0x00000004 // GPIO pin 2
|
| 52 |
|
|
#define GPIO_PIN_3 0x00000008 // GPIO pin 3
|
| 53 |
|
|
#define GPIO_PIN_4 0x00000010 // GPIO pin 4
|
| 54 |
|
|
#define GPIO_PIN_5 0x00000020 // GPIO pin 5
|
| 55 |
|
|
#define GPIO_PIN_6 0x00000040 // GPIO pin 6
|
| 56 |
|
|
#define GPIO_PIN_7 0x00000080 // GPIO pin 7
|
| 57 |
|
|
|
| 58 |
|
|
//*****************************************************************************
|
| 59 |
|
|
//
|
| 60 |
|
|
// Values that can be passed to GPIODirModeSet as the ulPinIO parameter, and
|
| 61 |
|
|
// returned from GPIODirModeGet.
|
| 62 |
|
|
//
|
| 63 |
|
|
//*****************************************************************************
|
| 64 |
|
|
#define GPIO_DIR_MODE_IN 0x00000000 // Pin is a GPIO input
|
| 65 |
|
|
#define GPIO_DIR_MODE_OUT 0x00000001 // Pin is a GPIO output
|
| 66 |
|
|
#define GPIO_DIR_MODE_HW 0x00000002 // Pin is a peripheral function
|
| 67 |
|
|
|
| 68 |
|
|
//*****************************************************************************
|
| 69 |
|
|
//
|
| 70 |
|
|
// Values that can be passed to GPIOIntTypeSet as the ulIntType parameter, and
|
| 71 |
|
|
// returned from GPIOIntTypeGet.
|
| 72 |
|
|
//
|
| 73 |
|
|
//*****************************************************************************
|
| 74 |
|
|
#define GPIO_FALLING_EDGE 0x00000000 // Interrupt on falling edge
|
| 75 |
|
|
#define GPIO_RISING_EDGE 0x00000004 // Interrupt on rising edge
|
| 76 |
|
|
#define GPIO_BOTH_EDGES 0x00000001 // Interrupt on both edges
|
| 77 |
|
|
#define GPIO_LOW_LEVEL 0x00000002 // Interrupt on low level
|
| 78 |
|
|
#define GPIO_HIGH_LEVEL 0x00000007 // Interrupt on high level
|
| 79 |
|
|
|
| 80 |
|
|
//*****************************************************************************
|
| 81 |
|
|
//
|
| 82 |
|
|
// Values that can be passed to GPIOPadConfigSet as the ulStrength parameter,
|
| 83 |
|
|
// and returned by GPIOPadConfigGet in the *pulStrength parameter.
|
| 84 |
|
|
//
|
| 85 |
|
|
//*****************************************************************************
|
| 86 |
|
|
#define GPIO_STRENGTH_2MA 0x00000001 // 2mA drive strength
|
| 87 |
|
|
#define GPIO_STRENGTH_4MA 0x00000002 // 4mA drive strength
|
| 88 |
|
|
#define GPIO_STRENGTH_8MA 0x00000004 // 8mA drive strength
|
| 89 |
|
|
#define GPIO_STRENGTH_8MA_SC 0x0000000C // 8mA drive with slew rate control
|
| 90 |
|
|
|
| 91 |
|
|
//*****************************************************************************
|
| 92 |
|
|
//
|
| 93 |
|
|
// Values that can be passed to GPIOPadConfigSet as the ulPadType parameter,
|
| 94 |
|
|
// and returned by GPIOPadConfigGet in the *pulPadType parameter.
|
| 95 |
|
|
//
|
| 96 |
|
|
//*****************************************************************************
|
| 97 |
|
|
#define GPIO_PIN_TYPE_STD 0x00000008 // Push-pull
|
| 98 |
|
|
#define GPIO_PIN_TYPE_STD_WPU 0x0000000A // Push-pull with weak pull-up
|
| 99 |
|
|
#define GPIO_PIN_TYPE_STD_WPD 0x0000000C // Push-pull with weak pull-down
|
| 100 |
|
|
#define GPIO_PIN_TYPE_OD 0x00000009 // Open-drain
|
| 101 |
|
|
#define GPIO_PIN_TYPE_OD_WPU 0x0000000B // Open-drain with weak pull-up
|
| 102 |
|
|
#define GPIO_PIN_TYPE_OD_WPD 0x0000000D // Open-drain with weak pull-down
|
| 103 |
|
|
#define GPIO_PIN_TYPE_ANALOG 0x00000000 // Analog comparator
|
| 104 |
|
|
|
| 105 |
|
|
//*****************************************************************************
|
| 106 |
|
|
//
|
| 107 |
|
|
// Prototypes for the APIs.
|
| 108 |
|
|
//
|
| 109 |
|
|
//*****************************************************************************
|
| 110 |
|
|
extern void GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
|
| 111 |
|
|
unsigned long ulPinIO);
|
| 112 |
|
|
extern unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin);
|
| 113 |
|
|
extern void GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,
|
| 114 |
|
|
unsigned long ulIntType);
|
| 115 |
|
|
extern unsigned long GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin);
|
| 116 |
|
|
extern void GPIOPadConfigSet(unsigned long ulPort, unsigned char ucPins,
|
| 117 |
|
|
unsigned long ulStrength,
|
| 118 |
|
|
unsigned long ulPadType);
|
| 119 |
|
|
extern void GPIOPadConfigGet(unsigned long ulPort, unsigned char ucPin,
|
| 120 |
|
|
unsigned long *pulStrength,
|
| 121 |
|
|
unsigned long *pulPadType);
|
| 122 |
|
|
extern void GPIOPinIntEnable(unsigned long ulPort, unsigned char ucPins);
|
| 123 |
|
|
extern void GPIOPinIntDisable(unsigned long ulPort, unsigned char ucPins);
|
| 124 |
|
|
extern long GPIOPinIntStatus(unsigned long ulPort, tBoolean bMasked);
|
| 125 |
|
|
extern void GPIOPinIntClear(unsigned long ulPort, unsigned char ucPins);
|
| 126 |
|
|
extern void GPIOPortIntRegister(unsigned long ulPort,
|
| 127 |
|
|
void (*pfnIntHandler)(void));
|
| 128 |
|
|
extern void GPIOPortIntUnregister(unsigned long ulPort);
|
| 129 |
|
|
extern long GPIOPinRead(unsigned long ulPort, unsigned char ucPins);
|
| 130 |
|
|
extern void GPIOPinWrite(unsigned long ulPort, unsigned char ucPins,
|
| 131 |
|
|
unsigned char ucVal);
|
| 132 |
|
|
extern void GPIOPinTypeADC(unsigned long ulPort, unsigned char ucPins);
|
| 133 |
|
|
extern void GPIOPinTypeCAN(unsigned long ulPort, unsigned char ucPins);
|
| 134 |
|
|
extern void GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins);
|
| 135 |
|
|
extern void GPIOPinTypeGPIOInput(unsigned long ulPort, unsigned char ucPins);
|
| 136 |
|
|
extern void GPIOPinTypeGPIOOutput(unsigned long ulPort, unsigned char ucPins);
|
| 137 |
|
|
extern void GPIOPinTypeGPIOOutputOD(unsigned long ulPort,
|
| 138 |
|
|
unsigned char ucPins);
|
| 139 |
|
|
extern void GPIOPinTypeI2C(unsigned long ulPort, unsigned char ucPins);
|
| 140 |
|
|
extern void GPIOPinTypePWM(unsigned long ulPort, unsigned char ucPins);
|
| 141 |
|
|
extern void GPIOPinTypeQEI(unsigned long ulPort, unsigned char ucPins);
|
| 142 |
|
|
extern void GPIOPinTypeSSI(unsigned long ulPort, unsigned char ucPins);
|
| 143 |
|
|
extern void GPIOPinTypeTimer(unsigned long ulPort, unsigned char ucPins);
|
| 144 |
|
|
extern void GPIOPinTypeUART(unsigned long ulPort, unsigned char ucPins);
|
| 145 |
|
|
extern void GPIOPinTypeUSBDigital(unsigned long ulPort, unsigned char ucPins);
|
| 146 |
|
|
|
| 147 |
|
|
//*****************************************************************************
|
| 148 |
|
|
//
|
| 149 |
|
|
// Mark the end of the C bindings section for C++ compilers.
|
| 150 |
|
|
//
|
| 151 |
|
|
//*****************************************************************************
|
| 152 |
|
|
#ifdef __cplusplus
|
| 153 |
|
|
}
|
| 154 |
|
|
#endif
|
| 155 |
|
|
|
| 156 |
|
|
#endif // __GPIO_H__
|