/****************************************************************************/
/* Copyright 2010, © Bendor Research Pty. Ltd. All rights reserved.			*/
/* Permission is granted to use this software for any purpose whatsoever	*/
/* as long as this copyright notice is preserved. The code is provided		*/
/* "as is", with no explicit, implicit or implied warranty or guarantee		*/
/* of any kind and Bendor Research Pty. Ltd. can not be held liable for		*/
/* any loss or damages arising out of the use of this software.				*/
/****************************************************************************/
/*																			*/
/*	Include file describing the NXP LPC23xx pin connect block				*/
/*	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~				*/
/*																			*/
/*	2010 Mar	ZK		Original											*/
/*	2010 May	ZK		Modified to match NXP's names						*/
/*																			*/
/****************************************************************************/

#ifndef _LPC23XX_PCB
#define _LPC23XX_PCB

/*
*	Note that this file describes every port, even if the given chip does
*	not have the functionality described or the port is not connected
*	to a physical pin. Port pins or functionalities not described in the
*	definitions are all reserved (by NXP) and shall not be used.
*
*	Note:
*
*	USB1 and USB2 are the same device. There is only one controller and
*	you can choose which pinset you want to use. The choice is not on a
*	pin-by-pin basis, but all the pins switch between USB1 and USB2. The
*	control for that is in the USB controller, not in the pin block. You
*	have to set them up in a coherent fashion.
*/

struct lpc23xx_pcb {

	unsigned pinsel[ 10 ];	// 000 Pin mode selects
	unsigned etm;			// 028 ETM pins function select	(pinsel10)
	unsigned _[5];
	unsigned pinmode[ 10 ];	// 040 Ports 0-4 resistor control
};

/*
*	Port0[ 15:0 ] pin assignments (pinsel[ 0 ])
*/

#define	PCB_P0_00_MASK		0x00000003		// Select mask
#define	PCB_P0_00_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_00_CAN1_RD	0x00000001		// Pin is CAN1 RD
#define	PCB_P0_00_SIO3_TXD	0x00000002		// Pin is SIO3 TxD
#define	PCB_P0_00_I2C1_SDA	0x00000003		// Pin is I2C1 SDA

#define	PCB_P0_01_MASK		0x0000000c		// Select mask
#define	PCB_P0_01_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_01_CAN1_TD	0x00000004		// Pin is CAN1 TD
#define	PCB_P0_01_SIO3_RXD	0x00000008		// Pin is SIO3 RxD
#define	PCB_P0_01_I2C1_SCL	0x0000000c		// Pin is I2C1 SCL

#define	PCB_P0_02_MASK		0x00000030		// Select mask
#define	PCB_P0_02_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_02_SIO0_TXD	0x00000010		// Pin is SIO0 TxD

#define	PCB_P0_03_MASK		0x000000c0		// Select mask
#define	PCB_P0_03_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_03_SIO0_RXD	0x00000040		// Pin is SIO0 RxD

#define	PCB_P0_04_MASK		0x00000300		// Select mask
#define	PCB_P0_04_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_04_I2S0_RCLK	0x00000100		// Pin is I2S  RX_CLK
#define	PCB_P0_04_CAN2_RD	0x00000200		// Pin is CAN2 RD
#define	PCB_P0_04_TIM2_CAP0	0x00000300		// Pin is TIM2 CAP0

#define	PCB_P0_05_MASK		0x00000c00		// Select mask
#define	PCB_P0_05_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_05_I2S0_RWS	0x00000400		// Pin is I2S  RX_WS
#define	PCB_P0_05_CAN2_TD	0x00000800		// Pin is CAN2 TD
#define	PCB_P0_05_TIM2_CAP1	0x00000c00		// Pin is TIM2 CAP1

#define	PCB_P0_06_MASK		0x00003000		// Select mask
#define	PCB_P0_06_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_06_I2S0_RSDA	0x00001000		// Pin is I2S  RX_SDA
#define	PCB_P0_06_SSP1_SSEL	0x00002000		// Pin is SSP1 SSEL
#define	PCB_P0_06_TIM2_MAT0	0x00003000		// Pin is TIM2 MCH0

#define	PCB_P0_07_MASK		0x0000c000		// Select mask
#define	PCB_P0_07_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_07_I2C0_TCLK	0x00004000		// Pin is I2C0 TX_CLK
#define	PCB_P0_07_SSP1_SCLK	0x00008000		// Pin is SSP1 SCLK
#define	PCB_P0_07_TIM2_MAT1	0x0000c000		// Pin is TIM2 MCH1

