/****************************************************************************/
/* 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 LPC210x pin connect block				*/
/*	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~				*/
/*																			*/
/*	2011 Jan	ZK		Generated from the LPC23xx version					*/
/*																			*/
/****************************************************************************/

#ifndef _LPC210X_PCB
#define _LPC210X_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 lpc210x_pcb {

	unsigned pinsel[ 2 ];	// 000 Pin mode selects
};

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

#define	PCB_00_MASK			0x00000003
#define	PCB_00_GPIO			0x00000000
#define	PCB_00_SIO0_TXD		0x00000001
#define	PCB_00_TIM3_MAT1	0x00000002

#define	PCB_01_MASK			0x0000000c
#define	PCB_01_GPIO			0x00000000
#define	PCB_01_SIO0_RXD		0x00000004
#define	PCB_01_TIM3_MAT2	0x00000008

#define	PCB_02_MASK			0x00000030
#define	PCB_02_GPIO			0x00000000
#define	PCB_02_I2C0_SCL		0x00000010
#define	PCB_02_TIM0_CAP0	0X00000020

#define	PCB_03_MASK			0x000000c0
#define	PCB_03_GPIO			0x00000000
#define	PCB_02_I2C0_SDA		0x00000040
#define	PCB_03_TIM0_MAT0	0x00000080

#define	PCB_04_MASK			0x00000300
#define	PCB_04_GPIO			0x00000000
#define	PCB_04_SPI_SCLK		0x00000100
#define	PCB_04_TIM0_CAP1	0x00000200

#define	PCB_05_MASK			0x00000c00
#define	PCB_05_GPIO			0x00000000
#define	PCB_05_SPI_MISO		0x00000400
#define	PCB_05_TIM0_MAT1	0x00000800

#define	PCB_06_MASK			0x00003000
#define	PCB_06_GPIO			0x00000000
#define	PCB_06_SPI_MOSI		0x00001000
#define	PCB_06_TIM0_CAP2	0x00002000

#define	PCB_07_MASK			0x0000c000
#define	PCB_07_GPIO			0x00000000
#define	PCB_07_SPI_SSEL		0x00004000
#define	PCB_07_TIM2_MAT0	0x00008000

#define	PCB_08_MASK			0x00030000
#define	PCB_08_GPIO			0x00000000
#define	PCB_08_SIO1_TXD		0x00010000
#define	PCB_08_TIM2_MAT1	0x00020000

#define	PCB_09_MASK			0x000c0000
#define	PCB_09_GPIO			0x00000000
#define	PCB_09_SIO1_RXD		0x00040000
#define	PCB_09_TIM2_MAT2	0x00080000

#define	PCB_10_MASK			0x00300000
#define	PCB_10_GPIO			0x00000000
#define	PCB_10_SIO1_RTS		0x00100000
#define	PCB_10_TIM1_CAP0	0x00200000
#define	PCB_10_ADC_IN3		0x00300000

#define	PCB_11_MASK			0x00c00000
#define	PCB_11_GPIO			0x00000000
#define	PCB_11_SIO1_CTS		0x00400000
#define	PCB_11_TIM1_CAP1	0x00800000
#define	PCB_11_ADC_IN4		0x00c00000

#define	PCB_12_MASK			0x03000000
#define	PCB_12_GPIO			0x00000000
#define	PCB_12_SIO1_DSR		0x01000000
#define	PCB_12_TIM1_MAT0	0x02000000
#define	PCB_12_ADC_IN5		0x03000000

#define	PCB_13_MASK			0x0c000000
#define	PCB_13_GPIO			0x00000000
#define	PCB_13_TIM1_MAT1	0x08000000
#define	PCB_13_SIO1_DTR		0x0c000000

#define	PCB_14_MASK			0x30000000
#define	PCB_14_GPIO			0x00000000
#define	PCB_14_EINT1		0x10000000
#define	PCB_14_SSP_SCLK		0x20000000
#define	PCB_14_SIO1_DCD		0x30000000

#define	PCB_15_MASK			0xc0000000
#define	PCB_15_GPIO			0x00000000
#define	PCB_15_EINT2		0x40000000
#define	PCB_15_SIO1_RI		0xc0000000

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

#define	PCB_16_MASK			0x00000003		// Select mask
#define	PCB_16_GPIO			0x00000000		// Pin is GPIO
#define	PCB_16_EINT0		0x00000001		// Pin is SIO1 RxD
#define	PCB_16_TIM0_MAT2	0x00000002		// Pin is SSP0 SSEL

