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