#define	PCB_P0_08_MASK		0x00030000		// Select mask
#define	PCB_P0_08_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_08_I2C0_TWS	0x00010000		// Pin is I2C0 TX_WS
#define	PCB_P0_08_SSP1_MISO	0x00020000		// Pin is SSP1 MISO
#define	PCB_P0_08_TIM2_MAT2	0x00030000		// Pin is TIM2 MCH2

#define	PCB_P0_09_MASK		0x000c0000		// Select mask
#define	PCB_P0_09_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_09_I2S0_TSDA	0x00040000		// Pin is I2S0 TX_SDA
#define	PCB_P0_09_SSP1_MOSI	0x00080000		// Pin is SSP1 MOSI
#define	PCB_P0_09_TIM2_MAT3	0x000c0000		// Pin is TIM2 MCH3

#define	PCB_P0_10_MASK		0x00300000		// Select mask
#define	PCB_P0_10_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_10_SIO2_TXD	0x00100000		// Pin is SIO2 TxD
#define	PCB_P0_10_I2C2_SDA	0x00200000		// Pin is I2C2 SDA
#define	PCB_P0_10_TIM3_MAT0	0x00300000		// Pin is TIM3 MCH0

#define	PCB_P0_11_MASK		0x00c00000		// Select mask
#define	PCB_P0_11_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_11_SIO2_RXD	0x00400000		// Pin is SIO2 RxD
#define	PCB_P0_11_I2C2_SCL	0x00800000		// Pin is I2C2 SCL
#define	PCB_P0_11_TIM3_MAT1	0x00c00000		// Pin is TIM3 MCH1

#define	PCB_P0_12_MASK		0x03000000		// Select mask
#define	PCB_P0_12_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_12_SSP1_MISO	0x02000000		// Pin is SSP1 MISO
#define	PCB_P0_12_ADC_INP6	0x03000000		// Pin is ADC  IN6

#define	PCB_P0_13_MASK		0x0c000000		// Select mask
#define	PCB_P0_13_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_13_USB2_LUP	0x04000000		// Pin is USB2 LED_UP
#define	PCB_P0_13_SSP1_MOSI	0x08000000		// Pin is SSP1 MOSI
#define	PCB_P0_13_ADC_INP7	0x0c000000		// Pin is ADC  IN7

#define	PCB_P0_14_MASK		0x30000000		// Select mask
#define	PCB_P0_14_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_14_USB2_HENA	0x10000000		// Pin is USB2 HOST_ENABLE
#define	PCB_P0_14_USB2_CONN	0x20000000		// Pin is USB2 CONNECT
#define	PCB_P0_14_SSP1_SSEL	0x30000000		// Pin is SSP1 SSEL

#define	PCB_P0_15_MASK		0xc0000000		// Select mask
#define	PCB_P0_15_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_15_SIO1_TXD	0x40000000		// Pin is SIO1 TxD
#define	PCB_P0_15_SSP0_SCLK	0x80000000		// Pin is SSP0 SLCK
#define	PCB_P0_15_SPI_SCLK	0xc0000000		// Pin is SPI  SCLK

/*
*	Port0[ 31:16 ] pin assignments (pinsel[ 1 ])
*/

#define	PCB_P0_16_MASK		0x00000003		// Select mask
#define	PCB_P0_16_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_16_SIO1_RXD	0x00000001		// Pin is SIO1 RxD
#define	PCB_P0_16_SSP0_SSEL	0x00000002		// Pin is SSP0 SSEL
#define	PCB_P0_16_SPI_SSEL	0x00000003		// Pin is SPI  SSEL

#define	PCB_P0_17_MASK		0x0000000c		// Select mask
#define	PCB_P0_17_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_17_SIO1_CTS	0x00000004		// Pin is SIO1 CTS
#define	PCB_P0_17_SSP0_MISO	0x00000008		// Pin is SSP0 MISO
#define	PCB_P0_17_SPI_MISO	0x0000000c		// Pin is SPI  MISO

#define	PCB_P0_18_MASK		0x00000030		// Select mask
#define	PCB_P0_18_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_18_SIO1_DCD	0x00000010		// Pin is SIO1 DCD
#define	PCB_P0_18_SSP0_MOSI	0x00000020		// Pin is SSP0 MOSI
#define	PCB_P0_18_SPI_MOSI	0x00000030		// Pin is SPI  MOSI

#define	PCB_P0_19_MASK		0x000000c0		// Select mask
#define	PCB_P0_19_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_19_SIO1_DSR	0x00000040		// Pin is SIO1 DSR
#define	PCB_P0_19_MCI_CLK	0x00000080		// Pin is MCI  CLK
#define	PCB_P0_19_I2C1_SDA	0x000000c0		// Pin is I2C1 SDA