#define	PCB_17_MASK			0x0000000c		// Select mask
#define	PCB_17_GPIO			0x00000000		// Pin is GPIO
#define	PCB_17_I2C1_SCL		0x00000004		// Pin is SIO1 CTS
#define	PCB_17_TIM1_CAP2	0x00000008		// Pin is SSP0 MISO

#define	PCB_18_MASK			0x00000030		// Select mask
#define	PCB_18_GPIO			0x00000000		// Pin is GPIO
#define	PCB_18_I2C1_SDA		0x00000010		// Pin is SIO1 DCD
#define	PCB_18_TIM1_CAP3	0x00000020		// Pin is SSP0 MOSI

#define	PCB_19_MASK			0x000000c0		// Select mask
#define	PCB_19_GPIO			0x00000000		// Pin is GPIO
#define	PCB_19_SSP_MISO		0x00000040		// Pin is SIO1 DSR
#define	PCB_19_TIM1_MAT2	0x00000080		// Pin is MCI  CLK

#define	PCB_20_MASK			0x00000300		// Select mask
#define	PCB_20_GPIO			0x00000000		// Pin is GPIO
#define	PCB_20_SSP_MOSI		0x00000100		// Pin is SIO1 DTR
#define	PCB_20_TIM1_MAT3	0x00000200		// Pin is MCI  CMD

#define	PCB_21_MASK			0x00000c00		// Select mask
#define	PCB_21_GPIO			0x00000000		// Pin is GPIO
#define	PCB_21_SSP_SSEL		0x00000400		// Pin is SIO1 RI
#define	PCB_21_TIM3_MAT0	0x00000800		// Pin is MCI  PWR

#define	PCB_22_MASK			0x00003000		// Select mask
#define	PCB_22_GPIO			0x00000000		// Pin is GPIO
#define	PCB_22_ADC_IN0		0x00003000		// Pin is CAN1 TD

#define	PCB_23_MASK			0x0000c000		// Select mask
#define	PCB_23_GPIO			0x00000000		// Pin is GPIO
#define	PCB_23_ADC_IN1		0x0000c000		// Pin is TIM3 CAP0

#define	PCB_24_MASK			0x00030000		// Select mask
#define	PCB_24_GPIO			0x00000000		// Pin is GPIO
#define	PCB_24_ADC_IN2		0x00030000		// Pin is TIM3 CAP1

#define	PCB_25_MASK			0x000c0000		// Select mask
#define	PCB_25_GPIO			0x00000000		// Pin is GPIO
#define	PCB_25_ADC_IN6		0x000c0000		// Pin is SIO3 TxD

#define	PCB_26_MASK			0x00300000		// Select mask
#define	PCB_26_GPIO			0x00000000		// Pin is GPIO
#define	PCB_26_ADC_IN7		0x00300000		// Pin is SIO3 RxD

#define	PCB_27_MASK			0x00c00000		// Select mask
#define	PCB_27_GPIO			0x00000000		// Pin is GPIO
#define	PCB_27_JTAG_TRST	0x00400000		// Pin is I2C0 SDA
#define	PCB_27_TIM2_CAP0	0x00800000		// Pin is I2C0 SDA

#define	PCB_28_MASK			0x03000000		// Select mask
#define	PCB_28_GPIO			0x00000000		// Pin is GPIO
#define	PCB_28_JTAG_TMS		0x01000000		// Pin is I2C0 SCL
#define	PCB_28_TIM2_CAP1	0x01000000		// Pin is I2C0 SCL

#define	PCB_29_MASK			0x0c000000		// Select mask
#define	PCB_29_GPIO			0x00000000		// Pin is GPIO
#define	PCB_29_JTAG_TCK		0x04000000		// Pin is USB1 D+
#define	PCB_29_TIM2_CAP2	0x08000000		// Pin is USB1 D+

#define	PCB_30_MASK			0x30000000		// Select mask
#define	PCB_30_GPIO			0x00000000		// Pin is GPIO
#define	PCB_30_JTAG_TDI		0x10000000		// Pin is USB1 D-
#define	PCB_30_TIM3_MAT3	0x20000000		// Pin is USB1 D-

#define	PCB_31_MASK			0xc0000000		// Select mask
#define	PCB_32_GPIO			0x00000000		// Pin is GPIO
#define	PCB_33_JTAG_TDO		0x40000000		// Pin is USB2 D+

/*
*	PCB instance
*/

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

#endif

