lpc17xx_pinsel.h (7779B)
1 /********************************************************************** 2 * $Id$ lpc17xx_pinsel.h 2010-05-21 3 *//** 4 * @file lpc17xx_pinsel.h 5 * @brief Contains all macro definitions and function prototypes 6 * support for Pin connect block firmware library on LPC17xx 7 * @version 2.0 8 * @date 21. May. 2010 9 * @author NXP MCU SW Application Team 10 * 11 * Copyright(C) 2010, NXP Semiconductor 12 * All rights reserved. 13 * 14 *********************************************************************** 15 * Software that is described herein is for illustrative purposes only 16 * which provides customers with programming information regarding the 17 * products. This software is supplied "AS IS" without any warranties. 18 * NXP Semiconductors assumes no responsibility or liability for the 19 * use of the software, conveys no license or title under any patent, 20 * copyright, or mask work right to the product. NXP Semiconductors 21 * reserves the right to make changes in the software without 22 * notification. NXP Semiconductors also make no representation or 23 * warranty that such application will be suitable for the specified 24 * use without further testing or modification. 25 * Permission to use, copy, modify, and distribute this software and its 26 * documentation is hereby granted, under NXP Semiconductors' 27 * relevant copyright in the software, without fee, provided that it 28 * is used in conjunction with NXP Semiconductors microcontrollers. This 29 * copyright, permission, and disclaimer notice must appear in all copies of 30 * this code. 31 **********************************************************************/ 32 33 /* Peripheral group ----------------------------------------------------------- */ 34 /** @defgroup PINSEL PINSEL (Pin Selection) 35 * @ingroup LPC1700CMSIS_FwLib_Drivers 36 * @{ 37 */ 38 39 #ifndef LPC17XX_PINSEL_H_ 40 #define LPC17XX_PINSEL_H_ 41 42 /* Includes ------------------------------------------------------------------- */ 43 #include "LPC17xx.h" 44 #include "lpc_types.h" 45 46 #ifdef __cplusplus 47 extern "C" 48 { 49 #endif 50 51 /* Public Macros -------------------------------------------------------------- */ 52 /** @defgroup PINSEL_Public_Macros PINSEL Public Macros 53 * @{ 54 */ 55 56 /*********************************************************************//** 57 *!< Macros define for PORT Selection 58 ***********************************************************************/ 59 #define PINSEL_PORT_0 ((0)) /**< PORT 0*/ 60 #define PINSEL_PORT_1 ((1)) /**< PORT 1*/ 61 #define PINSEL_PORT_2 ((2)) /**< PORT 2*/ 62 #define PINSEL_PORT_3 ((3)) /**< PORT 3*/ 63 #define PINSEL_PORT_4 ((4)) /**< PORT 4*/ 64 65 /*********************************************************************** 66 * Macros define for Pin Function selection 67 **********************************************************************/ 68 #define PINSEL_FUNC_0 ((0)) /**< default function*/ 69 #define PINSEL_FUNC_1 ((1)) /**< first alternate function*/ 70 #define PINSEL_FUNC_2 ((2)) /**< second alternate function*/ 71 #define PINSEL_FUNC_3 ((3)) /**< third or reserved alternate function*/ 72 73 /*********************************************************************** 74 * Macros define for Pin Number of Port 75 **********************************************************************/ 76 #define PINSEL_PIN_0 ((0)) /**< Pin 0 */ 77 #define PINSEL_PIN_1 ((1)) /**< Pin 1 */ 78 #define PINSEL_PIN_2 ((2)) /**< Pin 2 */ 79 #define PINSEL_PIN_3 ((3)) /**< Pin 3 */ 80 #define PINSEL_PIN_4 ((4)) /**< Pin 4 */ 81 #define PINSEL_PIN_5 ((5)) /**< Pin 5 */ 82 #define PINSEL_PIN_6 ((6)) /**< Pin 6 */ 83 #define PINSEL_PIN_7 ((7)) /**< Pin 7 */ 84 #define PINSEL_PIN_8 ((8)) /**< Pin 8 */ 85 #define PINSEL_PIN_9 ((9)) /**< Pin 9 */ 86 #define PINSEL_PIN_10 ((10)) /**< Pin 10 */ 87 #define PINSEL_PIN_11 ((11)) /**< Pin 11 */ 88 #define PINSEL_PIN_12 ((12)) /**< Pin 12 */ 89 #define PINSEL_PIN_13 ((13)) /**< Pin 13 */ 90 #define PINSEL_PIN_14 ((14)) /**< Pin 14 */ 91 #define PINSEL_PIN_15 ((15)) /**< Pin 15 */ 92 #define PINSEL_PIN_16 ((16)) /**< Pin 16 */ 93 #define PINSEL_PIN_17 ((17)) /**< Pin 17 */ 94 #define PINSEL_PIN_18 ((18)) /**< Pin 18 */ 95 #define PINSEL_PIN_19 ((19)) /**< Pin 19 */ 96 #define PINSEL_PIN_20 ((20)) /**< Pin 20 */ 97 #define PINSEL_PIN_21 ((21)) /**< Pin 21 */ 98 #define PINSEL_PIN_22 ((22)) /**< Pin 22 */ 99 #define PINSEL_PIN_23 ((23)) /**< Pin 23 */ 100 #define PINSEL_PIN_24 ((24)) /**< Pin 24 */ 101 #define PINSEL_PIN_25 ((25)) /**< Pin 25 */ 102 #define PINSEL_PIN_26 ((26)) /**< Pin 26 */ 103 #define PINSEL_PIN_27 ((27)) /**< Pin 27 */ 104 #define PINSEL_PIN_28 ((28)) /**< Pin 28 */ 105 #define PINSEL_PIN_29 ((29)) /**< Pin 29 */ 106 #define PINSEL_PIN_30 ((30)) /**< Pin 30 */ 107 #define PINSEL_PIN_31 ((31)) /**< Pin 31 */ 108 109 /*********************************************************************** 110 * Macros define for Pin mode 111 **********************************************************************/ 112 #define PINSEL_PINMODE_PULLUP ((0)) /**< Internal pull-up resistor*/ 113 #define PINSEL_PINMODE_TRISTATE ((2)) /**< Tri-state */ 114 #define PINSEL_PINMODE_PULLDOWN ((3)) /**< Internal pull-down resistor */ 115 116 /*********************************************************************** 117 * Macros define for Pin mode (normal/open drain) 118 **********************************************************************/ 119 #define PINSEL_PINMODE_NORMAL ((0)) /**< Pin is in the normal (not open drain) mode.*/ 120 #define PINSEL_PINMODE_OPENDRAIN ((1)) /**< Pin is in the open drain mode */ 121 122 /*********************************************************************** 123 * Macros define for I2C mode 124 ***********************************************************************/ 125 #define PINSEL_I2C_Normal_Mode ((0)) /**< The standard drive mode */ 126 #define PINSEL_I2C_Fast_Mode ((1)) /**< Fast Mode Plus drive mode */ 127 128 /** 129 * @} 130 */ 131 132 /* Private Macros ------------------------------------------------------------- */ 133 /** @defgroup PINSEL_Private_Macros PINSEL Private Macros 134 * @{ 135 */ 136 137 /* Pin selection define */ 138 /* I2C Pin Configuration register bit description */ 139 #define PINSEL_I2CPADCFG_SDADRV0 _BIT(0) /**< Drive mode control for the SDA0 pin, P0.27 */ 140 #define PINSEL_I2CPADCFG_SDAI2C0 _BIT(1) /**< I2C mode control for the SDA0 pin, P0.27 */ 141 #define PINSEL_I2CPADCFG_SCLDRV0 _BIT(2) /**< Drive mode control for the SCL0 pin, P0.28 */ 142 #define PINSEL_I2CPADCFG_SCLI2C0 _BIT(3) /**< I2C mode control for the SCL0 pin, P0.28 */ 143 144 /** 145 * @} 146 */ 147 148 149 /* Public Types --------------------------------------------------------------- */ 150 /** @defgroup PINSEL_Public_Types PINSEL Public Types 151 * @{ 152 */ 153 154 /** @brief Pin configuration structure */ 155 typedef struct 156 { 157 uint8_t Portnum; /**< Port Number, should be PINSEL_PORT_x, 158 where x should be in range from 0 to 4 */ 159 uint8_t Pinnum; /**< Pin Number, should be PINSEL_PIN_x, 160 where x should be in range from 0 to 31 */ 161 uint8_t Funcnum; /**< Function Number, should be PINSEL_FUNC_x, 162 where x should be in range from 0 to 3 */ 163 uint8_t Pinmode; /**< Pin Mode, should be: 164 - PINSEL_PINMODE_PULLUP: Internal pull-up resistor 165 - PINSEL_PINMODE_TRISTATE: Tri-state 166 - PINSEL_PINMODE_PULLDOWN: Internal pull-down resistor */ 167 uint8_t OpenDrain; /**< OpenDrain mode, should be: 168 - PINSEL_PINMODE_NORMAL: Pin is in the normal (not open drain) mode 169 - PINSEL_PINMODE_OPENDRAIN: Pin is in the open drain mode */ 170 } PINSEL_CFG_Type; 171 172 /** 173 * @} 174 */ 175 176 177 /* Public Functions ----------------------------------------------------------- */ 178 /** @defgroup PINSEL_Public_Functions PINSEL Public Functions 179 * @{ 180 */ 181 182 void PINSEL_ConfigPin(PINSEL_CFG_Type *PinCfg); 183 void PINSEL_ConfigTraceFunc (FunctionalState NewState); 184 void PINSEL_SetI2C0Pins(uint8_t i2cPinMode, FunctionalState filterSlewRateEnable); 185 186 187 /** 188 * @} 189 */ 190 191 192 #ifdef __cplusplus 193 } 194 #endif 195 196 #endif /* LPC17XX_PINSEL_H_ */ 197 198 /** 199 * @} 200 */ 201 202 /* --------------------------------- End Of File ------------------------------ */ 203