#define	PCB_P0_20_MASK		0x00000300		// Select mask
#define	PCB_P0_20_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_20_SIO1_DTR	0x00000100		// Pin is SIO1 DTR
#define	PCB_P0_20_MCI_CMD	0x00000200		// Pin is MCI  CMD
#define	PCB_P0_20_I2C1_SCL	0x00000300		// Pin is I2C1 SCL

#define	PCB_P0_21_MASK		0x00000c00		// Select mask
#define	PCB_P0_21_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_21_SIO1_RI	0x00000400		// Pin is SIO1 RI
#define	PCB_P0_21_MCI_PWR	0x00000800		// Pin is MCI  PWR
#define	PCB_P0_21_CAN1_RD1	0x00000c00		// Pin is CAN1 RD

#define	PCB_P0_22_MASK		0x00003000		// Select mask
#define	PCB_P0_22_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_22_SIO1_RTS	0x00001000		// Pin is SIO1 RTS
#define	PCB_P0_22_MCI_DAT0	0x00002000		// Pin is MCI  DATA0
#define	PCB_P0_22_CAN1_TD	0x00003000		// Pin is CAN1 TD

#define	PCB_P0_23_MASK		0x0000c000		// Select mask
#define	PCB_P0_23_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_23_ADC_INP0	0x00004000		// Pin is ADC  IN0
#define	PCB_P0_23_I2S0_RCLK	0x00008000		// Pin is I2S  RX_CLK
#define	PCB_P0_23_TIM3_CAP0	0x0000c000		// Pin is TIM3 CAP0

#define	PCB_P0_24_MASK		0x00030000		// Select mask
#define	PCB_P0_24_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_24_ADC_INP1	0x00010000		// Pin is ADC  IN1
#define	PCB_P0_24_I2S0_RWS	0x00020000		// Pin is I2S  RX_WS
#define	PCB_P0_24_TIM3_CAP1	0x00030000		// Pin is TIM3 CAP1

#define	PCB_P0_25_MASK		0x000c0000		// Select mask
#define	PCB_P0_25_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_25_ADC_INP2	0x00040000		// Pin is ADC  IN2
#define	PCB_P0_25_I2S0_RSDA	0x00080000		// Pin is I2S  RX_SDA
#define	PCB_P0_25_SIO3_TXD	0x000c0000		// Pin is SIO3 TxD

#define	PCB_P0_26_MASK		0x00300000		// Select mask
#define	PCB_P0_26_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_26_ADC_INP3	0x00100000		// Pin is ADC  IN3
#define	PCB_P0_26_DAC_OUT	0x00200000		// Pin is DAC  OUT
#define	PCB_P0_26_SIO2_RXD	0x00300000		// Pin is SIO3 RxD

#define	PCB_P0_27_MASK		0x00c00000		// Select mask
#define	PCB_P0_27_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_27_I2C0_SDA	0x00400000		// Pin is I2C0 SDA

#define	PCB_P0_28_MASK		0x03000000		// Select mask
#define	PCB_P0_28_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_28_I2C0_SCL	0x01000000		// Pin is I2C0 SCL

#define	PCB_P0_29_MASK		0x0c000000		// Select mask
#define	PCB_P0_29_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_29_USB1_DP	0x04000000		// Pin is USB1 D+

#define	PCB_P0_30_MASK		0x30000000		// Select mask
#define	PCB_P0_30_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_30_USB1_DM	0x10000000		// Pin is USB1 D-

#define	PCB_P0_31_MASK		0xc0000000		// Select mask
#define	PCB_P0_32_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P0_33_USB2_DP	0x40000000		// Pin is USB2 D+

/*
*	Port1[ 15:0 ] pin assignments (pinsel[ 2 ])
*/

#define	PCB_P1_00_MASK		0x00000003		// Select mask
#define	PCB_P1_00_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_00_ETH_TXD0	0x00000001		// Pin is ETH  TXD0

#define	PCB_P1_01_MASK		0x0000000c		// Select mask
#define	PCB_P1_01_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_01_ETH_TXD1	0x00000004		// Pin is ETH  TXD1

#define	PCB_P1_04_MASK		0x00000300		// Select mask
#define	PCB_P1_04_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_04_ETH_TENA	0x00000100		// Pin is ETH  TX_ENA

#define	PCB_P1_08_MASK		0x00030000		// Select mask
#define	PCB_P1_08_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_08_ETH_CRS	0x00010000		// Pin is ETH  CRS

#define	PCB_P1_09_MASK		0x000c0000		// Select mask
#define	PCB_P1_09_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_09_ETH_RXD0	0x00040000		// Pin is ETH  RXD0

#define	PCB_P1_10_MASK		0x00300000		// Select mask
#define	PCB_P1_10_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_10_ETH_RXD1	0x00100000		// Pin is ETH  RXD1

#define	PCB_P1_14_MASK		0x30000000		// Select mask
#define	PCB_P1_14_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_14_ETH_RERR	0x10000000		// Pin is ETH  RX_ERR

