Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
lpc17xx_pinsel.cpp@4:cb3dc3361be5, 2011-06-12 (annotated)
- Committer:
- Benoit
- Date:
- Sun Jun 12 20:24:23 2011 +0000
- Revision:
- 4:cb3dc3361be5
- Parent:
- 1:f4040665bc61
- Child:
- 5:3cd83fcb1467
Masked out all CMSIS code from doxygen doc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Benoit | 4:cb3dc3361be5 | 1 | /* @cond */ |
Benoit | 1:f4040665bc61 | 2 | /***********************************************************************//** |
Benoit | 1:f4040665bc61 | 3 | * @file lpc17xx_pinsel.c |
Benoit | 1:f4040665bc61 | 4 | * @brief Contains all functions support for Pin connect block firmware |
Benoit | 1:f4040665bc61 | 5 | * library on LPC17xx |
Benoit | 1:f4040665bc61 | 6 | * @version 2.0 |
Benoit | 1:f4040665bc61 | 7 | * @date 21. May. 2010 |
Benoit | 1:f4040665bc61 | 8 | * @author NXP MCU SW Application Team |
Benoit | 1:f4040665bc61 | 9 | ************************************************************************** |
Benoit | 1:f4040665bc61 | 10 | * Software that is described herein is for illustrative purposes only |
Benoit | 1:f4040665bc61 | 11 | * which provides customers with programming information regarding the |
Benoit | 1:f4040665bc61 | 12 | * products. This software is supplied "AS IS" without any warranties. |
Benoit | 1:f4040665bc61 | 13 | * NXP Semiconductors assumes no responsibility or liability for the |
Benoit | 1:f4040665bc61 | 14 | * use of the software, conveys no license or title under any patent, |
Benoit | 1:f4040665bc61 | 15 | * copyright, or mask work right to the product. NXP Semiconductors |
Benoit | 1:f4040665bc61 | 16 | * reserves the right to make changes in the software without |
Benoit | 1:f4040665bc61 | 17 | * notification. NXP Semiconductors also make no representation or |
Benoit | 1:f4040665bc61 | 18 | * warranty that such application will be suitable for the specified |
Benoit | 1:f4040665bc61 | 19 | * use without further testing or modification. |
Benoit | 1:f4040665bc61 | 20 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 21 | |
Benoit | 1:f4040665bc61 | 22 | /* Peripheral group ----------------------------------------------------------- */ |
Benoit | 1:f4040665bc61 | 23 | /** @addtogroup PINSEL |
Benoit | 1:f4040665bc61 | 24 | * @{ |
Benoit | 1:f4040665bc61 | 25 | */ |
Benoit | 1:f4040665bc61 | 26 | |
Benoit | 1:f4040665bc61 | 27 | /* Includes ------------------------------------------------------------------- */ |
Benoit | 1:f4040665bc61 | 28 | #include "lpc17xx_pinsel.h" |
Benoit | 1:f4040665bc61 | 29 | |
Benoit | 1:f4040665bc61 | 30 | /* Public Functions ----------------------------------------------------------- */ |
Benoit | 1:f4040665bc61 | 31 | |
Benoit | 1:f4040665bc61 | 32 | static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum); |
Benoit | 1:f4040665bc61 | 33 | static void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum); |
Benoit | 1:f4040665bc61 | 34 | static void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum); |
Benoit | 1:f4040665bc61 | 35 | |
Benoit | 1:f4040665bc61 | 36 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 37 | * @brief Setup the pin selection function |
Benoit | 1:f4040665bc61 | 38 | * @param[in] portnum PORT number, |
Benoit | 1:f4040665bc61 | 39 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 40 | * - PINSEL_PORT_0 : Port 0 |
Benoit | 1:f4040665bc61 | 41 | * - PINSEL_PORT_1 : Port 1 |
Benoit | 1:f4040665bc61 | 42 | * - PINSEL_PORT_2 : Port 2 |
Benoit | 1:f4040665bc61 | 43 | * - PINSEL_PORT_3 : Port 3 |
Benoit | 1:f4040665bc61 | 44 | * |
Benoit | 1:f4040665bc61 | 45 | * @param[in] pinnum Pin number, |
Benoit | 1:f4040665bc61 | 46 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 47 | - PINSEL_PIN_0 : Pin 0 |
Benoit | 1:f4040665bc61 | 48 | - PINSEL_PIN_1 : Pin 1 |
Benoit | 1:f4040665bc61 | 49 | - PINSEL_PIN_2 : Pin 2 |
Benoit | 1:f4040665bc61 | 50 | - PINSEL_PIN_3 : Pin 3 |
Benoit | 1:f4040665bc61 | 51 | - PINSEL_PIN_4 : Pin 4 |
Benoit | 1:f4040665bc61 | 52 | - PINSEL_PIN_5 : Pin 5 |
Benoit | 1:f4040665bc61 | 53 | - PINSEL_PIN_6 : Pin 6 |
Benoit | 1:f4040665bc61 | 54 | - PINSEL_PIN_7 : Pin 7 |
Benoit | 1:f4040665bc61 | 55 | - PINSEL_PIN_8 : Pin 8 |
Benoit | 1:f4040665bc61 | 56 | - PINSEL_PIN_9 : Pin 9 |
Benoit | 1:f4040665bc61 | 57 | - PINSEL_PIN_10 : Pin 10 |
Benoit | 1:f4040665bc61 | 58 | - PINSEL_PIN_11 : Pin 11 |
Benoit | 1:f4040665bc61 | 59 | - PINSEL_PIN_12 : Pin 12 |
Benoit | 1:f4040665bc61 | 60 | - PINSEL_PIN_13 : Pin 13 |
Benoit | 1:f4040665bc61 | 61 | - PINSEL_PIN_14 : Pin 14 |
Benoit | 1:f4040665bc61 | 62 | - PINSEL_PIN_15 : Pin 15 |
Benoit | 1:f4040665bc61 | 63 | - PINSEL_PIN_16 : Pin 16 |
Benoit | 1:f4040665bc61 | 64 | - PINSEL_PIN_17 : Pin 17 |
Benoit | 1:f4040665bc61 | 65 | - PINSEL_PIN_18 : Pin 18 |
Benoit | 1:f4040665bc61 | 66 | - PINSEL_PIN_19 : Pin 19 |
Benoit | 1:f4040665bc61 | 67 | - PINSEL_PIN_20 : Pin 20 |
Benoit | 1:f4040665bc61 | 68 | - PINSEL_PIN_21 : Pin 21 |
Benoit | 1:f4040665bc61 | 69 | - PINSEL_PIN_22 : Pin 22 |
Benoit | 1:f4040665bc61 | 70 | - PINSEL_PIN_23 : Pin 23 |
Benoit | 1:f4040665bc61 | 71 | - PINSEL_PIN_24 : Pin 24 |
Benoit | 1:f4040665bc61 | 72 | - PINSEL_PIN_25 : Pin 25 |
Benoit | 1:f4040665bc61 | 73 | - PINSEL_PIN_26 : Pin 26 |
Benoit | 1:f4040665bc61 | 74 | - PINSEL_PIN_27 : Pin 27 |
Benoit | 1:f4040665bc61 | 75 | - PINSEL_PIN_28 : Pin 28 |
Benoit | 1:f4040665bc61 | 76 | - PINSEL_PIN_29 : Pin 29 |
Benoit | 1:f4040665bc61 | 77 | - PINSEL_PIN_30 : Pin 30 |
Benoit | 1:f4040665bc61 | 78 | - PINSEL_PIN_31 : Pin 31 |
Benoit | 1:f4040665bc61 | 79 | |
Benoit | 1:f4040665bc61 | 80 | * @param[in] funcnum Function number, |
Benoit | 1:f4040665bc61 | 81 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 82 | * - PINSEL_FUNC_0 : default function |
Benoit | 1:f4040665bc61 | 83 | * - PINSEL_FUNC_1 : first alternate function |
Benoit | 1:f4040665bc61 | 84 | * - PINSEL_FUNC_2 : second alternate function |
Benoit | 1:f4040665bc61 | 85 | * - PINSEL_FUNC_3 : third alternate function |
Benoit | 1:f4040665bc61 | 86 | * |
Benoit | 1:f4040665bc61 | 87 | * @return None |
Benoit | 1:f4040665bc61 | 88 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 89 | static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum) |
Benoit | 1:f4040665bc61 | 90 | { |
Benoit | 1:f4040665bc61 | 91 | uint32_t pinnum_t = pinnum; |
Benoit | 1:f4040665bc61 | 92 | uint32_t pinselreg_idx = 2 * portnum; |
Benoit | 1:f4040665bc61 | 93 | uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINSEL0; |
Benoit | 1:f4040665bc61 | 94 | |
Benoit | 1:f4040665bc61 | 95 | if (pinnum_t >= 16) { |
Benoit | 1:f4040665bc61 | 96 | pinnum_t -= 16; |
Benoit | 1:f4040665bc61 | 97 | pinselreg_idx++; |
Benoit | 1:f4040665bc61 | 98 | } |
Benoit | 1:f4040665bc61 | 99 | *(uint32_t *)(pPinCon + pinselreg_idx) &= ~(0x03UL << (pinnum_t * 2)); |
Benoit | 1:f4040665bc61 | 100 | *(uint32_t *)(pPinCon + pinselreg_idx) |= ((uint32_t)funcnum) << (pinnum_t * 2); |
Benoit | 1:f4040665bc61 | 101 | } |
Benoit | 1:f4040665bc61 | 102 | |
Benoit | 1:f4040665bc61 | 103 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 104 | * @brief Setup resistor mode for each pin |
Benoit | 1:f4040665bc61 | 105 | * @param[in] portnum PORT number, |
Benoit | 1:f4040665bc61 | 106 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 107 | * - PINSEL_PORT_0 : Port 0 |
Benoit | 1:f4040665bc61 | 108 | * - PINSEL_PORT_1 : Port 1 |
Benoit | 1:f4040665bc61 | 109 | * - PINSEL_PORT_2 : Port 2 |
Benoit | 1:f4040665bc61 | 110 | * - PINSEL_PORT_3 : Port 3 |
Benoit | 1:f4040665bc61 | 111 | * @param[in] pinnum Pin number, |
Benoit | 1:f4040665bc61 | 112 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 113 | - PINSEL_PIN_0 : Pin 0 |
Benoit | 1:f4040665bc61 | 114 | - PINSEL_PIN_1 : Pin 1 |
Benoit | 1:f4040665bc61 | 115 | - PINSEL_PIN_2 : Pin 2 |
Benoit | 1:f4040665bc61 | 116 | - PINSEL_PIN_3 : Pin 3 |
Benoit | 1:f4040665bc61 | 117 | - PINSEL_PIN_4 : Pin 4 |
Benoit | 1:f4040665bc61 | 118 | - PINSEL_PIN_5 : Pin 5 |
Benoit | 1:f4040665bc61 | 119 | - PINSEL_PIN_6 : Pin 6 |
Benoit | 1:f4040665bc61 | 120 | - PINSEL_PIN_7 : Pin 7 |
Benoit | 1:f4040665bc61 | 121 | - PINSEL_PIN_8 : Pin 8 |
Benoit | 1:f4040665bc61 | 122 | - PINSEL_PIN_9 : Pin 9 |
Benoit | 1:f4040665bc61 | 123 | - PINSEL_PIN_10 : Pin 10 |
Benoit | 1:f4040665bc61 | 124 | - PINSEL_PIN_11 : Pin 11 |
Benoit | 1:f4040665bc61 | 125 | - PINSEL_PIN_12 : Pin 12 |
Benoit | 1:f4040665bc61 | 126 | - PINSEL_PIN_13 : Pin 13 |
Benoit | 1:f4040665bc61 | 127 | - PINSEL_PIN_14 : Pin 14 |
Benoit | 1:f4040665bc61 | 128 | - PINSEL_PIN_15 : Pin 15 |
Benoit | 1:f4040665bc61 | 129 | - PINSEL_PIN_16 : Pin 16 |
Benoit | 1:f4040665bc61 | 130 | - PINSEL_PIN_17 : Pin 17 |
Benoit | 1:f4040665bc61 | 131 | - PINSEL_PIN_18 : Pin 18 |
Benoit | 1:f4040665bc61 | 132 | - PINSEL_PIN_19 : Pin 19 |
Benoit | 1:f4040665bc61 | 133 | - PINSEL_PIN_20 : Pin 20 |
Benoit | 1:f4040665bc61 | 134 | - PINSEL_PIN_21 : Pin 21 |
Benoit | 1:f4040665bc61 | 135 | - PINSEL_PIN_22 : Pin 22 |
Benoit | 1:f4040665bc61 | 136 | - PINSEL_PIN_23 : Pin 23 |
Benoit | 1:f4040665bc61 | 137 | - PINSEL_PIN_24 : Pin 24 |
Benoit | 1:f4040665bc61 | 138 | - PINSEL_PIN_25 : Pin 25 |
Benoit | 1:f4040665bc61 | 139 | - PINSEL_PIN_26 : Pin 26 |
Benoit | 1:f4040665bc61 | 140 | - PINSEL_PIN_27 : Pin 27 |
Benoit | 1:f4040665bc61 | 141 | - PINSEL_PIN_28 : Pin 28 |
Benoit | 1:f4040665bc61 | 142 | - PINSEL_PIN_29 : Pin 29 |
Benoit | 1:f4040665bc61 | 143 | - PINSEL_PIN_30 : Pin 30 |
Benoit | 1:f4040665bc61 | 144 | - PINSEL_PIN_31 : Pin 31 |
Benoit | 1:f4040665bc61 | 145 | |
Benoit | 1:f4040665bc61 | 146 | * @param[in] modenum: Mode number, |
Benoit | 1:f4040665bc61 | 147 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 148 | - PINSEL_PINMODE_PULLUP : Internal pull-up resistor |
Benoit | 1:f4040665bc61 | 149 | - PINSEL_PINMODE_TRISTATE : Tri-state |
Benoit | 1:f4040665bc61 | 150 | - PINSEL_PINMODE_PULLDOWN : Internal pull-down resistor |
Benoit | 1:f4040665bc61 | 151 | |
Benoit | 1:f4040665bc61 | 152 | * @return None |
Benoit | 1:f4040665bc61 | 153 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 154 | void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum) |
Benoit | 1:f4040665bc61 | 155 | { |
Benoit | 1:f4040665bc61 | 156 | uint32_t pinnum_t = pinnum; |
Benoit | 1:f4040665bc61 | 157 | uint32_t pinmodereg_idx = 2 * portnum; |
Benoit | 1:f4040665bc61 | 158 | uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE0; |
Benoit | 1:f4040665bc61 | 159 | |
Benoit | 1:f4040665bc61 | 160 | if (pinnum_t >= 16) { |
Benoit | 1:f4040665bc61 | 161 | pinnum_t -= 16; |
Benoit | 1:f4040665bc61 | 162 | pinmodereg_idx++ ; |
Benoit | 1:f4040665bc61 | 163 | } |
Benoit | 1:f4040665bc61 | 164 | |
Benoit | 1:f4040665bc61 | 165 | *(uint32_t *)(pPinCon + pinmodereg_idx) &= ~(0x03UL << (pinnum_t * 2)); |
Benoit | 1:f4040665bc61 | 166 | *(uint32_t *)(pPinCon + pinmodereg_idx) |= ((uint32_t)modenum) << (pinnum_t * 2); |
Benoit | 1:f4040665bc61 | 167 | } |
Benoit | 1:f4040665bc61 | 168 | |
Benoit | 1:f4040665bc61 | 169 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 170 | * @brief Setup Open drain mode for each pin |
Benoit | 1:f4040665bc61 | 171 | * @param[in] portnum PORT number, |
Benoit | 1:f4040665bc61 | 172 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 173 | * - PINSEL_PORT_0 : Port 0 |
Benoit | 1:f4040665bc61 | 174 | * - PINSEL_PORT_1 : Port 1 |
Benoit | 1:f4040665bc61 | 175 | * - PINSEL_PORT_2 : Port 2 |
Benoit | 1:f4040665bc61 | 176 | * - PINSEL_PORT_3 : Port 3 |
Benoit | 1:f4040665bc61 | 177 | * |
Benoit | 1:f4040665bc61 | 178 | * @param[in] pinnum Pin number, |
Benoit | 1:f4040665bc61 | 179 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 180 | - PINSEL_PIN_0 : Pin 0 |
Benoit | 1:f4040665bc61 | 181 | - PINSEL_PIN_1 : Pin 1 |
Benoit | 1:f4040665bc61 | 182 | - PINSEL_PIN_2 : Pin 2 |
Benoit | 1:f4040665bc61 | 183 | - PINSEL_PIN_3 : Pin 3 |
Benoit | 1:f4040665bc61 | 184 | - PINSEL_PIN_4 : Pin 4 |
Benoit | 1:f4040665bc61 | 185 | - PINSEL_PIN_5 : Pin 5 |
Benoit | 1:f4040665bc61 | 186 | - PINSEL_PIN_6 : Pin 6 |
Benoit | 1:f4040665bc61 | 187 | - PINSEL_PIN_7 : Pin 7 |
Benoit | 1:f4040665bc61 | 188 | - PINSEL_PIN_8 : Pin 8 |
Benoit | 1:f4040665bc61 | 189 | - PINSEL_PIN_9 : Pin 9 |
Benoit | 1:f4040665bc61 | 190 | - PINSEL_PIN_10 : Pin 10 |
Benoit | 1:f4040665bc61 | 191 | - PINSEL_PIN_11 : Pin 11 |
Benoit | 1:f4040665bc61 | 192 | - PINSEL_PIN_12 : Pin 12 |
Benoit | 1:f4040665bc61 | 193 | - PINSEL_PIN_13 : Pin 13 |
Benoit | 1:f4040665bc61 | 194 | - PINSEL_PIN_14 : Pin 14 |
Benoit | 1:f4040665bc61 | 195 | - PINSEL_PIN_15 : Pin 15 |
Benoit | 1:f4040665bc61 | 196 | - PINSEL_PIN_16 : Pin 16 |
Benoit | 1:f4040665bc61 | 197 | - PINSEL_PIN_17 : Pin 17 |
Benoit | 1:f4040665bc61 | 198 | - PINSEL_PIN_18 : Pin 18 |
Benoit | 1:f4040665bc61 | 199 | - PINSEL_PIN_19 : Pin 19 |
Benoit | 1:f4040665bc61 | 200 | - PINSEL_PIN_20 : Pin 20 |
Benoit | 1:f4040665bc61 | 201 | - PINSEL_PIN_21 : Pin 21 |
Benoit | 1:f4040665bc61 | 202 | - PINSEL_PIN_22 : Pin 22 |
Benoit | 1:f4040665bc61 | 203 | - PINSEL_PIN_23 : Pin 23 |
Benoit | 1:f4040665bc61 | 204 | - PINSEL_PIN_24 : Pin 24 |
Benoit | 1:f4040665bc61 | 205 | - PINSEL_PIN_25 : Pin 25 |
Benoit | 1:f4040665bc61 | 206 | - PINSEL_PIN_26 : Pin 26 |
Benoit | 1:f4040665bc61 | 207 | - PINSEL_PIN_27 : Pin 27 |
Benoit | 1:f4040665bc61 | 208 | - PINSEL_PIN_28 : Pin 28 |
Benoit | 1:f4040665bc61 | 209 | - PINSEL_PIN_29 : Pin 29 |
Benoit | 1:f4040665bc61 | 210 | - PINSEL_PIN_30 : Pin 30 |
Benoit | 1:f4040665bc61 | 211 | - PINSEL_PIN_31 : Pin 31 |
Benoit | 1:f4040665bc61 | 212 | |
Benoit | 1:f4040665bc61 | 213 | * @param[in] modenum Open drain mode number, |
Benoit | 1:f4040665bc61 | 214 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 215 | * - PINSEL_PINMODE_NORMAL : Pin is in the normal (not open drain) mode |
Benoit | 1:f4040665bc61 | 216 | * - PINSEL_PINMODE_OPENDRAIN : Pin is in the open drain mode |
Benoit | 1:f4040665bc61 | 217 | * |
Benoit | 1:f4040665bc61 | 218 | * @return None |
Benoit | 1:f4040665bc61 | 219 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 220 | void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum) |
Benoit | 1:f4040665bc61 | 221 | { |
Benoit | 1:f4040665bc61 | 222 | uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE_OD0; |
Benoit | 1:f4040665bc61 | 223 | |
Benoit | 1:f4040665bc61 | 224 | if (modenum == PINSEL_PINMODE_OPENDRAIN){ |
Benoit | 1:f4040665bc61 | 225 | *(uint32_t *)(pPinCon + portnum) |= (0x01UL << pinnum); |
Benoit | 1:f4040665bc61 | 226 | } else { |
Benoit | 1:f4040665bc61 | 227 | *(uint32_t *)(pPinCon + portnum) &= ~(0x01UL << pinnum); |
Benoit | 1:f4040665bc61 | 228 | } |
Benoit | 1:f4040665bc61 | 229 | } |
Benoit | 1:f4040665bc61 | 230 | |
Benoit | 1:f4040665bc61 | 231 | /* End of Public Functions ---------------------------------------------------- */ |
Benoit | 1:f4040665bc61 | 232 | |
Benoit | 1:f4040665bc61 | 233 | /* Public Functions ----------------------------------------------------------- */ |
Benoit | 1:f4040665bc61 | 234 | /** @addtogroup PINSEL_Public_Functions |
Benoit | 1:f4040665bc61 | 235 | * @{ |
Benoit | 1:f4040665bc61 | 236 | */ |
Benoit | 1:f4040665bc61 | 237 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 238 | * @brief Configure trace function |
Benoit | 1:f4040665bc61 | 239 | * @param[in] NewState State of the Trace function configuration, |
Benoit | 1:f4040665bc61 | 240 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 241 | * - ENABLE : Enable Trace Function |
Benoit | 1:f4040665bc61 | 242 | * - DISABLE : Disable Trace Function |
Benoit | 1:f4040665bc61 | 243 | * |
Benoit | 1:f4040665bc61 | 244 | * @return None |
Benoit | 1:f4040665bc61 | 245 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 246 | void PINSEL_ConfigTraceFunc(FunctionalState NewState) |
Benoit | 1:f4040665bc61 | 247 | { |
Benoit | 1:f4040665bc61 | 248 | if (NewState == ENABLE) { |
Benoit | 1:f4040665bc61 | 249 | LPC_PINCON->PINSEL10 |= (0x01UL << 3); |
Benoit | 1:f4040665bc61 | 250 | } else if (NewState == DISABLE) { |
Benoit | 1:f4040665bc61 | 251 | LPC_PINCON->PINSEL10 &= ~(0x01UL << 3); |
Benoit | 1:f4040665bc61 | 252 | } |
Benoit | 1:f4040665bc61 | 253 | } |
Benoit | 1:f4040665bc61 | 254 | |
Benoit | 1:f4040665bc61 | 255 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 256 | * @brief Setup I2C0 pins |
Benoit | 1:f4040665bc61 | 257 | * @param[in] i2cPinMode I2C pin mode, |
Benoit | 1:f4040665bc61 | 258 | * should be one of the following: |
Benoit | 1:f4040665bc61 | 259 | * - PINSEL_I2C_Normal_Mode : The standard drive mode |
Benoit | 1:f4040665bc61 | 260 | * - PINSEL_I2C_Fast_Mode : Fast Mode Plus drive mode |
Benoit | 1:f4040665bc61 | 261 | * |
Benoit | 1:f4040665bc61 | 262 | * @param[in] filterSlewRateEnable should be: |
Benoit | 1:f4040665bc61 | 263 | * - ENABLE: Enable filter and slew rate. |
Benoit | 1:f4040665bc61 | 264 | * - DISABLE: Disable filter and slew rate. |
Benoit | 1:f4040665bc61 | 265 | * |
Benoit | 1:f4040665bc61 | 266 | * @return None |
Benoit | 1:f4040665bc61 | 267 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 268 | void PINSEL_SetI2C0Pins(uint8_t i2cPinMode, FunctionalState filterSlewRateEnable) |
Benoit | 1:f4040665bc61 | 269 | { |
Benoit | 1:f4040665bc61 | 270 | uint32_t regVal = 0; |
Benoit | 1:f4040665bc61 | 271 | |
Benoit | 1:f4040665bc61 | 272 | if (i2cPinMode == PINSEL_I2C_Fast_Mode){ |
Benoit | 1:f4040665bc61 | 273 | regVal = PINSEL_I2CPADCFG_SCLDRV0 | PINSEL_I2CPADCFG_SDADRV0; |
Benoit | 1:f4040665bc61 | 274 | } |
Benoit | 1:f4040665bc61 | 275 | |
Benoit | 1:f4040665bc61 | 276 | if (filterSlewRateEnable == DISABLE){ |
Benoit | 1:f4040665bc61 | 277 | regVal = PINSEL_I2CPADCFG_SCLI2C0 | PINSEL_I2CPADCFG_SDAI2C0; |
Benoit | 1:f4040665bc61 | 278 | } |
Benoit | 1:f4040665bc61 | 279 | LPC_PINCON->I2CPADCFG = regVal; |
Benoit | 1:f4040665bc61 | 280 | } |
Benoit | 1:f4040665bc61 | 281 | |
Benoit | 1:f4040665bc61 | 282 | |
Benoit | 1:f4040665bc61 | 283 | /*********************************************************************//** |
Benoit | 1:f4040665bc61 | 284 | * @brief Configure Pin corresponding to specified parameters passed |
Benoit | 1:f4040665bc61 | 285 | * in the PinCfg |
Benoit | 1:f4040665bc61 | 286 | * @param[in] PinCfg Pointer to a PINSEL_CFG_Type structure |
Benoit | 1:f4040665bc61 | 287 | * that contains the configuration information for the |
Benoit | 1:f4040665bc61 | 288 | * specified pin. |
Benoit | 1:f4040665bc61 | 289 | * @return None |
Benoit | 1:f4040665bc61 | 290 | **********************************************************************/ |
Benoit | 1:f4040665bc61 | 291 | void PINSEL_ConfigPin(PINSEL_CFG_Type *PinCfg) |
Benoit | 1:f4040665bc61 | 292 | { |
Benoit | 1:f4040665bc61 | 293 | set_PinFunc(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Funcnum); |
Benoit | 1:f4040665bc61 | 294 | set_ResistorMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Pinmode); |
Benoit | 1:f4040665bc61 | 295 | set_OpenDrainMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->OpenDrain); |
Benoit | 1:f4040665bc61 | 296 | } |
Benoit | 1:f4040665bc61 | 297 | |
Benoit | 1:f4040665bc61 | 298 | |
Benoit | 1:f4040665bc61 | 299 | /** |
Benoit | 1:f4040665bc61 | 300 | * @} |
Benoit | 1:f4040665bc61 | 301 | */ |
Benoit | 1:f4040665bc61 | 302 | |
Benoit | 1:f4040665bc61 | 303 | /** |
Benoit | 1:f4040665bc61 | 304 | * @} |
Benoit | 1:f4040665bc61 | 305 | */ |
Benoit | 1:f4040665bc61 | 306 | |
Benoit | 1:f4040665bc61 | 307 | /* --------------------------------- End Of File ------------------------------ */ |
Benoit | 4:cb3dc3361be5 | 308 | /* @endcond */ |