2 * Copyright(C) NXP Semiconductors, 2012
\r
3 * All rights reserved.
\r
5 * Software that is described herein is for illustrative purposes only
\r
6 * which provides customers with programming information regarding the
\r
7 * LPC products. This software is supplied "AS IS" without any warranties of
\r
8 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
9 * all warranties, express or implied, including all implied warranties of
\r
10 * merchantability, fitness for a particular purpose and non-infringement of
\r
11 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
12 * or liability for the use of the software, conveys no license or rights under any
\r
13 * patent, copyright, mask work right, or any other intellectual property rights in
\r
14 * or to any products. NXP Semiconductors reserves the right to make changes
\r
15 * in the software without notification. NXP Semiconductors also makes no
\r
16 * representation or warranty that such application will be suitable for the
\r
17 * specified use without further testing or modification.
\r
19 * Permission to use, copy, modify, and distribute this software and its
\r
20 * documentation is hereby granted, under NXP Semiconductors' and its
\r
21 * licensor's relevant copyrights in the software, without fee, provided that it
\r
22 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
23 * copyright, permission, and disclaimer notice must appear in all copies of
\r
27 #ifndef __SCU_18XX_43XX_H_
\r
28 #define __SCU_18XX_43XX_H_
\r
34 /** @defgroup SCU_18XX_43XX CHIP: LPC18xx/43xx SCU Driver (configures pin functions)
\r
35 * @ingroup CHIP_18XX_43XX_Drivers
\r
40 * @brief System Control Unit register block
\r
43 __IO uint32_t SFSP[16][32];
\r
44 __I uint32_t RESERVED0[256];
\r
45 __IO uint32_t SFSCLK[4]; /*!< Pin configuration register for pins CLK0-3 */
\r
46 __I uint32_t RESERVED16[28];
\r
47 __IO uint32_t SFSUSB; /*!< Pin configuration register for USB */
\r
48 __IO uint32_t SFSI2C0; /*!< Pin configuration register for I2C0-bus pins */
\r
49 __IO uint32_t ENAIO[3]; /*!< Analog function select registerS */
\r
50 __I uint32_t RESERVED17[27];
\r
51 __IO uint32_t EMCDELAYCLK; /*!< EMC clock delay register */
\r
52 __I uint32_t RESERVED18[63];
\r
53 __IO uint32_t PINTSEL0; /*!< Pin interrupt select register for pin interrupts 0 to 3. */
\r
54 __IO uint32_t PINTSEL1; /*!< Pin interrupt select register for pin interrupts 4 to 7. */
\r
58 * SCU function and mode selection definitions
\r
59 * See the User Manual for specific modes and functions supoprted by the
\r
60 * various LPC18xx/43xx devices. Functionality can vary per device.
\r
62 #define SCU_MODE_MODE_INACT (0x0 << 3) /*!< Disable pull-down and pull-up resistor at resistor at pad */
\r
63 #define SCU_MODE_MODE_PULLDOWN (0x1 << 3) /*!< Enable pull-down resistor at pad */
\r
64 #define SCU_MODE_MODE_PULLUP (0x2 << 3) /*!< Enable pull-up resistor at pad */
\r
65 #define SCU_MODE_MODE_REPEATER (0x3 << 3) /*!< Enable pull-down and pull-up resistor at resistor at pad (repeater mode) */
\r
66 #define SCU_MODE_HIGHSPEEDSLEW_EN (0x1 << 5) /*!< Enable high-speed slew */
\r
67 #define SCU_MODE_INBUFF_EN (0x1 << 6) /*!< Enable Input buffer */
\r
68 #define SCU_MODE_ZIF_DIS (0x1 << 7) /*!< Disable input glitch filter */
\r
69 #define SCU_MODE_4MA_DRIVESTR (0x0 << 8) /*!< Normal drive: 4mA drive strength */
\r
70 #define SCU_MODE_8MA_DRIVESTR (0x1 << 8) /*!< Medium drive: 8mA drive strength */
\r
71 #define SCU_MODE_14MA_DRIVESTR (0x2 << 8) /*!< High drive: 14mA drive strength */
\r
72 #define SCU_MODE_20MA_DRIVESTR (0x3 << 8) /*!< Ultra high- drive: 20mA drive strength */
\r
73 #define SCU_MODE_FUNC0 0x0 /*!< Selects pin function 0 */
\r
74 #define SCU_MODE_FUNC1 0x1 /*!< Selects pin function 1 */
\r
75 #define SCU_MODE_FUNC2 0x2 /*!< Selects pin function 2 */
\r
76 #define SCU_MODE_FUNC3 0x3 /*!< Selects pin function 3 */
\r
77 #define SCU_MODE_FUNC4 0x4 /*!< Selects pin function 4 */
\r
78 #define SCU_MODE_FUNC5 0x5 /*!< Selects pin function 5 */
\r
79 #define SCU_MODE_FUNC6 0x6 /*!< Selects pin function 6 */
\r
80 #define SCU_MODE_FUNC7 0x7 /*!< Selects pin function 7 */
\r
81 #define SCU_PINIO_FAST (SCU_MODE_MODE_PULLUP | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS)
\r
84 * SCU function and mode selection definitions (old)
\r
85 * For backwards compatibility.
\r
87 #define MD_PUP (0x0 << 3) /** Disable pull-down and pull-up resistor at resistor at pad */
\r
88 #define MD_BUK (0x1 << 3) /** Enable pull-down resistor at pad */
\r
89 #define MD_PLN (0x2 << 3) /** Enable pull-up resistor at pad */
\r
90 #define MD_PDN (0x3 << 3) /** Enable pull-down and pull-up resistor at resistor at pad (repeater mode) */
\r
91 #define MD_EHS (0x1 << 5) /** Enable fast slew rate */
\r
92 #define MD_EZI (0x1 << 6) /** Input buffer enable */
\r
93 #define MD_ZI (0x1 << 7) /** Disable input glitch filter */
\r
94 #define MD_EHD0 (0x1 << 8) /** EHD driver strength low bit */
\r
95 #define MD_EHD1 (0x1 << 8) /** EHD driver strength high bit */
\r
96 #define MD_PLN_FAST (MD_PLN | MD_EZI | MD_ZI | MD_EHS)
\r
97 #define I2C0_STANDARD_FAST_MODE (1 << 3 | 1 << 11) /** Pin configuration for STANDARD/FAST mode I2C */
\r
98 #define I2C0_FAST_MODE_PLUS (2 << 1 | 1 << 3 | 1 << 7 | 1 << 10 | 1 << 11) /** Pin configuration for Fast-mode Plus I2C */
\r
99 #define FUNC0 0x0 /** Pin function 0 */
\r
100 #define FUNC1 0x1 /** Pin function 1 */
\r
101 #define FUNC2 0x2 /** Pin function 2 */
\r
102 #define FUNC3 0x3 /** Pin function 3 */
\r
103 #define FUNC4 0x4 /** Pin function 4 */
\r
104 #define FUNC5 0x5 /** Pin function 5 */
\r
105 #define FUNC6 0x6 /** Pin function 6 */
\r
106 #define FUNC7 0x7 /** Pin function 7 */
\r
108 #define PORT_OFFSET 0x80 /** Port offset definition */
\r
109 #define PIN_OFFSET 0x04 /** Pin offset definition */
\r
111 /** Returns the SFSP register address in the SCU for a pin and port, recommend using (*(volatile int *) &LPC_SCU->SFSP[po][pi];) */
\r
112 #define LPC_SCU_PIN(LPC_SCU_BASE, po, pi) (*(volatile int *) ((LPC_SCU_BASE) + ((po) * 0x80) + ((pi) * 0x4))
\r
114 /** Returns the address in the SCU for a SFSCLK clock register, recommend using (*(volatile int *) &LPC_SCU->SFSCLK[c];) */
\r
115 #define LPC_SCU_CLK(LPC_SCU_BASE, c) (*(volatile int *) ((LPC_SCU_BASE) +0xC00 + ((c) * 0x4)))
\r
118 * @brief Sets I/O Control pin mux
\r
119 * @param port : Port number, should be: 0..15
\r
120 * @param pin : Pin number, should be: 0..31
\r
121 * @param modefunc : OR'ed values or type SCU_MODE_*
\r
123 * @note Do not use for clock pins (SFSCLK0 .. SFSCLK4). Use
\r
124 * Chip_SCU_ClockPinMux() function for SFSCLKx clock pins.
\r
126 STATIC INLINE void Chip_SCU_PinMuxSet(uint8_t port, uint8_t pin, uint16_t modefunc)
\r
128 LPC_SCU->SFSP[port][pin] = modefunc;
\r
132 * @brief Configure pin function
\r
133 * @param port : Port number, should be: 0..15
\r
134 * @param pin : Pin number, should be: 0..31
\r
135 * @param mode : OR'ed values or type SCU_MODE_*
\r
136 * @param func : Pin function, value of type SCU_MODE_FUNC0 to SCU_MODE_FUNC7
\r
138 * @note Do not use for clock pins (SFSCLK0 .. SFSCLK4). Use
\r
139 * Chip_SCU_ClockPinMux() function for SFSCLKx clock pins.
\r
141 STATIC INLINE void Chip_SCU_PinMux(uint8_t port, uint8_t pin, uint16_t mode, uint8_t func)
\r
143 Chip_SCU_PinMuxSet(port, pin, (mode | (uint16_t) func));
\r
147 * @brief Configure clock pin function (pins SFSCLKx)
\r
148 * @param clknum : Clock pin number, should be: 0..3
\r
149 * @param modefunc : OR'ed values or type SCU_MODE_*
\r
152 STATIC INLINE void Chip_SCU_ClockPinMuxSet(uint8_t clknum, uint16_t modefunc)
\r
154 LPC_SCU->SFSCLK[clknum] = (uint32_t) modefunc;
\r
158 * @brief Configure clock pin function (pins SFSCLKx)
\r
159 * @param clknum : Clock pin number, should be: 0..3
\r
160 * @param mode : OR'ed values or type SCU_MODE_*
\r
161 * @param func : Pin function, value of type SCU_MODE_FUNC0 to SCU_MODE_FUNC7
\r
164 STATIC INLINE void Chip_SCU_ClockPinMux(uint8_t clknum, uint16_t mode, uint8_t func)
\r
166 LPC_SCU->SFSCLK[clknum] = ((uint32_t) mode | (uint32_t) func);
\r
170 * @brief GPIO Interrupt Pin Select
\r
171 * @param PortSel : GPIO PINTSEL interrupt, should be: 0 to 7
\r
172 * @param PortNum : GPIO port number interrupt, should be: 0 to 7
\r
173 * @param PinNum : GPIO pin number Interrupt , should be: 0 to 31
\r
176 void Chip_SCU_GPIOIntPinSel(uint8_t PortSel, uint8_t PortNum, uint8_t PinNum);
\r
179 * @brief I2C Pin Configuration
\r
180 * @param I2C0Mode : I2C0 mode, should be:
\r
181 * - I2C0_STANDARD_FAST_MODE: Standard/Fast mode transmit
\r
182 * - I2C0_FAST_MODE_PLUS: Fast-mode Plus transmit
\r
185 STATIC INLINE void Chip_SCU_I2C0PinConfig(uint32_t I2C0Mode)
\r
187 LPC_SCU->SFSI2C0 = I2C0Mode;
\r
191 * @brief ADC Pin Configuration
\r
192 * @param ADC_ID : ADC number
\r
193 * @param channel : ADC channel
\r
196 STATIC INLINE void Chip_SCU_ADC_Channel_Config(uint32_t ADC_ID, uint8_t channel)
\r
198 LPC_SCU->ENAIO[ADC_ID] |= 1UL << channel;
\r
202 * @brief DAC Pin Configuration
\r
205 STATIC INLINE void Chip_SCU_DAC_Analog_Config(void)
\r
207 /*Enable analog function DAC on pin P4_4*/
\r
208 LPC_SCU->ENAIO[2] |= 1;
\r
219 #endif /* __SCU_18XX_43XX_H_ */
\r