#define	PCB_P1_15_MASK		0xc0000000		// Select mask
#define	PCB_P1_15_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_15_ETH_RCLK	0x40000000		// Pin is ETH  REF_CLK

/*
*	Port1[ 31:16 ] pin assignments (pinsel[ 3 ])
*/

#define	PCB_P1_16_MASK		0x00000003		// Select mask
#define	PCB_P1_16_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_16_ETH_MDC	0x00000001		// Pin is ETH  MDC

#define	PCB_P1_17_MASK		0x0000000c		// Select mask
#define	PCB_P1_17_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_17_ETH_MDIO	0x00000004		// Pin is ETH  MDIO

#define	PCB_P1_18_MASK		0x00000030		// Select mask
#define	PCB_P1_18_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_18_USB1_LUP	0x00000010		// Pin is USB1 LED_UP
#define	PCB_P1_18_PWM_OUT1	0x00000020		// Pin is PWM1 OUT1
#define	PCB_P1_18_TIM1_CAP1	0x00000030		// Pin is TIM1 CAP1

#define	PCB_P1_19_MASK		0x000000c0		// Select mask
#define	PCB_P1_19_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_19_USB1_TENA	0x00000040		// Pin is USB1 TX_ENA
#define	PCB_P1_19_USB1_PPWR	0x00000080		// Pin is USB1 PPWR
#define	PCB_P1_19_TIM1_CAP1	0x000000c0		// Pin is TIM1 CAP1

#define	PCB_P1_20_MASK		0x00000300		// Select mask
#define	PCB_P1_20_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_20_USB1_TDP	0x00000100		// Pin is USB1 TxD+
#define	PCB_P1_20_PWM_OUT2	0x00000200		// Pin is PWM1 OUT2
#define	PCB_P1_20_SSP0_SCLK	0x00000300		// Pin is SSP0 SCLK

#define	PCB_P1_21_MASK		0x00000c00		// Select mask
#define	PCB_P1_21_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_21_USB1_TDM	0x00000400		// Pin is USB1 TxD-
#define	PCB_P1_21_PWM_OUT3	0x00000800		// Pin is PWM1 OUT3
#define	PCB_P1_21_SSP0_SSEL	0x00000c00		// Pin is SSP0 SSEL

#define	PCB_P1_22_MASK		0x00003000		// Select mask
#define	PCB_P1_22_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_22_USB1_RCV	0x00001000		// Pin is USB1
#define	PCB_P1_22_USB1_PWRD	0x00002000		// Pin is
#define	PCB_P1_22_TIM1_MAT0	0x00003000		// Pin is TIM1 MAT0

#define	PCB_P1_23_MASK		0x0000c000		// Select mask
#define	PCB_P1_23_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_23_USB1_RDP	0x00004000		// Pin is USB1 RxD+
#define	PCB_P1_23_PWM_OUT4	0x00008000		// Pin is PWM1 OUT4
#define	PCB_P1_23_SSP0_MISO	0x0000c000		// Pin is SSP0 MISO

#define	PCB_P1_24_MASK		0x00030000		// Select mask
#define	PCB_P1_24_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_24_USB1_RDM	0x00010000		// Pin is USB1 RxD-
#define	PCB_P1_24_PWM_OUT5	0x00020000		// Pin is PWM1 OUT5
#define	PCB_P1_24_SSP0_MOSI	0x00030000		// Pin is SSP0 MOSI

#define	PCB_P1_25_MASK		0x000c0000		// Select mask
#define	PCB_P1_25_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_25_USB1_LS	0x00040000		// Pin is USB1
#define	PCB_P1_25_USB1_HENA	0x00080000		// Pin is USB1 HOST_ENABLE
#define	PCB_P1_25_TIM1_MAT1	0x000c0000		// Pin is TIM1 MAT1

#define	PCB_P1_26_MASK		0x00300000		// Select mask
#define	PCB_P1_26_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_26_USB1_SPND	0x00100000		// Pin is USB1 SSPND
#define	PCB_P1_26_PWM_OUT6	0x00200000		// Pin is PWM1 OUT6
#define	PCB_P1_26_TIM0_CAP0	0x00300000		// Pin is TIM0 CAP0

#define	PCB_P1_27_MASK		0x00c00000		// Select mask
#define	PCB_P1_27_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_27_USB1_INT	0x00400000		// Pin is USB1
#define	PCB_P1_27_USB1_OVCR	0x00800000		// Pin is USB1
#define	PCB_P1_27_TIM0_CAP1	0x00c00000		// Pin is TIM1 CAP1

