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