Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Committer:
Michael J. Spencer
Date:
Fri Feb 28 18:52:52 2014 -0800
Revision:
2:1df0b61d3b5a
Update to latest Smoothie.

Who changed what in which revision?

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