#define	PCB_P1_28_MASK		0x03000000		// Select mask
#define	PCB_P1_28_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_28_USB1_SCL	0x01000000		// Pin is USB1 I2C SCL
#define	PCB_P1_28_PWM_CAP0	0x02000000		// Pin is PWM1 CAP0
#define	PCB_P1_28_TIM0_MAT0	0x03000000		// Pin is TIM0 MAT0

#define	PCB_P1_29_MASK		0x0c000000		// Select mask
#define	PCB_P1_29_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_29_USB1_SDA	0x04000000		// Pin is USB1 I2C SDA
#define	PCB_P1_29_PWM_CAP1	0x08000000		// Pin is PWM1 CAP1
#define	PCB_P1_29_TIM0_MAT1	0x0c000000		// Pin is TIM1 MAT0

#define	PCB_P1_30_MASK		0x30000000		// Select mask
#define	PCB_P1_30_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_30_USB2_PWRD	0x10000000		// Pin is USB2
#define	PCB_P1_30_VBUS		0x20000000		// Pin is
#define	PCB_P1_30_ADC_INP4	0x30000000		// Pin is ADC  IN4

#define	PCB_P1_31_MASK		0xc0000000		// Select mask
#define	PCB_P1_31_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P1_31_USB2_OVCR	0x40000000		// Pin is USB2
#define	PCB_P1_31_SSP1_SCLK	0x80000000		// Pin is SSP1 SCLK
#define	PCB_P1_31_ADC_INP5	0xc0000000		// Pin is ADC0 IN5

/*
*	Port2[ 15:0 ] pin assignments (pinsel[ 4 ])
*/

#define	PCB_P2_00_MASK		0x00000003		// Select mask
#define	PCB_P2_00_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_00_PWM_OUT1	0x00000001		// Pin is PWM1 OUT0
#define	PCB_P2_00_SIO1_TXD	0x00000002		// Pin is SIO1 TxD
#define	PCB_P2_00_TRCE_CLK	0x00000003		// Pin is trace clock

#define	PCB_P2_01_MASK		0x0000000c		// Select mask
#define	PCB_P2_01_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_01_PWM_OUT2	0x00000004		// Pin is PWM1 OUT2
#define	PCB_P2_01_SIO1_RXD	0x00000008		// Pin is SIO1 RxD
#define	PCB_P2_01_TRCE_PST0	0x0000000c		// Pin is trace pipe state 0

#define	PCB_P2_02_MASK		0x00000030		// Select mask
#define	PCB_P2_02_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_02_PWM_OUT3	0x00000010		// Pin is PWM1 OUT3
#define	PCB_P2_02_SIO1_CTS	0x00000020		// Pin is SIO1 CTS
#define	PCB_P2_02_TRCE_PST1	0x00000030		// Pin is trace pipe state 1

#define	PCB_P2_03_MASK		0x000000c0		// Select mask
#define	PCB_P2_03_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_03_PWM_OUT4	0x00000040		// Pin is PWM1 OUT4
#define	PCB_P2_03_SIO1_DCD	0x00000080		// Pin is SIO1 DCD
#define	PCB_P2_03_TRCE_PST2	0x000000c0		// Pin is trace pipe state 2

#define	PCB_P2_04_MASK		0x00000300		// Select mask
#define	PCB_P2_04_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_04_PWM_OUT5	0x00000100		// Pin is PWM1 OUT5
#define	PCB_P2_04_SIO1_DSR	0x00000200		// Pin is SIO1 DSR
#define	PCB_P2_04_TRCE_SYNC	0x00000300		// Pin is trace synchron

#define	PCB_P2_05_MASK		0x00000c00		// Select mask
#define	PCB_P2_05_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_05_PWM_OUT6	0x00000400		// Pin is PWM1 OUT6
#define	PCB_P2_05_SIO1_DTR	0x00000800		// Pin is SIO1 DTR
#define	PCB_P2_05_TRCE_PKT0	0x00000c00		// Pin is trace packet bit 0

#define	PCB_P2_06_MASK		0x00003000		// Select mask
#define	PCB_P2_06_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_06_PWM_CAP0	0x00001000		// Pin is PWM1 CAP0
#define	PCB_P2_06_SIO1_RI	0x00002000		// Pin is SIO1 RI
#define	PCB_P2_06_TRCE_PKT1	0x00003000		// Pin is trace packet bit 1

#define	PCB_P2_07_MASK		0x0000c000		// Select mask
#define	PCB_P2_07_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_07_CAN2_RD	0x00004000		// Pin is CAN2 RD
#define	PCB_P2_07_SIO1_RTS	0x00008000		// Pin is SIO1 RTS
#define	PCB_P2_07_TRCE_PKT2	0x0000c000		// Pin is trace packet bit 2

#define	PCB_P2_08_MASK		0x00030000		// Select mask
#define	PCB_P2_08_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_08_CAN2_TD	0x00010000		// Pin is CAN2 TD
#define	PCB_P2_08_SIO2_TXD	0x00020000		// Pin is SIO2 TxD
#define	PCB_P2_08_TRCE_PKT3	0x00030000		// Pin is trace packet bit 2

#define	PCB_P2_09_MASK		0x000c0000		// Select mask
#define	PCB_P2_09_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_09_USB1_CONN	0x00040000		// Pin is USB1 CONNECT
#define	PCB_P2_09_SIO2_RXD	0x00080000		// Pin is SIO2 RxD
#define	PCB_P2_09_TRCE_EIN0	0x000c0000		// Pin is trace control

#define	PCB_P2_10_MASK		0x00300000		// Select mask
#define	PCB_P2_10_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_10_CORE_IRQ0	0x00100000		// Pin is CPU  -EXT_INT0

#define	PCB_P2_11_MASK		0x00c00000		// Select mask
#define	PCB_P2_11_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_11_CORE_IRQ1	0x00400000		// Pin is CPU  -EXT_INT1
#define	PCB_P2_11_MCI_DAT1	0x00800000		// Pin is MCI  DATA1
#define	PCB_P2_11_I2S0_TCLK	0x00c00000		// Pin is I2S  TX_CLK

#define	PCB_P2_12_MASK		0x03000000		// Select mask
#define	PCB_P2_12_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_12_CORE_IRQ2	0x01000000		// Pin is CPU  -EXT_INT2
#define	PCB_P2_12_MCI_DAT2	0x02000000		// Pin is MCI  DATA2
#define	PCB_P2_12_I2S0_TWS	0x03000000		// Pin is I2S  TX_WS

#define	PCB_P2_13_MASK		0x0c000000		// Select mask
#define	PCB_P2_13_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P2_13_CORE_IRQ3	0x04000000		// Pin is CPU  -EXT_INT3
#define	PCB_P2_13_MCI_DAT3	0x08000000		// Pin is MCI  DATA3
#define	PCB_P2_13_I2S0_TSDA	0x0c000000		// Pin is I2S  TX_SDA

/*
*	Port3[ 15:0 ] pin assignments (pinsel[ 6 ])
*/

#define	PCB_P3_00_MASK		0x00000003		// Select mask
#define	PCB_P3_00_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_00_EMC_D0	0x00000001		// Pin is EMC D0

#define	PCB_P3_01_MASK		0x0000000c		// Select mask
#define	PCB_P3_01_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_01_EMC_D1	0x00000004		// Pin is EMC D1

#define	PCB_P3_02_MASK		0x00000030		// Select mask
#define	PCB_P3_02_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_02_EMC_D2	0x00000010		// Pin is EMC D2

#define	PCB_P3_03_MASK		0x000000c0		// Select mask
#define	PCB_P3_03_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_03_EMC_D3	0x00000040		// Pin is EMC D3

#define	PCB_P3_04_MASK		0x00000300		// Select mask
#define	PCB_P3_04_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_04_EMC_D4	0x00000100		// Pin is EMC D4

#define	PCB_P3_05_MASK		0x00000c00		// Select mask
#define	PCB_P3_05_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_05_EMC_D5	0x00000400		// Pin is EMC D5

#define	PCB_P3_06_MASK		0x00003000		// Select mask
#define	PCB_P3_06_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_06_EMC_D6	0x00001000		// Pin is EMC D6

#define	PCB_P3_07_MASK		0x0000c000		// Select mask
#define	PCB_P3_07_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_07_EMC_D7	0x00004000		// Pin is EMC D7

/*
*	Port3[ 16:31 ] pin assignments (pinsel[ 7 ])
*/

#define	PCB_P3_23_MASK		0x0000c000		// Select mask
#define	PCB_P3_23_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_23_TIM0_CAP0	0x00008000		// Pin is TIM0 CAP0
#define	PCB_P3_23_PWM_CAP0	0x0000c000		// Pin is PWM1 CAP0

#define	PCB_P3_24_MASK		0x00030000		// Select mask
#define	PCB_P3_24_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_24_TIM0_CAP1	0x00020000		// Pin is TIM0 CAP1
#define	PCB_P3_24_PWM_MAT1	0x00030000		// Pin is PWM1 MAT1

#define	PCB_P3_25_MASK		0x000c0000		// Select mask
#define	PCB_P3_25_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_25_TIM0_MAT0	0x00080000		// Pin is TIM0 MAT0
#define	PCB_P3_25_PWM_MAT2	0x000c0000		// Pin is PWM1 MAT2

#define	PCB_P3_26_MASK		0x00300000		// Select mask
#define	PCB_P3_26_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P3_26_TIM0_MAT1	0x00200000		// Pin is TIM0 MAT1
#define	PCB_P3_26_PWM_MAT3	0x00300000		// Pin is PWM1 MAT3

/*
*	Port4[ 15:0 ] pin assignments (pinsel[ 8 ])
*/

#define	PCB_P4_00_MASK		0x00000003		// Select mask
#define	PCB_P4_00_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_00_EMC_A0	0x00000001		// Pin is EMC A0

#define	PCB_P4_01_MASK		0x0000000c		// Select mask
#define	PCB_P4_01_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_01_EMC_A1	0x00000004		// Pin is EMC A1

#define	PCB_P4_02_MASK		0x00000030		// Select mask
#define	PCB_P4_02_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_02_EMC_A2	0x00000010		// Pin is EMC A2

#define	PCB_P4_03_MASK		0x000000c0		// Select mask
#define	PCB_P4_03_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_03_EMC_A3	0x00000040		// Pin is EMC A3

#define	PCB_P4_04_MASK		0x00000300		// Select mask
#define	PCB_P4_04_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_04_EMC_A4	0x00000100		// Pin is EMC A4

#define	PCB_P4_05_MASK		0x00000c00		// Select mask
#define	PCB_P4_05_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_05_EMC_A5	0x00000400		// Pin is EMC A5

#define	PCB_P4_06_MASK		0x00003000		// Select mask
#define	PCB_P4_06_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_06_EMC_A6	0x00001000		// Pin is EMC A6

#define	PCB_P4_07_MASK		0x0000c000		// Select mask
#define	PCB_P4_07_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_07_EMC_A7	0x00004000		// Pin is EMC A7

#define	PCB_P4_08_MASK		0x00030000		// Select mask
#define	PCB_P4_08_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_08_EMC_A8	0x00010000		// Pin is EMC A8

#define	PCB_P4_09_MASK		0x000c0000		// Select mask
#define	PCB_P4_09_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_09_EMC_A9	0x00040000		// Pin is EMC A9

#define	PCB_P4_10_MASK		0x00300000		// Select mask
#define	PCB_P4_10_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_10_EMC_A10	0x00100000		// Pin is EMC A10

#define	PCB_P4_11_MASK		0x00c00000		// Select mask
#define	PCB_P4_11_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_11_EMC_A11	0x00400000		// Pin is EMC A11

#define	PCB_P4_12_MASK		0x03000000		// Select mask
#define	PCB_P4_12_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_12_EMC_A12	0x01000000		// Pin is EMC A12

#define	PCB_P4_13_MASK		0x0c000000		// Select mask
#define	PCB_P4_13_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_13_EMC_A13	0x04000000		// Pin is EMC A13

#define	PCB_P4_14_MASK		0x30000000		// Select mask
#define	PCB_P4_14_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_14_EMC_A14	0x10000000		// Pin is EMC A14

#define	PCB_P4_15_MASK		0xc0000000		// Select mask
#define	PCB_P4_15_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_15_EMC_A15	0x40000000		// Pin is EMC A15

/*
*	Port4[ 31:16 ] pin assignments (pinsel[ 9 ])
*/

#define	PCB_P4_24_MASK		0x00030000		// Select mask
#define	PCB_P4_24_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_24_EMC_OE	0x00010000		// Pin is EMC -OE

#define	PCB_P4_25_MASK		0x000c0000		// Select mask
#define	PCB_P4_25_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_25_EMC_WE	0x00080000		// Pin is EMC -WE (aka BLS0)

#define	PCB_P4_28_MASK		0x03000000		// Select mask
#define	PCB_P4_28_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_28_TIM2_MAT0	0x02000000		// Pin is TIM2 MAT0
#define	PCB_P4_28_SIO3_TXD	0x03000000		// Pin is SIO3 TxD

#define	PCB_P4_29_MASK		0x0c000000		// Select mask
#define	PCB_P4_29_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_29_TIM2_MAT1	0x08000000		// Pin is TIM2 MAT1
#define	PCB_P4_28_SIO3_RXD	0x0c000000		// Pin is SIO3 RTxD

#define	PCB_P4_30_MASK		0x30000000		// Select mask
#define	PCB_P4_30_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_30_EMC_CS0	0x10000000		// Pin is EMC -CS0

#define	PCB_P4_31_MASK		0xc0000000		// Select mask
#define	PCB_P4_31_GPIO		0x00000000		// Pin is GPIO
#define	PCB_P4_31_EMC_CS1	0x40000000		// Pin is EMC -CS1

/*
*	Resistor control values
*/

#define	PCB_MODE_PUP		0				// Pull-up is enabled
#define	PCB_MODE_FLT		2				// Resistors disabled (float)
#define	PCB_MODE_PDN		3				// Pull-down is enabled

#define	PCB_MODE_MSK(pin)		(3<<(((pin)&15)<<1))
#define	PCB_MODE_SET(pin,mode)	((mode)<<(((pin)&15)<<1))
#define	PCB_MODE_GET(reg,pin)	(((reg)>>(((pin)&15)<<1))&3)

/*
*	Array index for each port pin
*/

#define PCB_P0_00	0
#define PCB_P0_01	0
#define PCB_P0_02	0
#define PCB_P0_03	0
#define PCB_P0_04	0
#define PCB_P0_05	0
#define PCB_P0_06	0
#define PCB_P0_07	0
#define PCB_P0_08	0
#define PCB_P0_09	0
#define PCB_P0_10	0
#define PCB_P0_11	0
#define PCB_P0_12	0
#define PCB_P0_13	0
#define PCB_P0_14	0
#define PCB_P0_15	0
#define PCB_P0_16	1
#define PCB_P0_17	1
#define PCB_P0_18	1
#define PCB_P0_19	1
#define PCB_P0_20	1
#define PCB_P0_21	1
#define PCB_P0_22	1
#define PCB_P0_23	1
#define PCB_P0_24	1
#define PCB_P0_25	1
#define PCB_P0_26	1
#define PCB_P0_27	1
#define PCB_P0_28	1
#define PCB_P0_29	1
#define PCB_P0_30	1
#define PCB_P0_31	1
#define PCB_P1_00	2
#define PCB_P1_01	2
#define PCB_P1_02	2
#define PCB_P1_03	2
#define PCB_P1_04	2
#define PCB_P1_05	2
#define PCB_P1_06	2
#define PCB_P1_07	2
#define PCB_P1_08	2
#define PCB_P1_09	2
#define PCB_P1_10	2
#define PCB_P1_11	2
#define PCB_P1_12	2
#define PCB_P1_13	2
#define PCB_P1_14	2
#define PCB_P1_15	2
#define PCB_P1_16	3
#define PCB_P1_17	3
#define PCB_P1_18	3
#define PCB_P1_19	3
#define PCB_P1_20	3
#define PCB_P1_21	3
#define PCB_P1_22	3
#define PCB_P1_23	3
#define PCB_P1_24	3
#define PCB_P1_25	3
#define PCB_P1_26	3
#define PCB_P1_27	3
#define PCB_P1_28	3
#define PCB_P1_29	3
#define PCB_P1_30	3
#define PCB_P1_31	3
#define PCB_P2_00	4
#define PCB_P2_01	4
#define PCB_P2_02	4
#define PCB_P2_03	4
#define PCB_P2_04	4
#define PCB_P2_05	4
#define PCB_P2_06	4
#define PCB_P2_07	4
#define PCB_P2_08	4
#define PCB_P2_09	4
#define PCB_P2_10	4
#define PCB_P2_11	4
#define PCB_P2_12	4
#define PCB_P2_13	4
#define PCB_P2_14	4
#define PCB_P2_15	4
#define PCB_P2_16	5
#define PCB_P2_17	5
#define PCB_P2_18	5
#define PCB_P2_19	5
#define PCB_P2_20	5
#define PCB_P2_21	5
#define PCB_P2_22	5
#define PCB_P2_23	5
#define PCB_P2_24	5
#define PCB_P2_25	5
#define PCB_P2_26	5
#define PCB_P2_27	5
#define PCB_P2_28	5
#define PCB_P2_29	5
#define PCB_P2_30	5
#define PCB_P2_31	5
#define PCB_P3_00	6
#define PCB_P3_01	6
#define PCB_P3_02	6
#define PCB_P3_03	6
#define PCB_P3_04	6
#define PCB_P3_05	6
#define PCB_P3_06	6
#define PCB_P3_07	6
#define PCB_P3_23	7
#define PCB_P3_24	7
#define PCB_P3_25	7
#define PCB_P3_26	7
#define PCB_P4_00	8
#define PCB_P4_01	8
#define PCB_P4_02	8
#define PCB_P4_03	8
#define PCB_P4_04	8
#define PCB_P4_05	8
#define PCB_P4_06	8
#define PCB_P4_07	8
#define PCB_P4_08	8
#define PCB_P4_09	8
#define PCB_P4_10	8
#define PCB_P4_11	8
#define PCB_P4_12	8
#define PCB_P4_13	8
#define PCB_P4_14	8
#define PCB_P4_15	8
#define PCB_P4_23	9
#define PCB_P4_24	9
#define PCB_P4_25	9
#define PCB_P4_28	9
#define PCB_P4_29	9
#define PCB_P4_30	9
#define PCB_P4_31	9

/*
*	PCB instance
*/

static volatile struct lpc23xx_pcb * const lpc_pcb = (void *) 0xe002c000;

#endif

